Class EntityAspect
Aspect of an entity in the game world.
public class EntityAspect : BaseAspect<Entity>, IAspect<Entity>, IAspect
- Inheritance
-
BaseAspect<Entity>EntityAspect
- Implements
-
IAspect<Entity>
- Derived
- Inherited Members
- Extension Methods
Constructors
EntityAspect(EntityAspect, bool)
Initializes a new instance of the EntityAspect class with another aspect.
public EntityAspect(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.
EntityAspect(Entity, bool)
Initializes a new instance of the EntityAspect class with the specified entity.
public EntityAspect(Entity entity, bool strict = true)
Parameters
entity
EntityThe entity to associate with this aspect.
strict
boolIf true, the aspect will throw an exception if the entity is null.
Exceptions
- ArgumentNullException
Thrown when the entity is null.
Properties
BloodConsumeSource
public BloodConsumeSource? BloodConsumeSource { get; }
Property Value
- BloodConsumeSource?
Components
Gets the component monolith for this entity, which provides access to various components and their data.
public ComponentMonolith Components { get; }
Property Value
DestroyData
public DestroyData? DestroyData { get; }
Property Value
- DestroyData?
DestroyState
public DestroyState? DestroyState { get; }
Property Value
- DestroyState?
DropTable
public DropTable? DropTable { get; }
Property Value
- DropTable?
Entity
Gets the target entity of this aspect.
public Entity Entity { get; }
Property Value
- Entity
EntityCategory
public EntityCategory? EntityCategory { get; }
Property Value
- EntityCategory?
Follower
public Follower? Follower { get; }
Property Value
- Follower?
HasDrops
public bool HasDrops { get; }
Property Value
IsBehaviourTree
public bool IsBehaviourTree { get; }
Property Value
IsCharacter
public bool IsCharacter { get; }
Property Value
IsCombat
public bool IsCombat { get; }
Property Value
IsEntity
Indicates whether this aspect is an entity aspect.
public override bool IsEntity { get; }
Property Value
IsGatherable
public bool IsGatherable { get; }
Property Value
IsHybridModel
public bool IsHybridModel { get; }
Property Value
IsInventory
public bool IsInventory { get; }
Property Value
IsItem
public bool IsItem { get; }
Property Value
IsMoveable
public bool IsMoveable { get; }
Property Value
IsNetwork
public bool IsNetwork { get; }
Property Value
IsNpc
public bool IsNpc { get; }
Property Value
IsPlayer
public bool IsPlayer { get; }
Property Value
IsResource
public bool IsResource { get; }
Property Value
IsStructure
public bool IsStructure { get; }
Property Value
IsUnit
public bool IsUnit { get; }
Property Value
LocalToWorld
public LocalToWorld? LocalToWorld { get; }
Property Value
- LocalToWorld?
LocalTransform
public LocalTransform? LocalTransform { get; }
Property Value
- LocalTransform?
MainCategory
public MainEntityCategory? MainCategory { get; }
Property Value
- MainEntityCategory?
MapCollision
public MapCollision? MapCollision { get; }
Property Value
- MapCollision?
MaterialCategory
public MaterialCategory? MaterialCategory { get; }
Property Value
- MaterialCategory?
MoveEntity
public MoveEntity? MoveEntity { get; }
Property Value
- MoveEntity?
MoveVelocity
public MoveVelocity? MoveVelocity { get; }
Property Value
- MoveVelocity?
NetworkId
Gets the network ID of the entity, which is used for network communication.
public virtual NetworkId NetworkId { get; }
Property Value
- NetworkId
PackedNetworkId
Packs the network ID into a ulong for efficient storage and transmission.
public virtual ulong PackedNetworkId { get; }
Property Value
PrefabGuid
Gets the PrefabGUID of the entity, which is used to identify the prefab associated with this entity.
public PrefabGUID PrefabGuid { get; }
Property Value
- PrefabGUID
PrefabName
Looks up the name of the prefab associated with this entity's PrefabGUID.
public string PrefabName { get; }
Property Value
Queries
public static EntityQueries Queries { get; }
Property Value
Rotation
public Rotation? Rotation { get; }
Property Value
- Rotation?
SpawnTransform
public SpawnTransform? SpawnTransform { get; }
Property Value
- SpawnTransform?
Team
public Team? Team { get; }
Property Value
- Team?
TeamReference
public TeamReference? TeamReference { get; }
Property Value
- TeamReference?
Translation
public Translation? Translation { get; }
Property Value
- Translation?
UnitCategory
public UnitCategory? UnitCategory { get; }
Property Value
- UnitCategory?
WorldPosition
public float3 WorldPosition { get; }
Property Value
- float3
Methods
Create<TX>(Entity, bool, params object?[]?)
Creates a new instance of the EntityAspect class for the specified entity.
public static TX Create<TX>(Entity entity, bool strict = true, params object?[]? args) where TX : EntityAspect
Parameters
entity
EntityThe entity to associate with this aspect.
strict
boolIf true, the aspect will throw an exception if the entity is null.
args
object[]Optional arguments for the aspect creation.
Returns
- TX
Returns a new instance of the specified aspect type.
Type Parameters
TX
The type of the aspect to create, which must inherit from EntityAspect.
DisplayName(Entity)
Displays the name of the entity for debugging purposes.
protected override string DisplayName(Entity entity)
Parameters
entity
EntityThe entity to display.
Returns
- string
Returns the debug name of the entity.
DropItemNearby(PrefabGUID, int)
Drops an item nearby the entity's current position.
public void DropItemNearby(PrefabGUID itemGuid, int amount)
Parameters
itemGuid
PrefabGUIDThe PrefabGUID of the item to drop.
amount
intThe amount of the item to drop.
DumpUnqualifiedTarget(Entity, string)
Dumps the unqualified target entity with an error message.
protected override void DumpUnqualifiedTarget(Entity obj, string errorMessage)
Parameters
obj
EntityThe entity that does not qualify.
errorMessage
stringThe error message to display if the entity does not qualify.
ExtraDetails(Entity)
Provides extra details about the entity, such as its unit category and main category.
protected override string ExtraDetails(Entity entity)
Parameters
entity
EntityThe entity to provide details for.
Returns
- string
Returns a string containing extra details about the entity.
GetBufferInternal<T>()
Gets the component data of a specific type from the entity's components, allowing for unmanaged types.
public List<T>? GetBufferInternal<T>() where T : struct
Returns
- List<T>
Returns the unmanaged component data of type T if it exists, otherwise null.
Type Parameters
T
The type of unmanaged component data to retrieve.
GetComponentData<T>()
Gets the component data of a specific type from the entity's components.
public T? GetComponentData<T>() where T : new()
Returns
- T
Returns the component data of type T if it exists, otherwise null.
Type Parameters
T
The type of component data to retrieve.
GetManagedComponentData<T>()
Gets the component data of a specific type from the entity's components, allowing for managed types.
public T? GetManagedComponentData<T>() where T : class
Returns
- T
Returns the managed component data of type T if it exists, otherwise null.
Type Parameters
T
The type of managed component data to retrieve.
GetRawMetadata()
Gets the raw metadata of the entity, which is typically the name of the interactable if it exists.
protected override string GetRawMetadata()
Returns
Has(ComponentType)
Checks if the entity has a specific component type using a Unity.Entities.ComponentType.
public bool Has(ComponentType componentType)
Parameters
componentType
ComponentTypeThe component type to check for.
Returns
- bool
Returns true if the entity has the component, otherwise false.
Has<T>()
Checks if the entity has a specific component type.
public bool Has<T>()
Returns
- bool
Returns true if the entity has the component, otherwise false.
Type Parameters
T
The type of component to check for.
IsInCastle()
Checks if the entity is currently in a castle area.
public bool IsInCastle()
Returns
- bool
Returns true if the entity is in a castle area, otherwise false.
Qualifies(Entity)
Checks if the entity qualifies for this aspect.
public override bool Qualifies(Entity obj)
Parameters
obj
EntityThe entity to check.
Returns
- bool
Returns true if the entity qualifies, otherwise false.
SetRawMetadata(string)
Sets the raw metadata for the entity, which is typically the name of the interactable.
protected override void SetRawMetadata(string json)
Parameters
json
stringThe JSON string representing the name of the interactable.