Files
Fishing2Server/Hotfix/Game/Player/Entity/PlayerSystem.cs
2025-09-01 23:57:34 +08:00

90 lines
2.6 KiB
C#

using Fantasy;
using Fantasy.Async;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using Fantasy.Helper;
#pragma warning disable CS8625 // 无法将 null 字面量转换为非 null 的引用类型。
namespace NB.Game;
public sealed class PlayerDestroySystem : DestroySystem<Player>
{
protected override void Destroy(Player self)
{
self.NickName = string.Empty;
self.Level = 0;
self.Exp = 0;
self.Country = string.Empty;
self.Head = string.Empty;
// self.ItemContainer.Dispose();
// self.ItemContainer = null;
// self.FishContainer.Dispose();
// self.FishContainer = null;
// self.Wallet.Dispose();
// self.Wallet = null;
// self.Vip.Dispose();
// self.Vip = null;
// self.Statistics.Dispose();
// self.Statistics = null;
self.SessionRunTimeId = 0;
}
}
public static class PlayerSystem
{
#region
public static void SetTestData(this Player player)
{
List<int> addItemConfigs = new List<int>()
{
100001, 100002, 100003,
200001,
300001, 300002, 300003,
400001,
500001, 500002,
600001, 600002, 600003, 600004,
700001,
800001
};
Dictionary<int, List<int>> rigDic = new Dictionary<int, List<int>>()
{
{ 100001, [300001, 400001, 500002, 700001, 800001] },
{ 100002, [200001, 300001, 400001, 500002, 700001, 800001] },
{ 100003, [200001, 400001, 600001] }
};
//添加测试数据
if (player.ItemContainer != null && player.ItemContainer.Items.Count < 1)
{
foreach (var configId in addItemConfigs)
{
player.ItemContainer.Add(configId, 1);
}
foreach (var (rod, list) in rigDic)
{
if (player.ItemContainer.GetFistItemByConfigId(rod, out var item) && item != null)
{
var childs = new List<long>();
foreach (var i in list)
{
if (player.ItemContainer.GetFistItemByConfigId(i, out var itemChild) && itemChild != null)
{
childs.Add(itemChild.Id);
}
}
player.ItemContainer.FishingRig[item.Id] = childs;
}
}
// player.ItemContainer.FishingRig
}
// if(player.gr)
}
#endregion
}