//transpiler method investigate internal static bool SelectAllFormationsPrefix(ref OrderController __instance, Agent selectorAgent, bool uiFeedback) { if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage(new SelectAllFormations()); GameNetwork.EndModuleEventAsClient(); } if (uiFeedback && !GameNetwork.IsClientOrReplay && selectorAgent != null && Mission.Current.IsOrderShoutingAllowed()) { VoiceCommandQueue.QueueItem("Everyone", 800f); } var _selectedFormations = MissionAccessTools.Get_selectedFormations(ref __instance); _selectedFormations.Clear(); var _team = MissionAccessTools.Get_team(ref __instance); IEnumerable <Formation> formations = _team.Formations; foreach (Formation formation in _team.Formations.Where <Formation>((Func <Formation, bool>)(f => IsFormationSelectable(f, selectorAgent)))) { _selectedFormations.Add(formation); } OrderControllerReversePatches.OnSelectedFormationsCollectionChanged(__instance); return(false); }
public void ChangeTeam(Team team) { if (team == GameNetwork.MyPeer.GetComponent <MissionPeer>().Team) { return; } if (GameNetwork.IsServer) { Mission.Current.PlayerTeam = team; this.ChangeTeamServer(GameNetwork.MyPeer, team); } else { foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers) { networkPeer.GetComponent <MissionPeer>()?.ClearAllVisuals(); } GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new TeamChange(false, team)); GameNetwork.EndModuleEventAsClient(); } if (this.OnMyTeamChange == null) { return; } this.OnMyTeamChange(); }
private async void InitializeCustomGameAux(InitializeCustomGameMessage message) { if (message.InMission) { MBDebug.Print("Client: I have received InitializeCustomGameMessage with mission " + message.GameType + " " + message.Map + ". Loading it...", debugFilter: 17179869184UL); if (Module.CurrentModule.StartMultiplayerGame(message.GameType, message.Map)) { ; } } else { await Task.Delay(200); while (!(GameStateManager.Current.ActiveState is LobbyGameStateCustomGameClient)) { await Task.Delay(1); } LoadingWindow.DisableGlobalLoadingWindow(); MBDebug.Print("Client: I have received InitializeCustomGameMessage with no mission. Sending confirmation to server.", debugFilter: 17179869184UL); GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new FinishedLoading()); GameNetwork.EndModuleEventAsClient(); GameNetwork.SyncRelevantGameOptionsToServer(); } }
public void EquipmentUpdated() { if (GameNetwork.IsServer) { MissionPeer component = GameNetwork.MyPeer.GetComponent <MissionPeer>(); if (component.SelectedTroopIndex == component.NextSelectedTroopIndex) { return; } component.SelectedTroopIndex = component.NextSelectedTroopIndex; GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new UpdateSelectedTroopIndex(GameNetwork.MyPeer, component.SelectedTroopIndex)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, GameNetwork.MyPeer); if (this.OnEquipmentRefreshed == null) { return; } this.OnEquipmentRefreshed(component); } else { MissionPeer component = GameNetwork.MyPeer.GetComponent <MissionPeer>(); GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new RequestTroopIndexChange(component.NextSelectedTroopIndex)); GameNetwork.EndModuleEventAsClient(); } }
public void OnRequestForfeitSpawn() { if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new RequestForfeitSpawn()); GameNetwork.EndModuleEventAsClient(); } else { Mission.Current.GetMissionBehaviour <MissionMultiplayerFlagDomination>().ForfeitSpawning(GameNetwork.MyPeer); } }
private async void HandleServerEventUnloadMissionAux() { GameNetwork.MyPeer.IsSynchronized = false; this.CurrentIntermissionTimer = 0.0f; this.ClientIntermissionState = MultiplayerIntermissionState.Idle; BannerlordNetwork.EndMultiplayerLobbyMission(); while (Mission.Current != null) { await Task.Delay(1); } LoadingWindow.DisableGlobalLoadingWindow(); MBDebug.Print("Client: I finished HandleServerEventUnloadMissionAux. Sending confirmation to server.", debugFilter: 17179869184UL); GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new FinishedLoading()); GameNetwork.EndModuleEventAsClient(); }
public void Vote(bool accepted) { if (GameNetwork.IsServer) { if (GameNetwork.MyPeer == null) { return; } this.ApplyVote(GameNetwork.MyPeer, accepted); } else { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new PollResponse(accepted)); GameNetwork.EndModuleEventAsClient(); } }
public void StartGameChangePoll(string gameType, string map) { if (GameNetwork.IsServer) { if (GameNetwork.MyPeer == null) { return; } this.StartGameChangePollOnServer(GameNetwork.MyPeer, gameType, map); } else { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.ChangeGamePoll(gameType, map)); GameNetwork.EndModuleEventAsClient(); } }
public void SendMessageToTeam(string message) { if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.PlayerMessageTeam(message)); GameNetwork.EndModuleEventAsClient(); } else { if (!GameNetwork.IsServer) { return; } this.ServerPrepareAndSendMessage(GameNetwork.MyPeer, true, message); } }
public void StartPlayerKickPoll(NetworkCommunicator peer, bool banPlayer) { if (GameNetwork.IsServer) { if (GameNetwork.MyPeer == null) { return; } this.StartPlayerKickPollOnServer(GameNetwork.MyPeer, peer, banPlayer); } else { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.KickPlayerPoll(peer, banPlayer)); GameNetwork.EndModuleEventAsClient(); } }
public void PerkUpdated(int perkList, int perkIndex) { if (GameNetwork.IsServer) { MissionPeer component = GameNetwork.MyPeer.GetComponent <MissionPeer>(); if (this.OnEquipmentRefreshed == null) { return; } this.OnEquipmentRefreshed(component); } else { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new RequestPerkChange(perkList, perkIndex)); GameNetwork.EndModuleEventAsClient(); } }
public void SetOrder(SiegeWeaponOrderType order) { if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new ApplySiegeWeaponOrder(order)); GameNetwork.EndModuleEventAsClient(); } foreach (SiegeWeapon selectedWeapon in this.SelectedWeapons) { this.SetOrderAux(order, selectedWeapon); } Action <SiegeWeaponOrderType, IEnumerable <SiegeWeapon> > onOrderIssued = this.OnOrderIssued; if (onOrderIssued == null) { return; } onOrderIssued(order, (IEnumerable <SiegeWeapon>) this.SelectedWeapons); }
public void KickPlayer(NetworkCommunicator peerToKick, bool banPlayer) { if (GameNetwork.IsServer || GameNetwork.IsDedicatedServer) { if (peerToKick.IsMine) { return; } MissionPeer component = peerToKick.GetComponent <MissionPeer>(); if (component == null) { return; } if (banPlayer) { if (GameNetwork.IsClient) { BannedPlayerManagerCustomGameClient.AddBannedPlayer(component.Peer.Id, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000); } else if (GameNetwork.IsDedicatedServer) { BannedPlayerManagerCustomGameServer.AddBannedPlayer(component.Peer.Id, component.GetNetworkPeer().UserName, GameNetwork.IsDedicatedServer ? -1 : Environment.TickCount + 600000); } } if (GameNetwork.IsDedicatedServer) { throw new NotImplementedException(); } NetworkMain.GameClient.KickPlayer(component.Peer.Id, banPlayer); } else { if (!GameNetwork.IsClient) { return; } GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.KickPlayer(peerToKick, banPlayer)); GameNetwork.EndModuleEventAsClient(); } }
public override void OnAgentInteraction(Agent targetAgent) { if (this._requesters.Any <Tuple <Agent, MissionTime> >((Func <Tuple <Agent, MissionTime>, bool>)(req => req.Item1 == targetAgent))) { for (int index = 0; index < this._requesters.Count; ++index) { if (this._requesters[index].Item1 == this.ControlledAgent) { this._requesters.Remove(this._requesters[index]); break; } } switch (this.PlayerType) { case MissionRepresentativeBase.PlayerTypes.Client: GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new DuelResponse(targetAgent.MissionRepresentative.Peer.Communicator as NetworkCommunicator, true)); GameNetwork.EndModuleEventAsClient(); break; case MissionRepresentativeBase.PlayerTypes.Server: this._missionMultiplayerDuel.DuelRequestAccepted(targetAgent, this.ControlledAgent); break; } } else { switch (this.PlayerType) { case MissionRepresentativeBase.PlayerTypes.Client: GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromClient.DuelRequest(targetAgent)); GameNetwork.EndModuleEventAsClient(); break; case MissionRepresentativeBase.PlayerTypes.Server: this._missionMultiplayerDuel.DuelRequestReceived(this.ControlledAgent, targetAgent); break; } } }
public void SelectAll() { if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new SelectAllSiegeWeapons()); GameNetwork.EndModuleEventAsClient(); } this._selectedWeapons.Clear(); foreach (SiegeWeapon availableWeapon in this._availableWeapons) { this._selectedWeapons.Add(availableWeapon); } Action siegeWeaponsChanged = this.OnSelectedSiegeWeaponsChanged; if (siegeWeaponsChanged == null) { return; } siegeWeaponsChanged(); }
public void Deselect(SiegeWeapon weapon) { if (!this.SelectedWeapons.Contains(weapon)) { return; } if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new UnselectSiegeWeapon(weapon)); GameNetwork.EndModuleEventAsClient(); } this._selectedWeapons.Remove(weapon); Action siegeWeaponsChanged = this.OnSelectedSiegeWeaponsChanged; if (siegeWeaponsChanged == null) { return; } siegeWeaponsChanged(); }
public void Select(SiegeWeapon weapon) { if (this.SelectedWeapons.Contains(weapon) || !SiegeWeaponController.IsWeaponSelectable(weapon)) { return; } if (GameNetwork.IsClient) { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new SelectSiegeWeapon(weapon)); GameNetwork.EndModuleEventAsClient(); } this._selectedWeapons.Add(weapon); Action siegeWeaponsChanged = this.OnSelectedSiegeWeaponsChanged; if (siegeWeaponsChanged == null) { return; } siegeWeaponsChanged(); }
private void TickMission(float realDt) { if (this._firstMissionTickAfterLoading && this.CurrentMission != null && this.CurrentMission.CurrentState == Mission.State.Continuing) { if (GameNetwork.IsClient) { MBDebug.Print("Client: I finished loading. Sending confirmation to server.", debugFilter: 17179869184UL); GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new FinishedLoading()); GameNetwork.EndModuleEventAsClient(); GameNetwork.SyncRelevantGameOptionsToServer(); } this._firstMissionTickAfterLoading = false; } if (Game.Current.DeterministicMode) { Game.Current.ResetRandomGenerator(this._missionTickCount); } this.Handler?.BeforeMissionTick(this.CurrentMission, realDt); this.CurrentMission.PauseAITick = false; if (GameNetwork.IsSessionActive && (double)this.CurrentMission.ClearSceneTimerElapsedTime < 0.0) { this.CurrentMission.PauseAITick = true; } float dt = realDt; if (this.Paused || MBCommon.IsPaused) { dt = 0.0f; } else { if (this.CurrentMission.FixedDeltaTimeMode) { dt = this.CurrentMission.FixedDeltaTime; } if (this.CurrentMission.Scene.SlowMotionMode) { dt *= this.CurrentMission.Scene.SlowMotionFactor; } } if (!GameNetwork.IsSessionActive && NativeConfig.CheatMode) { if ((double)this.CurrentMission.TimeSpeedPeriod > 0.0) { float num = this.CurrentMission.TimeSpeedTimerElapsedTime / this.CurrentMission.TimeSpeedPeriod; if ((double)num >= 1.0) { this.CurrentMission.TimeSpeed = this.CurrentMission.TimeSpeedEnd; dt *= this.CurrentMission.TimeSpeed; this.CurrentMission.TimeSpeedPeriod = 0.0f; } else { dt *= (float)((double)this.CurrentMission.TimeSpeedEnd * (double)num + (double)this.CurrentMission.TimeSpeed * (1.0 - (double)num)); } } else { dt *= this.CurrentMission.TimeSpeed; } } if ((double)this.CurrentMission.ClearSceneTimerElapsedTime < -0.300000011920929 && !GameNetwork.IsClientOrReplay) { this.CurrentMission.ClearAgentActions(); } if (this.CurrentMission.CurrentState == Mission.State.Continuing || this.CurrentMission.MissionEnded()) { if (this.CurrentMission.IsFastForward) { float num = dt * 9f; while ((double)num > 9.99999997475243E-07) { if ((double)num > 0.100000001490116) { this.TickMissionAux(0.1f, 0.1f, false); if (this.CurrentMission.CurrentState != Mission.State.Over) { num -= 0.1f; } else { break; } } else { if ((double)num > 1.0 / 300.0) { this.TickMissionAux(num, num, false); } num = 0.0f; } } if (this.CurrentMission.CurrentState != Mission.State.Over) { this.TickMissionAux(dt, realDt, true); } } else { this.TickMissionAux(dt, realDt, true); } } if (this.Handler != null) { this.Handler.AfterMissionTick(this.CurrentMission, realDt); } ++this._missionTickCount; int num1 = Game.Current.DeterministicMode ? 1 : 0; }
public void AutoAssignTeam(NetworkCommunicator peer) { if (GameNetwork.IsServer) { List <Team> disabledTeams = this.GetDisabledTeams(); List <Team> list = this.Mission.Teams.Where <Team>((Func <Team, bool>)(x => !disabledTeams.Contains(x) && x.Side != BattleSideEnum.None)).ToList <Team>(); Team team; if (list.Count > 1) { int[] numArray = new int[list.Count]; foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers) { MissionPeer component = networkPeer.GetComponent <MissionPeer>(); if (component?.Team != null) { for (int index = 0; index < list.Count; ++index) { if (component.Team == list[index]) { ++numArray[index]; } } } } int num = -1; int index1 = -1; for (int index2 = 0; index2 < numArray.Length; ++index2) { if (index1 < 0 || numArray[index2] < num) { index1 = index2; num = numArray[index2]; } } team = list[index1]; } else { team = list[0]; } if (!peer.IsMine) { this.ChangeTeamServer(peer, team); } else { this.ChangeTeam(team); } } else { GameNetwork.BeginModuleEventAsClient(); GameNetwork.WriteMessage((GameNetworkMessage) new TeamChange(true, (Team)null)); GameNetwork.EndModuleEventAsClient(); if (this.OnMyTeamChange == null) { return; } this.OnMyTeamChange(); } }