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); } }
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 static void SendMissileCreated(IMyMissileGunObject launcher, Vector3 position, Vector3 initialVelocity, Vector3 direction, float customMaxDistance, MyAmmoBase.MyAmmoBaseFlags flags, long owner) { Debug.Assert(Sync.IsServer, "Only server can shoot missiles!"); Debug.Assert(launcher is MyEntity, "Missile launching object should be an entity!"); if (!Sync.IsServer || !(launcher is MyEntity)) return; MissileShootMsg msg = new MissileShootMsg(); msg.Position = position; msg.InitialVelocity = initialVelocity; msg.Direction = direction; msg.CustomMaxDistance = customMaxDistance; msg.Flags = flags; msg.LauncherEntityId = (launcher as MyEntity).EntityId; msg.Owner = owner; Sync.Layer.SendMessageToAll(ref msg); }