Add bounds hazards and triggers

This commit is contained in:
2026-04-16 11:50:37 +02:00
parent c79d5c8f0a
commit 45181d1f78
17 changed files with 405 additions and 25 deletions

View File

@@ -23,6 +23,8 @@ internal static class SimulationStateSerializer
public ulong LastRandomValue { get; init; }
public ImmutableArray<PlayerStateDocument> Players { get; init; }
public ImmutableArray<string> ActivatedTriggerIds { get; init; }
}
[ExcludeFromCodeCoverage]
@@ -45,6 +47,8 @@ internal static class SimulationStateSerializer
public int SelectedWeaponSlot { get; init; }
public int ButtonMask { get; init; }
public int Health { get; init; }
}
public static byte[] Serialize(SimulationState state)
@@ -62,7 +66,8 @@ internal static class SimulationStateSerializer
AimAxisX = player.AimAxisX,
AimAxisY = player.AimAxisY,
SelectedWeaponSlot = player.SelectedWeaponSlot,
ButtonMask = player.ButtonMask
ButtonMask = player.ButtonMask,
Health = player.Health
});
}
@@ -73,7 +78,8 @@ internal static class SimulationStateSerializer
Seed = state.Seed,
RandomState = state.RandomState,
LastRandomValue = state.LastRandomValue,
Players = players.ToImmutableArray()
Players = players.ToImmutableArray(),
ActivatedTriggerIds = state.ActivatedTriggerIds.Order(StringComparer.Ordinal).ToImmutableArray()
});
}
@@ -85,10 +91,8 @@ internal static class SimulationStateSerializer
var players = ImmutableArray.CreateBuilder<PlayerState>(document.Players.Length);
foreach (var player in document.Players)
{
players.Add(new(new(player.PlayerId), new(new() { m_Value = player.PositionX }, new FixPoint16 { m_Value = player.PositionY }), player.MoveAxisX, player.MoveAxisY, player.AimAxisX, player.AimAxisY, player.SelectedWeaponSlot, player.ButtonMask));
}
players.Add(new(new(player.PlayerId), new(new() { m_Value = player.PositionX }, new FixPoint16 { m_Value = player.PositionY }), player.MoveAxisX, player.MoveAxisY, player.AimAxisX, player.AimAxisY, player.SelectedWeaponSlot, player.ButtonMask, player.Health));
return new(document.Tick, document.Seed, document.RandomState, document.LastRandomValue, players.MoveToImmutable());
return new(document.Tick, document.Seed, document.RandomState, document.LastRandomValue, players.MoveToImmutable(), document.ActivatedTriggerIds.ToImmutableHashSet(StringComparer.Ordinal));
}
}