public void UpdateAmmo(MyAmmoBase ammo) { Debug.Assert(ammo.EntityId.HasValue, "All guided projectiles must have entity ID, this type hasn't: " + ammo.GetType().Name); if (ammo.EntityId.Value.PlayerId == MyEntityIdentifier.CurrentPlayerId) // Make sure to update only my ammo { MyEventAmmoUpdate msg = new MyEventAmmoUpdate(); msg.EntityId = ammo.EntityId.Value.NumericValue; msg.Velocity = ammo.Physics.LinearVelocity; msg.Position = new MyMwcPositionAndOrientation(ammo.WorldMatrix); Peers.SendToAll(ref msg, ammo.EntityId.Value, m_multiplayerConfig.ProjectilesTickRate, NetDeliveryMethod.Unreliable); } }
public void ExplodeAmmo(MyAmmoBase ammo) { // Explode only my missiles to prevent circullar SEND/RECEIVE if (IsControlledByMe(ammo)) { var msg = new MyEventAmmoExplosion(); msg.AmmoBaseEntityId = ammo.EntityId.Value.NumericValue; msg.Position = new MyMwcPositionAndOrientation(ammo.WorldMatrix); Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableUnordered); } }