void OnDestroy() { dead = true; if (onDeath != null) { onDeath.Invoke(gameObject); } if (gameEventChannel != null) { gameEventChannel.Raise(GameRecord.BotDied(gameObject, null)); } }
void OnTakeDamage(GameObject from, int amount) { onChange.Invoke(health); onChangePercent.Invoke(healthPercent); if (healthPercent <= 0 && !dead) { onDeath.Invoke(gameObject); dead = true; if (gameEventChannel != null) { gameEventChannel.Raise(GameRecord.BotDied(gameObject, from)); } } // notify channel if (gameEventChannel != null) { gameEventChannel.Raise(GameRecord.BotTookDamage(gameObject, from, amount)); } }