Skip to content
This repository was archived by the owner on Oct 22, 2023. It is now read-only.

Commit 3e1a018

Browse files
authored
Merge pull request #20 from proepkes/develop
Cleanup all input entities
2 parents 7bd23e6 + 29562ae commit 3e1a018

File tree

18 files changed

+52
-26
lines changed

18 files changed

+52
-26
lines changed

Engine/Client/Implementations/LocalDataReceiver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public void Init()
1414
InitReceived?.Invoke(this, EventArgs.Empty);
1515
}
1616

17-
public void AddFrame(Frame frame)
17+
public void Receive(Frame frame)
1818
{
1919
FrameReceived?.Invoke(this, frame);
2020
}

Engine/Client/Implementations/NetworkedDataReceiver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Lockstep.Network.Utils;
88

99
namespace Lockstep.Client.Implementations
10-
{
10+
{
1111
public class NetworkedDataReceiver : IDataReceiver
1212
{
1313
private readonly INetwork _network;

Engine/Client/Simulation.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
namespace Lockstep.Client
77
{
8-
/// <summary>
9-
/// This simulation listens for received data from the client and reacts accordingly. 'Executed' commands are first sent to the server.
10-
/// The final execution is done when the corresponding frame-packet arrives - this adds minimum 1 RTT delay to commands.
11-
/// </summary>
128
public class Simulation
139
{
1410
public event EventHandler Started;

Engine/Core/Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<Compile Include="Properties\AssemblyInfo.cs" />
129129
<Compile Include="ServiceContainer.cs" />
130130
<Compile Include="Systems\CalculateHashCode.cs" />
131+
<Compile Include="Systems\Input\CleanupInput.cs" />
131132
<Compile Include="Systems\Input\EmitInput.cs" />
132133
<Compile Include="Systems\Input\OnSpawnInputDoLoadEntityIntoGame.cs" />
133134
<Compile Include="Systems\Navigation\NavigationTick.cs" />

Engine/Core/Features/InputFeature.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ public InputFeature(Contexts contexts, ServiceContainer serviceContainer)
1111
//TODO: Add InputValidationSystem by matching input with playerId
1212
Add(new EmitInput(contexts));
1313

14-
Add(new OnSpawnInputDoLoadEntityIntoGame(contexts, serviceContainer.Get<IGameService>()));
14+
Add(new OnSpawnInputDoLoadEntityIntoGame(contexts, serviceContainer.Get<IGameService>()));
15+
16+
Add(new CleanupInput(contexts));
1517
}
1618
}
1719
}

Engine/Core/LockstepSystems.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
namespace Lockstep.Core
66
{
77
public sealed class LockstepSystems : Entitas.Systems, ISystems
8-
{
9-
private IFrameBuffer _frameBuffer;
10-
private readonly Contexts _contexts;
11-
8+
{
129
public long HashCode => _contexts.gameState.hashCode.value;
1310

14-
public void SetFrameBuffer(IFrameBuffer frameBuffer)
15-
{
16-
_frameBuffer = frameBuffer;
17-
}
11+
private IFrameBuffer _frameBuffer;
12+
private readonly Contexts _contexts;
1813

1914
public LockstepSystems(Contexts contexts, params IService[] additionalServices)
2015
{
@@ -36,6 +31,10 @@ public LockstepSystems(Contexts contexts, params IService[] additionalServices)
3631
Add(new HashCodeFeature(contexts, serviceContainer));
3732
}
3833

34+
public void SetFrameBuffer(IFrameBuffer frameBuffer)
35+
{
36+
_frameBuffer = frameBuffer;
37+
}
3938

4039
public void Tick()
4140
{
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Entitas;
2+
3+
namespace Lockstep.Core.Systems.Input
4+
{
5+
public class CleanupInput : ICleanupSystem
6+
{
7+
private readonly InputContext _inputContext;
8+
9+
public CleanupInput(Contexts contexts)
10+
{
11+
_inputContext = contexts.input;
12+
}
13+
14+
public void Cleanup()
15+
{
16+
_inputContext.DestroyAllEntities();
17+
}
18+
}
19+
}

Engine/Server/Room.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Server
99
{
1010
public class Room
1111
{
12-
private const int TargetFps = 20;
12+
private const int TargetFps = 50;
1313

1414
private byte _nextPlayerId;
1515
private readonly int _size;

Engine/Test/InputTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void TestGameEntityHasUniqueId()
3939
[Fact]
4040
public void TestCommandIsExecuted()
4141
{
42-
var command = new Mock<ICommand>();
42+
var command = new Mock<ICommand>();
4343

4444
new Simulation(new LockstepSystems(new Contexts()), new LocalDataReceiver()).Execute(command.Object);
4545

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)