-
Notifications
You must be signed in to change notification settings - Fork 2
/
ExampleModule.cs
62 lines (49 loc) · 2.67 KB
/
ExampleModule.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
// https://github.com/EverestAPI/Resources/wiki/Your-First-Code-Mod#module-class
using Monocle;
using System;
namespace Celeste.Mod.Example {
public class ExampleModule : EverestModule {
// Only one alive module instance can exist at any given time.
public static ExampleModule Instance;
public ExampleModule() {
Instance = this;
}
// Settings, SaveData, and Session are optional
// If you need to store settings:
public override Type SettingsType => typeof(ExampleModuleSettings);
public static ExampleModuleSettings Settings => (ExampleModuleSettings) Instance._Settings;
// If you need to store save data:
public override Type SaveDataType => typeof(ExampleModuleSaveData);
public static ExampleModuleSaveData SaveData => (ExampleModuleSaveData) Instance._SaveData;
// If you need to store session data:
public override Type SessionType => typeof(ExampleModuleSession);
public static ExampleModuleSession Session => (ExampleModuleSession) Instance._Session;
// Initialized in LoadContent, after graphics and other assets have been loaded.
public SpriteBank ExampleSpriteBank;
// Set up any hooks, event handlers and your mod in general here.
// Load runs before Celeste itself has initialized properly.
public override void Load() {
// SetLogLevel will set the *minimum* log level that will be written for logs that use the given prefix string.
Logger.SetLogLevel("ExampleModule", LogLevel.Verbose);
Logger.Log(LogLevel.Info, "ExampleModule", "Loading ExampleModule Hooks");
// The default LogLevel when using Logger.Log is Verbose.
Logger.Log(LogLevel.Verbose, "ExampleModule", "This line would not be logged with SetLogLevel LogLevel.Info");
Hooks.Load();
ExtendedDashBlock.Load();
}
// Optional, initialize anything after Celeste has initialized itself properly.
public override void Initialize() {
}
// Optional, do anything requiring either the Celeste or mod content here.
public override void LoadContent(bool firstLoad) {
// This creates a new spritebank from an xml file.
// This particular one uses textures from the Gameplay atlas, which is stored in GFX.Game
ExampleSpriteBank = new SpriteBank(GFX.Game, "Graphics/ExampleMod/ExampleSprites.xml");
}
// Unload the entirety of your mod's content. Free up any native resources.
public override void Unload() {
Hooks.Unload();
ExtendedDashBlock.Unload();
}
}
}