|
TopDown Engine v4.5
|
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. | |
| virtual void | StoreInitialPosition () |
| Stores the initial position for further use. | |
| virtual void | InitializeCurrentHealth () |
| Initializes health to either initial or current values. | |
| virtual bool | CanTakeDamageThisFrame () |
| Returns true if this Health component can be damaged this frame, and false otherwise. | |
| virtual void | Damage (float damage, GameObject instigator, float flickerDuration, float invincibilityDuration, Vector3 damageDirection, List< TypedDamage > typedDamages=null) |
| Called when the object takes damage. | |
| virtual void | InterruptAllDamageOverTime () |
| Interrupts all damage over time, regardless of type. | |
| virtual void | StopAllDamageOverTime () |
| Interrupts all damage over time, even the non interruptible ones (usually on death) | |
| virtual void | InterruptAllDamageOverTimeOfType (DamageType damageType) |
| Interrupts all damage over time of the specified type. | |
| 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. | |
| virtual float | ComputeDamageOutput (float damage, List< TypedDamage > typedDamages=null, bool damageApplied=false) |
| Returns the damage this health should take after processing potential resistances. | |
| virtual Vector3 | ComputeKnockbackForce (Vector3 knockbackForce, List< TypedDamage > typedDamages=null) |
| Determines a new knockback force by processing it through resistances. | |
| virtual bool | CanGetKnockback (List< TypedDamage > typedDamages) |
| Returns true if this Health can get knockbacked, false otherwise. | |
| virtual void | Kill () |
| Kills the character, instantiates death effects, handles points, etc. | |
| virtual void | Revive () |
| Revive this object. | |
| virtual void | SetHealth (float newValue) |
| Sets the current health to the specified new value, and updates the health bar. | |
| virtual void | ReceiveHealth (float health, GameObject instigator) |
| Called when the character gets health (from a stimpack for example) | |
| virtual void | ResetHealthToMaxHealth () |
| Resets the character's health to its max value. | |
| virtual void | UpdateHealthBar (bool show) |
| Forces a refresh of the character's health bar. | |
| virtual void | DamageDisabled () |
| Prevents the character from taking any damage. | |
| virtual void | DamageEnabled () |
| Allows the character to take damage. | |
| virtual IEnumerator | DamageEnabled (float delay) |
| makes the character able to take damage again after the specified delay | |
Public Attributes | |
| GameObject | Model |
| the model to disable (if set so) | |
| float | CurrentHealth |
| the current health of the character | |
| bool | Invulnerable = false |
| If this is true, this object can't take damage at this time. | |
| float | InitialHealth = 10 |
| the initial amount of health of the object | |
| float | MaximumHealth = 10 |
| the maximum amount of health of the object | |
| bool | ResetHealthOnEnable = true |
| if this is true, health values will be reset everytime this character is enabled (usually at the start of a scene) | |
| MMF_Player | OnHealFeedback |
| a feedback to play when health is restored | |
| bool | ImmuneToDamage = false |
| whether or not this Health object can be damaged | |
| MMFeedbacks | DamageMMFeedbacks |
| the feedback to play when getting damage | |
| 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 | |
| bool | PreventTakeSelfDamage = false |
| if you set this to true, other objects damaging this one won't take any self damage | |
| bool | ImmuneToKnockback = false |
| whether or not this object is immune to damage knockback | |
| bool | ImmuneToKnockbackIfZeroDamage = false |
| whether or not this object is immune to damage knockback if the damage received is zero | |
| 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 | |
| bool | DestroyOnDeath = true |
| whether or not this object should get destroyed on death | |
| float | DelayBeforeDestruction = 0f |
| the time (in seconds) before the character is destroyed or disabled | |
| int | PointsWhenDestroyed |
| the points the player gets when the object's health reaches zero | |
| 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) | |
| bool | DisableControllerOnDeath = true |
| if this is true, the controller will be disabled on death | |
| bool | DisableModelOnDeath = true |
| if this is true, the model will be disabled instantly on death (if a model has been set) | |
| bool | DisableCollisionsOnDeath = true |
| if this is true, collisions will be turned off when the character dies | |
| bool | DisableChildCollisionsOnDeath = false |
| if this is true, collisions will also be turned off on child colliders when the character dies | |
| bool | ChangeLayerOnDeath = false |
| whether or not this object should change layer on death | |
| bool | ChangeLayersRecursivelyOnDeath = false |
| whether or not this object should change layer on death | |
| MMLayer | LayerOnDeath |
| the layer we should move this character to on death | |
| MMFeedbacks | DeathMMFeedbacks |
| the feedback to play when dying | |
| bool | ResetColorOnRevive = true |
| if this is true, color will be reset on revive | |
| string | ColorMaterialPropertyName = "_Color" |
| the name of the property on your renderer's shader that defines its color | |
| bool | UseMaterialPropertyBlocks = false |
| if this is true, this component will use material property blocks instead of working on an instance of the material. | |
| Health | MasterHealth |
| another Health component (usually on another character) towards which all health will be redirected | |
| DamageResistanceProcessor | TargetDamageResistanceProcessor |
| a DamageResistanceProcessor this Health will use to process damage when it's received | |
| Animator | TargetAnimator |
| the target animator to pass a Death animation parameter to. The Health component will try to auto bind this if left empty | |
| bool | DisableAnimatorLogs = true |
| if this is true, animator logs for the associated animator will be turned off to avoid potential spam | |
| OnHitDelegate | OnHit |
| OnReviveDelegate | OnRevive |
| OnDeathDelegate | OnDeath |
Protected Member Functions | |
| virtual void | Awake () |
| On Awake, we initialize our health. | |
| virtual void | Start () |
| On Start we grab our animator. | |
| virtual void | GrabAnimator () |
| Grabs the target animator. | |
| virtual void | BindAnimator () |
| Finds and binds an animator if possible. | |
| virtual void | OnEnable () |
| When the object is enabled (on respawn for example), we restore its initial health levels. | |
| virtual void | OnDisable () |
| On Disable, we prevent any delayed destruction from running. | |
| 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. | |
| virtual void | ComputeCharacterConditionStateChanges (List< TypedDamage > typedDamages) |
| Goes through resistances and applies condition state changes if needed. | |
| virtual void | ComputeCharacterMovementMultipliers (List< TypedDamage > typedDamages) |
| Goes through the resistance list and applies movement multipliers if needed. | |
| virtual void | DestroyObject () |
| Destroys the object (technically only disables it, to avoid a costly runtime destruction and allow for revives), or tries to, depending on the character's settings. | |
| 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] |
| virtual bool | Initialized [get] |
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 (technically only disables it, to avoid a costly runtime destruction and allow for revives), 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
| 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 |
| MMF_Player MoreMountains.TopDownEngine.Health.OnHealFeedback |
a feedback to play when health is restored
| 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.
|
get |
|
getset |
|
getset |