Ending: the Director's call, flyovers into orbit, Earth turning green, credits

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>
This commit is contained in:
Bonchellon
2026-11-28 01:52:24 +03:00
parent 5e30bd4c26
commit 3ee5956694
43 changed files with 2405 additions and 72 deletions

View File

@ -31,7 +31,7 @@ namespace GrassCutter
static float s_next;
static bool s_read;
static bool Dev => CommandLine.Has("-autodemo") || CommandLine.Has("-mpdemo");
static bool Dev => CommandLine.Has("-autodemo") || CommandLine.Has("-mpdemo") || EndingCinematic.Preview;
static string Key => Dev ? "gc_awards_dev" : "gc_awards";
static Achievements()
@ -107,7 +107,8 @@ namespace GrassCutter
PlayerPrefs.Save();
Hud.Toast(Loc.F("Achievement: {0}", a.name), Hud.ToastKind.Info);
Sfx.Play("milestone", 0.7f);
if (SteamManager.Initialized)
// test runs earn them on this computer only, never on the player's Steam account
if (SteamManager.Initialized && !Dev)
{
SteamUserStats.SetAchievement(a.id);
SteamUserStats.StoreStats();

View File

@ -52,6 +52,7 @@ namespace GrassCutter
Add("beer", "", "Drink a Grass Beer, no machine and no grass needed.", _ => { TreatHand.I?.Play(TreatId.Beer); return "Cheers."; });
Add("cigar", "", "Light a Herb Cigar, no machine and no grass needed.", _ => { TreatHand.I?.Play(TreatId.Cigar); return "Puff."; });
Add("ufo", "", "Bring a saucer down 30 m ahead of you.", _ => { Ts.ServerUfo(Me.transform.position + Me.transform.forward * 30f); return "They're coming."; });
Add("ending", "", "Play the ending film now (for you only).", _ => { EndingCinematic.Force = true; return "The planet is mown."; }, hostOnly: false);
Add("save", "", "Save the game now.", _ => { Ts.Save(); return "Saved."; });
Add("clear", "", "Clear the console.", _ => null, hostOnly: false);
}

View File

