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,114 @@
using System.Linq;
using System.Collections.Generic;
using Unity.Netcode;
using UnityEngine;
namespace GrassCutter
{
/// <summary>The stations the crew has found, travel between them, and who isn't welcome.</summary>
public partial class TeamState
{
/// <summary>Stations found, not counting the base.</summary>
public NetworkList<byte> Opened;
List<string> _banned = new List<string>();
public bool StationOpen(int i) => i == 0 || (Opened != null && Opened.Contains((byte)i));
[Rpc(SendTo.Server)]
public void OpenStationRpc(int i, RpcParams rpc = default)
{
var who = PlayerOf(rpc.Receive.SenderClientId);
if (!who || i <= 0 || i >= Stations.Count || StationOpen(i)) return;
if ((who.transform.position - Stations.Spot(i)).sqrMagnitude > 3600f) return;
Opened.Add((byte)i);
AnnounceRpc(Loc.Pack("{0} found {1} Station!", who.DisplayName, Stations.Names[i]));
Save();
}
[Rpc(SendTo.Server)]
public void TravelRpc(int i, RpcParams rpc = default)
{
var who = PlayerOf(rpc.Receive.SenderClientId);
if (!who || i < 0 || i >= Stations.Count) return;
if (who.Driving.Value || !StationOpen(i) || i == Stations.Nearest(who.transform.position) || Money.Value < GameDefs.TravelPrice)
{
DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp));
return;
}
Money.Value -= GameDefs.TravelPrice;
who.ArriveRpc(Stations.Arrival(i));
}
/// <summary>Host: send someone away, for good if they are banned.</summary>
public void ServerKick(ulong client, bool ban)
{
if (!IsServer || client == NetworkManager.ServerClientId) return;
var who = PlayerOf(client);
if (ban && who && who.ClaimedSave && !_banned.Contains(who.SaveId)) _banned.Add(who.SaveId);
NetworkManager.DisconnectClient(client, ban ? Loc.Pack("You were banned from this game") : Loc.Pack("The host asked you to leave"));
Save();
}
public bool Banned(string key) => _banned.Contains(key);
/// <summary>The depots of the far stations: a new game has them, and an older save gets them now.</summary>
void ServerSpawnStations()
{
for (int i = 1; i < Stations.Count; i++) ServerSpawnPiece(PieceId.Depot, Stations.Spot(i), Stations.Turn(i), Vector3.zero, -1, true);
}
/// <summary>
/// Eight low intakes on the ground against the sides of the base deck, two on each side, so a belt from the meadow can
/// end at the base without climbing up top. They sit between the ladders, clear of the ramp, backs to the deck.
/// A new game has them, and an older save gets them now (the tall depots that stood there before go).
/// </summary>
void ServerSpawnIntakes()
{
foreach (var spot in IntakeSpots)
{
// straight out from the side it stands on, back square to the deck
var outward = Mathf.Abs(spot.x) > Mathf.Abs(spot.z) ? new Vector3(Mathf.Sign(spot.x), 0f, 0f) : new Vector3(0f, 0f, Mathf.Sign(spot.z));
ServerSpawnPiece(PieceId.Intake, Planet.Surface(spot), Quaternion.LookRotation(outward, Vector3.up), Vector3.zero, -1, true);
}
}
/// <summary>A save from stage 18 has tall depots round the foot of the deck: they make way for the intakes.</summary>
void ServerSwapIntakes()
{
foreach (var p in BuildPiece.All.ToArray())
{
if (!p || p.piece != PieceId.Depot || Planet.Altitude(p.transform.position) > 0.6f) continue;
var flat = new Vector2(p.transform.position.x, p.transform.position.z);
foreach (var old in OldIntakeSpots)
if ((flat - new Vector2(old.x, old.z)).magnitude < 2.5f) { p.NetworkObject.Despawn(true); break; }
}
ServerSpawnIntakes();
}
/// <summary>Saves from the first stage-19 build have the intakes turned 45° off the deck: they are set again.</summary>
void ServerRespawnIntakes()
{
foreach (var p in BuildPiece.All.ToArray())
if (p && p.piece == PieceId.Intake) p.NetworkObject.Despawn(true);
ServerSpawnIntakes();
}
/// <summary>The deck runs ±9 m; an intake is 1.5 m deep, so its middle is 9.77 m out, 6 m either side of each edge's middle.</summary>
public static readonly Vector3[] IntakeSpots =
{
new Vector3(-6f, 0f, 9.77f), new Vector3(6f, 0f, 9.77f),
new Vector3(-6f, 0f, -9.77f), new Vector3(6f, 0f, -9.77f),
new Vector3(9.77f, 0f, -6f), new Vector3(9.77f, 0f, 6f),
new Vector3(-9.77f, 0f, -6f), new Vector3(-9.77f, 0f, 6f),
};
static readonly Vector3[] OldIntakeSpots =
{
new Vector3(-6f, 0f, 11f), new Vector3(6f, 0f, 11f),
new Vector3(-6f, 0f, -11f), new Vector3(6f, 0f, -11f),
new Vector3(11f, 0f, -6f), new Vector3(11f, 0f, 6f),
new Vector3(-11f, 0f, -6f), new Vector3(-11f, 0f, 6f),
};
}
}