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>
63 lines
2.6 KiB
C#
63 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
/// <summary>
|
|
/// Where grass leaves for Earth: E empties the tool in your hands at once or takes the bundle in your arms, thrown
|
|
/// bundles and bundles arriving on a belt are paid for the moment they drop in. The HUD writes out a receipt.
|
|
/// </summary>
|
|
public class Depot : MonoBehaviour, IInteractable, ICargoSink, IPorts
|
|
{
|
|
public static readonly List<Depot> All = new List<Depot>();
|
|
|
|
public Transform mouth;
|
|
/// <summary>Half the footprint across and along; a base intake has its back to the deck and takes no belt there.</summary>
|
|
public float halfX = 1.05f, halfZ = 1.05f;
|
|
public bool backToDeck;
|
|
public Vector3 Mouth => mouth ? mouth.position : transform.position + Vector3.up * 1.1f;
|
|
|
|
void OnEnable() => All.Add(this);
|
|
void OnDisable() => All.Remove(this);
|
|
|
|
/// <summary>Three belts on each side, twelve in all.</summary>
|
|
public void Ports(List<Port> into)
|
|
{
|
|
for (int side = 0; side < 4; side++)
|
|
{
|
|
if (backToDeck && side == 2) continue;
|
|
var inward = Quaternion.AngleAxis(side * 90f, transform.up) * -transform.forward;
|
|
var across = Vector3.Cross(transform.up, inward);
|
|
float reach = side % 2 == 0 ? halfZ : halfX, room = side % 2 == 0 ? halfX : halfZ;
|
|
float step = Mathf.Min(0.6f, room * 0.45f);
|
|
for (int k = -1; k <= 1; k++)
|
|
into.Add(new Port { at = transform.position - inward * reach + across * (k * step) + transform.up * GameDefs.BeltLowest, dir = inward, input = true });
|
|
}
|
|
}
|
|
|
|
public string Prompt
|
|
{
|
|
get
|
|
{
|
|
var p = PlayerAgent.Local;
|
|
if (!p) return null;
|
|
return p.Tank.Value < 0.005f ? (backToDeck ? Loc.T("Base Intake — nothing to hand in") : Loc.T("Grass Depot — nothing to hand in")) : Loc.F("Hand in {0}", GameDefs.Kilos(p.Tank.Value));
|
|
}
|
|
}
|
|
|
|
public bool CanInteract => PlayerAgent.Local && PlayerAgent.Local.Tank.Value >= 0.005f;
|
|
|
|
public void Interact() => PlayerAgent.Local?.Tools.Deposit(this);
|
|
|
|
public bool ServerAccept(Cargo c, Vector3 from, Vector3 dir)
|
|
{
|
|
var ts = TeamState.Instance;
|
|
if (!ts || !c || !c.IsSpawned) return false;
|
|
ts.ServerDeposit(c.Kg.Value, c.kind, Mouth);
|
|
c.Grab.Consumed = true;
|
|
c.NetworkObject.Despawn(true);
|
|
return true;
|
|
}
|
|
}
|
|
}
|