-
Notifications
You must be signed in to change notification settings - Fork 7
Home
Welcome to the ContentLib API wiki. This wiki covers the core classes and API's available in ContentLib
- Core API:
- (ModDefinition)[]
- (ContentDefinition)[]
- (RegisterCallbacks)[]
- (MatchingTags)[]
- Enemy API:
- (EnemyDefinition)[]
- Hazard API
- (HazardDefinition)[]
ModDefinition is a core class in the ContentLib API, representing a mod and its content.
-
Properties
-
string ModGUID { get; }- A unique identifier for the mod. -
string ModName { get; }- The name of the mod. -
List<ContentDefinition> Content { get; }- A list of content definitions associated with the mod.
-
-
Static Properties
-
IReadOnlyDictionary<string modGUID, ModDefinition> AllMods { get; }- An immutable dictionary of all mods by GUID.
-
-
static ModDefinition Create(PluginInfo pluginInfo)- Creates a new
ModDefinitionusing the providedPluginInfo. - Throws an exception if
pluginInfois null. - Usage:
var modDef = ModDefinition.Create(pluginInfo);
- Creates a new
-
static ModDefinition Create(BepInPlugin bepInPlugin)- Creates a new
ModDefinitionusing the providedBepInPlugin. - Throws an exception if
bepInPluginis null.
- Creates a new
-
static ModDefinition Create(string modGUID, string modName)- Tries to return an identical
ModDefinitionbased on modGUID if found, otherwise, creates a newModDefinitionusing the provided GUID and name. - Throws an exception if
modGUIDormodNameare null or empty. - Usage:
var modDef = ModDefinition.Create("com.github.exampleauthor.examplemod", "Example Mod");
- Tries to return an identical
-
void RegisterContent()- Registers all content in the
ModDefinition - Usage:
modDef.RegisterContent();
- Registers all content in the
ContentDefinition is an abstract class representing a piece of content in a mod.
- Properties
-
[NonSerialized] ModDefinition Mod { get; }- The mod to which this content belongs. -
[NonSerialized] bool IsRegistered { get; }- Indicates whether the content is registered.
-
- Properties to be implemented by inheriting classes
Ignore<Content>DefinitionValidationFlags IgnoreValidationFlags { get; set; }
-
virtual (bool, string) Validate()- Validates the content. If the validation fails, a message is returned.
- Usage:
var (isValid, message) = contentDef.Validate();
-
abstract Register()- Registers the content. If validation fails, an exception is thrown.
RegisterCallbacks<T> provides a mechanism to register callbacks for content registration events.
- Delegate
CallbackInvoker(ModDefinition modDefinition, string contentDefinitionName, bool isBefore, T contentDefinition)
-
void RegisterCallbacks(ref CallbackInvoker callbackInvoker)- Registers the callback invoker.
-
void AddOnBeforeRegister(string authorName, string modName, string contentDefinitionName, Action<T> eventHandler)- Adds a callback to be invoked before content registration using AuthorName and ModName.
void AddOnBeforeRegister(ModDefintion modDefinition, string contentDefinitionName, Action<T> eventHandler) - Adds a callback to be invoked before content registration using ModDefinition.
- Adds a callback to be invoked before content registration using AuthorName and ModName.
-
void AddOnAfterRegister(string authorName, string modName, string contentDefinitionName, Action<T> eventHandler)- Adds a callback to be invoked after content registration using AuthorName and ModName.
void AddOnAfterRegister(ModDefinition modDefinition, string contentDefinitionName, Action<T> eventHandler) - Adds a callback to be invoked after content registration using ModDefinition.
- Adds a callback to be invoked after content registration using AuthorName and ModName.
MatchingTags represents a collection of tags with associated weights.
- Properties
-
List<WeightedTagsGroup> ModNameTags- Tags related to mod names. -
List<WeightedTagsGroup> AuthorNameTags- Tags related to author names.
-
EnemyDefinition is a content definition for enemy types in the game.
- Properties
-
EnemyType enemyType { get; set; }- The type of enemy. LevelMatchingTags InsideLevelMatchingTags { get; set; }LevelMatchingTags OutsideLevelMatchingTags { get; set; }LevelMatchingTags DaytimeLevelMatchingTags { get; set; }IgnoreEnemyDefinitionValidationFlags IgnoreValidationFlags { get; set; }
-
-
static EnemyDefinition Create(EnemyType? enemyType)- Creates a new
EnemyDefinitioninstance. - Usage:
var enemyDef = EnemyDefinition.Create(enemyType);
- Creates a new
-
static RegisterCallbacks<EnemyDefinition> Callbacks { get; }- Provides callbacks for enemy registration events.
-
override (bool, string) Validate()- Validates the enemy definition.
-
override Register()- Registers the enemy definition.