Add bounds hazards and triggers
This commit is contained in:
@@ -4,13 +4,14 @@ namespace SideScrollerGame.Sim.Runtime;
|
||||
|
||||
public sealed class SimulationState
|
||||
{
|
||||
public SimulationState(int tick, int seed, ulong randomState, ulong lastRandomValue, ImmutableArray<PlayerState> players)
|
||||
public SimulationState(int tick, int seed, ulong randomState, ulong lastRandomValue, ImmutableArray<PlayerState> players, ImmutableHashSet<string> activatedTriggerIds)
|
||||
{
|
||||
Tick = tick;
|
||||
Seed = seed;
|
||||
RandomState = randomState;
|
||||
LastRandomValue = lastRandomValue;
|
||||
Players = players.IsDefault ? ImmutableArray<PlayerState>.Empty : players;
|
||||
ActivatedTriggerIds = activatedTriggerIds == default ? ImmutableHashSet<string>.Empty : activatedTriggerIds;
|
||||
}
|
||||
|
||||
public SimulationState Clone()
|
||||
@@ -19,7 +20,7 @@ public sealed class SimulationState
|
||||
foreach (var player in Players)
|
||||
builder.Add(player.Clone());
|
||||
|
||||
return new(Tick, Seed, RandomState, LastRandomValue, builder.MoveToImmutable());
|
||||
return new(Tick, Seed, RandomState, LastRandomValue, builder.MoveToImmutable(), ActivatedTriggerIds);
|
||||
}
|
||||
|
||||
public PlayerState GetRequiredPlayer(PlayerId playerId)
|
||||
@@ -40,6 +41,15 @@ public sealed class SimulationState
|
||||
LastRandomValue = lastRandomValue;
|
||||
}
|
||||
|
||||
public bool ActivateTrigger(string triggerId)
|
||||
{
|
||||
if (ActivatedTriggerIds.Contains(triggerId))
|
||||
return false;
|
||||
|
||||
ActivatedTriggerIds = ActivatedTriggerIds.Add(triggerId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public int Tick { get; private set; }
|
||||
|
||||
public int Seed { get; }
|
||||
@@ -49,4 +59,6 @@ public sealed class SimulationState
|
||||
public ulong LastRandomValue { get; private set; }
|
||||
|
||||
public ImmutableArray<PlayerState> Players { get; }
|
||||
|
||||
public ImmutableHashSet<string> ActivatedTriggerIds { get; private set; }
|
||||
}
|
||||
Reference in New Issue
Block a user