Class BuffAspect
Aspect of an entity that understands buffs.
public class BuffAspect : EntityAspect, IAspect<Entity>, IAspect
- Inheritance
-
BaseAspect<Entity>BuffAspect
- Implements
-
IAspect<Entity>
- Inherited Members
- Extension Methods
Constructors
BuffAspect(EntityAspect, bool)
Initializes a new instance of the EntityAspect class with another aspect.
public BuffAspect(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.
BuffAspect(Entity, bool)
Initializes a new instance of the EntityAspect class with the specified entity.
public BuffAspect(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
Queries
public static BuffQueries Queries { get; }
Property Value
Methods
ApplyBuff(Entity, PrefabGUID, out Entity, float, bool)
Applies a buff to an entity with optional duration and persistence settings.
public static bool ApplyBuff(Entity target, PrefabGUID buff, out Entity buffEntity, float duration = 0, bool tryPersistThroughDeath = false)
Parameters
target
EntityEntity to apply the buff to.
buff
PrefabGUIDThe PrefabGUID of the buff to apply.
buffEntity
EntityOutput parameter that receives the created buff entity.
duration
floatDuration of the buff in seconds. 0 for infinite duration.
tryPersistThroughDeath
boolIf true, the buff will attempt to persist through death.
Returns
- bool
True if the buff was successfully applied, false otherwise.
ApplyCosmetic(Entity, PrefabGUID)
Applies a cosmetic buff to an entity and removes gameplay-related components.
public static void ApplyCosmetic(Entity entity, PrefabGUID visual)
Parameters
entity
EntityThe entity to apply the cosmetic to.
visual
PrefabGUIDThe PrefabGUID of the cosmetic buff to apply.
CreateAndApply(Entity, out BuffAspect?, float, bool)
public bool CreateAndApply(Entity target, out BuffAspect? buffAspect, float duration = 0, bool tryPersistThroughDeath = false)
Parameters
target
EntitybuffAspect
BuffAspectduration
floattryPersistThroughDeath
bool
Returns
HasBuff(Entity, PrefabGUID)
Checks if an entity has a specific buff.
public static bool HasBuff(Entity entity, PrefabGUID buff)
Parameters
entity
EntityThe entity to check for the buff.
buff
PrefabGUIDThe PrefabGUID of the buff to check for.
Returns
- bool
True if the entity has the specified buff, false otherwise.
Is(Entity)
public static bool Is(Entity entity)
Parameters
entity
Entity
Returns
Modify(BuffModificationTypes, bool)
Modifies a buff entity with specified modification types.
public void Modify(BuffModificationTypes buffModificationTypes, bool overwrite = false)
Parameters
buffModificationTypes
BuffModificationTypesThe types of modifications to apply.
overwrite
boolIf true, clears existing modifications before applying new ones.
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.
RemoveBuff(Entity, PrefabGUID)
Removes a specific buff from an entity.
public static void RemoveBuff(Entity entity, PrefabGUID guid)
Parameters
entity
EntityThe entity to remove the buff from.
guid
PrefabGUIDThe PrefabGUID of the buff to remove.