You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
|
|
namespace ET |
|
{ |
|
public class AccountSessionsComponentDestroySystem : DestroySystem<AccountSessionsComponent> |
|
{ |
|
public override void Destroy(AccountSessionsComponent self) |
|
{ |
|
self.AccountSessionDictionary.Clear(); |
|
} |
|
} |
|
|
|
[FriendClass(typeof(AccountSessionsComponent))] |
|
public static class AccountSessionsComponentSystem |
|
{ |
|
public static long Get(this AccountSessionsComponent self, long accountId) |
|
{ |
|
if (!self.AccountSessionDictionary.TryGetValue(accountId, out long instanceId)) |
|
{ |
|
return 0; |
|
} |
|
|
|
return instanceId; |
|
} |
|
|
|
public static void Add(this AccountSessionsComponent self, long accountId, long sessionInstanceId) |
|
{ |
|
if (self.AccountSessionDictionary.ContainsKey(accountId)) |
|
{ |
|
self.AccountSessionDictionary[accountId] = sessionInstanceId; |
|
return; |
|
} |
|
|
|
self.AccountSessionDictionary.Add(accountId, sessionInstanceId); |
|
} |
|
|
|
public static void Remove(this AccountSessionsComponent self, long accountId) |
|
{ |
|
if (self.AccountSessionDictionary.ContainsKey((accountId))) |
|
{ |
|
self.AccountSessionDictionary.Remove((accountId)); |
|
} |
|
} |
|
} |
|
}
|
|
|