44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using Fantasy.Entitas.Interface;
|
|
using Fantasy.Equip;
|
|
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
|
#pragma warning disable CS8601 // Possible null reference assignment.
|
|
|
|
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
|
|
|
|
namespace Fantasy;
|
|
|
|
public sealed class ItemDestroySystem : DestroySystem<Item>
|
|
{
|
|
protected override void Destroy(Item self)
|
|
{
|
|
self.CellId = 0;
|
|
self.Count = 0;
|
|
self.ConfigId = 0;
|
|
self.Container = null;
|
|
self.IsBind = false;
|
|
}
|
|
}
|
|
|
|
public static class ItemSystem
|
|
{
|
|
public static ItemInfo ToItemInfo(this Item self)
|
|
{
|
|
// 创建基础的物品信息
|
|
var mItemInfo = new ItemInfo()
|
|
{
|
|
ItemId = self.Id,
|
|
CellId = self.CellId,
|
|
Count = self.Count,
|
|
IsBind = self.IsBind,
|
|
ConfigId = (int)self.ConfigId,
|
|
Container = self.Container.Config.Type
|
|
};
|
|
// 添加装备信息
|
|
var equipComponent = self.GetComponent<EquipComponent>();
|
|
if (equipComponent != null)
|
|
{
|
|
mItemInfo.EquipInfo = equipComponent.ToEquipInfo();
|
|
}
|
|
return mItemInfo;
|
|
}
|
|
} |