Skip to content

Latest commit

 

History

History
70 lines (66 loc) · 12.5 KB

ModuleScript.md

File metadata and controls

70 lines (66 loc) · 12.5 KB

ModuleScript Class

Base class for solvable and needy modded modules in Keep Talking and Nobody Explodes.

public abstract class ModuleScript : KeepCoding.CacheableBehaviour,
KeepCoding.IAwake,
KeepCoding.IDump,
KeepCoding.ILog

Inheritance UnityEngine.MonoBehaviour 🡒 CacheableBehaviour 🡒 ModuleScript

Implements IAwake, IDump, ILog

Properties
Bomb The bomb that this module is in.
Colorblind Contains colorblind information. This property will return null in the event that OnColorblindChanged(bool) isn't implemented.
HasStruck Determines whether the module has been struck. OnInteractSequence(KMSelectable[], float, int[]) will set this to false when a command is interrupted.
Id The Unique Id for the module of this type.
IgnoredModules The ignored modules of this module from the Boss Module Manager.
IsActive Determines whether the bomb is currently active, and the timer is ticking.
IsColorblind Determines whether the module's colorblind mode is enabled.
IsEditor Determines whether the application is running from inside unity.
IsLastInstantiated Determines whether this module is the last instantiated instance.
IsNeedyActive Determines whether the needy is active.
IsSolved Determines whether the module has been solved.
IsVR Determines whether the game is being played with motion virtual reality. In the Editor, it always returns false.
LastId The last Id instantiation for the module of this type.
Module Contains either KMBombModule or KMNeedyModule, and allows for running commands through context.
Modules Contains every module in the KMBomb that this module is in.
RuleSeed The pseudo-random number generator whose number generations are based on the current Rule Seed.
RuleSeedId Gets the rule seed number.
Sounds Contains an instance for every Sound played by this module using PlaySound(Transform, bool, Sound[]) or any of its overloads.
TimeLeft The amount of time left on the bomb, in seconds, rounded down.
TP Gets the Twitch Plays UnityEngine.Component attached to this UnityEngine.GameObject.
Version The version number of the entire mod.
Methods
Append(Action, Action, Action, Action, Action, Action, Action<float>, Func<int>, Func<float>) Appends events to this instance's Module, preserving their existing values.
Assign(Action, Action, Action, Action, Action, Action, Action<float>, Func<int>, Func<float>) Assigns events to this instance's Module, replacing their existing values.
Awake() Sets up base functionality for the module. If you declare this method yourself, make sure to call base.Awake() to ensure that the module initializes correctly, or use OnAwake() instead.
ButtonEffect(KMSelectable, float, Sound[]) Handles typical button KMSelectable.OnInteract behaviour.
Dump<T>(T, bool) Dumps all information that it can find of the type using reflection. This should only be used to debug.
Dump(bool, Expression<Func<object>>[]) Dumps all information about the variables specified. Each element uses the syntax () => varName. This should only be used to debug.
Dump(Expression<Func<object>>[]) Dumps all information about the variables specified. Each element uses the syntax () => varName. This should only be used to debug.
Log<T>(T, LogType) Logs message, but formats it to be compliant with the Logfile Analyzer.
Log<T>(T, object[]) Logs multiple entries, but formats it to be compliant with the Logfile Analyzer.
LogMultiple(string[]) Logs multiple entries to the console.
OnActivate() Called when the lights turn on.
OnAwake() Called when the module instantiates, well before the lights turn on.
OnColorblindChanged(bool) Called when colorblind support needs to be updated for the module.
OnDestroy() Removes the module from UnityEngine.Application.logMessageReceived. If you declare this method, make sure to call base.OnDestroy() to ensure that the module cleans up correctly.
OnDestruct() Called when the module destroys itself, after the bomb unloads.
OnException(string) Called when an unhandled exception relating to this module has been thrown.
OnModuleSolved(ModuleContainer) Called when any KMBombModule or BombComponent on the current bomb has been solved.
OnModuleStrike(ModuleContainer) Called when any module on the current bomb has issued a strike.
OnNeedyActivate() Called when the needy activates.
OnNeedyDeactivate() Called when the needy deactivates or runs out of time.
OnTimerTick() Called when the timer's seconds-digit changes.
PlaySound(bool, Sound[]) Plays a sound, the sound source is the game object it is attached to. Requires KMAudio to be assigned.
PlaySound(Sound[]) Plays a sound, the sound source is the game object it is attached to. Requires KMAudio to be assigned.
PlaySound(Transform, bool, Sound[]) Plays a sound. Requires KMAudio to be assigned.
PlaySound(Transform, Sound[]) Plays a sound. Requires KMAudio to be assigned.
Read<T>(string, string, bool) Allows you to read a module's data that uses Write<T>(string, T), even from a different assembly.
Solve(string[]) Solves the module, and logs all of the parameters.
Strike(string[]) Strikes the module, and logs all of the parameters.
Write<T>(string, T) Sends information to a static variable such that other modules can access it.