forked from PenguinOwl/BGswitch
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBGswitchInterop.cs
More file actions
41 lines (36 loc) · 1.45 KB
/
BGswitchInterop.cs
File metadata and controls
41 lines (36 loc) · 1.45 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
using Monocle;
using MonoMod.ModInterop;
using System;
namespace Celeste.Mod.BGswitch {
[ModExportName("BGswitch")]
public static class BGswitchInterop {
internal static void Load() {
typeof(BGswitchInterop).ModInterop();
typeof(SpeedrunToolImports).ModInterop();
}
// Returns the current BG mode
public static bool IsBGMode() => BGModeManager.BGMode;
// Sets the BG mode
// bool bgMode: the value to set the BG mode to
// bool persistent: whether or not the value should be saved to the session
[Command("bg_mode", "[BGswitch] Sets the bg mode of the level")]
public static void SetBGMode(bool bgMode = false, bool persistent = false) {
if (Engine.Scene is Level) {
BGModeManager.BGMode = bgMode;
if (persistent) {
BGswitch.Session.BGMode = bgMode;
}
}
}
// Creates and returns a BGModeListener as a Component.
// Action<bool> action: the delegate that will be called when the BG mode changes
public static Component GetBGModeListener(Action<bool> action) {
return new BGModeListener(action);
}
}
[ModImportName("SpeedrunTool.SaveLoad")]
public static class SpeedrunToolImports {
public static Func<Type, string[], object> RegisterStaticTypes;
public static Action<object> Unregister;
}
}