private void AddEntity(Entity entity) { // Add entity to the list _simulationState.Entities.Add(entity); var packet = new EntityAddPacket(entity); foreach (var player in _simulationState.Entities) { // Grab the connection var playerComponent = (PlayerComponent)player.GetComponent(typeof(PlayerComponent)); if (playerComponent == null) { continue; } var connection = playerComponent.Connection; if (connection != null) { ClientNetworkManager.Instance.SendPacket(packet, connection); } } }
/// <summary> /// Responsible for recieving and piping entities into the game network. /// </summary> /// <param name="entityAddPacket"></param> private void HandleEntityAdd(EntityAddPacket entityAddPacket) { ServiceManager.AddEntity(entityAddPacket.Entity); }