Class CharacterAspect
Character aspect in the game, providing access to character-specific data and functionality.
public class CharacterAspect : UnitAspect, IAspect<Entity>, IAspect
- Inheritance
-
BaseAspect<Entity>CharacterAspect
- Implements
-
IAspect<Entity>
- Inherited Members
- Extension Methods
Constructors
CharacterAspect(EntityAspect, bool)
Initializes a new instance of the CharacterAspect class from an existing EntityAspect.
public CharacterAspect(EntityAspect aspect, bool strict = true)
Parameters
aspect
EntityAspectThe existing EntityAspect to initialize from.
strict
boolIf true, enforces strict type checking. Default is true.
CharacterAspect(Entity, bool)
Initializes a new instance of the CharacterAspect class from an Unity.Entities.Entity.
public CharacterAspect(Entity entity, bool strict = true)
Parameters
entity
EntityThe Unity.Entities.Entity to initialize from.
strict
boolIf true, enforces strict type checking. Default is true.
Properties
Equipment
Gets the equipment aspect of the character, if available.
public EquipmentAspect? Equipment { get; }
Property Value
Level
Gets the level of the character, if available.
public override float? Level { get; }
Property Value
Queries
public static CharacterQueries Queries { get; }
Property Value
Methods
AddItemToInventory(PrefabGUID, int, out Entity, int, bool, bool, bool)
Adds an item to an entity's inventory with optional equipping and dropping functionality.
public AddItemResponse AddItemToInventory(PrefabGUID guid, int amount, out Entity entity, int startSlot = 0, bool dropRemainder = true, bool tryEquip = true, bool onlyFillEmptySlots = false)
Parameters
guid
PrefabGUIDThe prefab GUID of the item to add.
amount
intThe quantity of items to add.
entity
EntityOutput parameter that receives the newly created item entity.
startSlot
intThe inventory slot to place the item in. Default is 0.
dropRemainder
boolIf true, drops excess items that don't fit in inventory. Default is true.
tryEquip
boolIf true, attempts to equip the item after adding. Default is true.
onlyFillEmptySlots
boolIf true, Will only fill empty slots and not auto stack. Default false.
Returns
- AddItemResponse
True if the item was successfully added to the inventory, false otherwise.
ClearInventory()
Clears the inventory of a specified entity.
public void ClearInventory()
GetBloodBuffInfo()
Gets the blood buff information for the character, if available.
public BloodBuffInfo? GetBloodBuffInfo()
Returns
- BloodBuffInfo
A ProjectM.UI.BloodBuffInfo object containing the blood buff information, or null if not available.
GetDurabilityInfo(EquipmentType)
Gets the durability information for a specified equipment type.
public DurabilityInfo? GetDurabilityInfo(EquipmentType equipmentType)
Parameters
equipmentType
EquipmentTypeThe type of equipment to retrieve durability information for.
Returns
- DurabilityInfo?
A ProjectM.UI.DurabilityInfo object containing the durability information, or null if not available.
GetInventoryItems(int)
Gets the inventory items of the character at a specified index.
public List<InventoryItemData>? GetInventoryItems(int index = 0)
Parameters
index
intThe index of the inventory to retrieve items from. Default is 0.
Returns
- List<InventoryItemData>
A list of inventory items, or null if the inventory entity is not found.
GetItemSetInfo(PrefabGUID)
Gets the item set information for a specified prefab GUID.
public ItemSetInfo GetItemSetInfo(PrefabGUID prefabGuid)
Parameters
prefabGuid
PrefabGUIDThe prefab GUID to retrieve item set information for.
Returns
- ItemSetInfo
A ProjectM.UI.ItemSetInfo object containing the item set information, or null if not available.
GetSlotCounts()
public (int freeSlots, int totalSlots) GetSlotCounts()
Returns
GetStashes(bool)
Gets the stashes of the character, optionally filtering by allied only.
public IEnumerable<InventoryAspect> GetStashes(bool alliedOnly = false)
Parameters
alliedOnly
boolIf true, only retrieves stashes that are allied. Default is false.
Returns
- IEnumerable<InventoryAspect>
An enumerable collection of InventoryAspect representing the stashes.
GetUnlockInfo(PrefabGUID)
Gets the unlock information for a specified prefab GUID.
public UnlockInfo? GetUnlockInfo(PrefabGUID prefabGuid)
Parameters
prefabGuid
PrefabGUIDThe prefab GUID to retrieve unlock information for.
Returns
- UnlockInfo
A ProjectM.UI.UnlockInfo object containing the unlock information, or null if not available.
Is(Entity)
public static bool Is(Entity entity)
Parameters
entity
Entity
Returns
Qualifies(Entity)
Checks if the entity qualifies for this aspect.
public override bool Qualifies(Entity entity)
Parameters
entity
Entity
Returns
- bool
Returns true if the entity qualifies, otherwise false.
TryGiveItem(PrefabGUID, int, out Entity)
Attempts to give an item to the character's inventory.
public bool TryGiveItem(PrefabGUID itemGuid, int amount, out Entity itemEntity)
Parameters
itemGuid
PrefabGUIDThe prefab GUID of the item to give.
amount
intThe quantity of the item to give.
itemEntity
EntityOutput parameter that receives the newly created item entity.
Returns
- bool
True if the item was successfully given, false otherwise.