forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesianGridMovementAuthoring.cs
More file actions
40 lines (36 loc) · 1.03 KB
/
Copy pathCartesianGridMovementAuthoring.cs
File metadata and controls
40 lines (36 loc) · 1.03 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
using Unity.Entities;
using Unity.Rendering;
using UnityEngine;
[AddComponentMenu("DOTS Samples/GridPath/Cartesian Grid Movement")]
public class CartesianGridMovementAuthoring : MonoBehaviour
{
public enum MovementOptions
{
Bounce,
FollowTarget
};
[Range(0.0f, 2.0f)]
public float Speed;
public MovementOptions Movement;
class Baker : Baker<CartesianGridMovementAuthoring>
{
public override void Bake(CartesianGridMovementAuthoring authoring)
{
AddComponent( new CartesianGridDirection
{
Value = 0, // default N
});
AddComponent( new CartesianGridSpeed
{
Value = (ushort)(authoring.Speed * 1024.0f)
});
AddComponent( new CartesianGridCoordinates
{
x = 0,
y = 0
});
if (authoring.Movement == MovementOptions.FollowTarget)
AddComponent( new CartesianGridFollowTarget());
}
}
}