Show / Hide Table of Contents

Class PieceManager

Manager for handling custom pieces added to the game.
Inheritance
object
PieceManager
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Jotunn.Managers
Assembly: Jotunn.dll
Syntax
public class PieceManager

Properties

Name Description
Instance The singleton instance of this manager.

Methods

Name Description
AddPiece(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 PieceTables after ObjectDB.Awake.
AddPieceCategory(string) Add a new Piece.PieceCategory 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.
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.
GetPiece(string) Get a custom piece by its name.
GetPieceCategoriesMap() Get a complete map of all piece categories. This includes vanilla, Jötunn and other modded categories that use the same system
GetPieceCategory(string) Get a Piece.PieceCategory by name. Translates vanilla or custom Piece Categories to their current integer value.
GetPieceTable(string) Get a PieceTable by name.

Search hierarchy:
  1. PieceTable with the exact name (e.g. "_HammerPieceTable")
  2. PieceTable via "item" name (e.g. "Hammer")
GetPieceTables() Returns all PieceTable instances in the game. The list is gathered on every ObjectDB.Awake() from all items in it, so depending on the timing of the call, the list might not be complete.
RegisterPieceInPieceTable(GameObject, string, string) Register a single piece prefab into a piece table by name.
Also adds the prefab to the PrefabManager and ZNetScene if necessary.
Custom categories can be referenced if they have been added to the manager before.
No mock references are fixed.
RemovePiece(CustomPiece) Remove a custom piece by its ref.
RemovePiece(string) Remove a custom piece by its name.
RemovePieceCategory(string) Remove a Piece.PieceCategory from a table by name. This does noting if a piece is still assigned to the category, remove it before calling this.

Events

Name Description
OnPiecesRegistered 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.

Extension Methods

PrefabExtension.FixReferences(object)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