private void OpenArmyManagement() { if (this._gauntletLayer == null) { return; } this._armyManagementVM = new ArmyManagementVM(new Action(this.CloseArmyManagement)); this._gauntletArmyManagementMovie = this._gauntletLayer.LoadMovie("ArmyManagement", (ViewModel)this._armyManagementVM); this._timeControlModeBeforeArmyManagementOpened = Campaign.Current.TimeControlMode; Campaign.Current.TimeControlMode = CampaignTimeControlMode.Stop; Campaign.Current.SetTimeControlModeLock(true); if (!(ScreenManager.TopScreen is MapScreen topScreen)) { return; } topScreen.IsInArmyManagement = true; }
protected override void OnApplicationTick(float dt) { if (Campaign.Current != null) { var test = HotKeyManager.GetAllCategories().First().RegisteredGameKeys; if (Campaign.Current.CurrentMenuContext != null && (!Campaign.Current.CurrentMenuContext.GameMenu.IsWaitActive || Campaign.Current.TimeControlModeLock)) { return; } if (Input.IsKeyReleased(InputKey.D4)) { Campaign.Current.SpeedUpMultiplier = Support.settings.extra_fast_forward_speed; Campaign.Current.SetTimeSpeed(2); } if (Input.IsKeyReleased(InputKey.D3)) { Campaign.Current.SpeedUpMultiplier = Support.settings.fast_forward_speed; } if (Input.IsKeyDown(InputKey.LeftControl) && Input.IsKeyDown(InputKey.Space)) { if (Campaign.Current.SpeedUpMultiplier != Support.settings.ctrl_space_speed) { currentSpeed = Campaign.Current.SpeedUpMultiplier; currentTimeMode = Campaign.Current.TimeControlMode; timeSpedUp = true; } Campaign.Current.SpeedUpMultiplier = Support.settings.ctrl_space_speed; Campaign.Current.SetTimeSpeed(2); } else if (timeSpedUp) { timeSpedUp = false; Campaign.Current.SpeedUpMultiplier = currentSpeed; Campaign.Current.TimeControlMode = currentTimeMode; } } }
private void ClientServerCommunication() { // Initialization CampaignTimeControlMode expectedTimeControl = CampaignTimeControlMode.StoppablePlay; RailClientRoom clientRoom = m_Client.StartRoom(); RailServerRoom serverRoom = m_Server.StartRoom(); RailEntityServer <SomeState> entityServerSide = serverRoom.AddNewEntity <RailEntityServer <SomeState> >(); entityServerSide.State.Mode = expectedTimeControl; m_Server.AddClient(m_PeerServerSide.Object, ""); m_Client.SetPeer(m_PeerClientSide.Object); Assert.Empty(clientRoom.Entities); Assert.Single(serverRoom.Entities); // Sync entity from server to client for (int i = 0; i < RailConfig.SERVER_SEND_RATE + RailConfig.CLIENT_SEND_RATE + 1; ++i) { m_ConClientSide.ExecuteSends(); m_Server.Update(); m_ConServerSide.ExecuteSends(); m_Client.Update(); } // The client has received the entity. Assert.Single(clientRoom.Entities); Assert.Single(serverRoom.Entities); // Clients representation of the entity is identical to the server RailEntityBase entityProxy = clientRoom.Entities.First(); Assert.IsType <RailEntityClient <SomeState> >(entityProxy); RailEntityClient <SomeState> entityClientSide = entityProxy as RailEntityClient <SomeState>; Assert.NotNull(entityClientSide); Assert.Equal(entityServerSide.Id, entityProxy.Id); Assert.Equal(expectedTimeControl, entityServerSide.State.Mode); Assert.Equal(expectedTimeControl, entityClientSide.State.Mode); // Change the entity on server side and sync to the client expectedTimeControl = CampaignTimeControlMode.Stop; entityServerSide.State.Mode = expectedTimeControl; // Let the server detect the change and send the packet bool bWasSendTick = false; while (!bWasSendTick) { m_Server.Update(); bWasSendTick = serverRoom.Tick.IsSendTick(RailConfig.SERVER_SEND_RATE); } // Let the client receive & process the packet. We need to bring the client up to the same tick as the server to see the result. while (clientRoom.Tick < serverRoom.Tick) { m_ConServerSide.ExecuteSends(); m_Client.Update(); } Assert.Equal(expectedTimeControl, entityServerSide.State.Mode); Assert.Equal(expectedTimeControl, entityClientSide.State.Mode); }
public static void Encode(this RailBitBuffer buffer, CampaignTimeControlMode mode) { buffer.WriteByte((byte)mode); }