This commit is contained in:
2025-07-27 12:34:04 +08:00
parent 6311c7cb12
commit 743c1d2baa
194 changed files with 81685 additions and 696 deletions

View File

@@ -0,0 +1,49 @@
using Fantasy.Entitas.Interface;
namespace NB.Gate.System;
public sealed class PlayerManageComponentDestroySystem : DestroySystem<PlayerManageComponent>
{
protected override void Destroy(PlayerManageComponent self)
{
foreach (var (_, gameAccount) in self.Players)
{
gameAccount.Dispose();
}
self.Players.Clear();
}
}
public static class PlayerManageComponentSystem
{
public static void Add(this PlayerManageComponent self, Player account)
{
self.Players.Add(account.Id, account);
}
public static Player Get(this PlayerManageComponent self, long accountId)
{
return self.Players.GetValueOrDefault(accountId);
}
public static bool TryGet(this PlayerManageComponent self, long accountId, out Player? account)
{
return self.Players.TryGetValue(accountId, out account);
}
public static void Remove(this PlayerManageComponent self, long accountId, bool isDispose = true)
{
if (!self.Players.Remove(accountId, out var account))
{
return;
}
if (!isDispose)
{
return;
}
account.Dispose();
}
}