Files
grass-cutters/Assets/Scripts/Gameplay/Lamppost.cs
NiemandKG 36e4bb2a10 Round 6 fixes: held tools, headlamp glare, ladder openings, level horizon, roof hulls, rain hits, idle motion, belt packs, meadow variety
- Held tools sit lower and further right; the hammer faces forward and strikes about the camera's right
- Headlamp leaves held items, treats and vending machines alone (rendering layer NoLamp); other lights keep lighting them
- Hay grounded on the floor in world space (it floated)
- Deck fence opens at each ladder, rail colliders split around it; ladders moved to 2 m off the edge middle, clear of the intakes; climbing goes over a rail only if one is in the way
- Crew stand to the soil's up (Planet.Level): flat round the base, the ball's up past it, so the horizon stays level on a small planet
- Convex roof hulls for the crew cabin, garage, pitched roof and windmill tower; cabin box lowered to the eaves
- Rain and acid rain hits differ by surface: soil, grass, wood, metal
- Idle motion: dishes pan, sways sway, sensors turn, eyes blink, windmill turns in the breeze, reels and parked rotors tick over
- Belt: take tools off at the supply wall; hold E at a vending machine for a pack of 3 on the belt, LMB has one
- New meadow pieces: boulders, slab stones, crystals, mushrooms, stump, bulb plants
- -demofix checks for all of the above; loc rows in all 11 tables

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 22:52:05 +06:00

45 lines
1.6 KiB
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>A lamp post that comes on as the light goes: its glass glows and it throws a warm pool round its foot.</summary>
public class Lamppost : MonoBehaviour
{
public Renderer glow;
Light _light;
MaterialPropertyBlock _mpb;
float _on = -1f;
static readonly int EmissionId = Shader.PropertyToID("_EmissionColor"), BaseId = Shader.PropertyToID("_BaseColor");
static readonly Color Warm = new Color(1f, 0.78f, 0.45f);
void Start()
{
var go = new GameObject("Light");
go.transform.SetParent(transform, false);
go.transform.localPosition = new Vector3(0f, 2.35f, 0f);
_light = go.AddComponent<Light>();
_light.renderingLayerMask = -1;
_light.type = LightType.Point;
_light.color = Warm;
_light.range = 9f;
_light.shadows = LightShadows.None;
_mpb = new MaterialPropertyBlock();
}
void Update()
{
// lit a little before it's properly dark, out a little after the sun is up
float on = Mathf.Clamp01(DayNight.Dark * 1.6f + DayNight.Dusk * 0.6f);
if (Mathf.Abs(on - _on) < 0.02f) return;
_on = on;
_light.enabled = on > 0.05f;
_light.intensity = on * 2.2f;
if (!glow) return;
glow.GetPropertyBlock(_mpb);
_mpb.SetColor(EmissionId, Warm * (0.2f + on * 3f));
_mpb.SetColor(BaseId, Color.Lerp(new Color(0.85f, 0.82f, 0.7f), Warm, on));
glow.SetPropertyBlock(_mpb);
}
}
}