- 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>
102 lines
3.8 KiB
C#
102 lines
3.8 KiB
C#
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
/// <summary>The Reaper belongs to no dock: it goes from sector to sector over the whole planet and shoots its bundles into a catcher, however far.</summary>
|
|
public class Reaper : Mowbot
|
|
{
|
|
const float ShotEvery = 0.5f, ShowEvery = 0.4f, ReelSpeed = 420f;
|
|
|
|
public Transform muzzle, reel;
|
|
|
|
float _nextShow, _spun;
|
|
int _reelAxis = -1;
|
|
|
|
protected override Transform Body => transform;
|
|
protected override Vector3 Origin => At.Value;
|
|
protected override int Reach => 100000;
|
|
|
|
public override string Prompt => Loc.F("{0}: {1}, {2} of {3}", Def.name, MoodText, GameDefs.Kilos(Hopper.Value), GameDefs.Kilos(HopperCap));
|
|
|
|
public override void Moved(Vector3 at)
|
|
{
|
|
base.Moved(at);
|
|
Teleported(at);
|
|
}
|
|
|
|
protected override bool Stay(float dt)
|
|
{
|
|
int shots = Mathf.CeilToInt(dt / ShotEvery);
|
|
while (Hopper.Value >= GameDefs.BundleKg && shots-- > 0)
|
|
{
|
|
var c = Catcher.WithRoom();
|
|
if (!c) break;
|
|
c.ServerCatch(GameDefs.BundleKg);
|
|
Hopper.Value -= GameDefs.BundleKg;
|
|
if (Time.time >= _nextShow)
|
|
{
|
|
_nextShow = Time.time + ShowEvery;
|
|
ShotRpc(c.transform.position + c.transform.up * 2f);
|
|
}
|
|
}
|
|
if (Hopper.Value < HopperCap) return false;
|
|
Mowing.Value = false;
|
|
Mood.Value = (byte)RobotMood.NoCatcher;
|
|
return true;
|
|
}
|
|
|
|
protected override void NoWork() => Mood.Value = (byte)RobotMood.Finished;
|
|
|
|
[Rpc(SendTo.Everyone)]
|
|
void ShotRpc(Vector3 to)
|
|
{
|
|
BundleShot.Fly(muzzle ? muzzle.position : At.Value + transform.up * 1.5f, to);
|
|
Sfx.PlayAt("launcher_fire", At.Value, 0.5f, 1.2f);
|
|
}
|
|
|
|
void LateUpdate()
|
|
{
|
|
if (!reel) return;
|
|
if (_reelAxis < 0) _reelAxis = BaseRot.LocalAxisFor(reel, transform.right);
|
|
_spun += (Mowing.Value ? ReelSpeed : 14f) * Time.deltaTime;
|
|
var axis = _reelAxis == 0 ? Vector3.right : _reelAxis == 1 ? Vector3.up : Vector3.forward;
|
|
reel.localRotation = BaseRot.Of(reel) * Quaternion.Euler(axis * _spun);
|
|
}
|
|
}
|
|
|
|
/// <summary>A bundle in the air. Only for the eyes: the catcher has it already.</summary>
|
|
public class BundleShot : MonoBehaviour
|
|
{
|
|
const float Near = 600f;
|
|
|
|
Vector3 _from, _to;
|
|
float _t, _time, _arc;
|
|
|
|
public static void Fly(Vector3 from, Vector3 to)
|
|
{
|
|
var cam = Camera.main;
|
|
if (!cam || (Vector3.Distance(cam.transform.position, from) > Near && Vector3.Distance(cam.transform.position, to) > Near)) return;
|
|
var go = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
|
Destroy(go.GetComponent<Collider>());
|
|
go.transform.localScale = Vector3.one * 0.5f;
|
|
go.GetComponent<Renderer>().sharedMaterial = BuildLook.Mat("M_Bundle", new Color(0.62f, 0.78f, 0.28f));
|
|
var shot = go.AddComponent<BundleShot>();
|
|
float far = Vector3.Distance(from, to);
|
|
shot._from = Planet.Up(from);
|
|
shot._to = Planet.Up(to);
|
|
shot._time = Mathf.Clamp(1f + far / 150f, 1f, 8f);
|
|
shot._arc = Mathf.Min(8f + far * 0.25f, 200f);
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
_t += Time.deltaTime / _time;
|
|
if (_t >= 1f) { Destroy(gameObject); return; }
|
|
var d = Vector3.Slerp(_from, _to, _t);
|
|
transform.position = Planet.OnSurface(d) + d * (1.5f + Mathf.Sin(_t * Mathf.PI) * _arc);
|
|
transform.Rotate(180f * Time.deltaTime, 90f * Time.deltaTime, 0f);
|
|
}
|
|
}
|
|
}
|