Cut 5c-1: Multi-human authoritative sim, SimSnapshot/SimEvent boundary, RustToDust.Net & RustToDust.Server
This commit is contained in:
parent
8eba2ea39f
commit
d8f5c49b8d
34 changed files with 5785 additions and 700 deletions
|
|
@ -520,7 +520,7 @@ public partial class ArenaRenderer : Node3D
|
|||
vis.Visual.Root.QueueFree();
|
||||
}
|
||||
|
||||
var role = c.IsPlayer ? VehicleVisualRole.Player : VehicleVisualRole.Rival;
|
||||
var role = c.Id == 0 ? VehicleVisualRole.Player : VehicleVisualRole.Rival;
|
||||
var instance = VehicleVisualInstance.Create(_assetCache, c.Grid.Spec.Id, role);
|
||||
instance.SyncMountedGear(c.Grid);
|
||||
_actorsGroup.AddChild(instance.Root);
|
||||
|
|
@ -537,15 +537,15 @@ public partial class ArenaRenderer : Node3D
|
|||
vis.Visual.Root.Transform = new Transform3D(new Basis(q), pos);
|
||||
|
||||
float distSq = hasCam ? pos.DistanceSquaredTo(camPos) : 0f;
|
||||
bool castShadows = !hasCam || c.IsPlayer || distSq <= 75f * 75f;
|
||||
bool useStaticLod = hasCam && !c.IsPlayer && !vis.Visual.HasAnyStrippedCell &&
|
||||
bool castShadows = !hasCam || c.Id == 0 || distSq <= 75f * 75f;
|
||||
bool useStaticLod = hasCam && c.Id != 0 && !vis.Visual.HasAnyStrippedCell &&
|
||||
(vis.Visual.IsStaticLod ? distSq > 64f * 64f : distSq > 68f * 68f);
|
||||
vis.Visual.SetLodState(useStaticLod, castShadows);
|
||||
|
||||
vis.Visual.SyncMountedGear(c.Grid);
|
||||
if (!useStaticLod)
|
||||
{
|
||||
if (!hasCam || c.IsPlayer || distSq <= 55f * 55f)
|
||||
if (!hasCam || c.Id == 0 || distSq <= 55f * 55f)
|
||||
{
|
||||
vis.RigDtAccum = 0f;
|
||||
vis.RigSkipFrames = 0;
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public partial class Hud : CanvasLayer
|
|||
public void Sync(ArenaSession session)
|
||||
{
|
||||
var state = session.State;
|
||||
var player = state.Player;
|
||||
var player = state.Contenders[0];
|
||||
|
||||
// Top-Left Status
|
||||
_chassisHeader.Text = player.Grid.Spec.Name.ToUpperInvariant();
|
||||
|
|
@ -202,9 +202,10 @@ public partial class Hud : CanvasLayer
|
|||
_safeLabel.Modulate = RedCol;
|
||||
}
|
||||
|
||||
if (state.PlayerDetectedByCount > 0)
|
||||
int detectedBy = state.ObserverStates.TryGetValue(0, out var obs0) ? obs0.DetectedByCount : 0;
|
||||
if (detectedBy > 0)
|
||||
{
|
||||
_detectionLabel.Text = $"DETECTED BY {state.PlayerDetectedByCount}";
|
||||
_detectionLabel.Text = $"DETECTED BY {detectedBy}";
|
||||
_detectionLabel.Modulate = RedCol;
|
||||
}
|
||||
else
|
||||
|
|
@ -237,14 +238,14 @@ public partial class Hud : CanvasLayer
|
|||
SyncBroadcastChyron(state.Broadcast);
|
||||
|
||||
// Outcome
|
||||
if (state.Phase == MatchPhase.Victory)
|
||||
if (state.Phase == MatchPhase.Completed && state.WinnerContenderId == 0)
|
||||
{
|
||||
_outcomeBanner.Visible = true;
|
||||
_outcomeBanner.ChromeMaterial.SetShaderParameter("accent_color", OliveCol);
|
||||
_outcomeLabel.Text = "VICTORY — LAST RIG STANDING\n[R] New Drop";
|
||||
_outcomeLabel.Modulate = OliveCol;
|
||||
}
|
||||
else if (state.Phase == MatchPhase.Defeat)
|
||||
else if (!player.Alive || state.Phase == MatchPhase.Completed)
|
||||
{
|
||||
_outcomeBanner.Visible = true;
|
||||
_outcomeBanner.ChromeMaterial.SetShaderParameter("accent_color", RedCol);
|
||||
|
|
@ -513,7 +514,7 @@ public partial class Hud : CanvasLayer
|
|||
{
|
||||
var session = _getSession();
|
||||
if (session is null) return;
|
||||
var cargo = session.State.Player.Grid.Cargo;
|
||||
var cargo = session.State.Contenders[0].Grid.Cargo;
|
||||
if (_selectedCargoIndex >= 0 && _selectedCargoIndex < cargo.Count)
|
||||
{
|
||||
_onEquipCargo(_selectedCargoIndex, hardpointId);
|
||||
|
|
@ -1068,13 +1069,14 @@ public partial class Hud : CanvasLayer
|
|||
}
|
||||
|
||||
// Spectator Wall (LOS / Tourist horizon rule / 5s ghost memory; hidden Exemplars vanish!)
|
||||
var obs0 = _state.GetOrCreateObserverState(0);
|
||||
var specs = _state.Spectators.Spectators;
|
||||
for (int i = 0; i < specs.Count; i++)
|
||||
{
|
||||
var s = specs[i];
|
||||
if (!s.Alive) continue;
|
||||
|
||||
_state.SpectatorContacts.TryGetValue(s.Id, out var mem);
|
||||
obs0.SpectatorContacts.TryGetValue(s.Id, out var mem);
|
||||
if (!MatchState.IsContactOnRadar(mem))
|
||||
{
|
||||
continue;
|
||||
|
|
@ -1100,11 +1102,11 @@ public partial class Hud : CanvasLayer
|
|||
if (tid >= 0 && tid < _state.Contenders.Count && _state.Contenders[tid].Alive)
|
||||
{
|
||||
var tgt = _state.Contenders[tid];
|
||||
bool targetVisible = tgt.IsPlayer ||
|
||||
(_state.ContenderContacts.TryGetValue(tgt.Id, out var tgtMem) && tgtMem.VisibleToPlayer);
|
||||
bool targetVisible = tgt.Id == 0 ||
|
||||
(obs0.ContenderContacts.TryGetValue(tgt.Id, out var tgtMem) && tgtMem.VisibleToPlayer);
|
||||
if (targetVisible)
|
||||
{
|
||||
float tgtClampR = MathF.Max(4f, radius - (tgt.IsPlayer ? 7.5f : 4.3f));
|
||||
float tgtClampR = MathF.Max(4f, radius - (tgt.Id == 0 ? 7.5f : 4.3f));
|
||||
var tp = ClampToRadarDisc(center, tgtClampR, WorldToRadar(center, scale, tgt.X, tgt.Z, _cameraYaw));
|
||||
DrawLine(p, tp, new Color(RedCol.R, RedCol.G, RedCol.B, 0.65f), 1.3f);
|
||||
}
|
||||
|
|
@ -1134,7 +1136,7 @@ public partial class Hud : CanvasLayer
|
|||
var c = _state.Contenders[i];
|
||||
if (!c.Alive) continue;
|
||||
|
||||
if (c.IsPlayer)
|
||||
if (c.Id == 0)
|
||||
{
|
||||
float playerClampR = MathF.Max(4f, radius - 6.5f - 1f);
|
||||
var p = ClampToRadarDisc(center, playerClampR, WorldToRadar(center, scale, c.X, c.Z, _cameraYaw));
|
||||
|
|
@ -1152,7 +1154,7 @@ public partial class Hud : CanvasLayer
|
|||
continue;
|
||||
}
|
||||
|
||||
_state.ContenderContacts.TryGetValue(c.Id, out var mem);
|
||||
obs0.ContenderContacts.TryGetValue(c.Id, out var mem);
|
||||
if (!MatchState.IsContactOnRadar(mem))
|
||||
{
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public partial class Main : Node3D
|
|||
|
||||
private void SetupPerfCombatScenario(ArenaSession session)
|
||||
{
|
||||
var p = session.State.Player;
|
||||
var p = session.State.Contenders[0];
|
||||
float fwdX = MathF.Sin(p.Yaw);
|
||||
float fwdZ = MathF.Cos(p.Yaw);
|
||||
float rightX = -fwdZ;
|
||||
|
|
@ -187,8 +187,8 @@ public partial class Main : Node3D
|
|||
|
||||
try
|
||||
{
|
||||
_session = new ArenaSession(seed, _mapKind);
|
||||
var p = _session.State.Player;
|
||||
_session = new ArenaSession(seed, _mapKind, slot0Human: true);
|
||||
var p = _session.State.Contenders[0];
|
||||
_cameraYaw = p.Yaw;
|
||||
_cameraPitch = _mapKind == ArenaMapKind.Sion ? Mathf.DegToRad(5f) : Mathf.DegToRad(12f);
|
||||
_cameraZoom = 1.0f;
|
||||
|
|
@ -319,7 +319,8 @@ public partial class Main : Node3D
|
|||
if (_perfTargetFrames > 0)
|
||||
{
|
||||
long t0 = Stopwatch.GetTimestamp();
|
||||
_session.Step(input);
|
||||
_session.SetHumanInput(0, input);
|
||||
_session.Step();
|
||||
long t1 = Stopwatch.GetTimestamp();
|
||||
double toMs = 1000.0 / Stopwatch.Frequency;
|
||||
_perfPendingStepMs += (t1 - t0) * toMs;
|
||||
|
|
@ -327,7 +328,8 @@ public partial class Main : Node3D
|
|||
}
|
||||
else
|
||||
{
|
||||
_session.Step(input);
|
||||
_session.SetHumanInput(0, input);
|
||||
_session.Step();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,7 +538,7 @@ public partial class Main : Node3D
|
|||
if (Input.IsKeyPressed(Key.D) || Input.IsKeyPressed(Key.Right)) steer += 1f;
|
||||
if (Input.IsKeyPressed(Key.A) || Input.IsKeyPressed(Key.Left)) steer -= 1f;
|
||||
|
||||
bool isVtol = Session.State.Player.Grid.Spec.IsVtol;
|
||||
bool isVtol = Session.State.Contenders[0].Grid.Spec.IsVtol;
|
||||
float verticalThrottle = 0f;
|
||||
if (Input.IsKeyPressed(Key.Space)) verticalThrottle += 1f;
|
||||
if (Input.IsKeyPressed(Key.C) || Input.IsKeyPressed(Key.Ctrl)) verticalThrottle -= 1f;
|
||||
|
|
@ -561,7 +563,7 @@ public partial class Main : Node3D
|
|||
|
||||
private (float AimX, float AimY, float AimZ) ComputeCenterScreenAim()
|
||||
{
|
||||
var player = Session.State.Player;
|
||||
var player = Session.State.Contenders[0];
|
||||
var spec = player.Grid.Spec;
|
||||
Vector2 screenSize = GetViewport().GetVisibleRect().Size;
|
||||
if (screenSize.X < 2f || screenSize.Y < 2f)
|
||||
|
|
@ -667,7 +669,7 @@ public partial class Main : Node3D
|
|||
|
||||
private void UpdateCamera(float dt, float alpha)
|
||||
{
|
||||
var p = Session.State.Player;
|
||||
var p = Session.State.Contenders[0];
|
||||
var spec = p.Grid.Spec;
|
||||
var (posInterp, _, _) = Session.GetInterpolatedContenderPose(p.Id, alpha);
|
||||
|
||||
|
|
@ -794,7 +796,7 @@ public partial class Main : Node3D
|
|||
|
||||
private void OnEquipCargo(int cargoIndex, string hardpointId)
|
||||
{
|
||||
_session?.TryEquipCargo(cargoIndex, hardpointId);
|
||||
_session?.TryEquipCargo(0, cargoIndex, hardpointId);
|
||||
}
|
||||
|
||||
private void SetupLightingAndSky()
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public partial class Smoke : Node
|
|||
Check(!_main.GetWorld3D().Space.IsValid, "Godot should have no active 3D physics space");
|
||||
Check(_main.Terrain.BakedTileCount == 64, $"Expected 64 baked terrain tiles, got {_main.Terrain.BakedTileCount}");
|
||||
|
||||
var player = _main.Session.State.Player;
|
||||
var player = _main.Session.State.Contenders[0];
|
||||
float startX = player.X;
|
||||
float startZ = player.Z;
|
||||
|
||||
|
|
@ -580,7 +580,7 @@ public partial class Smoke : Node
|
|||
}
|
||||
|
||||
// Seed realistic combat telemetry so the preview clearly showcases armor stripping, hit-flash, cargo rack, and thermal heat
|
||||
var player = _main.Session.State.Player;
|
||||
var player = _main.Session.State.Contenders[0];
|
||||
var grid = player.Grid;
|
||||
grid.TryAddCargo(Catalog.TouringPlasma);
|
||||
grid.TryAddCargo(Catalog.GoldRadiator);
|
||||
|
|
@ -925,7 +925,7 @@ public partial class Smoke : Node
|
|||
|
||||
// 6. All 7 walkers (including Kestrel) walk through real ArenaSession + Hybrid B FK snapshot cleanly
|
||||
{
|
||||
using var walkSession = new RustToDust.Ymir.ArenaSession(seed: 42, mapKind: ArenaMapKind.Desert);
|
||||
using var walkSession = new RustToDust.Ymir.ArenaSession(seed: 42, mapKind: ArenaMapKind.Desert, slot0Human: true);
|
||||
for (int cIdx = 1; cIdx < walkSession.State.Contenders.Count; cIdx++)
|
||||
{
|
||||
walkSession.SetContenderPose(cIdx, 450f + cIdx * 18f, 450f);
|
||||
|
|
@ -946,10 +946,10 @@ public partial class Smoke : Node
|
|||
{
|
||||
var wSpec = Catalog.ChassisById[wId];
|
||||
walkSession.SetContenderPose(0, 0f, 0f, 0f);
|
||||
if (walkSession.State.Player.Grid.Spec.Id != wId)
|
||||
if (walkSession.State.Contenders[0].Grid.Spec.Id != wId)
|
||||
{
|
||||
walkSession.State.SpawnChassisDrop(0f, 0f, wSpec);
|
||||
Check(walkSession.TrySwapNearbyChassis(), $"Failed to swap walkSession player to '{wId}'");
|
||||
Check(walkSession.TrySwapNearbyChassis(0), $"Failed to swap walkSession player to '{wId}'");
|
||||
}
|
||||
|
||||
var vis = VehicleVisualInstance.Create(cache, wId, VehicleVisualRole.Player);
|
||||
|
|
@ -961,10 +961,10 @@ public partial class Smoke : Node
|
|||
Check(footNode is not null && pelvisNode is not null,
|
||||
$"Missing FK nodes '{footNodeName}'/'{pelvisNodeName}' on walker '{wId}'");
|
||||
|
||||
var player = walkSession.State.Player;
|
||||
var player = walkSession.State.Contenders[0];
|
||||
for (int step = 0; step < 60; step++)
|
||||
{
|
||||
walkSession.Step(new PlayerInput(
|
||||
walkSession.SetHumanInput(0, new PlayerInput(
|
||||
Throttle: 1f,
|
||||
Steer: 0f,
|
||||
AimWorldX: player.X,
|
||||
|
|
@ -972,6 +972,7 @@ public partial class Smoke : Node
|
|||
Fire: false,
|
||||
InteractPickup: false,
|
||||
Brake: false));
|
||||
walkSession.Step();
|
||||
|
||||
bool hasSnap = walkSession.TrySampleInterpolatedWalkerPose(true, player.Id, 1f, out var walkerSnap);
|
||||
Check(hasSnap, $"Missing WalkerVisualSnapshot for '{wId}' at step {step}");
|
||||
|
|
@ -1133,7 +1134,7 @@ public partial class Smoke : Node
|
|||
// 10. MultiMeshPartPool & PomDecalPool sanity: live arena submits into MultiMeshPartPool and PomDecalPool stamps impacts cleanly
|
||||
{
|
||||
_main.Arena.PomDecals.StampTestDecal(
|
||||
new Vector3(_main.Session.State.Player.X + 2f, _main.Session.State.Terrain.SampleHeight(_main.Session.State.Player.X + 2f, _main.Session.State.Player.Z) + 0.03f, _main.Session.State.Player.Z),
|
||||
new Vector3(_main.Session.State.Contenders[0].X + 2f, _main.Session.State.Terrain.SampleHeight(_main.Session.State.Contenders[0].X + 2f, _main.Session.State.Contenders[0].Z) + 0.03f, _main.Session.State.Contenders[0].Z),
|
||||
Vector3.Up, 1.2f, tileIndex: 14);
|
||||
_main.Arena.Sync(_main.Session, 1.6f, 1f / 60f);
|
||||
Check(_main.Arena.PartPool.TotalSubmittedInstances > 0,
|
||||
|
|
@ -1141,7 +1142,7 @@ public partial class Smoke : Node
|
|||
Check(_main.Arena.PomDecals.ActiveCount >= 1,
|
||||
$"Expected PomDecalPool to hold >= 1 active decal, got {_main.Arena.PomDecals.ActiveCount}");
|
||||
|
||||
_main.Hud.PushTestHitArc(_main.Session.State.Player.X + 20f, _main.Session.State.Player.Z + 10f, WeaponVisualClass.Explosive);
|
||||
_main.Hud.PushTestHitArc(_main.Session.State.Contenders[0].X + 20f, _main.Session.State.Contenders[0].Z + 10f, WeaponVisualClass.Explosive);
|
||||
Check(_main.Hud.ActiveHitArcCount >= 1, "Expected CrosshairOverlay to accept incoming hit arc");
|
||||
}
|
||||
|
||||
|
|
@ -1223,7 +1224,7 @@ public partial class Smoke : Node
|
|||
int vfxBefore = _main.Arena.TransientVfxCount;
|
||||
|
||||
int tracerId = _main.Session.State.AllocateTracerId();
|
||||
Vector3 pPos = new(_main.Session.State.Player.X, _main.Session.State.Player.Y, _main.Session.State.Player.Z);
|
||||
Vector3 pPos = new(_main.Session.State.Contenders[0].X, _main.Session.State.Contenders[0].Y, _main.Session.State.Contenders[0].Z);
|
||||
tracers.Add(new TracerEvent(
|
||||
pPos.X, pPos.Y + 1f, pPos.Z,
|
||||
pPos.X + 20f, pPos.Y + 1f, pPos.Z,
|
||||
|
|
@ -1400,7 +1401,7 @@ public partial class Smoke : Node
|
|||
|
||||
private async Task VerifyMaxLoadPaladinGarageAsync()
|
||||
{
|
||||
var grid = _main.Session.State.Player.Grid;
|
||||
var grid = _main.Session.State.Contenders[0].Grid;
|
||||
grid.SwapChassis(Catalog.Paladin);
|
||||
Check(grid.TryMount(Catalog.TouringPlasma, "hp.weapon.sh_l"), "Expected TouringPlasma on Paladin hp.weapon.sh_l");
|
||||
Check(grid.TryMount(Catalog.WeldedPlate, "hp.armor.torso"), "Expected WeldedPlate on Paladin hp.armor.torso");
|
||||
|
|
@ -1483,7 +1484,7 @@ public partial class Smoke : Node
|
|||
Vector2 vpSize = GetViewport().GetVisibleRect().Size;
|
||||
Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"Sion HUD panels overlapped or clipped at {vpSize}");
|
||||
|
||||
var player = sionState.Player;
|
||||
var player = sionState.Contenders[0];
|
||||
float startX = player.X;
|
||||
float startZ = player.Z;
|
||||
_main.SetScriptedInput(new PlayerInput(
|
||||
|
|
|
|||
Loading…
Reference in a new issue