void OnSetEntityFaction(ref MyEventSetEntityFaction msg)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(msg.EntityId.ToEntityId(), out entity))
     {
         entity.Faction = msg.Faction;
     }
     else
     {
         Alert("Entity not found: " + msg.EntityId, msg.SenderEndpoint, msg.EventType);
     }
 }
        public void SendSetEntityFaction(MyEntity entity, MyMwcObjectBuilder_FactionEnum faction)
        {
            Debug.Assert(entity.EntityId.HasValue, "Entity must have id");

            var msg = new MyEventSetEntityFaction();
            msg.Faction = faction;
            msg.EntityId = entity.EntityId.Value.NumericValue;

            Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered);
        }