using Milimoe.FunGame.Core.Api.Utility; using Milimoe.FunGame.Core.Interface.Entity; using Milimoe.FunGame.Core.Library.Constant; namespace Milimoe.FunGame.Core.Entity { /// /// 和 一样,需要继承构造 /// public class Item : BaseEntity, IItem { /// /// 物品的描述 /// public string Description { get; } = ""; /// /// 物品类型 /// public virtual ItemType ItemType { get; set; } = ItemType.Others; /// /// 物品槽位 /// public virtual EquipSlotType EquipSlotType { get; set; } = EquipSlotType.None; /// /// 物品的价格 /// public double Price { get; set; } = 0; /// /// 快捷键 /// public char Key { get; set; } = '/'; /// /// 是否是主动物品 /// public bool IsActive => Skills.Active != null; /// /// 是否可用(涉及冷却和禁用等) /// public bool Enable { get; set; } = true; /// /// 物品所属的角色 /// public Character? Character { get; set; } = null; /// /// 物品拥有的技能 /// public SkillGroup Skills { get; set; } = new(); /// /// 当获得物品时 /// public void OnItemGained() { foreach (Skill skill in Skills.Passive) { if (!skill.IsActive && skill.Level > 0) { foreach (Effect e in skill.AddInactiveEffectToCharacter()) { e.ActionQueue = skill.ActionQueue; if (Character != null && !Character.Effects.Contains(e)) { Character.Effects.Add(e); e.OnEffectGained(Character); } } } } } /// /// 局内使用物品触发 /// public void UseItem(ActionQueue queue, List enemys, List teammates) { if (Skills.Active != null && Character != null) { Skills.Active.OnSkillCasted(queue, Character, enemys, teammates); } OnItemUsed(); } /// /// 局外(库存)使用物品触发 /// public void UseItem(/*Inventory inventory*/) { OnItemUsed(); } /// /// 当物品被使用时 /// public virtual void OnItemUsed() { } protected Item(ItemType type, EquipSlotType slot = EquipSlotType.None) { ItemType = type; EquipSlotType = slot; } internal Item() { } /// /// 判断两个物品是否相同 检查Id.Name /// /// /// public override bool Equals(IBaseEntity? other) { return other is Item c && c.Id + "." + c.Name == Id + "." + Name; } } }