forked from EverestAPI/ExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCutscene.cs
45 lines (37 loc) · 1.64 KB
/
Cutscene.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
// https://github.com/EverestAPI/Resources/wiki/Creating-Custom-Events
using Celeste.Mod.Entities;
using Monocle;
using System.Collections;
namespace Celeste.Mod.Example {
[CustomEvent("ExampleMod/CustomEvent")]
public class ExampleCutscene : CutsceneEntity {
private Player player;
public ExampleCutscene(EventTrigger trigger, Player player, string eventID) {
this.player = player;
}
public override void OnBegin(Level level) {
Add(new Coroutine(Cutscene(level)));
}
// Makes use of Iterator Methods:
// https://docs.microsoft.com/en-us/dotnet/csharp/iterators#enumeration-sources-with-iterator-methods
private IEnumerator Cutscene(Level level) {
player.StateMachine.State = Player.StDummy;
player.StateMachine.Locked = true;
yield return null;
// returning another IEnumerator will cause that routine to run before resuming this one.
yield return player.DummyWalkTo(CutsceneNode.Find("ExampleMod/CustomEventNode1").X, true);
// returning an int or float will cause the Coroutine to pause for that many seconds before resuming.
yield return 2;
if (false)
// Use yield break to exit from an Iterator Method early.
yield break;
player.StateMachine.State = Player.StNormal;
// yield break is automatically inserted at the end of IEnumerator functions.
}
public override void OnEnd(Level level) {
if (WasSkipped) {
// Go to end state of cutscene.
}
}
}
}