Semi Mod Loader
Public Member Functions | Static Public Member Functions | Static Public Attributes | Properties | Private Attributes | Static Private Attributes | List of all members
Semi.Mod Class Referenceabstract
Inheritance diagram for Semi.Mod:

Public Member Functions

string GetFullResourcePath (string res_path)
 Expands a path relative to the mod resources directory into an absolute path. Additionally, it will convert forward slash directory separators into backward slashes on Windows. Resource paths can only use forward slashes - this method will throw if it detects a backward slash. More...
 
string GetFullID (string id, bool require_local)
 Expands an ID, filling in context namespace if necessary. More...
 
SpriteDefinition CreateSpriteDefinition (string id, string sprite_path)
 Creates a single sprite definition from an image resource. More...
 
SpriteDefinition RegisterEncounterIcon (string id, string sprite_path)
 Registers an encounter icon (used for example in the Ammonomicon) from an image resource. More...
 
SpriteCollection RegisterSpriteCollection (string id, params SpriteDefinition[] defs)
 Registers a new sprite collection. More...
 
Sprite RegisterSpriteTemplate (string id, string coll_id, string start_def_id=null)
 Registers a new sprite template. More...
 
I18N.ModLocalization RegisterLocalization (string id, string path, string lang_id, I18N.StringTable table, bool allow_overwrite=false)
 Registers a new localization. More...
 
RegisterItem< T > (string id, string enc_icon_id, string sprite_template_id, string name_key="", string short_desc_key="", string long_desc_key="")
 Registers a new PickupObject. More...
 
AdvancedSynergyEntry RegisterSynergy (string id, string name_loc_id, int objects_required, string[] optional_gun_ids=null, string[] mandatory_gun_ids=null, string[] optional_item_ids=null, string[] mandatory_item_ids=null, List< StatModifier > stat_modifiers=null, bool active_when_gun_unequipped=false, bool ignore_lich_eye_bullets=false, bool require_at_least_one_gun_and_one_item=false, bool suppress_vfx=false, Gungeon.SynergyStateChangeAction on_activated=null, Gungeon.SynergyStateChangeAction on_deactivated=null)
 Registers a new synergy. More...
 
SpriteCollection LoadSpriteCollection (string path)
 Loads a sprite collection in Semi Collection format. More...
 
SpriteAnimation LoadSpriteAnimation (string path)
 Loads a sprite animation in Semi Animation format. More...
 
Sound RegisterSound (string id, string path)
 
Music RegisterMusic (string id, string path)
 
PickupObject GetItem (string id)
 
AIActor GetEnemy (string id)
 
AdvancedSynergyEntry GetSynergy (string id)
 
SpriteCollectionGetSpriteCollection (string id)
 
SpriteGetSpriteTemplate (string id)
 
SpriteAnimationGetAnimationTemplate (string id)
 
I18N.LocalizationSource GetLocalization (string id)
 
I18N.Language GetLanguage (string id)
 
Audio GetAudioTrack (string id)
 
Sprite AttachSpriteInstance (GameObject target, string id)
 Attaches an instance of a sprite template to a GameObject. More...
 
Sprite ReplaceSpriteInstance (Sprite target, string id)
 Removes an existing sprite instance and attaches a new one to the same GameObject. More...
 
