-
Notifications
You must be signed in to change notification settings - Fork 7
Custom States
Everest has an API to add custom states to StateMachine
s; this is most useful to add new Player states.
This should be done after the relevant StateMachine
component is created, and it's important that you add states to every relevant StateMachine
instance — eg. when adding a Player state, you have to add the state to every player that's created.
In practice that means you should use an event or hook to add the states.
Everest has some events you can use for this purpose:
Everest.Events.Player.OnRegisterStates(Player player)
Everest.Events.Seeker.OnRegisterStates(Seeker seeker)
Everest.Events.AngryOshiro.OnRegisterStates(AngryOshiro oshiro)
For example, to add a Player state:
// in your EverestModule:
public override void Load() {
Everest.Events.Player.OnRegisterStates += RegisterPlayerState;
}
public override void Unload() {
Everest.Events.Player.OnRegisterStates -= RegisterPlayerState;
}
// adding the state:
public static int StYourState; // store the state index so you can reference it
internal static void RegisterPlayerState(Player player) {
StYourState = player.AddState(
"YourState",
YourStateUpdate,
// these are optional:
YourStateCoroutine,
YourStateBegin,
YourStateEnd
);
}
// state implementation:
internal static int YourStateUpdate(Player player) { /* your implementation; returns the state to transition to */ }
internal static IEnumerator YourStateCoroutine(Player player) { }
internal static void YourStateBegin(Player player) { }
internal static void YourStateEnd(Player player) { }
For more information about AddState
, see its implementation in the StateMachine patch class.
Note that for convenience, Player
, Seeker
, and AngryOshiro
also have AddState
methods that simply call their StateMachine
's AddState
.
Home
Contributing
FAQ
Useful Links
Your First Custom Map
Your First Texture Pack
Mod Setup
Custom Maps
Texture Packs
Uploading Mods
Generated Dialog Keys
Reference Code Mod🔗
Vanilla Audio IDs
Character Portraits
Mod Structure
Debug Mode
Command Line Arguments
Environment Variables
Install Issues
Common Crashes
Latency Guide
everest.yaml Setup
Mapping FAQ
Map Metadata
Vanilla Metadata Reference
Adding Custom Dialogue
Overworld Customisation
Entity & Trigger Documentation
Custom Entity List🔗
Camera
Ahorn Scripts
Custom Tilesets
Tileset Format Reference
Stylegrounds
Reskinning Entities
Skinmods
Decal Registry
Chapter Complete Screen
Custom Portraits
Adding Custom Audio
Advanced Custom Audio
Code Mod Setup
Making Code Mods
Mod Settings
Everest Events
Understanding Input
Logging
Cross-Mod Functionality
Recommended Practices
Core Migration Guide
Lönn Integration🔗
Custom Events
Adding Sprites
Adding Preexisting Audio