| 123456789101112131415161718192021222324252627282930313233343536 |
- using System.Collections.Generic;
- using System.Linq;
- namespace ET
- {
- public class PlayerComponent : Entity, IAwake, IDestroy, IAppClose
- {
- private readonly Dictionary<long, Player> idPlayers = new Dictionary<long, Player>();
- public void Add(Player player)
- {
- idPlayers.Add(player.AccountId, player);
- }
- public Player Get(long id)
- {
- idPlayers.TryGetValue(id, out Player gamer);
- return gamer;
- }
- public void Remove(long id)
- {
- idPlayers.Remove(id);
- }
- public int Count
- {
- get { return idPlayers.Count; }
- }
- public Player[] GetAll()
- {
- return idPlayers.Values.ToArray();
- }
- }
- }
|