void OverrideAudio (string old_id, string new_id)
 Registers an audio override (any attempt to play More...
 
abstract void RegisterContent ()
 Called after all Loaded methods are ran. This is where you should register any content that your mod adds - items, guns etc. Do not iterate any ID lists (e.g. the item database) in this method, as there may be mods loaded after yours that add to them. If you need to register content that depends on ID lists, register only the most basic skeleton of your content in this method and initialize it in InitializeContent. More...
 
abstract void InitializeContent ()
 Called after all RegisterContent methods are ran. You can't register any new content in this method, but you can use pre-existing references and modify their fields. You can do things like iterating on items in this method because no new ID pool entries will be added. More...
 
abstract void Loaded ()
 Called when Semi loads the mod. You cannot register any content in this method. Use it to setup fields and such. More...
 
virtual string Serialize ()
 Called when the save file is updated. This method should return a string that you will later load in Deserialize(). Use this to implement persistence in your mod (save file interaction). More...
 
virtual void Deserialize (string s)
 Called when the save file is loaded. This method is fed the last recorded result of Serialize(). Use this to implement persistence in your mod (save file interaction). More...
 

Static Public Member Functions

static string NormalizePath (string path)
 Normalize a path, removing all '..' entries. This is used to avoid filesystem access outside of the resources directory in Semi methods. Note that this does not make mods secure, as there are still other ways that you could access the filesystem (for example, by directly using the System.IO APIs). More...
 

Static Public Attributes

const string RESOURCES_DIR_NAME = "resources"
 Name of the mod resources directory. More...
 

Properties

string ID [get]
 Gets the ID specified in the mod metadata. More...
 
ModConfig Config [get]
 Gets the loaded mod metadata. More...
 
Logger Logger [get, set]
 
SemiLoader.ModInfo Info [get, set]
 

Private Attributes

SemiLoader.ModInfo _Info
 Gets the stored representation of the loaded mod. More...
 

Static Private Attributes

static char[] _SeparatorSplitArray = { '\\', '/' }
 

Member Function Documentation

◆ AttachSpriteInstance()

Sprite Semi.Mod.AttachSpriteInstance ( GameObject  target,
string  id 
)
inline

Attaches an instance of a sprite template to a GameObject.

Returns
The new sprite instance parented to target.
Parameters
targetTarget object.
idGlobal ID of the sprite template.

◆ CreateSpriteDefinition()

SpriteDefinition Semi.Mod.CreateSpriteDefinition ( string  id,
string  sprite_path 
)
inline

Creates a single sprite definition from an image resource.

Returns
The sprite definition.
Parameters
idID (including the mod's namespace) for the new sprite definition.
sprite_pathRelative resource path to the image.

◆ Deserialize()

virtual void Semi.Mod.Deserialize ( string  s)
inlinevirtual

Called when the save file is loaded. This method is fed the last recorded result of Serialize(). Use this to implement persistence in your mod (save file interaction).

◆ GetAnimationTemplate()

SpriteAnimation? Semi.Mod.GetAnimationTemplate ( string  id)
inline

◆ GetAudioTrack()

Audio Semi.Mod.GetAudioTrack ( string  id)
inline

◆ GetEnemy()

AIActor Semi.Mod.GetEnemy ( string  id)
inline

◆ GetFullID()

string Semi.Mod.GetFullID ( string  id,
bool  require_local 
)
inline

Expands an ID, filling in context namespace if necessary.

Returns
The full ID including the namespace.
Parameters
idThe ID.
require_localWhether this ID must point to the mod's namespace.

◆ GetFullResourcePath()

string Semi.Mod.GetFullResourcePath ( string  res_path)
inline

Expands a path relative to the mod resources directory into an absolute path. Additionally, it will convert forward slash directory separators into backward slashes on Windows. Resource paths can only use forward slashes - this method will throw if it detects a backward slash.

Returns
The full resource path.
Parameters
res_pathRelative resource path.

◆ GetItem()

PickupObject Semi.Mod.GetItem ( string  id)
inline

◆ GetLanguage()

I18N.Language Semi.Mod.GetLanguage ( string  id)
inline

◆ GetLocalization()

I18N.LocalizationSource Semi.Mod.GetLocalization ( string  id)
inline

◆ GetSpriteCollection()

SpriteCollection? Semi.Mod.GetSpriteCollection ( string  id)
inline

◆ GetSpriteTemplate()

Sprite? Semi.Mod.GetSpriteTemplate ( string  id)
inline

◆ GetSynergy()

AdvancedSynergyEntry Semi.Mod.GetSynergy ( string  id)
inline

◆ InitializeContent()

abstract void Semi.Mod.InitializeContent ( )
pure virtual

Called after all RegisterContent methods are ran. You can't register any new content in this method, but you can use pre-existing references and modify their fields. You can do things like iterating on items in this method because no new ID pool entries will be added.

◆ Loaded()

abstract void Semi.Mod.Loaded ( )
pure virtual

Called when Semi loads the mod. You cannot register any content in this method. Use it to setup fields and such.

◆ LoadSpriteAnimation()

SpriteAnimation Semi.Mod.LoadSpriteAnimation ( string  path)
inline

Loads a sprite animation in Semi Animation format.

Returns
The newly registered sprite animation.
Parameters
pathRelative resource path to the file in Semi Animation format.

◆ LoadSpriteCollection()

SpriteCollection Semi.Mod.LoadSpriteCollection ( string  path)
inline

Loads a sprite collection in Semi Collection format.

Returns
The newly registered sprite collection.
Parameters
pathRelative resource path to the file in Semi Collection format.

◆ NormalizePath()

static string Semi.Mod.NormalizePath ( string  path)
inlinestatic

Normalize a path, removing all '..' entries. This is used to avoid filesystem access outside of the resources directory in Semi methods. Note that this does not make mods secure, as there are still other ways that you could access the filesystem (for example, by directly using the System.IO APIs).

Returns
The normalized path.
Parameters
pathPath.

◆ OverrideAudio()

void Semi.Mod.OverrideAudio ( string  old_id,
string  new_id 
)
inline

Registers an audio override (any attempt to play

old_id ends up playing new_id).

Parameters
old_idAudio event ID to replace.
new_idAudio event ID to replace with.

◆ RegisterContent()

abstract void Semi.Mod.RegisterContent ( )
pure virtual

Called after all Loaded methods are ran. This is where you should register any content that your mod adds - items, guns etc. Do not iterate any ID lists (e.g. the item database) in this method, as there may be mods loaded after yours that add to them. If you need to register content that depends on ID lists, register only the most basic skeleton of your content in this method and initialize it in InitializeContent.

◆ RegisterEncounterIcon()

SpriteDefinition Semi.Mod.RegisterEncounterIcon ( string  id,
string  sprite_path 
)
inline

Registers an encounter icon (used for example in the Ammonomicon) from an image resource.

Returns
The sprite definition of the new encounter icon.
Parameters
idID (including the mod's namespace) for the new encounter icon.
sprite_pathRelative resource path to the image.

◆ RegisterItem< T >()

T Semi.Mod.RegisterItem< T > ( string  id,
string  enc_icon_id,
string  sprite_template_id,
string  name_key = "",
string  short_desc_key = "",
string  long_desc_key = "" 
)
inline

Registers a new PickupObject.

Returns
Prefab object for the newly registered item.
Parameters
idID (including the mod's namespace) for the new item.
enc_icon_idGlobal ID of the encounter icon to use for this item.
sprite_template_idGlobal ID of the sprite template to use for this item.
name_keyGlobal ID of the localization string to use for the full name of this item.
short_desc_keyGlobal ID of the localization string to use for the short description of this item.
long_desc_keyGlobal ID of the localization string to use for the long description of this item.
Template Parameters
TComponent type to initialize as the PickupObject.
Type Constraints
T :PickupObject 

◆ RegisterLocalization()

I18N.ModLocalization Semi.Mod.RegisterLocalization ( string  id,
string  path,
string  lang_id,
I18N.StringTable  table,
bool  allow_overwrite = false 
)
inline

Registers a new localization.

Returns
The representation of the new localization.
Parameters
idID (including the mod's namespace) for the new localization.
pathRelative resource path to the localization text file.
lang_idGlobal ID of the language to apply this localization for.
tableTarget string table to apply this localization for.
allow_overwriteIf set to true allows this localization to overwrite others (note - depends on loading order!).

◆ RegisterMusic()

Music Semi.Mod.RegisterMusic ( string  id,
string  path 
)
inline

◆ RegisterSound()

Sound Semi.Mod.RegisterSound ( string  id,
string  path 
)
inline

◆ RegisterSpriteCollection()

SpriteCollection Semi.Mod.RegisterSpriteCollection ( string  id,
params SpriteDefinition[]  defs 
)
inline

Registers a new sprite collection.

Returns
The new sprite collection.
Parameters
idID (including the mod's namespace) for the new collection.
defsOptional array of sprite definitions to initialize the sprite collection with.

◆ RegisterSpriteTemplate()

Sprite Semi.Mod.RegisterSpriteTemplate ( string  id,
string  coll_id,
string  start_def_id = null 
)
inline

Registers a new sprite template.

Returns
The new sprite template.
Parameters
idID (including the mod's namespace) for the new sprite template.
coll_idGlobal ID of the sprite collection to uses.
start_def_idOptional global ID of the sprite definition from the sprite collection to use, the first definition will be used if not specified.

◆ RegisterSynergy()

AdvancedSynergyEntry Semi.Mod.RegisterSynergy ( string  id,
string  name_loc_id,
int  objects_required,
string[]  optional_gun_ids = null,
string[]  mandatory_gun_ids = null,
string[]  optional_item_ids = null,
string[]  mandatory_item_ids = null,
List< StatModifier >  stat_modifiers = null,
bool  active_when_gun_unequipped = false,
bool  ignore_lich_eye_bullets = false,
bool  require_at_least_one_gun_and_one_item = false,
bool  suppress_vfx = false,
Gungeon.SynergyStateChangeAction  on_activated = null,
Gungeon.SynergyStateChangeAction  on_deactivated = null 
)
inline

Registers a new synergy.

Returns
Newly registered synergy entry.
Parameters
idID (including the mod's namespace) for the new item.
name_loc_idID of the localization key for the name of this synergy (StringTable.Synergies).
objects_requiredHow many of the listed items and guns are needed to trigger the synergy.
optional_gun_idsA list of gun IDs that will count for the synergy, but aren't required to trigger it. DOES NOT SUPPORT CONTEXT IDS.
mandatory_gun_idsA list of gun IDs that are required for the synergy to trigger. DOES NOT SUPPORT CONTEXT IDS.
optional_item_idsA list of item IDs that will count for the synergy, but aren't required to trigger it. DOES NOT SUPPORT CONTEXT IDS.
mandatory_item_idsA list of item IDs that are required for the synergy to trigger. DOES NOT SUPPORT CONTEXT IDS.
stat_modifiersA list of stat modifiers to go into effect when the synergy is active.
active_when_gun_unequippedWhether the synergy should be active if conditions are met, but none of the mentioned guns are being held.
ignore_lich_eye_bulletsWhether Lich's Eye Bullets should not attempt to activate this synergy when one of the listed guns is picked up.
require_at_least_one_gun_and_one_itemWhether the synergy should require both an item and a gun to be picked up to activate the synergy, regardless of whether
objects_required
is met.
suppress_vfxWhether the synergy should avoid triggering the arrow visual effect.
on_activatedDelegate executed when the synergy becomes active.
on_deactivatedDelegate executed when the synergy stops being active.

◆ ReplaceSpriteInstance()

Sprite Semi.Mod.ReplaceSpriteInstance ( Sprite  target,
string  id 
)
inline

Removes an existing sprite instance and attaches a new one to the same GameObject.

Returns
The new sprite instance.
Parameters
targetSprite to replace.
idGlobal ID of the sprite template.

◆ Serialize()

virtual string Semi.Mod.Serialize ( )
inlinevirtual

Called when the save file is updated. This method should return a string that you will later load in Deserialize(). Use this to implement persistence in your mod (save file interaction).

Member Data Documentation

◆ _Info

SemiLoader.ModInfo Semi.Mod._Info
private

Gets the stored representation of the loaded mod.

The stored mod object.

◆ _SeparatorSplitArray

char [] Semi.Mod._SeparatorSplitArray = { '\\', '/' }
staticprivate

◆ RESOURCES_DIR_NAME

const string Semi.Mod.RESOURCES_DIR_NAME = "resources"
static

Name of the mod resources directory.

Property Documentation

◆ Config

ModConfig Semi.Mod.Config
get

Gets the loaded mod metadata.

The mod's metadata representation.

◆ ID

string Semi.Mod.ID
get

Gets the ID specified in the mod metadata.

The mod's ID.

◆ Info

SemiLoader.ModInfo Semi.Mod.Info
getset

◆ Logger

Logger Semi.Mod.Logger
getset


The documentation for this class was generated from the following files: