Comment on page
Mod
The Mod class serves as the base class for all mods, containing essential information about your mod, customizable events, and more. All mods inherit from this class.
Method
Example
// Mod.CanUnload(System.String@)
public virtual bool CanUnload(ref string message)
bool stillLoading = true;
public override bool CanUnload(ref string message)
{
if (stillLoading)
{
message = "The mod is still loading";
return false;
}
return base.CanUnload(ref message);
}
// Mod.UnloadMod()
public virtual void UnloadMod()
Returns the bytes of the embedded file, or null if the file doesn't exist.
Method
Example
// Mod.GetEmbeddedFileBytes(System.String)
public virtual byte[] GetEmbeddedFileBytes(string path)
byte[] myBundleBytes = GetEmbeddedFileBytes("mybundle.assets");
AssetBundle bundle = AssetBundle.LoadFromMemory(myBundleBytes);
Returns the mod information from the modinfo.json file.
Method
Example
// Mod.GetModInfo()
public JsonModInfo GetModInfo()
Debug.Log("Mod version: "+GetModInfo().version);
Method
Example
// Mod.Log(System.Object)
public void Log(object message)
Log("This is a message"); // Outputs: "[ModName] This is a message".
Method
Example
// Mod.WorldEvent_WorldLoaded()
public virtual void WorldEvent_WorldLoaded()
public override void WorldEvent_WorldLoaded()
{
Debug.Log("The world has loaded");
}
Method
Example
// Mod.WorldEvent_WorldSaved()
public virtual void WorldEvent_WorldSaved()
public override void WorldEvent_WorldSaved()
{
Debug.Log("The world has been saved");
}
Method
Example
// Mod.LocalPlayerEvent_Hurt(System.Single,UnityEngine.Vector3,UnityEngine.Vector3,EntityType)
public virtual void LocalPlayerEvent_Hurt(float damage, Vector3 hitPoint, Vector3 hitNormal, EntityType damageInflictorEntityType)
public override void LocalPlayerEvent_Hurt(float damage, Vector3 hitPoint, Vector3 hitNormal, EntityType damageInflictorEntityType)
{
Debug.Log("Player hurt: " + damage + " damage taken");
}
Method
Example
// Mod.LocalPlayerEvent_Death(UnityEngine.Vector3)
public virtual void LocalPlayerEvent_Death(Vector3 deathPosition)
public override void LocalPlayerEvent_Death(Vector3 deathPosition)
{
Debug.Log("Player died at: " + deathPosition);
}
Method
Example
// Mod.LocalPlayerEvent_Respawn()
public virtual void LocalPlayerEvent_Respawn()
public override void LocalPlayerEvent_Respawn()
{
Debug.Log("Player respawned");
}
Method
Example
// Mod.LocalPlayerEvent_ItemCrafted(Item_Base)
public virtual void LocalPlayerEvent_ItemCrafted(Item_Base item)
public override void LocalPlayerEvent_ItemCrafted(Item_Base item)
{
Debug.Log("Item crafted: " + item.UniqueName);
}
Method
Example
// Mod.LocalPlayerEvent_PickupItem(PickupItem)
public virtual void LocalPlayerEvent_PickupItem(PickupItem item)
public override void LocalPlayerEvent_PickupItem(PickupItem item)
{
Debug.Log("Picked up item: " + item.itemInstance?.UniqueName);
}
Method
Example
// Mod.LocalPlayerEvent_DropItem(ItemInstance,UnityEngine.Vector3,UnityEngine.Vector3,System.Boolean)
public virtual void LocalPlayerEvent_DropItem(ItemInstance item, Vector3 position, Vector3 direction, bool parentedToRaft)
public override void LocalPlayerEvent_DropItem(ItemInstance item, Vector3 position, Vector3 direction, bool parentedToRaft)
{
Debug.Log("Dropped item: " + item.UniqueName + " at position: " + position);
}
Method
Example
// Mod.WorldEvent_OnPlayerConnected(Steamworks.CSteamID,RGD_Settings_Character)
public virtual void WorldEvent_OnPlayerConnected(CSteamID steamid, RGD_Settings_Character characterSettings)
public override void WorldEvent_OnPlayerConnected(CSteamID steamid, RGD_Settings_Character characterSettings)
{
Debug.Log("Player connected: " + steamid);
}
Method
Example
// Mod.WorldEvent_OnPlayerDisconnected(Steamworks.CSteamID,DisconnectReason)
public virtual void WorldEvent_OnPlayerDisconnected(CSteamID steamid, DisconnectReason disconnectReason)
public override void WorldEvent_OnPlayerDisconnected(CSteamID steamid, DisconnectReason disconnectReason)
{
Debug.Log("Player disconnected: " + steamid + " Reason: " + disconnectReason);
}
Method
Example
// Mod.WorldEvent_WorldUnloaded()
public virtual void WorldEvent_WorldUnloaded()
public override void WorldEvent_WorldUnloaded()
{
Debug.Log("World unloaded");
}
Method
Example
// Mod.ModEvent_OnModLoaded(HMLLibrary.Mod)
public virtual void ModEvent_OnModLoaded(Mod mod)
public override void ModEvent_OnModLoaded(Mod mod)
{
Debug.Log("Mod loaded: " + mod.name);
}
Method
Example
// Mod.ModEvent_OnModUnloaded(HMLLibrary.Mod)
public virtual void ModEvent_OnModUnloaded(Mod mod)
public override void ModEvent_OnModUnloaded(Mod mod)
{
Debug.Log("Mod unloaded: " + mod.name);
}
Last modified 1mo ago