水电费
This commit is contained in:
50
Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs
Normal file
50
Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Fantasy.Gate;
|
||||
|
||||
namespace System.Gate.System;
|
||||
|
||||
public sealed class GameAccountManageComponentDestroySystem : DestroySystem<GameAccountManageComponent>
|
||||
{
|
||||
protected override void Destroy(GameAccountManageComponent self)
|
||||
{
|
||||
foreach (var (_, gameAccount) in self.Accounts)
|
||||
{
|
||||
gameAccount.Dispose();
|
||||
}
|
||||
|
||||
self.Accounts.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static class GameAccountManageComponentSystem
|
||||
{
|
||||
public static void Add(this GameAccountManageComponent self, GameAccount account)
|
||||
{
|
||||
self.Accounts.Add(account.Id, account);
|
||||
}
|
||||
|
||||
public static GameAccount? Get(this GameAccountManageComponent self, long accountId)
|
||||
{
|
||||
return self.Accounts.GetValueOrDefault(accountId);
|
||||
}
|
||||
|
||||
public static bool TryGet(this GameAccountManageComponent self, long accountId, out GameAccount? account)
|
||||
{
|
||||
return self.Accounts.TryGetValue(accountId, out account);
|
||||
}
|
||||
|
||||
public static void Remove(this GameAccountManageComponent self, long accountId, bool isDispose = true)
|
||||
{
|
||||
if (!self.Accounts.Remove(accountId, out var account))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDispose)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
account.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user