// using System; // using System.Collections; // using System.Collections.Generic; // using System.Linq; // using BITFALL.Entities.Equipment; // using BITFALL.Player.Inventory; // using UnityEngine; // using BITKit; // using BITKit.Entities; // // namespace BITFALL // { // // /// // /// 玩家装备容器 // /// 支持,护甲,头盔和背包等 // /// // [CustomType(typeof(IEntityEquipmentContainer))] // public class PlayerEquipContainer : EntityComponent, IEntityEquipmentContainer // { // private Dictionary Equipment = new(); // [Inject] // private IBasicItemContainer inventory; // public override void OnAwake() // { // var health = entity.Get(); // health.OnSetAlive += OnSetAlive; // } // // private void OnSetAlive(bool obj) // { // if (obj) return; // foreach (var x in Equipment.ToArray()) // { // OnDeEquip?.Invoke(x.Key, x.Value); // inventory.Add(x.Value); // } // Equipment.Clear(); // } // // public override void OnStart() // { // base.OnStart(); // inventory = entity.Get(); // var playerInventory = entity.Get(); // playerInventory.OnUseItem += TryExecute; // } // // public Action OnEquip { get; set; } // public Action OnDeEquip { get; set; } // // public bool TryDeEquip(T slot) where T : IEquipmentSlot // { // if (!Equipment.TryGetValue(slot, out var equipable)) return false; // if (inventory.Add(equipable)) // { // DeEquip(slot, equipable); // } // return false; // } // private bool Equip(IEquipmentSlot slot, IBasicItem item) // { // Equipment.Add(slot, item); // OnEquip?.Invoke(slot, item); // return true; // } // private bool DeEquip(IEquipmentSlot slot, IBasicItem item) // { // Equipment.Remove(slot); // OnDeEquip?.Invoke(slot, item); // return true; // } // public int Priority => 0; // // public bool TryExecute(IBasicItem value) // { // var asset = value.GetAssetable(); // //尝试获取可装备信息 // if (!asset.TryGetProperty(out var equipable)) return false; // //已装备物品 // if (Equipment.TryGetValue(equipable.slot, out var equipedItem)) // { // //尝试将装配放回背包 // if (inventory.Add(equipedItem)) // { // //移除已装备物品 // DeEquip(equipable.slot, value); // } // } // //从库存中移除物品 // if (inventory.Remove(value)) // { // //装配物品 // Equip(equipable.slot, value); // } // return false; // } // } // }