ModelReplacementAPI Methods and Functionality - BunyaPineTree/LethalCompany_ModelReplacementAPI GitHub Wiki
ModelReplacementAPI Methods and Functionality
ModelReplacementAPI implements a registry that handles basic functionality on Update()
. Simple mods should be able to register their desired behavior without needing to worry about managing the model replacements themselves. Note that all methods are static, and all Type
's involved must be derived from BodyReplacementBase
Registry Methods
RegisterSuitModelReplacement(string suitNameToReplace, Type type)
- Registers a model replacement to a given suit name. A player will put on this model replacement upon wearing a suit with given name. This works with the MoreSuits mod. Note that only one model replacement can be registered to a given suit name, and any further attempts will print an error to console.
RegisterModelReplacementDefault(Type type)
- Registers a model replacement class as default. If a player is not wearing a registered suit name and a default has been registered, they will wear this model replacement. Note that only one default can be registered, and any further attempts will print an error to console.
RegisterModelReplacementOverride(Type type)
- Registers a model replacement to be worn by all players, irrespective of whether the suit they are wearing has been registered. This likely only has use a debug function. Note that only one override can be registered, and any further attempts will print an error to console.
RegisterModelReplacementException(Type type)
- Registers a model replacement to be excepted from all above logic. Any player wearing a model replacement that has been registered as an exception will have to be removed or changed manually via the mod producer.
RegisterPlayerBlackList(PlayerControllerB player, bool blackListed)
- Registers a player's steam ID to a blacklist that will prevent them from being assigned model replacements via this API.
RegisterPlayerBlackList(ulong steamID, bool blackListed)
- Registers a steam ID to a blacklist that does the same as above.
Besides the registry methods, ModelReplacementAPI also has base methods for more complex mods that want to implement model replacement logic themselves. Any model replacement that the mod maker wants to handle manually must be registered as an exception, otherwise it will be overwritten on the next call of Update()
Base Methods
SetPlayerModelReplacement(PlayerControllerB player, Type type)
- Sets the given player to a given model replacement. Note that this will do nothing if the player's current model replacement is of the same type as given, and if their suit name has not changed. If the player puts on a different suit while their model replacement type remains the same, their active model replacement will be destroyed and replaced. This is to account for mods that want to apply the suit textures to their model replacement.
GetPlayerModelReplacement(PlayerControllerB player, out BodyReplacementBase modelReplacement)
- Returns true if the player has a model replacement, and false otherwise. Optionally provides the BodyReplacementBase as an out parameter.
RemovePlayerModelReplacement(PlayerControllerB player)
- Does as advertised.
ResetPlayerModelReplacement(PlayerControllerB player)
- Destroys and instantiates any existing model replacement on the provided player.
Example Use
Mods that want to simply change the in game suits to different models can simply register those models on the Awake()
call of their BaseUnityPLugin, such as:
ModelReplacementAPI.RegisterSuitModelReplacement("Orange suit", typeof(ScoutReplacement));
ModelReplacementAPI.RegisterSuitModelReplacement("Green suit", typeof(EngineerReplacement));
ModelReplacementAPI.RegisterSuitModelReplacement("Pajama suit", typeof(SpyReplacement));
ModelReplacementAPI.RegisterSuitModelReplacement("Hazard suit", typeof(SniperReplacement));
...
To account for lobbies adding additional suits that they don't have access to, they can register a default
ModelReplacementAPI.RegisterModelReplacementDefault(typeof(ScoutReplacement));
It is also possible to mix and match mods with config options to set which suits are registered to what. An example of this can be found at the Miku Example Mod
Some examples of mods that would have to implement custom logic with RegisterModelReplacementException(Type type)
- A mod that wants to add a bloodstained variant for their character. this can be achieved by registering their base model and variant model as exceptions, and switching between the two when a script detects a character is bloodstained.
- A mod that wants to add variants for players who are critically injured, or for players who were killed by spring head, or other monsters that disfigure the corpse.
- Goku hair.