+
+
+ Class ModHooks
+
+ Class to hook into various events for the game.
+
+
+
+
Inheritance
+
System.Object
+
ModHooks
+
+
+ Assembly: Assembly-CSharp.mm.dll
+ Syntax
+
+
public class ModHooks : object
+
+ Fields
+
+
+
+ LoadedModsWithVersions
+ Dictionary of mods and their version #s
+
+
+ Declaration
+
+
public static readonly Dictionary<string, string> LoadedModsWithVersions
+
+ Field Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Dictionary<System.String, System.String> |
+ |
+
+
+
+
+
+ ModVersion
+ The Version of the Modding API
+
+
+ Declaration
+
+
public static string ModVersion
+
+ Field Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ System.String |
+ |
+
+
+
+
+
+ version
+
+
+ Declaration
+
+
public static GameVersionData version
+
+ Field Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ GameVersionData |
+ |
+
+
+
+ Properties
+
+
+
+
+
+ A map of mods to their built menu screens.
+
+
+ Declaration
+
+
public static ReadOnlyDictionary<IMod, MenuScreen> BuiltModMenuScreens { get; }
+
+ Property Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ ReadOnlyDictionary<IMod, MenuScreen> |
+ |
+
+
+
+
+
+
+ GlobalSettings
+ The global ModHooks settings.
+
+
+ Declaration
+
+
public static ModHooksGlobalSettings GlobalSettings { get; }
+
+ Property Value
+
+
+
+
+ Instance
+ Current instance of Modhooks.
+
+
+ Declaration
+
+
public static ModHooks Instance { get; }
+
+ Property Value
+
+
+
+ Type |
+ Description |
+
+
+
+
+ ModHooks |
+ |
+
+
+
+ Methods
+
+
+
+
+ GetAllMods(Boolean, Boolean)
+ Returns an iterator over all mods.
+
+
+ Declaration
+
+
public static IEnumerable<IMod> GetAllMods(bool onlyEnabled = false, bool allowLoadError = false)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ System.Boolean |
+ onlyEnabled |
+ Should the iterator only contain enabled mods.
+ |
+
+
+ System.Boolean |
+ allowLoadError |
+ Should the iterator contain mods which have load errors.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ IEnumerable<IMod> |
+ |
+
+
+
+
+
+
+ GetMod(String, Boolean, Boolean)
+ Gets a mod instance by name.
+
+
+ Declaration
+
+
public static IMod GetMod(string name, bool onlyEnabled = false, bool allowLoadError = false)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ System.String |
+ name |
+ The name of the mod.
+ |
+
+
+ System.Boolean |
+ onlyEnabled |
+ Should the method only return the mod if it is enabled.
+ |
+
+
+ System.Boolean |
+ allowLoadError |
+ Should the method return the mod even if it had load errors.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ IMod |
+ |
+
+
+
+
+
+
+ GetMod(Type, Boolean, Boolean)
+ Gets a mod instance by type.
+
+
+ Declaration
+
+
public static IMod GetMod(Type type, bool onlyEnabled = false, bool allowLoadError = false)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ Type |
+ type |
+ The type of the mod.
+ |
+
+
+ System.Boolean |
+ onlyEnabled |
+ Should the method only return the mod if it is enabled.
+ |
+
+
+ System.Boolean |
+ allowLoadError |
+ Should the method return the mod even if it had load errors.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ IMod |
+ |
+
+
+
+
+
+
+ ModEnabled(ITogglableMod)
+ Gets if the mod is currently enabled.
+
+
+ Declaration
+
+
public static bool ModEnabled(ITogglableMod mod)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ ITogglableMod |
+ mod |
+ The togglable mod to check.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ System.Boolean |
+ |
+
+
+
+
+
+
+ ModEnabled(String)
+ Gets if a mod is currently enabled.
+
+
+ Declaration
+
+
public static bool ModEnabled(string name)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ System.String |
+ name |
+ The name of the mod to check.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ System.Boolean |
+ |
+
+
+
+
+
+
+ ModEnabled(Type)
+ Gets if a mod is currently enabled.
+
+
+ Declaration
+
+
public static bool ModEnabled(Type type)
+
+ Parameters
+
+
+
+ Type |
+ Name |
+ Description |
+
+
+
+
+ Type |
+ type |
+ The type of the mod to check.
+ |
+
+
+
+ Returns
+
+
+
+ Type |
+ Description |
+
+
+
+
+ System.Boolean |
+ |
+
+
+
+ Events
+
+
+
+ AfterAttackHook
+ Called at the end of the attack function
+
+
+ Declaration
+
+
public static event Action<AttackDirection> AfterAttackHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<AttackDirection> |
+ |
+
+
+
+
+
+
+
+ AfterPlayerDeadHook
+ Called after the player dies
+
+
+ Declaration
+
+
public static event Action AfterPlayerDeadHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+
+
+ AfterSaveGameClearHook
+ Called after a game has been cleared from a slot.
+
+
+ Declaration
+
+
public static event Action<int> AfterSaveGameClearHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<System.Int32> |
+ |
+
+
+
+
+
+ AfterSavegameLoadHook
+ Called directly after a save has been loaded. Allows for accessing SaveGame instance.
+
+
+ Declaration
+
+
public static event Action<SaveGameData> AfterSavegameLoadHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<SaveGameData> |
+ |
+
+
+
+
+
+
+
+ AfterTakeDamageHook
+ Called in the take damage function, immediately before applying damage (just before checking overcharm)
+
+
+ Declaration
+
+
public static event AfterTakeDamageHandler AfterTakeDamageHook
+
+ Event Type
+
+
+
+ ApplicationQuitHook
+ Called when the game is fully closed
+
+
+ Declaration
+
+
public static event Action ApplicationQuitHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+
+
+ AttackHook
+ Called whenever the player attacks
+
+
+ Declaration
+
+
public static event Action<AttackDirection> AttackHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<AttackDirection> |
+ |
+
+
+
+
+
+
+
+ BeforeAddHealthHook
+ Called whenever the player heals, overrides health added.
+
+
+ Declaration
+
+
public static event Func<int, int> BeforeAddHealthHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Int32, System.Int32> |
+ |
+
+
+
+
+
+
+
+ BeforePlayerDeadHook
+ Called when the player dies
+
+
+ Declaration
+
+
public static event Action BeforePlayerDeadHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+
+
+ BeforeSavegameSaveHook
+ Called directly before save has been saved to allow for changes to the data before persisted.
+
+
+ Declaration
+
+
public static event Action<SaveGameData> BeforeSavegameSaveHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<SaveGameData> |
+ |
+
+
+
+
+
+
+
+ BeforeSceneLoadHook
+ Called right before a scene gets loaded, can change which scene gets loaded
+
+
+ Declaration
+
+
public static event Func<string, string> BeforeSceneLoadHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.String, System.String> |
+ |
+
+
+
+
+
+
+
+ BlueHealthHook
+ Called whenever blue health is updated
+
+
+ Declaration
+
+
public static event Func<int> BlueHealthHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Int32> |
+ |
+
+
+
+
+
+ CharmUpdateHook
+ Called after player values for charms have been set
+
+
+ Declaration
+
+
public static event CharmUpdateHandler CharmUpdateHook
+
+ Event Type
+
+
+
+
+
+ ColliderCreateHook
+ Called whenever a new gameobject is created with a collider and playmaker2d
+
+
+ Declaration
+
+
public static event Action<GameObject> ColliderCreateHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<GameObject> |
+ |
+
+
+
+
+
+
+
+ CursorHook
+ Called whenever game tries to show cursor
+
+
+ Declaration
+
+
public static event Action CursorHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+ DashPressedHook
+ Called whenever the dash key is pressed.
+Returns whether or not to override normal dash functionality - if true, preventing a normal dash
+
+
+ Declaration
+
+
public static event Func<bool> DashPressedHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Boolean> |
+ |
+
+
+
+
+
+
+
+ DashVectorHook
+ Called during dash function to change velocity
+
+
+ Declaration
+
+
public static event Func<Vector2, Vector2> DashVectorHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<Vector2, Vector2> |
+ A changed vector.
+ |
+
+
+
+
+
+
+
+ DoAttackHook
+ Called at the start of the DoAttack function
+
+
+ Declaration
+
+
public static event Action DoAttackHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+ DrawBlackBordersHook
+ Called when a SceneManager calls DrawBlackBorders and creates boarders for a scene. You may use or modify the
+bounds of an area of the scene with these.
+
+
+ Declaration
+
+
public static event Action<List<GameObject>> DrawBlackBordersHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<List<GameObject>> |
+ |
+
+
+
+
+
+
+
+ FinishedLoadingModsHook
+ Event invoked when mods have finished loading. If modloading has already finished, subscribers will be invoked immediately.
+
+
+ Declaration
+
+
public static event Action FinishedLoadingModsHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+ FocusCostHook
+ Called whenever focus cost is calculated, allows a focus cost multiplier.
+
+
+ Declaration
+
+
public static event Func<float> FocusCostHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Single> |
+ |
+
+
+
+
+
+ GetPlayerBoolHook
+ Called when anything in the game tries to get a bool from player data
+
+
+ Declaration
+
+
public static event GetBoolProxy GetPlayerBoolHook
+
+ Event Type
+
+
+
+ Examples
+ ModHooks.GetPlayerBoolHook += GetBool;
+
+// In this example, we always give the player dash, and
+// leave other bools as-is.
+bool? GetBool(string name, bool orig) {
+ return name == "canDash" ? true : orig;
+}
+
+
+
+ GetPlayerFloatHook
+ Called when anything in the game tries to get a float from player data
+
+
+ Declaration
+
+
public static event GetFloatProxy GetPlayerFloatHook
+
+ Event Type
+
+
+
+
+
+ GetPlayerIntHook
+ Called when anything in the game tries to get an int from player data
+
+
+ Declaration
+
+
public static event GetIntProxy GetPlayerIntHook
+
+ Event Type
+
+
+
+ Examples
+ ModHooks.GetPlayerIntHook += GetInt;
+
+// This overrides the number of charm slots we have to 999,
+// effectively giving us infinite charm notches.
+// We ignore any other GetInt calls.
+int? GetInt(string name, int orig) {
+ return name == "charmSlots" ? 999 : orig;
+}
+
+
+
+ GetPlayerStringHook
+ Called when anything in the game tries to get a string from player data
+
+
+ Declaration
+
+
public static event GetStringProxy GetPlayerStringHook
+
+ Event Type
+
+
+
+
+
+ GetPlayerVariableHook
+ Called when anything in the game tries to get a generic variable from player data
+
+
+ Declaration
+
+
public static event GetVariableProxy GetPlayerVariableHook
+
+ Event Type
+
+
+
+
+
+ GetPlayerVector3Hook
+ Called when anything in the game tries to get a Vector3 from player data
+
+
+ Declaration
+
+
public static event GetVector3Proxy GetPlayerVector3Hook
+
+ Event Type
+
+
+
+
+
+ GetSaveFileNameHook
+ Overrides the filename to load for a given slot. Return null to use vanilla names.
+
+
+ Declaration
+
+
public static event Func<int, string> GetSaveFileNameHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Int32, System.String> |
+ |
+
+
+
+
+
+ HeroUpdateHook
+ Called whenever the hero updates
+
+
+ Declaration
+
+
public static event Action HeroUpdateHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+
+
+ HitInstanceHook
+ Called whenever a HitInstance is created. Overrides hit.
+
+
+ Declaration
+
+
public static event HitInstanceHandler HitInstanceHook
+
+ Event Type
+
+
+
+ LanguageGetHook
+ Called whenever localization specific strings are requested
+
+
+ Declaration
+
+
public static event LanguageGetProxy LanguageGetHook
+
+ Event Type
+
+
+
+
+
+ NewGameHook
+ Called whenever a new game is started
+
+
+ Declaration
+
+
public static event Action NewGameHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action |
+ |
+
+
+
+
+
+
+
+ ObjectPoolSpawnHook
+ Called whenever game tries to create a new gameobject. This happens often, care should be taken.
+
+
+ Declaration
+
+
public static event Func<GameObject, GameObject> ObjectPoolSpawnHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<GameObject, GameObject> |
+ |
+
+
+
+
+
+ OnEnableEnemyHook
+ Called when an enemy is enabled. Check this isDead flag to see if they're already dead. If you return true, this
+will mark the enemy as already dead on load. Default behavior is to return the value inside "isAlreadyDead".
+
+
+ Declaration
+
+
public static event OnEnableEnemyHandler OnEnableEnemyHook
+
+ Event Type
+
+
+
+
+
+ OnReceiveDeathEventHook
+ Called when an enemy recieves a death event. It looks like this event may be called multiple times on an enemy, so
+check "eventAlreadyRecieved" to see if the event has been fired more than once.
+
+
+ Declaration
+
+
public static event OnReceiveDeathEventHandler OnReceiveDeathEventHook
+
+ Event Type
+
+
+
+
+
+ RecordKillForJournalHook
+ Called when an enemy dies and a journal kill is recorded. You may use the "playerDataName" string or one of the
+additional pre-formatted player data strings to look up values in playerData.
+
+
+ Declaration
+
+
public static event RecordKillForJournalHandler RecordKillForJournalHook
+
+ Event Type
+
+
+
+
+
+ SavegameClearHook
+ Called before a save file is deleted
+
+
+ Declaration
+
+
public static event Action<int> SavegameClearHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<System.Int32> |
+ |
+
+
+
+
+
+
+
+ SavegameLoadHook
+ Called directly after a save has been loaded
+
+
+ Declaration
+
+
public static event Action<int> SavegameLoadHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<System.Int32> |
+ |
+
+
+
+
+
+
+
+ SavegameSaveHook
+ Called directly after a save has been saved
+
+
+ Declaration
+
+
public static event Action<int> SavegameSaveHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<System.Int32> |
+ |
+
+
+
+
+
+
+
+ SceneChanged
+ Called after a new Scene has been loaded
+
+
+ Declaration
+
+
public static event Action<string> SceneChanged
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Action<System.String> |
+ |
+
+
+
+
+
+
+
+ SetPlayerBoolHook
+ Called when anything in the game tries to set a bool in player data
+
+
+ Declaration
+
+
public static event SetBoolProxy SetPlayerBoolHook
+
+ Event Type
+
+
+
+ Examples
+ public int KillCount { get; set; }
+
+ModHooks.Instance.SetPlayerBoolHook += SetBool;
+
+/*
+ * This uses the bool set to trigger a death, killing the player
+ * as well as preventing them from picking up dash, which could be used
+ * in something like a dashless mod.
+ *
+ * We are also able to use SetBool for counting things, as it is often
+ * called every time sometthing happens, regardless of the value
+ * this can be seen in our check for "killedMageLord", which counts the
+ * number of times the player kills Soul Master with the mod on.
+ */
+bool SetBool(string name, bool orig) {
+ switch (name) {
+ case "hasDash":
+ var hc = HeroController.instance;
+
+ // Kill the player
+ hc.StartCoroutine(hc.Die());
+
+ // Prevent dash from being picked up
+ return false;
+ case "killedMageLord":
+ // Just increment the counter.
+ KillCount++;
+
+ // We could also do something like award them geo for each kill
+ // And despite being a set, this would trigger on *every* kill
+ HeroController.instance.AddGeo(300);
+
+ // Not changing the value.
+ return orig;
+ default:
+ return orig;
+ }
+}
+
+
+
+ SetPlayerFloatHook
+ Called when anything in the game tries to set a float in player data
+
+
+ Declaration
+
+
public static event SetFloatProxy SetPlayerFloatHook
+
+ Event Type
+
+
+
+
+
+ SetPlayerIntHook
+ Called when anything in the game tries to set an int in player data
+
+
+ Declaration
+
+
public static event SetIntProxy SetPlayerIntHook
+
+ Event Type
+
+
+
+ Examples
+ ModHooks.Instance.SetPlayerIntHook += SetInt;
+
+int? SetInt(string name, int orig) {
+ // We could do something every time the player
+ // receives or loses geo.
+ if (name == "geo") {
+ // Let's give the player soul if they *gain* geo
+ if (PlayerData.instance.geo < orig) {
+ PlayerData.instance.AddMPChargeSpa(10);
+ }
+ }
+
+ // In this case, we aren't changing the value being set
+ // at all, so we just leave the value as the original for everything.
+ return orig;
+}
+
+
+
+ SetPlayerStringHook
+ Called when anything in the game tries to set a string in player data
+
+
+ Declaration
+
+
public static event SetStringProxy SetPlayerStringHook
+
+ Event Type
+
+
+
+
+
+ SetPlayerVariableHook
+ Called when anything in the game tries to set a generic variable in player data
+
+
+ Declaration
+
+
public static event SetVariableProxy SetPlayerVariableHook
+
+ Event Type
+
+
+
+
+
+ SetPlayerVector3Hook
+ Called when anything in the game tries to set a Vector3 in player data
+
+
+ Declaration
+
+
public static event SetVector3Proxy SetPlayerVector3Hook
+
+ Event Type
+
+
+
+
+
+ SlashHitHook
+ Called whenever nail strikes something
+
+
+ Declaration
+
+
public static event SlashHitHandler SlashHitHook
+
+ Event Type
+
+
+
+ SoulGainHook
+ Called when Hero recovers Soul from hitting enemies
+
+
+ Declaration
+
+
public static event Func<int, int> SoulGainHook
+
+ Event Type
+
+
+
+ Type |
+ Description |
+
+
+
+
+ Func<System.Int32, System.Int32> |
+ The amount of soul to recover
+ |
+
+
+
+
+
+ TakeDamageHook
+ Called when damage is dealt to the player, at the start of the take damage function.
+
+
+ Declaration
+
+
public static event TakeDamageProxy TakeDamageHook
+
+ Event Type
+
+
+
+
+
+ TakeHealthHook
+ Called when health is taken from the player
+
+
+ Declaration
+
+
public static event TakeHealthProxy TakeHealthHook
+
+ Event Type
+
+
+
+