public void OnAmmoUpdate(ref MyEventAmmoUpdate msg) { var player = (MyPlayerRemote)msg.SenderConnection.Tag; if (player != null) { MyEntity projectile; if (MyEntityIdentifier.TryGetEntity(new MyEntityIdentifier(msg.EntityId), out projectile)) { projectile.WorldMatrix = msg.Position.GetMatrix(); projectile.Physics.LinearVelocity = msg.Velocity; } } }
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); } }