提交示例代码
This commit is contained in:
44
物品和背包的完整代码/Server/Hotfix/Gate/Container/ItemSystem.cs
Normal file
44
物品和背包的完整代码/Server/Hotfix/Gate/Container/ItemSystem.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user