Files
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

51 lines
1.5 KiB
C#

using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
namespace GrassCutter
{
/// <summary>Catches what a Reaper shoots from anywhere on the planet and puts it on the belt.</summary>
public class Catcher : SiloPiece
{
const float Room = 100f;
static readonly List<Catcher> s_all = new List<Catcher>();
public override string Prompt => Loc.F("Bundle Catcher: {0} of {1}", GameDefs.Kilos(Silo.Value), GameDefs.Kilos(Room));
public override void Interact() => Sfx.Play("ui_click", 0.6f);
public override void OnNetworkSpawn() => s_all.Add(this);
public override void OnNetworkDespawn() => s_all.Remove(this);
public override void OnDestroy()
{
s_all.Remove(this);
base.OnDestroy();
}
public override void Ports(List<Port> into)
{
into.Add(BeltNet.Front(transform));
}
/// <summary>The emptiest catcher that still has room.</summary>
public static Catcher WithRoom()
{
Catcher best = null;
foreach (var c in s_all)
if (c && c.Silo.Value + GameDefs.BundleKg <= Room && (!best || c.Silo.Value < best.Silo.Value)) best = c;
return best;
}
public void ServerCatch(float kg)
{
Silo.Value += kg;
CaughtRpc();
}
[Rpc(SendTo.Everyone)]
void CaughtRpc() => Sfx.PlayAt("cargo_load", transform.position, 0.5f, 1f, 0.1f, 0.4f);
}
}