1
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Items;
|
||||
using BITFALL.Player.Inventory;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using UnityEditor;
|
||||
@@ -31,32 +31,30 @@ namespace BITFALL.Entities
|
||||
private IHealth _health;
|
||||
|
||||
[Inject]
|
||||
private IPlayerInventory _inventory;
|
||||
private IEntityInventory _inventory;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
_health.OnDamage += OnDamage;
|
||||
_health.OnDamageFactory += OnDamageFactory;
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHealthPoint;
|
||||
|
||||
_inventory.OnUseItem += OnUseItem;
|
||||
_inventory.OnUsedItem += OnUseItem;
|
||||
}
|
||||
|
||||
private void OnSetHealthPoint(int obj)
|
||||
{
|
||||
if (obj > 0 && IsKnockdown && _health.IsAlive)
|
||||
{
|
||||
IsKnockdown = false;
|
||||
OnRevive?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private bool OnUseItem(IBasicItem arg)
|
||||
{
|
||||
if (IsKnockdown is false || arg.GetAssetable().TryGetProperty<PlayerReviveItem>(out var reviveItem) is false) return false;
|
||||
OnRevive?.Invoke();
|
||||
if (obj <= 0 || !IsKnockdown || !_health.IsAlive) return;
|
||||
IsKnockdown = false;
|
||||
return true;
|
||||
OnRevive?.Invoke();
|
||||
}
|
||||
private void OnUseItem(IBasicItem arg)
|
||||
{
|
||||
if (IsKnockdown is false ||
|
||||
arg.GetAssetable().TryGetProperty<PlayerReviveItem>(out var reviveItem) is false) return;
|
||||
IsKnockdown = false;
|
||||
OnRevive?.Invoke();
|
||||
|
||||
}
|
||||
|
||||
private void OnSetAlive(bool obj)
|
||||
@@ -64,7 +62,7 @@ namespace BITFALL.Entities
|
||||
IsKnockdown = false;
|
||||
}
|
||||
|
||||
private int OnDamage(DamageMessage arg,int currentDamage)
|
||||
private int OnDamageFactory(DamageMessage arg,int currentDamage)
|
||||
{
|
||||
if (IsKnockdown || _health.HealthPoint - currentDamage >=0 ) return currentDamage;
|
||||
IsKnockdown = true;
|
||||
|
Reference in New Issue
Block a user