@ -0,0 +1,125 @@
using System.Collections;
using System.Linq;
using UnityEngine;
namespace GrassCutter
{
public partial class DemoBot
{
/// <summary>
/// -ending: a new world mown bald sector by sector until the planet goes past the line, and the ending that follows by
/// itself: the call, the climb, the planet, the results, the credits, THE END and the card; then back into the game,
/// and the film again from the cheat, skipped.
/// </summary>
IEnumerator EndingDemo()
{
TeamState.DeleteSave();
yield return new WaitForSeconds(2f);
NetSession.Instance.HostLocal();
while (!Me || !Ts) yield return null;
Clock(9.5f);
yield return new WaitForSeconds(9f);
Ts.ServerDeposit(48000f, CargoKind.Grass, Me.transform.position);
yield return Shot("end_00_before");
// every sector down, a slice a frame
float t0 = Time.realtimeSinceStartup;
for (int id = 0; id < HexGrid.Cells; id++)
{
MowMap.Close(id);
if (id % 4000 == 0) yield return null;
}
Log($"closed {HexGrid.Cells} sectors in {Time.realtimeSinceStartup - t0:0.0} s");
{
float fsum = 0f; double total = 0d; int empty = 0, done = 0;
foreach (var m in MowMap.All) { fsum += m.mown; total += m.total; if (m.total <= 0f) empty++; if (m.done) done++; }
Log($"mown {MowMap.MownArea():0} m² (float sum {fsum:0}), grass {total:0} m², planet {GameDefs.PlanetArea:0} m², sector {GameDefs.SectorArea:0.0} m², masks {MowMap.All.Count()} done {done} empty {empty}, finished {MowMap.Finished}");
}
float wait = Time.time;
while (!EndingCinematic.Running && Time.time - wait < 60f) yield return null;
Log($"ending started by itself: {EndingCinematic.Running}, planet {Ts.Mown01 * 100d:0.00000}%, seen before {EndingCinematic.Seen}");
if (!EndingCinematic.Running) { EndingCinematic.Force = true; while (!EndingCinematic.Running) yield return null; }
float s = Time.time;
yield return Until(s, 9f, "Call"); yield return Shot("end_01_call");
// the flights: skim, arc round the base, (a machine), the rise; times from the start of each stage
yield return AtStage("Climb", 2.5f, "end_02_skim");
yield return AtStage("Climb", 5.6f, "end_02b_skim_late");
yield return AtStage("Climb", 8.5f, "end_03_arc");
yield return AtStage("Climb", 12.5f, "end_03b_arc_late");
yield return AtStage("Space", 1.5f, "end_04a_rise_low");
yield return AtStage("Space", 5.5f, "end_04b_rise_mid");
yield return AtStage("Space", 8.5f, "end_04c_rise_high");
yield return AtStage("Space", 10.8f, "end_04d_rise_top");
yield return AtStage("Space", 14.0f, "end_05_title");
yield return AtStage("Space", 21.5f, "end_06_line");
yield return StageShot("Results", 5.5f, "end_07_results");
yield return AtStage("Earth", 0.5f, "end_08a_warp");
yield return AtStage("Earth", 5.0f, "end_08b_earth_title");
yield return AtStage("Earth", 8.7f, "end_08c_rocket_pass");
yield return AtStage("Earth", 9.7f, "end_08c2_rocket_away");
yield return AtStage("Earth", 12.5f, "end_08d_rocket_down");
yield return AtStage("Earth", 15.6f, "end_08e_landing");
yield return AtStage("Earth", 20f, "end_08f_greening");
yield return AtStage("Earth", 26f, "end_08g_line");
yield return AtStage("Earth", 33.5f, "end_08h_green");
yield return StageShot("Credits", 12f, "end_09_credits");
while (EndingCinematic.Stage != "End" && EndingCinematic.Running) yield return null;
yield return new WaitForSeconds(2.2f);
yield return Shot("end_10_theend");
yield return new WaitForSeconds(4.5f);
yield return Shot("end_10_card");
Log($"at the card: seen {EndingCinematic.Seen}, cinematic {Ctl.Cinematic}, modal {UIRoot.I.AnyModal}, {Time.time - s:0} s in");
UIRoot.I.CloseTopModal();
yield return new WaitForSeconds(1.5f);
Log($"keep mowing: running {EndingCinematic.Running}, cinematic {Ctl.Cinematic}, camera local {CameraFx.Cam.transform.localPosition}");
yield return Shot("end_11_back");
// again from the cheat, skipped a few seconds in
Cheats.Run("ending");
while (!EndingCinematic.Running) yield return null;
yield return new WaitForSeconds(4f);
EndingCinematic.SkipNow();
yield return new WaitForSeconds(7.5f);
yield return Shot("end_12_skipped");
Log($"skipped: stage {EndingCinematic.Stage}, modal {UIRoot.I.AnyModal}");
UIRoot.I.CloseTopModal();
yield return new WaitForSeconds(1f);
Log($"ending done: running {EndingCinematic.Running}, cinematic {Ctl.Cinematic}");
Application.Quit();
}
static IEnumerator Until(float since, float maxWait, string stage)
{
while (EndingCinematic.Stage != stage && Time.time - since < maxWait + 60f && EndingCinematic.Running) yield return null;
}
string _endStage;
float _endStageAt;
/// <summary>A picture this long after the film reached a stage (skipped when the film has moved past the stage).</summary>
IEnumerator AtStage(string stage, float at, string name)
{
while (EndingCinematic.Running)
{
var now = EndingCinematic.Stage;
if (now != _endStage) { _endStage = now; _endStageAt = Time.time; }
if (now == stage && Time.time - _endStageAt >= at) break;
if (now != stage && _seenStages.Contains(stage)) yield break;
if (now == stage) _seenStages.Add(stage);
yield return null;
}
if (!EndingCinematic.Running) yield break;
yield return Shot(name);
}
readonly System.Collections.Generic.HashSet<string> _seenStages = new System.Collections.Generic.HashSet<string>();
IEnumerator StageShot(string stage, float after, string name)
{
while (EndingCinematic.Stage != stage && EndingCinematic.Running) yield return null;
yield return new WaitForSeconds(after);
yield return Shot(name);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bab9c3d61fba2e147a3b0a62314efc20

View File

@ -43,7 +43,7 @@ namespace GrassCutter
var train = Train.All.Count > 0 ? Train.All[0] : null;
if (!train) { Log($"{me}: no train"); Application.Quit(); yield break; }
MowMap.Count();
float mown0 = MowMap.MownArea();
double mown0 = MowMap.MownArea();
float at0 = train.At.Value;
yield return new WaitForSeconds(12f);
MowMap.Count();

View File

@ -2879,7 +2879,7 @@ namespace GrassCutter
// the client takes the mower out: its strip must land on the host too
var rider = Vehicle.All.Find(v => v.kind == VehicleKind.Rider);
float mownBefore = MowMap.MownArea();
double mownBefore = MowMap.MownArea();
if (!host && rider)
{
rider.Interact();
@ -3086,6 +3086,11 @@ namespace GrassCutter
yield return gameObject.AddComponent<Trailer>().Shoot(folder);
yield break;
}
if (CommandLine.Has("-ending"))
{
yield return EndingDemo();
yield break;
}
if (CommandLine.Has("-demoend"))
{
yield return DemoEndDemo();

View File

@ -69,7 +69,7 @@ namespace GrassCutter
return -1;
}
static bool Dev => CommandLine.Has("-autodemo") || CommandLine.Has("-mpdemo");
static bool Dev => CommandLine.Has("-autodemo") || CommandLine.Has("-mpdemo") || EndingCinematic.Preview;
/// <summary>Without Steam (and in test runs) the slots sit straight in here.</summary>
static string Shared => Path.Combine(Application.persistentDataPath, Dev ? "saves_dev" : "saves");
static string _ready;