forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoInGameClientSystem.cs
More file actions
39 lines (36 loc) · 1.22 KB
/
Copy pathGoInGameClientSystem.cs
File metadata and controls
39 lines (36 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.NetCode;
namespace KickBall
{
public struct GoInGameRequest : IRpcCommand
{
}
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation | WorldSystemFilterFlags.ThinClientSimulation)]
public partial struct GoInGameClientSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate<EntityPrefabs>();
state.RequireForUpdate<NetworkId>();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(Allocator.Temp);
foreach (var (id, entity) in
SystemAPI.Query<RefRO<NetworkId>>()
.WithNone<NetworkStreamInGame>()
.WithEntityAccess())
{
ecb.AddComponent<NetworkStreamInGame>(entity);
var req = ecb.CreateEntity();
ecb.AddComponent<GoInGameRequest>(req);
ecb.AddComponent(req, new SendRpcCommandRequest { TargetConnection = entity });
}
ecb.Playback(state.EntityManager);
}
}
}