1
This commit is contained in:
@@ -26,6 +26,8 @@ namespace BITFALL.Entities.Equipment
|
||||
{
|
||||
[Header(Constant.Header.InternalVariables)]
|
||||
private readonly Dictionary<int, IBasicItem> equips=new();
|
||||
|
||||
public event Func<IBasicItem, bool> OnTryEquip;
|
||||
public event Action<IDictionary<int, IBasicItem>> OnUpdateEquip;
|
||||
|
||||
[Inject(true)]
|
||||
@@ -179,8 +181,13 @@ namespace BITFALL.Entities.Equipment
|
||||
switch (asset)
|
||||
{
|
||||
case var _ when asset.TryGetProperty<EquipmentUseItem>(out _):
|
||||
if (OnTryEquip?.CastAsFunc().Any(x => x.Invoke(value)) is false) return false;
|
||||
_equipment.EntryEquip(value);
|
||||
_improvisedService?.TryUnEquipImprovised(out _);
|
||||
if (currentEquip is not null)
|
||||
{
|
||||
_cachedItem.Release(currentEquip);
|
||||
}
|
||||
currentEquip = value;
|
||||
return true;
|
||||
}
|
||||
@@ -263,6 +270,18 @@ namespace BITFALL.Entities.Equipment
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Cancel()
|
||||
{
|
||||
if (currentEquip is null) return false;
|
||||
if (_cachedItem.TryGetRelease(out var item))
|
||||
{
|
||||
Equip(item);
|
||||
return true;
|
||||
}
|
||||
Equip(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Equip(IBasicItem item)
|
||||
{
|
||||
_equipment.EntryEquip(item);
|
||||
|
Reference in New Issue
Block a user