private void OnHealthUpdate(ref MyEventHealthUpdate msg)
 {
     MyEntity entity;
     if (MyEntities.TryGetEntityById(new MyEntityIdentifier(msg.EntityId), out entity))
     {
         entity.HealthRatio = msg.NewHealthRatio;
     }
     else
     {
         Alert("Update health on nonexistent entity", msg.SenderEndpoint, msg.EventType);
     }
 }
        public void UpdateHealth(MyEntity entity, float newHealthRatio)
        {
            if (!IsControlledByMe(entity)) return;

            Debug.Assert(entity.EntityId.HasValue);
            MyEventHealthUpdate msg = new MyEventHealthUpdate();
            msg.EntityId = entity.EntityId.Value.NumericValue;
            msg.NewHealthRatio = entity.HealthRatio;

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