public void OnMouseInput( MouseInput input ) { Sync.CheckSyncUnchanged( world, () => { Widget.DoHandleInput( input ); } ); }
public void OnKeyInput( KeyInput input ) { Sync.CheckSyncUnchanged( world, () => { Widget.DoHandleKeyPress( input ); } ); }
static void TickInner(OrderManager orderManager) { int t = Environment.TickCount; int dt = t - orderManager.LastTickTime; if (dt >= Settings.Game.Timestep) { using (new PerfSample("tick_time")) { orderManager.LastTickTime += Settings.Game.Timestep; Ui.Tick(); var world = orderManager.world; if (orderManager.GameStarted) { ++Viewport.TicksSinceLastMove; } Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world != null) { var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = Environment.TickCount; } Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); cursorFrame += 0.5f; } } } }
static void InnerLogicTick(OrderManager orderManager) { var tick = RunTime; var world = orderManager.World; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Sync.CheckSyncUnchanged(world, Ui.Tick); } var worldTimestep = world == null ? Timestep : world.Timestep; var worldTickDelta = tick - orderManager.LastTickTime; if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world == null) { return; } var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (BenchmarkMode) { Log.Write("cpu", "{0};{1}".F(LocalTick, PerfHistory.Items["tick_time"].LastValue)); } if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = RunTime; } // Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); } } } }
public void OnMouseInput(MouseInput input) { Sync.CheckSyncUnchanged(world, () => Ui.HandleInput(input)); }
public void OnTextInput(string text) { Sync.CheckSyncUnchanged(world, () => Ui.HandleTextInput(text)); }
public void OnKeyInput(KeyInput input) { Sync.CheckSyncUnchanged(world, () => Ui.HandleKeyPress(input)); }
static void TickInner(OrderManager orderManager) { var tick = Environment.TickCount; var world = orderManager.world; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Viewport.TicksSinceLastMove += uiTickDelta / Timestep; Sync.CheckSyncUnchanged(world, Ui.Tick); cursorFrame += 0.5f; } var worldTimestep = world == null ? Timestep : world.Timestep; var worldTickDelta = (tick - orderManager.LastTickTime); if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world != null) { var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = Environment.TickCount; } Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); } } } }