Class EntityHealth
Used to keep track of the health of an enemy
Namespace: WeaverCore.Components
Assembly: WeaverCore.dll
Syntax
public class EntityHealth : MonoBehaviour, IHittable, IExtraDamageable, IOnPool
Fields
| Edit this page View SourceDeflectBlows
If true, it causes all attacks from the player to result in a massive clink and deflection. This is only used if invicible is set to true
Declaration
public bool DeflectBlows
Field Value
Type | Description |
---|---|
bool |
DoEffectsOnHit
If true, will play the enemy's hit effects when hit
Declaration
public bool DoEffectsOnHit
Field Value
Type | Description |
---|---|
bool |
EffectsOffset
Applies an offset to hit effects if desired
Declaration
public Vector3 EffectsOffset
Field Value
Type | Description |
---|---|
Vector3 |
EvasionTime
Controls how often the enemy is able to receive attacks. For example, if the value is set to 0.15, then that means this enemy will not receive any more hits, until 0.15 seconds have elapsed since the last hit
Declaration
public float EvasionTime
Field Value
Type | Description |
---|---|
float |
GainSoul
If true, will cause the player to gain soul points when hit
Declaration
public bool GainSoul
Field Value
Type | Description |
---|---|
bool |
Invincible
Whether the enemy is invincible to attacks
Declaration
public bool Invincible
Field Value
Type | Description |
---|---|
bool |
LargeGeo
Declaration
public int LargeGeo
Field Value
Type | Description |
---|---|
int |
MediumGeo
Declaration
public int MediumGeo
Field Value
Type | Description |
---|---|
int |
SmallGeo
Declaration
[Space]
[Space]
[Header("Geo Dropped on Death")]
public int SmallGeo
Field Value
Type | Description |
---|---|
int |
impl
Declaration
protected HealthManager_I impl
Field Value
Type | Description |
---|---|
HealthManager_I |
Properties
| Edit this page View SourceEvasionTimeLeft
How much evasion time is left EvasionTime
Declaration
public float EvasionTimeLeft { get; set; }
Property Value
Type | Description |
---|---|
float |
Health
How much health the enemy has. This gets decreased each time the player hits this enemy
Declaration
public int Health { get; set; }
Property Value
Type | Description |
---|---|
int |
LastAttackDirection
The direction the last attack came from
Declaration
public CardinalDirection LastAttackDirection { get; }
Property Value
Type | Description |
---|---|
CardinalDirection |
LastAttackInfo
Contains info about the most recent hit on the enemy
Declaration
public HitInfo LastAttackInfo { get; }
Property Value
Type | Description |
---|---|
HitInfo |
Recoiler
The recoiler on the enemy. If a recoiler is attached to the object, then the enemy will recoil when hit
Declaration
public Recoiler Recoiler { get; set; }
Property Value
Type | Description |
---|---|
Recoiler |
Methods
| Edit this page View SourceAddHealthMilestone(int, Action)
Declaration
public void AddHealthMilestone(int health, Action action)
Parameters
Type | Name | Description |
---|---|---|
int | health | |
Action | action |
AddModifier(IHealthModifier)
Adds a health modifier. The modifier will be used to modify how the health gets changed when the player hits the enemy
Declaration
public void AddModifier(IHealthModifier modifier)
Parameters
Type | Name | Description |
---|---|---|
IHealthModifier | modifier | The modifier to be added |
AddModifier<T>()
Adds a health modifier. The modifier will be used to modify how the health gets changed when the player hits the enemy
Declaration
public T AddModifier<T>() where T : IHealthModifier, new()
Returns
Type | Description |
---|---|
T | Returns an instance of the modifier that was added |
Type Parameters
Name | Description |
---|---|
T | The type of health modifier to add |
Awake()
Declaration
protected virtual void Awake()
Die()
Forces the entity to die
Declaration
public void Die()
Die(HitInfo)
Forces the entity to die
Declaration
public void Die(HitInfo finalHit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | finalHit | The final hit on the entity |
DoDeathEvent()
Calls the OnDeath Event, but does not change the health. This is if you only want to trigger the death event and nothing else
Declaration
public void DoDeathEvent()
DoDeathEvent(HitInfo)
Calls the OnDeath Event, but does not change the health. This is if you only want to trigger the death event and nothing else
Declaration
public void DoDeathEvent(HitInfo finalHit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | finalHit | The final hit on the entity |
GetDamageOfType(ExtraDamageTypes)
Declaration
public static int GetDamageOfType(ExtraDamageTypes extraDamageTypes)
Parameters
Type | Name | Description |
---|---|---|
ExtraDamageTypes | extraDamageTypes |
Returns
Type | Description |
---|---|
int |
HasModifier<T>()
Has a health modifier of the specific type been added?
Declaration
public bool HasModifier<T>()
Returns
Type | Description |
---|---|
bool | Returns whether the modifier has been added |
Type Parameters
Name | Description |
---|---|
T | The type of health modifier to check for |
HasModifier<T>(out T)
Has a health modifier of the specific type been added?
Declaration
public bool HasModifier<T>(out T modifier) where T : IHealthModifier
Parameters
Type | Name | Description |
---|---|---|
T | modifier | If the modifier has been added, this will be a reference to the modifier that is added |
Returns
Type | Description |
---|---|
bool | Returns whether the modifier has been added |
Type Parameters
Name | Description |
---|---|
T | The type of health modifier to check for |
Hit(HitInfo)
Hits the target. Returns true if the hit was valid and damage to the enemy was dealt
Declaration
public virtual bool Hit(HitInfo hit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | hit | The hit on the enemy |
Returns
Type | Description |
---|---|
bool | Returns whether the hit was a valid hit or not |
IsValidHit(HitInfo)
Checks if a hit on this enemy is valid
Declaration
public EntityHealth.HitResult IsValidHit(HitInfo hit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | hit | The hit to check for |
Returns
Type | Description |
---|---|
EntityHealth.HitResult | Returns whether this hit is valid |
NormalHit(HitInfo)
Declaration
protected virtual void NormalHit(HitInfo hit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | hit |
OnDeath(HitInfo)
Triggered when the entity dies
Declaration
protected virtual void OnDeath(HitInfo finalHit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | finalHit | The final hit on the entity |
OnPool()
Called when the object is sent back to a pool
Declaration
public virtual void OnPool()
PlayHitEffects(HitInfo, Player)
Declaration
public void PlayHitEffects(HitInfo hit, Player player = null)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | hit | |
Player | player |
PlayInvincibleHitEffects(HitInfo)
Declaration
public void PlayInvincibleHitEffects(HitInfo hit)
Parameters
Type | Name | Description |
---|---|---|
HitInfo | hit |
RemoveModifier(IHealthModifier)
Removes a health modifier
Declaration
public bool RemoveModifier(IHealthModifier modifier)
Parameters
Type | Name | Description |
---|---|---|
IHealthModifier | modifier | The modifier to be removed |
Returns
Type | Description |
---|---|
bool | Returns true if the modifier has been successfully removed |
RemoveModifier<T>()
Removes a modifier of the specified type
Declaration
public bool RemoveModifier<T>() where T : IHealthModifier
Returns
Type | Description |
---|---|
bool | Returns true if the modifier has been successfully removed |
Type Parameters
Name | Description |
---|---|
T | The type of modifier to be removed |
SetHealthRaw(int)
Sets the new health without triggering any IHealthModifiers, events, or milestones
Declaration
public void SetHealthRaw(int newHealth)
Parameters
Type | Name | Description |
---|---|---|
int | newHealth | The new health value to set |
Update()
Declaration
protected virtual void Update()
Events
| Edit this page View SourceOnDeathEvent
Called when the entity's health reaches zero
Declaration
public event Action<HitInfo> OnDeathEvent
Event Type
Type | Description |
---|---|
Action<HitInfo> |
OnHealthChangeEvent
Called when the entity's health has been modified
Declaration
public event EntityHealth.HealthChangeDelegate OnHealthChangeEvent
Event Type
Type | Description |
---|---|
EntityHealth.HealthChangeDelegate |