-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.cs
80 lines (66 loc) · 1.91 KB
/
Scene.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Binocle.Processors;
using UnityEngine;
namespace Binocle
{
public class Scene : MonoBehaviour
{
private Game _game;
public Game Game
{
get { return _game; }
set { _game = value; }
}
public EntityProcessorList EntityProcessors
{
get { return _entityProcessors; }
}
private EntityProcessorList _entityProcessors = new EntityProcessorList();
public virtual void Awake()
{
}
public virtual void Start()
{
}
public virtual void Update()
{
if (_entityProcessors != null)
_entityProcessors.update();
}
public void AddEntityProcessor(EntityProcessor processor)
{
processor.Game = _game;
processor.Scene = this;
_entityProcessors.add(processor);
}
/// <summary>
/// Gets an EntitySystem processor
/// </summary>
/// <returns>The processor.</returns>
/// <typeparam name="T">The 1st type parameter.</typeparam>
public T GetEntityProcessor<T>() where T : EntityProcessor
{
return _entityProcessors.getProcessor<T>();
}
public Entity CreateEntity(string name)
{
var go = new GameObject(name);
var e = go.AddComponent<Entity>();
e.GameObject = go;
e.Scene = this;
e.GameObject.transform.SetParent(this.transform);
return e;
}
public T CreateEntity<T>(string name) where T : Entity
{
var go = new GameObject(name);
var e = go.AddComponent<T>();
e.GameObject = go;
e.Scene = this;
e.GameObject.transform.SetParent(this.transform);
return e;
}
public virtual void Remove()
{
}
}
}