This commit is contained in:
CortexCore
2023-11-15 23:54:54 +08:00
parent ee3ecec6cb
commit 3c837a4a33
356 changed files with 73756 additions and 26493 deletions

View File

@@ -12,6 +12,7 @@ using System.Threading.Tasks;
using BITFALL.Entities;
using BITFALL.Entities.Improvised;
using BITFALL.Entities.Inventory;
using BITFALL.Player.Equip;
using BITFALL.Player.Inventory;
using BITKit.Entities.Player;
using Cysharp.Threading.Tasks;
@@ -45,6 +46,9 @@ namespace BITFALL.Entities.Equipment
private ImprovisedServiceInterface _improvisedService;
[Inject]
private IEntityEquipmentContainer _equipmentContainer;
[Inject]
private IEquipService _equipService;
private readonly DoubleBuffer<IBasicItem> _cachedItem=new();
@@ -58,6 +62,17 @@ namespace BITFALL.Entities.Equipment
_knockdown.OnKnockdown +=()=>
{
Equip(null);
if (_equipService is not null)
{
_equipService.AllowEquip.AddDisableElements(this);
}
};
_knockdown.OnRevive += () =>
{
if (_equipService is not null)
{
_equipService.AllowEquip.RemoveDisableElements(this);
}
};
}
@@ -140,6 +155,7 @@ namespace BITFALL.Entities.Equipment
}
private void OnSetAlive(bool alive)
{
_equipService.AllowEquip.SetDisableElements(this,!alive);
if (alive) return;
foreach (var x in equips.ToArray())
{
@@ -151,6 +167,7 @@ namespace BITFALL.Entities.Equipment
}
private bool TryEquip(IBasicItem value)
{
if (_equipService.AllowEquip.Allow is false) return false;
if (_knockdown is not null && _knockdown.IsKnockdown) return false;
var asset = value.GetAssetable();
if (_equipment.IsSupportItem(value) is false) return false;
@@ -278,13 +295,14 @@ namespace BITFALL.Entities.Equipment
private void Equip(IBasicItem item)
{
if (_equipService.AllowEquip.Allow is false) return;
_equipment.EntryEquip(item);
currentEquip = item;
}
private bool Equip(int index)
{
if (_equipService.AllowEquip.Allow is false) return false;
if (!equips.TryGetValue(index, out var x) && index is not -1) return false;
if (_knockdown is not null && _knockdown.IsKnockdown) return false;
currentEquip = x;
@@ -301,5 +319,6 @@ namespace BITFALL.Entities.Equipment
Equip(item.Value);
return true;
}
}
}