This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
/
TransformSynchronizationHelper.cs
60 lines (56 loc) · 2.66 KB
/
TransformSynchronizationHelper.cs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Improbable.Gdk.Core;
using Unity.Entities;
using UnityEngine;
namespace Improbable.Gdk.TransformSynchronization
{
public static class TransformSynchronizationHelper
{
public static void AddTransformSynchronizationComponents(EntityTemplate template,
string writeAccess,
Vector3 location = default(Vector3),
Vector3 velocity = default(Vector3))
{
AddTransformSynchronizationComponents(template, writeAccess,
UnityEngine.Quaternion.identity,
location,
velocity);
}
public static void AddTransformSynchronizationComponents(EntityTemplate template,
string writeAccess,
UnityEngine.Quaternion rotation,
Vector3 location = default(Vector3),
Vector3 velocity = default(Vector3))
{
var transformSnapshot = TransformUtils.CreateTransformSnapshot(location, rotation, velocity);
template.AddComponent(transformSnapshot, writeAccess);
}
public static void AddClientSystems(World world)
{
world.GetOrCreateSystem<TickRateEstimationSystem>();
world.GetOrCreateSystem<DirectTransformUpdateSystem>();
world.GetOrCreateSystem<InterpolateTransformSystem>();
world.GetOrCreateSystem<GetTransformValueToSetSystem>();
world.GetOrCreateSystem<DefaultApplyLatestTransformSystem>();
world.GetOrCreateSystem<DefaultUpdateLatestTransformSystem>();
world.GetOrCreateSystem<RateLimitedPositionSendSystem>();
world.GetOrCreateSystem<RateLimitedTransformSendSystem>();
world.GetOrCreateSystem<ResetForAuthorityGainedSystem>();
world.GetOrCreateSystem<SetKinematicFromAuthoritySystem>();
world.GetOrCreateSystem<TickSystem>();
}
public static void AddServerSystems(World world)
{
world.GetOrCreateSystem<TickRateEstimationSystem>();
world.GetOrCreateSystem<DirectTransformUpdateSystem>();
world.GetOrCreateSystem<InterpolateTransformSystem>();
world.GetOrCreateSystem<GetTransformValueToSetSystem>();
world.GetOrCreateSystem<DefaultApplyLatestTransformSystem>();
world.GetOrCreateSystem<DefaultUpdateLatestTransformSystem>();
world.GetOrCreateSystem<RateLimitedPositionSendSystem>();
world.GetOrCreateSystem<RateLimitedTransformSendSystem>();
world.GetOrCreateSystem<ResetForAuthorityGainedSystem>();
world.GetOrCreateSystem<SetKinematicFromAuthoritySystem>();
world.GetOrCreateSystem<TickSystem>();
}
}
}