forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionLogSystem.cs
More file actions
44 lines (41 loc) · 1.36 KB
/
Copy pathConnectionLogSystem.cs
File metadata and controls
44 lines (41 loc) · 1.36 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
40
41
42
43
44
#if UNITY_DOTS_SERVER_CI
using Unity.Collections;
using Unity.Entities;
using Unity.NetCode;
namespace Asteroids.CI
{
public struct ConnectionHitTag : IComponentData
{
}
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation | WorldSystemFilterFlags.ServerSimulation)]
public partial class ConnectionLogSystem : SystemBase
{
protected override void OnUpdate()
{
var type =
#if UNITY_SERVER
"server"
#elif UNITY_CLIENT
"client"
#elif UNITY_EDITOR
"editor"
#else
"null"
#endif
;
Entities.WithNone<ConnectionHitTag>().ForEach(
(Entity entity, in NetworkStreamConnection conn, in NetworkId id) =>
{
EntityManager.AddComponent<ConnectionHitTag>(entity);
System.Console.WriteLine(
FixedString.Format(
"Asteroids.CI.ConnectionLogSystem: Connection live={0} for {1}\n({2}, network id={3})",
conn.Value.IsCreated ? 1 : 0,
type,
conn.Value.ToFixedString(),
id.Value));
}).WithStructuralChanges().WithoutBurst().Run();
}
}
}
#endif