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>
This commit is contained in:
60
Assets/Scripts/Gameplay/Garage.cs
Normal file
60
Assets/Scripts/Gameplay/Garage.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// A garage you build yourself: sells and calls machines like the one at the base, and whatever a machine unloads on the pad
|
||||
/// in front goes into its silo. Two ports at the back turn the silo into bundles for the belts.
|
||||
/// </summary>
|
||||
public class Garage : SiloPiece
|
||||
{
|
||||
public static readonly List<Garage> All = new List<Garage>();
|
||||
|
||||
// the garage stands at 0.6 times the pack model (half what it was: it towered over the base): its front is 1.9 m out,
|
||||
// its back wall 1.9 m back. The pad is still sized for the machines.
|
||||
const float PadFront = 2.4f, PadLong = 11f, PadWide = 6.5f, PortBack = 2.24f;
|
||||
|
||||
public override string Prompt => Loc.F("Garage — buy, call & upgrade machines (silo {0})", GameDefs.Kilos(Silo.Value));
|
||||
|
||||
public override void Interact()
|
||||
{
|
||||
Sfx.Play("ui_open");
|
||||
UIRoot.I?.OpenGarage(this);
|
||||
}
|
||||
|
||||
public override void OnNetworkSpawn() { All.Add(this); base.OnNetworkSpawn(); }
|
||||
public override void OnNetworkDespawn() { All.Remove(this); base.OnNetworkDespawn(); }
|
||||
|
||||
public override string PadName => Loc.T("Garage pad");
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
All.Remove(this);
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
public override void Ports(List<Port> into)
|
||||
{
|
||||
var back = -transform.forward;
|
||||
var at = transform.position + transform.up * GameDefs.BeltLowest + back * PortBack;
|
||||
into.Add(new Port { at = at - transform.right * 0.8f, dir = back });
|
||||
into.Add(new Port { at = at + transform.right * 0.8f, dir = back });
|
||||
}
|
||||
|
||||
/// <summary>Where a called machine appears: the middle of the pad.</summary>
|
||||
public override Vector3 PadSpot => transform.position + transform.forward * (PadFront + PadLong * 0.5f) + transform.up * 0.6f;
|
||||
|
||||
public override bool OnPad(Vector3 p)
|
||||
{
|
||||
var l = transform.InverseTransformPoint(p);
|
||||
return Mathf.Abs(l.x) < PadWide && l.z > PadFront - 1f && l.z < PadFront + PadLong && Mathf.Abs(l.y) < 4f;
|
||||
}
|
||||
|
||||
public static Garage Under(Vector3 p)
|
||||
{
|
||||
foreach (var g in All) if (g && g.OnPad(p)) return g;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user