When the planet is mown the ending plays by itself: G.R.A.S.S.A. calls, the camera skims the stubble into the base, circles it and rises without a cut into orbit over the bald planet (title, the crew's results). Then a jump across space to a scorched, dried-out Earth: a rocket from Herbaria-7 passes the lens and lands in Africa, and the green spreads from there over the whole globe (seed pods, a glowing front, clouds and blue air coming back). The credits roll over the green Earth (PlayWay credited as publisher), then THE END and a card to keep mowing, leave a review or go to the menu. Space, Enter or Esc skips to the green Earth and the card. - EndingCinematic, EndingEarth (globe, air shell, rocket, seeds), SpaceSky (split out of the intro), EarthGlobe/EarthAir shaders and Earth maps in Resources/Ending - the far meadow shows as stubble once the planet is mown - "all of it" mown now means no sector with grass left (MowMap.Left); mown area summed in double - the crew's total pay and play time are counted and saved for the results - the "ending" cheat; -ending previews it in a test world; the -ending bot shoots every stage - loc for the new lines in all 11 languages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
3.2 KiB
C#
93 lines
3.2 KiB
C#
using System;
|
|
using Unity.Collections;
|
|
using Unity.Netcode;
|
|
using UnityEngine;
|
|
|
|
namespace GrassCutter
|
|
{
|
|
public partial class TeamState
|
|
{
|
|
/// <summary>Sector, what it paid.</summary>
|
|
public static event Action<int, double> SectorClosed;
|
|
/// <summary>Who, which landmark, what it paid.</summary>
|
|
public static event Action<string, int, double> MarkFound;
|
|
|
|
float _mownAt;
|
|
|
|
void WatchSectors()
|
|
{
|
|
MowMap.SectorDone += OnSectorDone;
|
|
Found.OnListChanged += _ => { if (Landmarks.Instance) Landmarks.Instance.Refresh(); Changed?.Invoke(); };
|
|
if (Landmarks.Instance) Landmarks.Instance.Refresh();
|
|
}
|
|
|
|
void UnwatchSectors() => MowMap.SectorDone -= OnSectorDone;
|
|
|
|
/// <summary>Each peer finishes sectors for itself, a little apart: whoever gets there first tells the host.</summary>
|
|
void OnSectorDone(int id)
|
|
{
|
|
if (IsServer) ServerCloseSector(id);
|
|
else SectorDoneRpc(id);
|
|
}
|
|
|
|
[Rpc(SendTo.Server)]
|
|
void SectorDoneRpc(int id, RpcParams rpc = default) => ServerCloseSector(id);
|
|
|
|
void ServerCloseSector(int id)
|
|
{
|
|
if (id < 0 || id >= HexGrid.Cells || !MowMap.Claim(id)) return;
|
|
double pay = GameDefs.SectorBonus(Level(PerkId.RegionBonus)) * Crops.Pays(Crops.At(id));
|
|
Money.Value += pay;
|
|
Earned.Value += pay;
|
|
Closed.Value++;
|
|
SectorClosedRpc(id, pay);
|
|
}
|
|
|
|
[Rpc(SendTo.Everyone)]
|
|
void SectorClosedRpc(int id, double pay)
|
|
{
|
|
MowMap.Close(id);
|
|
SectorClosed?.Invoke(id, pay);
|
|
}
|
|
|
|
/// <summary>What the crew has mown; the whole planet once the last sector with grass on it is done.</summary>
|
|
static double MownNow()
|
|
{
|
|
double area = MowMap.MownArea();
|
|
return MowMap.Left == 0 ? GameDefs.PlanetArea : System.Math.Min(area, GameDefs.PlanetArea * 0.99998d);
|
|
}
|
|
|
|
void TickSectors()
|
|
{
|
|
if (Time.time < _mownAt) return;
|
|
_mownAt = Time.time + 1f;
|
|
Mown.Value = MownNow();
|
|
}
|
|
|
|
// ───────────────────────── stakes & survey points ─────────────────────────
|
|
|
|
[Rpc(SendTo.Server)]
|
|
public void ClaimMarkRpc(int id, RpcParams rpc = default)
|
|
{
|
|
var who = PlayerOf(rpc.Receive.SenderClientId);
|
|
if (!who || id < 0 || id >= Landmarks.Count || Found.Contains(id)) return;
|
|
if ((who.transform.position - Landmarks.Spot(id)).sqrMagnitude > 64f) return;
|
|
double pay = Landmarks.Pay(id);
|
|
Found.Add(id);
|
|
Money.Value += pay;
|
|
Earned.Value += pay;
|
|
MarkFoundRpc(who.DisplayName, id, pay);
|
|
}
|
|
|
|
[Rpc(SendTo.Everyone)]
|
|
void MarkFoundRpc(FixedString64Bytes who, int id, double pay) => MarkFound?.Invoke(who.ToString(), id, pay);
|
|
|
|
public int FoundCount(bool points)
|
|
{
|
|
int n = 0;
|
|
foreach (int id in Found) if (Landmarks.IsPoint(id) == points) n++;
|
|
return n;
|
|
}
|
|
}
|
|
}
|