protected override void OnEnd() { base.OnEnd(); //Get revival data from the item IRevivalItem revivalData = RevivalItem as IRevivalItem; if (revivalData != null && revivalData.RevivalHPRestored > 0) { RevivedEntity.HealHP(revivalData.RevivalHPRestored); //Play the idle animation RevivedEntity.AnimManager.PlayAnimation(RevivedEntity.GetIdleAnim()); //Remove the item //NOTE: For now just handle players and remove from the inventory - enemies will need to remove their held items Inventory.Instance.RemoveItem(RevivalItem); } else { Debug.LogError($"{RevivalItem.Name} does not implement {nameof(IRevivalItem)} or heals 0 or less HP, so the BattleEntity can't be revived!"); } //Clear references RevivedEntity = null; RevivalItem = null; }
protected override void OnEnd() { base.OnEnd(); //Remove the item over the BattleEntity's head if (RevivalItemShown != null) { RevivedEntity.BManager.battleUIManager.RemoveUIElement(RevivalItemShown); RevivalItemShown = null; } //Revive the BattleEntity only if it's currently in battle if (RevivedEntity.IsInBattle == true) { //Get revival data from the item IRevivalItem revivalData = RevivalItem as IRevivalItem; if (revivalData != null) { //If the revival item heals 0 or fewer HP, log a warning if (revivalData.RevivalHPRestored <= 0) { Debug.LogWarning($"{RevivalItem.Name} heals 0 or fewer HP, so {RevivedEntity.Name} won't actually be revived!"); } //Heal HP RevivedEntity.HealHP(revivalData.RevivalHPRestored); //Play the idle animation RevivedEntity.AnimManager.PlayAnimation(RevivedEntity.GetIdleAnim()); //Remove the item //For players, remove it from the inventory if (RevivedEntity.EntityType == Enumerations.EntityTypes.Player) { Inventory.Instance.RemoveItem(RevivalItem); } //It has to be an enemy, so remove its held item else { BattleEnemy revivedEnemy = (BattleEnemy)RevivedEntity; revivedEnemy.SetHeldCollectible(null); } } else { Debug.LogError($"{RevivalItem.Name} does not implement {nameof(IRevivalItem)}, so {RevivedEntity.Name} can't be revived!"); } //Failsafe; handle a dead BattleEntity in the event the RevivalItem doesn't actually revive or heal if (RevivedEntity.IsDead == true) { RevivedEntity.BManager.HandleEntityDeath(RevivedEntity); } } else { Debug.LogWarning($"{RevivedEntity.Name} isn't in battle and thus won't be revived!"); } //Clear references RevivedEntity = null; RevivalItem = null; }