Corgi Engine
v9.1
|
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 More... | |
virtual void | StoreInitialPosition () |
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 | Kill () |
Kills the character, instantiates death effects, handles points, etc More... | |
virtual void | Revive () |
Revive this object. 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 Vector2 | ComputeKnockbackForce (Vector2 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 | GetHealth (float health, GameObject instigator) |
Called when the character gets health (from a stimpack for example) More... | |
virtual void | SetHealth (float newHealth, GameObject instigator) |
Sets the health of the character to the one specified in parameters More... | |
virtual void | ResetHealthToMaxHealth () |
Resets the character's health to its max value More... | |
virtual void | UpdateHealthBar (bool show) |
Updates the character's health bar progress. More... | |
virtual void | DamageDisabled () |
Prevents the character from taking any damage More... | |
virtual void | DamageEnabled () |
Allows the character to take damage More... | |
virtual void | EnablePostDamageInvulnerability () |
Prevents the character from taking any damage More... | |
virtual void | DisablePostDamageInvulnerability () |
Allows the character to take damage More... | |
virtual IEnumerator | DisablePostDamageInvulnerability (float delay) |
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... | |
void | OnMMEvent (HealthDeathEvent deathEvent) |
Public Member Functions inherited from MoreMountains.Tools.MMEventListener< HealthDeathEvent > | |
void | OnMMEvent (T eventType) |
Public Attributes | |
float | CurrentHealth |
the current health of the character More... | |
bool | TemporarilyInvulnerable = false |
If this is true, this object can't take damage at the moment. More... | |
bool | PostDamageInvulnerable = false |
If this is true, this object is in post damage invulnerability state. 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 | Invulnerable = false |
if this is true, this object can't take damage More... | |
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. More... | |
MMFeedbacks | DamageFeedbacks |
the MMFeedbacks to play when the character gets hit 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 | FlickerSpriteOnHit = true |
should the sprite (if there's one) flicker when getting damage ? More... | |
Color | FlickerColor = new Color32(255, 20, 20, 255) |
the color the sprite should flicker to More... | |
bool | ImmuneToKnockback = false |
whether or not this object can get knockback More... | |
bool | ImmuneToKnockbackIfZeroDamage = false |
whether or not this object is immune to damage knockback if the damage received is zero More... | |
MMFeedbacks | DeathFeedbacks |
the MMFeedbacks to play when the character dies More... | |
bool | DestroyOnDeath = true |
if this is not true, the object will remain there after its death More... | |
float | DelayBeforeDestruction = 0f |
the time (in seconds) before the character is destroyed or disabled More... | |
bool | CollisionsOffOnDeath = true |
if this is true, collisions will be turned off when the character dies More... | |
bool | GravityOffOnDeath = false |
if this is true, gravity will be turned off on death 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 | ApplyDeathForce = true |
whether or not to apply a force on death More... | |
Vector2 | DeathForce = new Vector2(0, 10) |
the force applied when the character dies More... | |
bool | ResetForcesOnDeath = false |
whether or not the controller's forces should be set to 0 on death 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... | |
Character | AssociatedCharacter |
the Character this Health should impact, if left empty, will pick one on the same game object More... | |
Health | MasterHealth |
another Health component (usually on another character) towards which all health will be redirected More... | |
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 More... | |
bool | KillOnMasterHealthDeath = false |
if this is true, when using a MasterHealth, if the MasterHealth dies, this Health will also die More... | |
DamageResistanceProcessor | TargetDamageResistanceProcessor |
a DamageResistanceProcessor this Health will use to process damage when it's received More... | |
bool | Initialized => _initialized |
CorgiController | AssociatedController => _controller |
OnDeathDelegate | OnDeath |
OnHitDelegate | OnHit |
OnHitZeroDelegate | OnHitZero |
OnReviveDelegate | OnRevive |
Protected Member Functions | |
virtual void | Start () |
On Awake, we initialize our health More... | |
virtual void | Initialization () |
Grabs useful components, enables damage and gets the inital color More... | |
virtual void | InitializeSpriteColor () |
Stores the inital color of the Character's sprite. More... | |
virtual void | ResetSpriteColor () |
Restores the original sprite color More... | |
virtual void | DestroyObject () |
Destroys the object, or tries to, depending on the character's settings 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 | OnEnable () |
When the object is enabled (on respawn for example), we restore its initial health levels More... | |
virtual void | OnDisable () |
Cancels all running invokes on disable More... | |
Protected Attributes | |
CharacterHorizontalMovement | _characterHorizontalMovement |
Vector3 | _initialPosition |
Color | _initialColor |
Renderer | _renderer |
Character | _character |
CorgiController | _controller |
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] |
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 |
|
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 |
bool MoreMountains.CorgiEngine.Health.ApplyDeathForce = true |
whether or not to apply a force on death
Character MoreMountains.CorgiEngine.Health.AssociatedCharacter |
CorgiController MoreMountains.CorgiEngine.Health.AssociatedController => _controller |
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.Initialized => _initialized |
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.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.UseMaterialPropertyBlocks = false |
if this is true, this component will use material property blocks instead of working on an instance of the material.
|
getset |
|
getset |