-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScene.cs
More file actions
132 lines (100 loc) · 3.93 KB
/
Scene.cs
File metadata and controls
132 lines (100 loc) · 3.93 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
using System.Collections.Generic;
using LevelEditor.Engine.Mesh;
using LevelEditor.Engine.Postprocessing;
namespace LevelEditor.Engine
{
/// <summary>
/// The Scene class is used to represent a scene. This is useful
/// if we want many actors in one place e.g for a level.
/// </summary>
internal sealed class Scene
{
public readonly List<ActorBatch> mActorBatches;
public readonly List<Light> mLights;
public readonly PostProcessing mPostProcessing;
/// <summary>
/// Constructs a <see cref="Scene"/>.
/// </summary>
public Scene()
{
mActorBatches = new List<ActorBatch>();
mLights = new List<Light>();
mPostProcessing = new PostProcessing();
}
/// <summary>
/// Adds an actor to the scene.
/// </summary>
/// <param name="actor"> The actor which you want to add to the scene</param>
public void Add(Actor actor)
{
// Search for the ActorBatch
var actorBatch = mActorBatches.Find(ele => ele.mMesh == actor.mMesh);
// If there is no ActorBatch which already uses the mesh of the Actor we
// need to create a new ActorBatch and add it to mActorBatches
if (actorBatch == null)
{
actorBatch = new ActorBatch(actor.mMesh);
mActorBatches.Add(actorBatch);
}
actorBatch.Add(actor);
}
/// <summary>
/// Adds an actor to the scene.
/// </summary>
/// <param name="interfaceActor">The object which you want to add to the scene</param>
public void Add(IActor interfaceActor)
{
var actor = interfaceActor.MeshActor;
// Search for the ActorBatch
var actorBatch = mActorBatches.Find(ele => ele.mMesh == actor.mMesh);
// If there is no ActorBatch which already uses the mesh of the Actor we
// need to create a new ActorBatch and add it to mActorBatches
if (actorBatch == null)
{
actorBatch = new ActorBatch(actor.mMesh);
mActorBatches.Add(actorBatch);
}
actorBatch.Add(actor);
}
/// <summary>
/// Removes an actor from the scene.
/// </summary>
/// <param name="actor">The actor which you want to remove from the scene.</param>
/// <returns>A boolean whether the actor was found in the scene.
/// If there is no ActorBatch existing the return value will be null</returns>
public bool? Remove(Actor actor)
{
var actorBatch = mActorBatches.Find(ele => ele.mMesh == actor.mMesh);
return actorBatch?.Remove(actor);
}
/// <summary>
/// Removes an actor from the scene.
/// </summary>
/// <param name="interfaceActor">The object which you want remove from the scene.</param>
/// <returns>A boolean whether the object wasn't found in the scene.
/// If there is no ActorBatch existing the return value will be null</returns>
public bool? Remove(IActor interfaceActor)
{
var actor = interfaceActor.MeshActor;
var actorBatch = mActorBatches.Find(ele => ele.mMesh == actor.mMesh);
return actorBatch?.Remove(actor);
}
/// <summary>
/// Adds a light to the scene.
/// </summary>
/// <param name="light">The light which you want to add to the scene</param>
public void Add(Light light)
{
mLights.Add(light);
}
/// <summary>
/// Removes a light from the scene.
/// </summary>
/// <param name="light"></param>
/// <returns>A boolean whether the light was found in the scene.</returns>
public bool Remove(Light light)
{
return mLights.Remove(light);
}
}
}