Mod
See the code atresources/mod.gd
Description
Inherits Resource
The Mod
class represents a mod in the Mod System. It extends the Resource
class and provides metadata, assets, and functionality for granting and revoking the mod to/from game objects.
Signals
installed
signal installed
This signal is emitted when the mod is installed with ModSystem.
uninstalled
signal uninstalled
This signal is emitted when the mod is uninstalled from ModSystem.
enabled
signal enabled
This signal is emitted when the mod is enabled.
disabled
signal disabled
This signal is emitted when the mod is disabled.
granted
signal granted(instance: ModInstance)
This signal is emitted when the mod is granted to an object.
Parameters
Name | Type | Description |
---|---|---|
| ModInstance | The granted mod instance. |
revoked
signal revoked(instance: ModInstance)
This signal is emitted when the mod is revoked from an object.
Parameters
Name | Type | Description |
---|---|---|
| ModInstance | The revoked mod instance. |
Properties
requires_restart
var requires_restart: bool
A flag indicating whether the mod requires a game restart to take effect.
Type | bool |
---|---|
Default | false |
is_cheat
var is_cheat: bool
A flag indicating whether the mod provides cheats or cheat-like functionality.
Type | bool |
---|---|
Default | false |
grantable_owners
var grantable_owners: PackedStringArray
An array of registered class names that can receive this mod.
Type | PackedStringArray |
---|---|
Default | PackedStringArray([]) |
instance_script
var instance_script: ModScript
The script to be run when the mod is granted to an object.
Type | ModScript |
---|---|
Default | null |
assets
var assets: Array[ModAsset]
An array of mod assets associated with the mod.
Type | Array [ModAsset ] |
---|---|
Default | [] |
name
var name: String
The name of the mod.
Type | String |
---|---|
Default |
author
var author: String
The author of the mod.
Type | String |
---|---|
Default |
version
var version: String
The version of the mod.
Type | String |
---|---|
Default |
url
var url: String
The URL where the mod can be downloaded or accessed.
Type | String |
---|---|
Default |
thumbnail
var thumbnail: Texture2D
A thumbnail image representing the mod.
Type | Texture2D |
---|---|
Default | null |
instances
var instances: Dictionary[Object, ModInstance]
A dictionary that maps objects to their corresponding mod instances.
Type | Dictionary [Object , ModInstance ] |
---|---|
Default | {} |
is_enabled
var is_enabled: bool setget
A computed property indicating whether this mod is currently enabled.
Type | bool |
---|---|
Default |
Methods
grant
func grant(owner: Object) -> void
Grants the mod to the specified object. This method creates a mod instance for the specified object and emits the granted
signal
Parameters
Name | Type | Description |
---|---|---|
owner | Object | The object to grant the mod to. |
Returns
void
revoke
func revoke(owner: Object) -> void
Revokes the mod from the specified object. This method removes the mod instance associated with the specified object and emits the revoked
signal.
Parameters
Name | Type | Description |
---|---|---|
| Object | The object to revoke the mod from. |
Returns
void
get_instance
func get_instance(owner: Object) -> ModInstance
Retrieves the mod instance associated with the specified object. If no instance exists, it returns null
.
Parameters
Name | Type | Description |
---|---|---|
owner | Object | The object to retrieve the mod instance for. |
Returns
Type | ModInstance |
---|---|
Description | TThe mod instance associated with the object, or null if no instance exists. |
get_asset
func get_asset(key: String) -> ModAsset
Retrieves a mod asset by its key. This method searches the assets
array and returns the mod asset with the matching key. If no asset is found, it returns null
.
Parameters
Name | Type | Description |
---|---|---|
key | String | The key of the asset to retrieve. |
Returns
Type | ModAsset |
---|---|
Description | The mod asset with the specified key, or null if not found. |
_on_installed
func _on_installed() -> void
This method is called when the mod is installed with ModSystem.
Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is installed.
Returns
void
_on_uninstalled
func _on_uninstalled() -> void
This method is called when the mod is uninstalled from ModSystem.
Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is uninstalled.
Returns
void
_on_enabled
func _on_enabled() -> void
This method is called when the mod is enabled.
Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is enabled.
Returns
void
_on_disabled
func _on_disabled() -> void
This method is called when the mod is disabled.
Note: This method is intended to be overridden by subclasses to perform additional actions when the mod is disabled.
Returns
void
get_identifier
func get_identifier() -> String
Retrieves the unique identifier of the mod. This method returns a unique identifier for the mod, which can be used to differentiate it from other mods.
Returns
Type | String |
---|---|
Description | The mod's unique identifier. |