Add platformer locomotion slice
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Immutable;
|
||||
using SideScrollerGame.Sim.Definitions;
|
||||
using SideScrollerGame.Sim.Input;
|
||||
using SideScrollerGame.Sim.Math;
|
||||
|
||||
namespace SideScrollerGame.Sim.Tests;
|
||||
|
||||
@@ -9,11 +10,11 @@ public sealed class SimulationSerializationTests
|
||||
[Fact]
|
||||
public void SaveStateLoadState_PreservesStateAndNextStepHash()
|
||||
{
|
||||
var definition = SimulationTestFactory.CreateGameDefinition(triggers: ImmutableArray.Create(new TriggerDefinition("checkpoint_a", new(new(11, 21), new(12, 22)), "TriggerActivated")));
|
||||
var definition = SimulationTestFactory.CreateGameDefinition(new(new(0, 0), new(50, 20)), triggers: ImmutableArray.Create(new TriggerDefinition("checkpoint_a", new(new(11, 17), new(12, 18)), "TriggerActivated")), players: ImmutableArray.Create(new PlayerDefinition(new(1), new(10, 20), 10, true, FixPoint16.One, FixPoint16.One, new(3), 1, 1)));
|
||||
var config = SimulationTestFactory.CreateConfig();
|
||||
|
||||
Simulation original = new(definition, config, 17);
|
||||
original.Step(SimulationTestFactory.CreateTick(1, new MoveAxisChanged(new(1), 1, 1)));
|
||||
original.Step(SimulationTestFactory.CreateTick(1, new MoveAxisChanged(new(1), 1, 1), new ButtonChanged(new(1), InputButton.Jump, true)));
|
||||
|
||||
var bytes = original.SaveState();
|
||||
var loaded = Simulation.LoadState(bytes, definition, config);
|
||||
@@ -22,8 +23,10 @@ public sealed class SimulationSerializationTests
|
||||
Assert.Equal(original.CurrentSnapshot.StateHash, loaded.CurrentSnapshot.StateHash);
|
||||
Assert.Equal(original.CurrentState.GetRequiredPlayer(new(1)).Health, loaded.CurrentState.GetRequiredPlayer(new(1)).Health);
|
||||
Assert.Equal(original.CurrentState.ActivatedTriggerIds, loaded.CurrentState.ActivatedTriggerIds);
|
||||
Assert.Equal(original.CurrentState.GetRequiredPlayer(new(1)).VerticalVelocity, loaded.CurrentState.GetRequiredPlayer(new(1)).VerticalVelocity);
|
||||
Assert.Equal(original.CurrentState.GetRequiredPlayer(new(1)).IsGrounded, loaded.CurrentState.GetRequiredPlayer(new(1)).IsGrounded);
|
||||
|
||||
var nextBatch = SimulationTestFactory.CreateTick(2, new ButtonChanged(new(1), InputButton.FirePrimary, true));
|
||||
var nextBatch = SimulationTestFactory.CreateTick(2, new MoveAxisChanged(new(1), 0, 0), new ButtonChanged(new(1), InputButton.FirePrimary, true));
|
||||
var originalHash = original.Step(nextBatch).StateHash;
|
||||
var loadedHash = loaded.Step(nextBatch).StateHash;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user