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
aspectEntityAspectThe aspect to copy from.
strictboolIf 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
characterNameFixedString64BytesThe name of the character.
steamIdulongThe Steam ID of the player.
userEntityEntityThe entity representing the user.
charEntityEntityThe entity representing the character.
strictboolIf 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
entityEntityThe entity representing the player.
strictboolIf 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
achievementPrefabGuidPrefabGUIDThe PrefabGUID of the achievement to complete.
reapplyModeboolIf true, the achievement will be reapplied even if it has already been completed.
logOnDuplicateboolIf 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
achievementPrefabGuidintThe GUID of the achievement prefab to complete.
reapplyModeboolIf true, the achievement will be reapplied even if it has already been completed.
logOnDuplicateboolIf 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
entityEntity
Returns
Qualifies(Entity)
Checks if the entity qualifies for this aspect.
public override bool Qualifies(Entity entity)
Parameters
entityEntity
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
itemGuidPrefabGUIDThe GUID of the item to give.
amountintThe amount of the item to give.
itemEntityEntityOutput parameter that receives the item entity if the operation is successful.
Returns
- bool
True if the item was successfully given; otherwise, false.