Class PlayerAspect
Aspect of an entity that represents a player in the game.
public class PlayerAspect : UnitAspect, IAspect<Entity>, IAspect, IData
- Inheritance
-
BaseAspect<Entity>PlayerAspect
- Implements
-
IAspect<Entity>
- Inherited Members
- Extension Methods
Constructors
PlayerAspect(EntityAspect, bool)
Initializes a new instance of the EntityAspect class with another aspect.
public PlayerAspect(EntityAspect aspect, bool strict = true)
Parameters
aspect
EntityAspectThe aspect to copy from.
strict
boolIf true, the aspect will throw an exception if the entity is null.
Exceptions
- ArgumentNullException
Thrown when the entity of the aspect is null.
PlayerAspect(FixedString64Bytes, ulong, Entity, Entity, bool)
Initializes a new instance of the PlayerAspect class.
public PlayerAspect(FixedString64Bytes characterName, ulong steamId, Entity userEntity, Entity charEntity, bool strict = true)
Parameters
characterName
FixedString64BytesThe name of the character.
steamId
ulongThe Steam ID of the player.
userEntity
EntityThe entity representing the user.
charEntity
EntityThe entity representing the character.
strict
boolIf true, the aspect will only be valid if the entities have the required components.
Exceptions
- ArgumentException
Thrown if the userEntity does not have a User component or charEntity does not have a PlayerCharacter component.
PlayerAspect(Entity, bool)
Aspect of an entity that represents a player in the game.
public PlayerAspect(Entity entity, bool strict = true)
Parameters
entity
EntityThe entity representing the player.
strict
boolIf true, the aspect will only be valid if the entity has the required components.
Properties
AdminLevel
public AdminLevel AdminLevel { get; }
Property Value
- AdminLevel
AdminUser
public AdminUser? AdminUser { get; }
Property Value
- AdminUser?
CharEntity
public Entity CharEntity { get; }
Property Value
- Entity
Character
public CharacterAspect Character { get; }
Property Value
CharacterName
public FixedString64Bytes CharacterName { get; }
Property Value
- FixedString64Bytes
Equipment
public EquipmentAspect? Equipment { get; }
Property Value
FromCharacter
public FromCharacter FromCharacter { get; }
Property Value
- FromCharacter
IsAdmin
public bool IsAdmin { get; }
Property Value
IsConnected
public bool IsConnected { get; }
Property Value
Level
public override float? Level { get; }
Property Value
PackedNetworkId
Packs the network ID into a ulong for efficient storage and transmission.
public override ulong PackedNetworkId { get; }
Property Value
PlayerCharacter
public PlayerCharacter? PlayerCharacter { get; }
Property Value
- PlayerCharacter?
Queries
public static PlayerQueries Queries { get; }
Property Value
SteamId
public ulong SteamId { get; }
Property Value
User
public User User { get; }
Property Value
- User
UserContent
public UserContentFlags? UserContent { get; }
Property Value
- UserContentFlags?
UserEntity
public Entity UserEntity { get; }
Property Value
- Entity
Methods
ClearInventory()
Clears the player's inventory by removing all items.
public void ClearInventory()
CompleteAchievement(PrefabGUID, bool, bool)
Completes an achievement for the player using a PrefabGUID.
public bool CompleteAchievement(PrefabGUID achievementPrefabGuid, bool reapplyMode = false, bool logOnDuplicate = true)
Parameters
achievementPrefabGuid
PrefabGUIDThe PrefabGUID of the achievement to complete.
reapplyMode
boolIf true, the achievement will be reapplied even if it has already been completed.
logOnDuplicate
boolIf true, logs a message if the achievement has already been completed.
Returns
- bool
True if the achievement was successfully completed; otherwise, false.
CompleteAchievement(int, bool, bool)
Completes an achievement for the player.
public bool CompleteAchievement(int achievementPrefabGuid, bool reapplyMode = false, bool logOnDuplicate = true)
Parameters
achievementPrefabGuid
intThe GUID of the achievement prefab to complete.
reapplyMode
boolIf true, the achievement will be reapplied even if it has already been completed.
logOnDuplicate
boolIf true, logs a message if the achievement has already been completed.
Returns
- bool
True if the achievement was successfully completed; otherwise, false.
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.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
TryGiveItem(PrefabGUID, int, out Entity)
Attempts to give an item to the player's inventory.
public bool TryGiveItem(PrefabGUID itemGuid, int amount, out Entity itemEntity)
Parameters
itemGuid
PrefabGUIDThe GUID of the item to give.
amount
intThe amount of the item to give.
itemEntity
EntityOutput parameter that receives the item entity if the operation is successful.
Returns
- bool
True if the item was successfully given; otherwise, false.