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

Commit cc9305b

Browse files
authored
Upgrade entities (#191)
* Upgrade to use Entities preview.33 Remove BlittableBool Fix bug where stopping the game threw an error about removing the authoritative player entity. * Changelog * Update pin
1 parent 106d8f1 commit cc9305b

23 files changed

+118
-125
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Marked the Linux builds for the GameLogic worker and the Simulated Player Coordinator as required.
99
- Updated `GdkToolsConfiguration.json` following the [no-more-schema-copying change in the GDK](https://github.com/spatialos/gdk-for-unity/pull/953).
1010
- Updated the package names of FPS project schema.
11+
- Upgrade to Unity Entities preview.33
1112

1213
## `0.2.2` - 2019-05-15
1314

gdk.pinned

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
402f53a4ead891177fb5bc099f66474991ede2ef
1+
3efffab0103556d09f2ae7e788d555e23367f069

workers/unity/Assets/Fps/Scripts/GameLogic/Animation/ProxyAnimation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private void Update()
5555
}
5656
}
5757

58-
private void OnAiming(BlittableBool isAiming)
58+
private void OnAiming(bool isAiming)
5959
{
6060
fpsAnimator.SetAiming(isAiming);
6161
}
@@ -72,7 +72,7 @@ private void OnRotation(RotationUpdate rotation)
7272
{
7373
pitch -= 360;
7474
}
75-
75+
7676
// AnimController treats negative pitch as pointing downwards
7777
fpsAnimator.SetPitch(-pitch);
7878
}

workers/unity/Assets/Fps/Scripts/GameLogic/FovManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void CheckForDeathModifier(HealthModifiedInfo info)
4646
}
4747
}
4848

49-
private void OnAimingChanged(BlittableBool _)
49+
private void OnAimingChanged(bool _)
5050
{
5151
RecalculateFov();
5252
}

workers/unity/Assets/Fps/Scripts/GameLogic/FpsDriver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private void Aiming(bool shouldBeAiming)
217217
{
218218
var update = new GunStateComponent.Update
219219
{
220-
IsAiming = new Option<BlittableBool>(shouldBeAiming)
220+
IsAiming = shouldBeAiming
221221
};
222222
gunState.SendUpdate(update);
223223
}

workers/unity/Assets/Fps/Scripts/GameLogic/Session/PlayerStateServerSystem.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ protected override void OnCreateManager()
1414
{
1515
base.OnCreateManager();
1616

17-
commandSystem = World.GetExistingManager<CommandSystem>();
18-
workerSystem = World.GetExistingManager<WorkerSystem>();
17+
commandSystem = World.GetExistingSystem<CommandSystem>();
18+
workerSystem = World.GetExistingSystem<WorkerSystem>();
1919
}
2020

2121
protected override void OnUpdate()

workers/unity/Assets/Fps/Scripts/GameLogic/Session/TrackPlayerSystem.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
using Improbable.Worker.CInterop.Query;
77
using Unity.Entities;
88
using UnityEngine;
9+
using EntityQuery = Improbable.Worker.CInterop.Query.EntityQuery;
910

1011
namespace Fps
1112
{
1213
[DisableAutoCreation]
1314
public class TrackPlayerSystem : ComponentSystem
1415
{
1516
private long? sentPlayerStateQueryId;
16-
private ComponentGroup sessionGroup;
17+
private Unity.Entities.EntityQuery sessionGroup;
1718
private CommandSystem commandSystem;
1819
private ILogDispatcher logDispatcher;
1920

@@ -30,9 +31,9 @@ protected override void OnCreateManager()
3031
{
3132
base.OnCreateManager();
3233

33-
commandSystem = World.GetExistingManager<CommandSystem>();
34-
logDispatcher = World.GetExistingManager<WorkerSystem>().LogDispatcher;
35-
sessionGroup = GetComponentGroup(ComponentType.ReadOnly<Session.Component>());
34+
commandSystem = World.GetExistingSystem<CommandSystem>();
35+
logDispatcher = World.GetExistingSystem<WorkerSystem>().LogDispatcher;
36+
sessionGroup = GetEntityQuery(ComponentType.ReadOnly<Session.Component>());
3637

3738
PlayerResults = new List<ResultsData>();
3839
}
@@ -45,7 +46,10 @@ protected override void OnUpdate()
4546
}
4647
else
4748
{
48-
SessionStatus = sessionGroup.GetComponentDataArray<Session.Component>()[0].Status;
49+
Entities.With(sessionGroup).ForEach((ref Session.Component session) =>
50+
{
51+
SessionStatus = session.Status;
52+
});
4953
}
5054

5155
if (SessionStatus != Status.STOPPING)
@@ -55,7 +59,8 @@ protected override void OnUpdate()
5559

5660
if (sentPlayerStateQueryId == null && PlayerResults.Count == 0)
5761
{
58-
sentPlayerStateQueryId = commandSystem.SendCommand(new WorldCommands.EntityQuery.Request(playerStateQuery));
62+
sentPlayerStateQueryId =
63+
commandSystem.SendCommand(new WorldCommands.EntityQuery.Request(playerStateQuery));
5964
}
6065

6166
var entityQueryResponses = commandSystem.GetResponses<WorldCommands.EntityQuery.ReceivedResponse>();

workers/unity/Assets/Fps/Scripts/GameLogic/StateMachine/Session/PlayState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class PlayState : SessionState
88

99
public PlayState(UIManager manager, ConnectionStateMachine owner) : base(manager, owner)
1010
{
11-
trackPlayerSystem = Blackboard.ClientConnector.Worker.World.GetExistingManager<TrackPlayerSystem>();
11+
trackPlayerSystem = Blackboard.ClientConnector.Worker.World.GetExistingSystem<TrackPlayerSystem>();
1212
}
1313

1414
public override void StartState()

workers/unity/Assets/Fps/Scripts/GameLogic/StateMachine/Session/QuerySessionStatusState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class QuerySessionStatusState : SessionState
1414

1515
public QuerySessionStatusState(State nextState, UIManager manager, ConnectionStateMachine owner) : base(manager, owner)
1616
{
17-
commandSystem = Blackboard.ClientConnector.Worker.World.GetExistingManager<CommandSystem>();
17+
commandSystem = Blackboard.ClientConnector.Worker.World.GetExistingSystem<CommandSystem>();
1818
this.nextState = nextState;
1919
}
2020

workers/unity/Assets/Fps/Scripts/GameLogic/StateMachine/Session/ResultsState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ResultsState : SessionState
1010

1111
public ResultsState(UIManager manager, ConnectionStateMachine owner) : base(manager, owner)
1212
{
13-
trackPlayerSystem = Blackboard.ClientConnector.Worker.World.GetExistingManager<TrackPlayerSystem>();
13+
trackPlayerSystem = Blackboard.ClientConnector.Worker.World.GetExistingSystem<TrackPlayerSystem>();
1414
}
1515

1616
public override void StartState()

0 commit comments

Comments
 (0)