Map sectors show again, clients get their own machines and the train's swath, machines stay out of the ground

- Map: the sectors are wound the screen's way (most were wound the other way and culled, leaving a blank chart),
  kept inside the chart, and drawn as ball, sectors and marks layers; the scale bar is no longer sized mid-draw.
- Players' save keys are replicated, so a client's garage finds its machines and their upgrades; two players under
  one key get separate ones.
- The grass train sends its mowing to the clients; moving the depot or resizing the planet relays its line.
- A hard floor under vehicle springs: hard landings, steep rises and hand-overs no longer sink a machine.
- Tests: -demosink, -demorep host|client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-12 01:33:03 +06:00
parent 86c8403c2a
commit d61167e22b
10 changed files with 474 additions and 33 deletions

View File

@ -274,6 +274,35 @@ namespace GrassCutter
// ───────────────────────── physics (owner) ─────────────────────────
readonly float[] _clear = new float[4];
/// <summary>The nose and the tail, along the middle, past the springs: what digs in first on a rise or a hard landing.</summary>
static readonly float[] Ends = { 0.5f, -0.5f, 0f };
/// <summary>
/// A hard floor under the springs. They are soft enough to ride a meadow, so a hard landing, a steep rise or the
/// moment after a hand-over squeezed them right through and a corner (or the nose) went into the ground; nothing
/// else holds a machine up, the ground itself has no collider. Whatever is below the ground comes straight back
/// up, and stops falling.
/// </summary>
void Floor(Vector3 up)
{
float sink = 0f;
for (int i = 0; i < _clear.Length; i++) sink = Mathf.Max(sink, -_clear[i]);
for (int i = 0; i < Ends.Length; i++)
sink = Mathf.Max(sink, -Planet.Altitude(transform.TransformPoint(new Vector3(0f, 0f, Ends[i] * length))));
if (sink < 0.02f || NoFloor) return;
sink = Mathf.Min(sink, 3f);
Body.position += up * sink;
float down = Vector3.Dot(Body.linearVelocity, up);
if (down < 0f) Body.linearVelocity -= up * down;
Sinks++;
}
/// <summary>How often the floor had to catch a machine (the tests read it).</summary>
public static int Sinks;
/// <summary>Tests: the floor off, to see how it was.</summary>
public static bool NoFloor;
static readonly Vector2[] Probes = { new Vector2(-0.5f, 0.42f), new Vector2(0.5f, 0.42f), new Vector2(-0.5f, -0.42f), new Vector2(0.5f, -0.42f) };
void FixedUpdate()
@ -311,6 +340,7 @@ namespace GrassCutter
if (_ghost) clearance = Mathf.Min(clearance, DeckClearance(wp, up, 1.2f + ride + 1.5f));
else if (Physics.Raycast(wp + up * 1.2f, -up, out var sh, 1.2f + ride + 1.5f, groundMask, QueryTriggerInteraction.Ignore))
clearance = Mathf.Min(clearance, sh.distance - 1.2f);
_clear[i] = clearance;
float depth = ride - clearance;
if (depth > 0f)
{
@ -321,6 +351,7 @@ namespace GrassCutter
}
}
bool onGround = wet > 0;
Floor(up);
// drive
var fwd = Vector3.ProjectOnPlane(transform.forward, up).normalized;