public Group(GroupType groupType, HashSet <Type> filters, EventType _eventType, OnEntityUpdate onEntityUpdate) { Filters = filters; EventType = _eventType; OnEntityUpdateEvent += onEntityUpdate; Entities = new HashSet <Entity.Entity>(); GroupType = groupType; }
/* * @brief 實體更新 * @param id [in] 組件編號 * @note 限定管理器使用 */ public void UpdateEntity(T entity, int id, IComponent oldComponent, IComponent newComponent) { if (HasEntity(entity) == false) { return; } OnEntityRemove?.Invoke(this, entity); OnEntityAdd?.Invoke(this, entity); OnEntityUpdate?.Invoke(this, entity, id, oldComponent, newComponent); }
public void EntityUpdated() { OnEntityUpdate?.Invoke(); }
public void Update() { // grab all new messages. do this in your Update loop. Telepathy.Message msg; while (_client.GetNextMessage(out msg)) { switch (msg.eventType) { case Telepathy.EventType.Connected: Telepathy.Logger.Log("Client " + msg.connectionId + " Connected"); break; case Telepathy.EventType.Data: var simpleData = SimpleMessage.Parser.ParseFrom(msg.data); Telepathy.Logger.Log("Client " + ClientId + " Data: " + (ServerCodes)simpleData.MessageId); switch ((ServerCodes)simpleData.MessageId) { case ServerCodes.ClientConnect: ClientId = ClientConnect.Parser.ParseFrom(simpleData.Info).ClientId; Telepathy.Logger.Log("My Client Id is " + ClientId); OnConnect?.Invoke(); break; case ServerCodes.GameData: var gameData = GameData.Parser.ParseFrom(simpleData.Info); Telepathy.Logger.Log($"Client Game Data: {BitConverter.ToString(gameData.Info.ToByteArray())}"); break; case ServerCodes.EntityInfo: var entityInfo = EntityInfo.Parser.ParseFrom(simpleData.Info); Telepathy.Logger.Log($"Client Entity Info: {entityInfo.EntityId}"); foreach (var pair in entityInfo.EntityData) { Telepathy.Logger.Log($"{pair.Key} {BitConverter.ToString(pair.Value.ToByteArray())}"); } OnEntityCreation?.Invoke(entityInfo); break; case ServerCodes.EntityUpdate: var entityUpdate = EntityUpdate.Parser.ParseFrom(simpleData.Info); OnEntityUpdate?.Invoke(entityUpdate); break; default: break; } break; case Telepathy.EventType.Disconnected: Telepathy.Logger.Log("Client " + msg.connectionId + " Disconnected"); break; } } }