void OnUpdatePositionFast(ref MyEventUpdatePositionFast msg) { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("Update position fast"); MyPlayerRemote player = (MyPlayerRemote)msg.SenderConnection.Tag; MyEntityIdentifier entityId = new MyEntityIdentifier(msg.EntityId); if (!CheckSenderId(msg, msg.EntityId)) { Alert("Player is updating entity which is not his", msg.SenderEndpoint, msg.EventType); return; } MyEntity entity; if (MyEntities.TryGetEntityById(entityId, out entity)) { var m = entity.WorldMatrix; m.Translation = msg.Position; if (msg.Up != null) m.Up = msg.Up.Value; if (msg.Forward != null) m.Forward = msg.Forward.Value; entity.WorldMatrix = m; } else { Alert("Entity to update not found", msg.SenderEndpoint, msg.EventType); } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
public void UpdatePositionFast(MyEntity entity, Vector3 position, Vector3? up = null, Vector3? forward = null) { Debug.Assert(entity != null); Debug.Assert(!entity.Closed); var posMsg = new MyEventUpdatePositionFast(); posMsg.EntityId = entity.EntityId.Value.NumericValue; posMsg.Position = position; posMsg.Up = up; posMsg.Forward = forward; Peers.SendToAll(ref posMsg, NetDeliveryMethod.ReliableSequenced, 2); }