Class PieceManager
Manager for handling custom pieces added to the game.
Inheritance
System.Object
PieceManager
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Jotunn.Managers
Assembly: Jotunn.dll
Syntax
public class PieceManager : IManager
Properties
| Improve this Doc View SourceInstance
The singleton instance of this manager.
Declaration
public static PieceManager Instance { get; }
Property Value
Type | Description |
---|---|
PieceManager |
Methods
| Improve this Doc View SourceAddPiece(CustomPiece)
Add a CustomPiece to the game.
Checks if the custom piece is valid and unique and adds it to the list of custom pieces.
Custom pieces are added to their respective s after .
Checks if the custom piece is valid and unique and adds it to the list of custom pieces.
Custom pieces are added to their respective
Declaration
public bool AddPiece(CustomPiece customPiece)
Parameters
Type | Name | Description |
---|---|---|
CustomPiece | customPiece | The custom piece to add. |
Returns
Type | Description |
---|---|
System.Boolean | true if the custom piece was added to the manager. |
AddPieceCategory(String, String)
Add a new by name. A new category
gets assigned a random integer for internal use. If you pass a vanilla category
the actual integer value of the enum is returned.
Declaration
public Piece.PieceCategory AddPieceCategory(string table, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | table | Prefab or item name of the PieceTable. |
System.String | name | Name of the category. |
Returns
Type | Description |
---|---|
Piece.PieceCategory | int value of the vanilla or custom category |
AddPieceTable(GameObject)
Declaration
[Obsolete("Use CustomPieceTable instead")]
public void AddPieceTable(GameObject prefab)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | The |
AddPieceTable(CustomPieceTable)
Add a CustomPieceTable to the game.
Checks if the custom piece table is valid and unique and adds it to the list of custom piece tables.
Checks if the custom piece table is valid and unique and adds it to the list of custom piece tables.
Declaration
public bool AddPieceTable(CustomPieceTable customPieceTable)
Parameters
Type | Name | Description |
---|---|---|
CustomPieceTable | customPieceTable | The custom piece table to add. |
Returns
Type | Description |
---|---|
System.Boolean | true if the custom piece table was added to the manager. |
AddPieceTable(String)
Declaration
[Obsolete("Use CustomPieceTable instead")]
public void AddPieceTable(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the new piece table. |
GetPiece(String)
Get a custom piece by its name.
Declaration
public CustomPiece GetPiece(string pieceName)
Parameters
Type | Name | Description |
---|---|---|
System.String | pieceName | Name of the piece to search. |
Returns
Type | Description |
---|---|
CustomPiece |
GetPieceCategories()
Get a list of all custom piece category names
Declaration
public List<string> GetPieceCategories()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<System.String> |
GetPieceTable(String)
Get a by name.
Search hierarchy:
Search hierarchy:
Declaration
public PieceTable GetPieceTable(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Prefab or item name of the PieceTable |
Returns
Type | Description |
---|---|
PieceTable |
Init()
Creates the piece table container and registers all hooks.
Declaration
public void Init()
RegisterPieceInPieceTable(GameObject, String, String)
Register a single piece prefab into a piece table by name.
Also adds the prefab to the PrefabManager and if necessary.
Custom categories can be referenced if they have been added to the manager before.
No mock references are fixed.
Also adds the prefab to the PrefabManager and
Custom categories can be referenced if they have been added to the manager before.
No mock references are fixed.
Declaration
public void RegisterPieceInPieceTable(GameObject prefab, string pieceTable, string category = null)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | |
System.String | pieceTable | Prefab or item name of the PieceTable |
System.String | category | Optional category string, does not create new custom categories |
RemovePiece(CustomPiece)
Remove a custom piece by its ref.
Declaration
public void RemovePiece(CustomPiece piece)
Parameters
Type | Name | Description |
---|---|---|
CustomPiece | piece | CustomPiece to remove. |
RemovePiece(String)
Remove a custom piece by its name.
Declaration
public void RemovePiece(string pieceName)
Parameters
Type | Name | Description |
---|---|---|
System.String | pieceName | Name of the piece to remove. |
Events
| Improve this Doc View SourceOnPiecesRegistered
Event that gets fired after all pieces were added to their respective PieceTables.
Your code will execute every time a new ObjectDB is created (on every game start).
If you want to execute just once you will need to unregister from the event after execution.
Declaration
public static event Action OnPiecesRegistered
Event Type
Type | Description |
---|---|
System.Action |