提交示例代码

This commit is contained in:
Bob.Song
2026-03-05 11:39:06 +08:00
commit 25958f58c3
2534 changed files with 209593 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
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;
}
}