TopDown Engine
v4.2
|
This class manages the health of an object, pilots its potential health bar, handles what happens when it takes damage, and what happens when it dies. More...
Classes | |
class | InterruptiblesDamageOverTimeCoroutine |
Public Member Functions | |
delegate void | OnHitDelegate () |
delegate void | OnReviveDelegate () |
delegate void | OnDeathDelegate () |
virtual void | Initialization () |
Grabs useful components, enables damage and gets the inital color More... | |
virtual void | StoreInitialPosition () |
Stores the initial position for further use More... | |
virtual void | InitializeCurrentHealth () |
Initializes health to either initial or current values More... | |
virtual bool | CanTakeDamageThisFrame () |
Returns true if this Health component can be damaged this frame, and false otherwise More... | |
virtual void | Damage (float damage, GameObject instigator, float flickerDuration, float invincibilityDuration, Vector3 damageDirection, List< TypedDamage > typedDamages=null) |
Called when the object takes damage More... | |
virtual void | InterruptAllDamageOverTime () |
Interrupts all damage over time, regardless of type More... | |
virtual void | StopAllDamageOverTime () |
Interrupts all damage over time, even the non interruptible ones (usually on death) More... | |
virtual void | InterruptAllDamageOverTimeOfType (DamageType damageType) |
Interrupts all damage over time of the specified type More... | |
virtual void | DamageOverTime (float damage, GameObject instigator, float flickerDuration, float invincibilityDuration, Vector3 damageDirection, List< TypedDamage > typedDamages=null, int amountOfRepeats=0, float durationBetweenRepeats=1f, bool interruptible=true, DamageType damageType=null) |
Applies damage over time, for the specified amount of repeats (which includes the first application of damage, makes it easier to do quick maths in the inspector, and at the specified interval). Optionally you can decide that your damage is interruptible, in which case, calling InterruptAllDamageOverTime() will stop these from being applied, useful to cure poison for example. More... | |
virtual float | ComputeDamageOutput (float damage, List< TypedDamage > typedDamages=null, bool damageApplied=false) |
Returns the damage this health should take after processing potential resistances More... | |
virtual Vector3 | ComputeKnockbackForce (Vector3 knockbackForce, List< TypedDamage > typedDamages=null) |
Determines a new knockback force by processing it through resistances More... | |
virtual bool | CanGetKnockback (List< TypedDamage > typedDamages) |
Returns true if this Health can get knockbacked, false otherwise More... | |
virtual void | Kill () |
Kills the character, instantiates death effects, handles points, etc More... | |
virtual void | Revive () |
Revive this object. More... | |
virtual void | SetHealth (float newValue) |
Sets the current health to the specified new value, and updates the health bar More... | |
virtual void | ReceiveHealth (float health, GameObject instigator) |
Called when the character gets health (from a stimpack for example) More... | |
virtual void | ResetHealthToMaxHealth () |
Resets the character's health to its max value More... | |
virtual void | UpdateHealthBar (bool show) |
Forces a refresh of the character's health bar More... | |
virtual void | DamageDisabled () |
Prevents the character from taking any damage More... | |
virtual void | DamageEnabled () |
Allows the character to take damage More... | |
virtual IEnumerator | DamageEnabled (float delay) |
makes the character able to take damage again after the specified delay More... | |
Public Attributes | |
GameObject | Model |
the model to disable (if set so) More... | |
float | CurrentHealth |
the current health of the character More... | |
bool | Invulnerable = false |
If this is true, this object can't take damage at this time. More... | |
float | InitialHealth = 10 |
the initial amount of health of the object More... | |
float | MaximumHealth = 10 |
the maximum amount of health of the object More... | |
bool | ResetHealthOnEnable = true |
if this is true, health values will be reset everytime this character is enabled (usually at the start of a scene) More... | |
bool | ImmuneToDamage = false |
whether or not this Health object can be damaged More... | |
MMFeedbacks | DamageMMFeedbacks |
the feedback to play when getting damage More... | |
bool | FeedbackIsProportionalToDamage = false |
if this is true, the damage value will be passed to the MMFeedbacks as its Intensity parameter, letting you trigger more intense feedbacks as damage increases More... | |
bool | PreventTakeSelfDamage = false |
if you set this to true, other objects damaging this one won't take any self damage More... | |
bool | ImmuneToKnockback = false |
whether or not this object is immune to damage knockback More... | |
bool | ImmuneToKnockbackIfZeroDamage = false |
whether or not this object is immune to damage knockback if the damage received is zero More... | |
float | KnockbackForceMultiplier = 1f |
a multiplier applied to the incoming knockback forces. 0 will cancel all knockback, 0.5 will cut it in half, 1 will have no effect, 2 will double the knockback force, etc More... | |
bool | DestroyOnDeath = true |
whether or not this object should get destroyed on death More... | |
float | DelayBeforeDestruction = 0f |
the time (in seconds) before the character is destroyed or disabled More... | |
int | PointsWhenDestroyed |
the points the player gets when the object's health reaches zero More... | |
bool | RespawnAtInitialLocation = false |
if this is set to false, the character will respawn at the location of its death, otherwise it'll be moved to its initial position (when the scene started) More... | |
bool | DisableControllerOnDeath = true |
if this is true, the controller will be disabled on death More... | |
bool | DisableModelOnDeath = true |
if this is true, the model will be disabled instantly on death (if a model has been set) More... | |
bool | DisableCollisionsOnDeath = true |
if this is true, collisions will be turned off when the character dies More... | |
bool | DisableChildCollisionsOnDeath = false |
if this is true, collisions will also be turned off on child colliders when the character dies More... | |
bool | ChangeLayerOnDeath = false |
whether or not this object should change layer on death More... | |
bool | ChangeLayersRecursivelyOnDeath = false |
whether or not this object should change layer on death More... | |
MMLayer | LayerOnDeath |
the layer we should move this character to on death More... | |
MMFeedbacks | DeathMMFeedbacks |
the feedback to play when dying More... | |
bool | ResetColorOnRevive = true |
if this is true, color will be reset on revive More... | |
string | ColorMaterialPropertyName = "_Color" |
the name of the property on your renderer's shader that defines its color More... | |
bool | UseMaterialPropertyBlocks = false |
if this is true, this component will use material property blocks instead of working on an instance of the material. More... | |
Health | MasterHealth |
another Health component (usually on another character) towards which all health will be redirected More... | |
DamageResistanceProcessor | TargetDamageResistanceProcessor |
a DamageResistanceProcessor this Health will use to process damage when it's received More... | |
Animator | TargetAnimator |
the target animator to pass a Death animation parameter to. The Health component will try to auto bind this if left empty More... | |
bool | DisableAnimatorLogs = true |
if this is true, animator logs for the associated animator will be turned off to avoid potential spam More... | |
virtual bool | Initialized => _initialized |
OnHitDelegate | OnHit |
OnReviveDelegate | OnRevive |
OnDeathDelegate | OnDeath |
Protected Member Functions | |
virtual void | Awake () |
On Awake, we initialize our health More... | |
virtual void | Start () |
On Start we grab our animator More... | |
virtual void | GrabAnimator () |
Grabs the target animator More... | |
virtual void | BindAnimator () |
Finds and binds an animator if possible More... | |
virtual void | OnEnable () |
When the object is enabled (on respawn for example), we restore its initial health levels More... | |
virtual void | OnDisable () |
On Disable, we prevent any delayed destruction from running More... | |
virtual IEnumerator | DamageOverTimeCo (float damage, GameObject instigator, float flickerDuration, float invincibilityDuration, Vector3 damageDirection, List< TypedDamage > typedDamages=null, int amountOfRepeats=0, float durationBetweenRepeats=1f, bool interruptible=true, DamageType damageType=null) |
A coroutine used to apply damage over time More... | |
virtual void | ComputeCharacterConditionStateChanges (List< TypedDamage > typedDamages) |
Goes through resistances and applies condition state changes if needed More... | |
virtual void | ComputeCharacterMovementMultipliers (List< TypedDamage > typedDamages) |
Goes through the resistance list and applies movement multipliers if needed More... | |
virtual void | DestroyObject () |
Destroys the object, or tries to, depending on the character's settings More... | |
virtual void | UpdateHealthAnimationParameters () |
Protected Attributes | |
Vector3 | _initialPosition |
Renderer | _renderer |
Character | _character |
CharacterMovement | _characterMovement |
TopDownController | _controller |
MMHealthBar | _healthBar |
Collider2D | _collider2D |
Collider | _collider3D |
CharacterController | _characterController |
bool | _initialized = false |
Color | _initialColor |
AutoRespawn | _autoRespawn |
int | _initialLayer |
MaterialPropertyBlock | _propertyBlock |
bool | _hasColorProperty = false |
ProximityManaged | _proximityManaged |
int | _deathAnimatorParameter |
int | _healthAnimatorParameter |
int | _healthAsIntAnimatorParameter |
bool | _hasDeathParameter = false |
bool | _hasHealthParameter = false |
bool | _hasHealthAsIntParameter = false |
List< InterruptiblesDamageOverTimeCoroutine > | _interruptiblesDamageOverTimeCoroutines |
List< InterruptiblesDamageOverTimeCoroutine > | _damageOverTimeCoroutines |
Static Protected Attributes | |
const string | _deathAnimatorParameterName = "Death" |
const string | _healthAnimatorParameterName = "Health" |
const string | _healthAsIntAnimatorParameterName = "HealthAsInt" |
Properties | |
virtual float | LastDamage [get, set] |
virtual Vector3 | LastDamageDirection [get, set] |
This class manages the health of an object, pilots its potential health bar, handles what happens when it takes damage, and what happens when it dies.
|
protectedvirtual |
On Awake, we initialize our health
|
protectedvirtual |
Finds and binds an animator if possible
|
virtual |
|
virtual |
Returns true if this Health component can be damaged this frame, and false otherwise
|
protectedvirtual |
Goes through resistances and applies condition state changes if needed
typedDamages |
|
protectedvirtual |
Goes through the resistance list and applies movement multipliers if needed
typedDamages |
|
virtual |
Returns the damage this health should take after processing potential resistances
damage |
|
virtual |
Determines a new knockback force by processing it through resistances
knockbackForce | |
typedDamages |
|
virtual |
Called when the object takes damage
damage | The amount of health points that will get lost. |
instigator | The object that caused the damage. |
flickerDuration | The time (in seconds) the object should flicker after taking the damage - not used anymore, kept to not break retrocompatibility |
invincibilityDuration | The duration of the short invincibility following the hit. |
|
virtual |
Prevents the character from taking any damage
|
virtual |
Allows the character to take damage
|
virtual |
makes the character able to take damage again after the specified delay
|
virtual |
Applies damage over time, for the specified amount of repeats (which includes the first application of damage, makes it easier to do quick maths in the inspector, and at the specified interval). Optionally you can decide that your damage is interruptible, in which case, calling InterruptAllDamageOverTime() will stop these from being applied, useful to cure poison for example.
damage | |
instigator | |
flickerDuration | |
invincibilityDuration | |
damageDirection | |
typedDamages | |
amountOfRepeats | |
durationBetweenRepeats | |
interruptible |
|
protectedvirtual |
A coroutine used to apply damage over time
damage | |
instigator | |
flickerDuration | |
invincibilityDuration | |
damageDirection | |
typedDamages | |
amountOfRepeats | |
durationBetweenRepeats | |
interruptible | |
damageType |
|
protectedvirtual |
Destroys the object, or tries to, depending on the character's settings
|
protectedvirtual |
Grabs the target animator
|
virtual |
Grabs useful components, enables damage and gets the inital color
|
virtual |
Initializes health to either initial or current values
|
virtual |
Interrupts all damage over time, regardless of type
|
virtual |
Interrupts all damage over time of the specified type
damageType |
|
virtual |
Kills the character, instantiates death effects, handles points, etc
delegate void MoreMountains.TopDownEngine.Health.OnDeathDelegate | ( | ) |
|
protectedvirtual |
On Disable, we prevent any delayed destruction from running
|
protectedvirtual |
When the object is enabled (on respawn for example), we restore its initial health levels
delegate void MoreMountains.TopDownEngine.Health.OnHitDelegate | ( | ) |
delegate void MoreMountains.TopDownEngine.Health.OnReviveDelegate | ( | ) |
|
virtual |
Called when the character gets health (from a stimpack for example)
health | The health the character gets. |
instigator | The thing that gives the character health. |
|
virtual |
Resets the character's health to its max value
|
virtual |
Revive this object.
|
virtual |
Sets the current health to the specified new value, and updates the health bar
newValue |
|
protectedvirtual |
On Start we grab our animator
|
virtual |
Interrupts all damage over time, even the non interruptible ones (usually on death)
|
virtual |
Stores the initial position for further use
|
protectedvirtual |
|
virtual |
Forces a refresh of the character's health bar
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
protected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool MoreMountains.TopDownEngine.Health.ChangeLayerOnDeath = false |
whether or not this object should change layer on death
bool MoreMountains.TopDownEngine.Health.ChangeLayersRecursivelyOnDeath = false |
whether or not this object should change layer on death
string MoreMountains.TopDownEngine.Health.ColorMaterialPropertyName = "_Color" |
the name of the property on your renderer's shader that defines its color
float MoreMountains.TopDownEngine.Health.CurrentHealth |
the current health of the character
MMFeedbacks MoreMountains.TopDownEngine.Health.DamageMMFeedbacks |
the feedback to play when getting damage
MMFeedbacks MoreMountains.TopDownEngine.Health.DeathMMFeedbacks |
the feedback to play when dying
float MoreMountains.TopDownEngine.Health.DelayBeforeDestruction = 0f |
the time (in seconds) before the character is destroyed or disabled
bool MoreMountains.TopDownEngine.Health.DestroyOnDeath = true |
whether or not this object should get destroyed on death
bool MoreMountains.TopDownEngine.Health.DisableAnimatorLogs = true |
if this is true, animator logs for the associated animator will be turned off to avoid potential spam
bool MoreMountains.TopDownEngine.Health.DisableChildCollisionsOnDeath = false |
if this is true, collisions will also be turned off on child colliders when the character dies
bool MoreMountains.TopDownEngine.Health.DisableCollisionsOnDeath = true |
if this is true, collisions will be turned off when the character dies
bool MoreMountains.TopDownEngine.Health.DisableControllerOnDeath = true |
if this is true, the controller will be disabled on death
bool MoreMountains.TopDownEngine.Health.DisableModelOnDeath = true |
if this is true, the model will be disabled instantly on death (if a model has been set)
bool MoreMountains.TopDownEngine.Health.FeedbackIsProportionalToDamage = false |
if this is true, the damage value will be passed to the MMFeedbacks as its Intensity parameter, letting you trigger more intense feedbacks as damage increases
bool MoreMountains.TopDownEngine.Health.ImmuneToDamage = false |
whether or not this Health object can be damaged
bool MoreMountains.TopDownEngine.Health.ImmuneToKnockback = false |
whether or not this object is immune to damage knockback
bool MoreMountains.TopDownEngine.Health.ImmuneToKnockbackIfZeroDamage = false |
whether or not this object is immune to damage knockback if the damage received is zero
float MoreMountains.TopDownEngine.Health.InitialHealth = 10 |
the initial amount of health of the object
virtual bool MoreMountains.TopDownEngine.Health.Initialized => _initialized |
bool MoreMountains.TopDownEngine.Health.Invulnerable = false |
If this is true, this object can't take damage at this time.
float MoreMountains.TopDownEngine.Health.KnockbackForceMultiplier = 1f |
a multiplier applied to the incoming knockback forces. 0 will cancel all knockback, 0.5 will cut it in half, 1 will have no effect, 2 will double the knockback force, etc
MMLayer MoreMountains.TopDownEngine.Health.LayerOnDeath |
the layer we should move this character to on death
Health MoreMountains.TopDownEngine.Health.MasterHealth |
another Health component (usually on another character) towards which all health will be redirected
float MoreMountains.TopDownEngine.Health.MaximumHealth = 10 |
the maximum amount of health of the object
GameObject MoreMountains.TopDownEngine.Health.Model |
the model to disable (if set so)
OnDeathDelegate MoreMountains.TopDownEngine.Health.OnDeath |
OnHitDelegate MoreMountains.TopDownEngine.Health.OnHit |
OnReviveDelegate MoreMountains.TopDownEngine.Health.OnRevive |
int MoreMountains.TopDownEngine.Health.PointsWhenDestroyed |
the points the player gets when the object's health reaches zero
bool MoreMountains.TopDownEngine.Health.PreventTakeSelfDamage = false |
if you set this to true, other objects damaging this one won't take any self damage
bool MoreMountains.TopDownEngine.Health.ResetColorOnRevive = true |
if this is true, color will be reset on revive
bool MoreMountains.TopDownEngine.Health.ResetHealthOnEnable = true |
if this is true, health values will be reset everytime this character is enabled (usually at the start of a scene)
bool MoreMountains.TopDownEngine.Health.RespawnAtInitialLocation = false |
if this is set to false, the character will respawn at the location of its death, otherwise it'll be moved to its initial position (when the scene started)
Animator MoreMountains.TopDownEngine.Health.TargetAnimator |
the target animator to pass a Death animation parameter to. The Health component will try to auto bind this if left empty
DamageResistanceProcessor MoreMountains.TopDownEngine.Health.TargetDamageResistanceProcessor |
a DamageResistanceProcessor this Health will use to process damage when it's received
bool MoreMountains.TopDownEngine.Health.UseMaterialPropertyBlocks = false |
if this is true, this component will use material property blocks instead of working on an instance of the material.
|
getset |
|
getset |