|
Corgi Engine v9.4
|
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 | OnHitZeroDelegate () |
| delegate void | OnReviveDelegate () |
| delegate void | OnDeathDelegate () |
| virtual void | InitializeCurrentHealth () |
| Initializes health to either initial or current values. | |
| virtual void | StoreInitialPosition () |
| 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 | DamageZero () |
| Doesn't apply damage, but triggers OnHitZero. | |
| virtual void | Kill () |
| Kills the character, instantiates death effects, handles points, etc. | |
| virtual void | Revive () |
| Revive this object. | |
| 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 Vector2 | ComputeKnockbackForce (Vector2 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 | GetHealth (float health, GameObject instigator) |
| Called when the character gets health (from a stimpack for example) | |
| virtual void | SetHealth (float newHealth, GameObject instigator) |
| Sets the health of the character to the one specified in parameters. | |
| virtual void | ResetHealthToMaxHealth () |
| Resets the character's health to its max value. | |
| virtual void | UpdateHealthBar (bool show) |
| Updates the character's health bar progress. | |
| virtual void | DamageDisabled () |
| Prevents the character from taking any damage. | |
| virtual void | DamageEnabled () |
| Allows the character to take damage. | |
| virtual void | EnablePostDamageInvulnerability () |
| Prevents the character from taking any damage. | |
| virtual void | DisablePostDamageInvulnerability () |
| Allows the character to take damage. | |
| virtual IEnumerator | DisablePostDamageInvulnerability (float delay) |
| Allows the character to take damage. | |
| virtual IEnumerator | DamageEnabled (float delay) |
| makes the character able to take damage again after the specified delay | |
| void | OnMMEvent (HealthDeathEvent deathEvent) |
| Public Member Functions inherited from MoreMountains.Tools.MMEventListener< T > | |
| void | OnMMEvent (T eventType) |
Public Attributes | |
| float | CurrentHealth |
| the current health of the character | |
| bool | TemporarilyInvulnerable = false |
| If this is true, this object can't take damage at the moment. | |
| bool | PostDamageInvulnerable = false |
| If this is true, this object is in post damage invulnerability state. | |
| float | InitialHealth = 10 |
| the initial amount of health of the object | |
| float | MaximumHealth = 10 |
| the maximum amount of health of the object | |
| bool | Invulnerable = false |
| if this is true, this object can't take damage | |
| bool | ResetHealthOnEnable = true |
| if this is true, health will be reset automatically on enable (after a respawn for instance). You may want to turn this off when using a SwitchManager for example. | |
| bool | ImmuneToDamage = false |
| whether or not this Health object can be damaged, you can play with this on top of Invulnerable, which will be turned on/off temporarily for temporary invulnerability. ImmuneToDamage is more of a permanent solution. | |
| MMFeedbacks | DamageFeedbacks |
| the MMFeedbacks to play when the character gets hit | |
| bool | TriggerDamageFeedbackOnDeath = true |
| if this is true, the DamageFeedback will play, whether this is a fatal hit or not | |
| 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 | FlickerSpriteOnHit = true |
| should the sprite (if there's one) flicker when getting damage ? | |
| Color | FlickerColor = new Color32(255, 20, 20, 255) |
| the color the sprite should flicker to | |
| bool | ImmuneToKnockback = false |
| whether or not this object can get knockback | |
| bool | ImmuneToKnockbackIfZeroDamage = false |
| whether or not this object is immune to damage knockback if the damage received is zero | |
| MMFeedbacks | DeathFeedbacks |
| the MMFeedbacks to play when the character dies | |
| bool | DestroyOnDeath = true |
| if this is not true, the object will remain there after its death | |
| float | DelayBeforeDestruction = 0f |
| the time (in seconds) before the character is destroyed or disabled | |
| bool | CollisionsOffOnDeath = true |
| if this is true, collisions will be turned off when the character dies | |
| bool | GravityOffOnDeath = false |
| if this is true, gravity will be turned off on death | |
| 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 | ApplyDeathForce = true |
| whether or not to apply a force on death | |
| Vector2 | DeathForce = new Vector2(0, 10) |
| the force applied when the character dies | |
| bool | ResetForcesOnDeath = false |
| whether or not the controller's forces should be set to 0 on death | |
| 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. | |
| Character | AssociatedCharacter |
| the Character this Health should impact, if left empty, will pick one on the same game object | |
| Health | MasterHealth |
| another Health component (usually on another character) towards which all health will be redirected | |
| bool | OnlyDamageMaster = true |
| if this is true, when using a MasterHealth, this Health won't take damage, and all damage will be redirected. If this is false, this Health will be able to die when its own Health is consumed | |
| bool | KillOnMasterHealthDeath = false |
| if this is true, when using a MasterHealth, if the MasterHealth dies, this Health will also die | |
| DamageResistanceProcessor | TargetDamageResistanceProcessor |
| a DamageResistanceProcessor this Health will use to process damage when it's received | |
| OnDeathDelegate | OnDeath |
| OnHitDelegate | OnHit |
| OnHitZeroDelegate | OnHitZero |
| OnReviveDelegate | OnRevive |
Protected Member Functions | |
| virtual void | Start () |
| On Awake, we initialize our health. | |
| virtual void | Initialization () |
| Grabs useful components, enables damage and gets the inital color. | |
| virtual void | InitializeSpriteColor () |
| Stores the inital color of the Character's sprite. | |
| virtual void | ResetSpriteColor () |
| Restores the original sprite color. | |
| virtual void | DestroyObject () |
| Destroys the object, or tries to, depending on the character's settings. | |
| 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 | OnEnable () |
| When the object is enabled (on respawn for example), we restore its initial health levels. | |
| virtual void | OnDisable () |
| Cancels all running invokes on disable. | |
Protected Attributes | |
| CharacterHorizontalMovement | _characterHorizontalMovement |
| Vector3 | _initialPosition |
| Color | _initialColor |
| Renderer | _renderer |
| Character | _character |
| CorgiController | _controller |
| ProximityManaged | _proximityManaged |
| MMHealthBar | _healthBar |
| Collider2D | _collider2D |
| bool | _initialized = false |
| AutoRespawn | _autoRespawn |
| Animator | _animator |
| CharacterPersistence | _characterPersistence = null |
| MaterialPropertyBlock | _propertyBlock |
| bool | _hasColorProperty = false |
| GameObject | _thisObject |
| List< InterruptiblesDamageOverTimeCoroutine > | _interruptiblesDamageOverTimeCoroutines |
| List< InterruptiblesDamageOverTimeCoroutine > | _damageOverTimeCoroutines |
Properties | |
| float | LastDamage [get, set] |
| Vector3 | LastDamageDirection [get, set] |
| bool | Initialized [get] |
| CorgiController | AssociatedController [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.
|
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. |
| invincibilityDuration | The duration of the short invincibility following the hit. |
Reimplemented in MoreMountains.CorgiEngine.SuperHipsterBrosHealth.
|
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 |
|
virtual |
Doesn't apply damage, but triggers OnHitZero.
|
protectedvirtual |
Destroys the object, or tries to, depending on the character's settings.
|
virtual |
Allows the character to take damage.
|
virtual |
Allows the character to take damage.
|
virtual |
Prevents the character from taking any damage.
|
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. |
|
protectedvirtual |
Grabs useful components, enables damage and gets the inital color.
Reimplemented in MoreMountains.CorgiEngine.SuperHipsterBrosHealth.
|
virtual |
Initializes health to either initial or current values.
|
protectedvirtual |
Stores the inital color of the Character's sprite.
|
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.
Reimplemented in MoreMountains.CorgiEngine.SuperHipsterBrosHealth.
| delegate void MoreMountains.CorgiEngine.Health.OnDeathDelegate | ( | ) |
|
protectedvirtual |
Cancels all running invokes on disable.
|
protectedvirtual |
When the object is enabled (on respawn for example), we restore its initial health levels.
| delegate void MoreMountains.CorgiEngine.Health.OnHitDelegate | ( | ) |
| delegate void MoreMountains.CorgiEngine.Health.OnHitZeroDelegate | ( | ) |
| void MoreMountains.CorgiEngine.Health.OnMMEvent | ( | HealthDeathEvent | deathEvent | ) |
| delegate void MoreMountains.CorgiEngine.Health.OnReviveDelegate | ( | ) |
|
virtual |
Resets the character's health to its max value.
|
protectedvirtual |
Restores the original sprite color.
|
virtual |
Revive this object.
|
virtual |
Sets the health of the character to the one specified in parameters.
| newHealth | |
| instigator |
|
protectedvirtual |
On Awake, we initialize our health.
|
virtual |
Interrupts all damage over time, even the non interruptible ones (usually on death)
|
virtual |
|
virtual |
Updates the character's health bar progress.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
| bool MoreMountains.CorgiEngine.Health.ApplyDeathForce = true |
whether or not to apply a force on death
| Character MoreMountains.CorgiEngine.Health.AssociatedCharacter |
| bool MoreMountains.CorgiEngine.Health.CollisionsOffOnDeath = true |
if this is true, collisions will be turned off when the character dies
| string MoreMountains.CorgiEngine.Health.ColorMaterialPropertyName = "_Color" |
the name of the property on your renderer's shader that defines its color
| float MoreMountains.CorgiEngine.Health.CurrentHealth |
the current health of the character
| MMFeedbacks MoreMountains.CorgiEngine.Health.DamageFeedbacks |
the MMFeedbacks to play when the character gets hit
| MMFeedbacks MoreMountains.CorgiEngine.Health.DeathFeedbacks |
the MMFeedbacks to play when the character dies
| Vector2 MoreMountains.CorgiEngine.Health.DeathForce = new Vector2(0, 10) |
the force applied when the character dies
| float MoreMountains.CorgiEngine.Health.DelayBeforeDestruction = 0f |
the time (in seconds) before the character is destroyed or disabled
| bool MoreMountains.CorgiEngine.Health.DestroyOnDeath = true |
if this is not true, the object will remain there after its death
| bool MoreMountains.CorgiEngine.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
| Color MoreMountains.CorgiEngine.Health.FlickerColor = new Color32(255, 20, 20, 255) |
the color the sprite should flicker to
| bool MoreMountains.CorgiEngine.Health.FlickerSpriteOnHit = true |
should the sprite (if there's one) flicker when getting damage ?
| bool MoreMountains.CorgiEngine.Health.GravityOffOnDeath = false |
if this is true, gravity will be turned off on death
| bool MoreMountains.CorgiEngine.Health.ImmuneToDamage = false |
whether or not this Health object can be damaged, you can play with this on top of Invulnerable, which will be turned on/off temporarily for temporary invulnerability. ImmuneToDamage is more of a permanent solution.
| bool MoreMountains.CorgiEngine.Health.ImmuneToKnockback = false |
whether or not this object can get knockback
| bool MoreMountains.CorgiEngine.Health.ImmuneToKnockbackIfZeroDamage = false |
whether or not this object is immune to damage knockback if the damage received is zero
| float MoreMountains.CorgiEngine.Health.InitialHealth = 10 |
the initial amount of health of the object
| bool MoreMountains.CorgiEngine.Health.Invulnerable = false |
if this is true, this object can't take damage
| bool MoreMountains.CorgiEngine.Health.KillOnMasterHealthDeath = false |
if this is true, when using a MasterHealth, if the MasterHealth dies, this Health will also die
| Health MoreMountains.CorgiEngine.Health.MasterHealth |
another Health component (usually on another character) towards which all health will be redirected
| float MoreMountains.CorgiEngine.Health.MaximumHealth = 10 |
the maximum amount of health of the object
| OnDeathDelegate MoreMountains.CorgiEngine.Health.OnDeath |
| OnHitDelegate MoreMountains.CorgiEngine.Health.OnHit |
| OnHitZeroDelegate MoreMountains.CorgiEngine.Health.OnHitZero |
| bool MoreMountains.CorgiEngine.Health.OnlyDamageMaster = true |
| OnReviveDelegate MoreMountains.CorgiEngine.Health.OnRevive |
| int MoreMountains.CorgiEngine.Health.PointsWhenDestroyed |
the points the player gets when the object's health reaches zero
| bool MoreMountains.CorgiEngine.Health.PostDamageInvulnerable = false |
If this is true, this object is in post damage invulnerability state.
| bool MoreMountains.CorgiEngine.Health.ResetColorOnRevive = true |
if this is true, color will be reset on revive
| bool MoreMountains.CorgiEngine.Health.ResetForcesOnDeath = false |
whether or not the controller's forces should be set to 0 on death
| bool MoreMountains.CorgiEngine.Health.ResetHealthOnEnable = true |
if this is true, health will be reset automatically on enable (after a respawn for instance). You may want to turn this off when using a SwitchManager for example.
| bool MoreMountains.CorgiEngine.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)
| DamageResistanceProcessor MoreMountains.CorgiEngine.Health.TargetDamageResistanceProcessor |
a DamageResistanceProcessor this Health will use to process damage when it's received
| bool MoreMountains.CorgiEngine.Health.TemporarilyInvulnerable = false |
If this is true, this object can't take damage at the moment.
| bool MoreMountains.CorgiEngine.Health.TriggerDamageFeedbackOnDeath = true |
if this is true, the DamageFeedback will play, whether this is a fatal hit or not
| bool MoreMountains.CorgiEngine.Health.UseMaterialPropertyBlocks = false |
if this is true, this component will use material property blocks instead of working on an instance of the material.
|
get |
|
get |
|
getset |
|
getset |