forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerAuthoring.cs
34 lines (29 loc) · 907 Bytes
/
PlayerAuthoring.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
using Unity.Entities;
using UnityEngine;
namespace Tutorials.Kickball.Step2
{
// Same pattern as ObstacleAuthoring.cs in Step 1.
public class PlayerAuthoring : MonoBehaviour
{
class Baker : Baker<PlayerAuthoring>
{
public override void Bake(PlayerAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent<Player>(entity);
// Used in Step 5
AddComponent<Carry>(entity);
SetComponentEnabled<Carry>(entity, false);
}
}
}
public struct Player : IComponentData
{
}
// Used in Step 5
public struct Carry : IComponentData, IEnableableComponent
{
// on a ball, this denotes the player carrying the ball; on a player, this denotes the ball being carried
public Entity Target;
}
}