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:
NiemandKG
2026-11-06 18:44:40 +06:00
parent 0f0467cd0c
commit d1c3761e58
4190 changed files with 270757 additions and 1 deletions

View File

@ -0,0 +1,124 @@
using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace GrassCutter
{
/// <summary>
/// T on anything built: its upgrade level and what the next one does and costs, its mode if it is a splitter or a merger,
/// and its switch if it has one (a belt stopped, a machine paused). Everything here is for the whole crew, paid from the wallet.
/// </summary>
public class PieceScreen
{
public VisualElement Card { get; }
readonly BuildPiece _p;
readonly VisualElement _body;
readonly Action _close;
public PieceScreen(VisualElement layer, Action close, BuildPiece piece)
{
_p = piece;
_close = close;
Card = UIK.El("card", layer);
Card.pickingMode = PickingMode.Position;
Card.style.width = 680;
var header = UIK.El("card-header", Card);
UIK.Text(piece.Def.name.ToUpper(Loc.Culture), "t-h1 t-dark", header);
UIK.Btn("X", close, "btn btn-red btn-small", header);
_body = UIK.El(null, Card);
Refresh();
// the numbers follow the wallet and the piece while the card is up
int was = Stamp();
Card.schedule.Execute(() =>
{
if (!_p || !_p.IsSpawned) { _close(); return; }
int now = Stamp();
if (now != was) { was = now; Refresh(); }
}).Every(200);
}
int Stamp() => !_p ? 0 : _p.Setting * 31 + (TeamState.Instance ? (int)TeamState.Instance.Money.Value : 0);
void Refresh()
{
_body.Clear();
var ts = TeamState.Instance;
if (!_p || !ts) return;
var kind = _p.Upgrades;
int tier = _p.Tier.Value;
if (kind != UpgradeKind.None)
{
var row = UIK.El("tune-row", _body);
var names = UIK.El("tune-names", row);
UIK.Text($"{GameDefs.TierName(tier)}", "t-small t-dark", names, false);
UIK.Text(tier == 0 ? Loc.T("As built.") : Loc.F("Now {0}.", GameDefs.TierEffect(kind, tier)), "tune-effect", names, false);
if (tier < GameDefs.MaxTier)
{
double price = GameDefs.UpgradePrice(_p, tier);
bool can = ts.Money.Value >= price;
var up = UIK.El("tune-row", _body);
var upNames = UIK.El("tune-names", up);
UIK.Text(Loc.F("Upgrade to {0}", GameDefs.TierName(tier + 1)), "t-small t-dark", upNames, false);
UIK.Text(Loc.F("{0}.", Cap(GameDefs.TierEffect(kind, tier + 1))), "tune-effect", upNames, false);
UIK.Btn(UIK.Money(price), () =>
{
if (!can) { Sfx.Play("error", 0.7f); return; }
_p.UpgradeRpc();
Sfx.Play("cash_register", 0.9f);
}, (can ? "btn btn-green" : "btn btn-grey") + " btn-small", up);
}
else UIK.Text(Loc.T("Fully upgraded."), "tune-effect", _body, false);
}
var junction = _p.GetComponentInChildren<IJunction>();
if (junction != null)
{
var row = UIK.El("tune-row", _body);
var names = UIK.El("tune-names", row);
UIK.Text(Loc.T("Mode"), "t-small t-dark", names, false);
UIK.Text(Cap(junction.ModeName(_p.Mode.Value)), "tune-effect", names, false);
UIK.Btn(Loc.T("CHANGE"), () => { _p.NextModeRpc(junction.ModeCount); Sfx.Play("ui_click", 0.7f); }, "btn btn-blue btn-small", row);
}
string switchName = SwitchName();
if (switchName != null)
{
var row = UIK.El("tune-row", _body);
var names = UIK.El("tune-names", row);
UIK.Text(switchName, "t-small t-dark", names, false);
UIK.Text(_p.Switched ? SwitchOff() : _p.Upgrades == UpgradeKind.Silo ? Loc.T("Open: bundles go out to the belts.") : Loc.T("Running."), "tune-effect", names, false);
UIK.Btn(_p.Switched ? (_p.Upgrades == UpgradeKind.Silo ? Loc.T("OPEN") : Loc.T("START")) : (_p.Upgrades == UpgradeKind.Silo ? Loc.T("SHUT") : Loc.T("STOP")), () => { _p.SwitchRpc(); Sfx.Play("ui_click", 0.7f); }, (_p.Switched ? "btn btn-green" : "btn btn-red") + " btn-small", row);
}
if (kind == UpgradeKind.None && junction == null && switchName == null)
UIK.Text(Loc.T("Nothing to set on this one."), "tune-effect", _body, false);
UIK.Text(Loc.T("Upgrades are for the whole crew and come out of the shared wallet."), "t-small t-muted wrap", _body, false).style.marginTop = 10;
}
string SwitchName()
{
switch (_p.Upgrades)
{
case UpgradeKind.Belt: return Loc.T("Belt");
case UpgradeKind.Machine: return Loc.T("Machine");
case UpgradeKind.Robot: return _p.GetComponent<Mowbot>() ? Loc.T("Robot") : null;
case UpgradeKind.Silo: return Loc.T("Hatches");
default: return null;
}
}
string SwitchOff()
{
switch (_p.Upgrades)
{
case UpgradeKind.Belt: return Loc.T("Stopped: what's on it waits where it is.");
case UpgradeKind.Robot: return Loc.T("Stopped: it waits where it is.");
case UpgradeKind.Silo: return Loc.T("Shut: everything stays in the silo.");
default: return Loc.T("Paused: it takes grass in but doesn't work it.");
}
}
static string Cap(string s) => string.IsNullOrEmpty(s) ? s : char.ToUpper(s[0], Loc.Culture) + s.Substring(1);
}
}