-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTracker.cs
46 lines (36 loc) · 1.61 KB
/
Tracker.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
// https://github.com/EverestAPI/Resources/wiki/Custom-Entities-and-Triggers#tracked
// https://github.com/EverestAPI/Resources/wiki/Monocle-Reference#Tracker
using Microsoft.Xna.Framework;
using Monocle;
using System.Linq;
namespace Celeste.Mod.Example {
// Track this entity in the Tracker, do not track child classes.
[Tracked(inherited:false)]
// Track this entity in the Tracker AS A DreamBlock, include child classes.
[TrackedAs(typeof(DreamBlock), inherited:true)]
public class TrackedExample : DreamBlock {
public TrackedExample(EntityData data, Vector2 offset)
: base(data, offset) {
}
public override void Awake(Scene scene) {
base.Awake(scene);
// Will only return entities of type TrackedExample
scene.Tracker.GetEntities<TrackedExample>();
// Will return any entities of type TrackedChildExample and child classes
scene.Tracker.GetEntities<TrackedChildExample>();
// Will return entities of type DreamBlock, TrackedExample, AND TrackedChildExample
scene.Tracker.GetEntities<DreamBlock>();
// Retrieve untracked entities from the scene. Much slower than using the Tracker
scene.Entities.Select(e => e is UnTrackedExample);
}
}
// Track this entity in the Tracker, include child classes.
[Tracked(inherited:true)]
public class TrackedChildExample : TrackedExample {
public TrackedChildExample(EntityData data, Vector2 offset)
: base(data, offset) {
}
}
public class UnTrackedExample : Entity {
}
}