Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit fa6e267

Browse files
authored
Fix PlayerHeartbeatInitializationSystem (#1352)
* Fix PlayerHeartbeatInitializationSystem to filter on the SERVER component instead of the CLIENT component. Stop using old API for adding components * Changelog
1 parent 4fbd2bb commit fa6e267

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- Burst is now enabled for all PC platforms.
1515
- Component replication will no longer attempt to replicate components the worker does not have authority over.
1616

17-
## Added
17+
### Added
1818

1919
- Added new methods to `Snapshot` utility class. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
2020
- `GetNextEntityId()` returns the next available entity ID.
@@ -23,12 +23,16 @@
2323
- This allows users to add undelegated components on entities.
2424
- Added debug names to entities shown in EntityDebugger. [#1342](https://github.com/spatialos/gdk-for-unity/pull/1342)
2525

26-
## Changed
26+
### Changed
2727

2828
- Allow headless development builds for Linux. [#1347](https://github.com/spatialos/gdk-for-unity/pull/1347)
2929
- Upgrade to Worker SDK v14.6.1. [#1350](https://github.com/spatialos/gdk-for-unity/pull/1350)
3030

31-
## Internal
31+
### Fixed
32+
33+
- Fix `PlayerHeartbeatInitializationSystem` to use the right components for filtering. [#1352](https://github.com/spatialos/gdk-for-unity/pull/1352)
34+
35+
### Internal
3236

3337
- Added component result type filters to playground QBI queries. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
3438
- Replaced `InitUISystem` with the `InitUIBehaviour` script on the `Character` prefab. [#1338](https://github.com/spatialos/gdk-for-unity/pull/1338)
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
21
using Improbable.Gdk.Core;
3-
using Improbable.Gdk.PlayerLifecycle;
4-
using Unity.Collections;
52
using Unity.Entities;
63

74
namespace Improbable.Gdk.PlayerLifecycle
@@ -11,43 +8,30 @@ namespace Improbable.Gdk.PlayerLifecycle
118
[UpdateBefore(typeof(HandlePlayerHeartbeatResponseSystem))]
129
public class PlayerHeartbeatInitializationSystem : ComponentSystem
1310
{
14-
private EntityQuery initializerGroup;
11+
private EntityQuery initializerQuery;
1512

1613
protected override void OnCreate()
1714
{
1815
base.OnCreate();
1916

20-
var initializerQuery = new EntityQueryDesc
17+
var entityQueryDesc = new EntityQueryDesc
2118
{
2219
All = new[]
2320
{
24-
ComponentType.ReadOnly<PlayerHeartbeatClient.Component>(),
21+
ComponentType.ReadOnly<PlayerHeartbeatServer.Component>(),
2522
},
26-
Any = Array.Empty<ComponentType>(),
2723
None = new[]
2824
{
2925
ComponentType.ReadWrite<HeartbeatData>(),
3026
},
3127
};
3228

33-
initializerGroup = GetEntityQuery(initializerQuery);
29+
initializerQuery = GetEntityQuery(entityQueryDesc);
3430
}
3531

3632
protected override void OnUpdate()
3733
{
38-
var entityType = GetArchetypeChunkEntityType();
39-
var chunkArray = initializerGroup.CreateArchetypeChunkArray(Allocator.TempJob);
40-
41-
foreach (var chunk in chunkArray)
42-
{
43-
var entities = chunk.GetNativeArray(entityType);
44-
for (int i = 0; i < entities.Length; i++)
45-
{
46-
PostUpdateCommands.AddComponent(entities[i], new HeartbeatData());
47-
}
48-
}
49-
50-
chunkArray.Dispose();
34+
EntityManager.AddComponent<HeartbeatData>(initializerQuery);
5135
}
5236
}
5337
}

0 commit comments

Comments
 (0)