public void ApplyDamage(int amount) { if (amount < _damageResistance) { return; } else { amount -= _damageResistance; } if (!_isTakingDamage && amount > 0) { ApplyDeduct(amount); if (Health.IsAlive) { OnDamage(); OnActorDamaged.Raise(this); _isTakingDamage = true; Timekeeper.SetTimer(_damageInvulnerabilityDuration, () => _isTakingDamage = false); } } }
// Scene is completely active 1 from after the callback, so we will have our callback fire 1 frame after theirs private static void OnActiveSceneChangedCallback(Scene scene, LoadSceneMode mode) { SceneManager.sceneLoaded -= OnActiveSceneChangedCallback; Timekeeper.SetTimer(1, OnSceneIsReady.Raise); }
private void StartCooldown() => Timekeeper.SetTimer(_cooldown, () => _canFire = true);