public PingPlugin(DalamudPluginInterface pluginInterface, CommandManager commands, DtrBar dtrBar, GameNetwork network) { this.pluginInterface = pluginInterface; this.network = network; this.config = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration(); this.config.Initialize(this.pluginInterface); this.addressDetector = this.pluginInterface.Create <AggregateAddressDetector>(); if (this.addressDetector == null) { throw new InvalidOperationException("Failed to create game address detector. The provided arguments may be incorrect."); } this.pingTracker = RequestNewPingTracker(this.config.TrackingMode); this.pingTracker.Start(); InitIpc(); // Most of these can't be created using service injection because the service container only checks ctors for // exact types. this.ui = new PingUI(this.pingTracker, this.pluginInterface, dtrBar, this.config, RequestNewPingTracker); this.pingTracker.OnPingUpdated += this.ui.UpdateDtrBarPing; this.pluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi; this.pluginInterface.UiBuilder.Draw += this.ui.Draw; this.pluginCommandManager = new PluginCommandManager <PingPlugin>(this, commands); }
public override void OnUdpNetworkHandlerTick(float dt) { if (!GameNetwork.IsServer) { return; } float time = MBCommon.GetTime(MBCommon.TimeType.Mission); if ((double)this._lastTestSendTime >= (double)time + 10.0) { return; } IReadOnlyList <Agent> agents = Mission.Current.Agents; int count = agents.Count; this._lastTestSendTime = time; Agent toTest = agents[(int)(new Random().NextDouble() * (double)count)]; if (!toTest.IsActive()) { return; } GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new DebugAgentScaleOnNetworkTest(toTest, toTest.AgentScale)); GameNetwork.EndBroadcastModuleEventUnreliable(GameNetwork.EventBroadcastFlags.None); }
public static string MPHostKickPlayer(List <string> strings) { if (MultiplayerAdminComponent._multiplayerAdminComponent == null) { return("Failed: MultiplayerAdminComponent has not been created."); } if (!GameNetwork.IsServerOrRecorder) { return("Failed: Only the host can use mp_host commands."); } if (strings.Count != 1) { return("Failed: Input is incorrect."); } string str = strings[0]; foreach (NetworkCommunicator networkPeer in GameNetwork.NetworkPeers) { if (networkPeer.UserName == str) { DisconnectInfo disconnectInfo = networkPeer.PlayerConnectionInfo.GetParameter <DisconnectInfo>("DisconnectInfo") ?? new DisconnectInfo(); disconnectInfo.Type = DisconnectType.KickedByHost; networkPeer.PlayerConnectionInfo.AddParameter("DisconnectInfo", (object)disconnectInfo); GameNetwork.AddNetworkPeerToDisconnectAsServer(networkPeer); return("Player " + str + " has been kicked from the server."); } } return(str + " could not be found."); }
public void OnApplySettings() { MultiplayerOptions.Instance.InitializeOptionsFromUi(); GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new MultiplayerOptionsImmediate()); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); }
void IGameNetworkHandler.OnEndMultiplayer() { GameManagerBase.Current.OnGameNetworkEnd(); GameNetwork.DestroyComponent((UdpNetworkComponent)GameNetwork.GetNetworkComponent <LobbyNetworkComponent>()); GameNetwork.DestroyComponent((UdpNetworkComponent)GameNetwork.GetNetworkComponent <NetworkStatusReplicationComponent>()); GameNetwork.DestroyComponent((UdpNetworkComponent)GameNetwork.GetNetworkComponent <BaseNetworkComponent>()); }
void Awake() { if (!m_instance) { m_instance = this; } }
/// <summary> /// Loop do servidor. /// </summary> public static void Loop() { try { //Recebe os dados do world server WorldNetwork.ReceivedData(); // Verifica e tenta uma nova conexão com o game server GameNetwork.GameServerConnect(); // Recebe os dados do game server GameNetwork.GameServerReceiveData(); // Percorre todos os hexid e verifica se o tempo limite já foi ultrapassado ... // Se verdadeiro, é retirado da lista Authentication.VerifyHexID(); // Percorre todos os hexid de jogadores, se ambos hexid estiverem corretos, aceita a conexão Authentication.VerifyPlayerHexID(); if (Environment.TickCount >= tick + 1000) { CPS = count; tick = Environment.TickCount; count = 0; } count++; } catch (Exception ex) { throw new Exception($"Ocorreu um erro: {ex.Message}", ex); } }
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(); }
public void SetGlobalFrameSynched(ref MatrixFrame frame, bool isClient = false) { this._duration = 0.0f; this._timer = 0.0f; if (!(this.GameEntity.GetGlobalFrame() != frame)) { return; } if (GameNetwork.IsClientOrReplay) { this._lastSynchedFrame = (NativeObject)this.GameEntity.Parent != (NativeObject)null ? this.GameEntity.Parent.GetGlobalFrame().TransformToLocalNonOrthogonal(ref frame) : frame; this.SetSynchState(SynchedMissionObject.SynchState.SynchronizeFrame); } else { if (GameNetwork.IsServerOrRecorder) { GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new SetMissionObjectGlobalFrame((MissionObject)this, ref frame)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.AddToMissionRecord); } this.SetSynchState(SynchedMissionObject.SynchState.SynchronizeCompleted); this.GameEntity.SetGlobalFrame(frame); this._initialSynchFlags |= SynchedMissionObject.SynchFlags.SynchTransform; } }
public void SetAnimationAtChannelSynched( string animationName, int channelNo, float animationSpeed = 1f) { int animationIndexWithName1 = MBAnimation.GetAnimationIndexWithName(animationName); if (GameNetwork.IsServerOrRecorder) { int animationIndexWithName2 = MBAnimation.GetAnimationIndexWithName(this.GameEntity.Skeleton.GetAnimationAtChannel(channelNo)); bool flag = true; int num = animationIndexWithName1; if (animationIndexWithName2 == num && this.GameEntity.Skeleton.GetAnimationSpeedAtChannel(channelNo).ApproximatelyEqualsTo(animationSpeed) && (double)this.GameEntity.Skeleton.GetAnimationParameterAtChannel(channelNo) < 0.0199999995529652) { flag = false; } if (flag) { GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new SetMissionObjectAnimationAtChannel((MissionObject)this, channelNo, animationIndexWithName1, animationSpeed)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.AddToMissionRecord); this._initialSynchFlags |= SynchedMissionObject.SynchFlags.SynchAnimation; } } this.GameEntity.Skeleton.SetAnimationAtChannel(animationIndexWithName1, channelNo, animationSpeed); }
public int GetGoldGainsFromKillData( MPPerkObject.MPPerkHandler killerPerkHandler, MPPerkObject.MPPerkHandler assistingHitterPerkHandler, MultiplayerClassDivisions.MPHeroClass victimClass, bool isAssist) { int num1; if (isAssist) { num1 = (killerPerkHandler != null ? killerPerkHandler.GetRewardedGoldOnAssist() : 0) + (assistingHitterPerkHandler != null ? assistingHitterPerkHandler.GetGoldOnAssist() : 0); } else { int num2 = this.ControlledAgent != null?MultiplayerClassDivisions.GetMPHeroClassForCharacter(this.ControlledAgent.Character).TroopCost : 0; num1 = killerPerkHandler != null?killerPerkHandler.GetGoldOnKill((float)num2, (float)victimClass.TroopCost) : 0; } if (num1 > 0) { GameNetwork.BeginModuleEventAsServer(this.Peer); GameNetwork.WriteMessage((GameNetworkMessage) new TDMGoldGain(new List <KeyValuePair <ushort, int> >() { new KeyValuePair <ushort, int>((ushort)2048, num1) })); GameNetwork.EndModuleEventAsServer(); } return(num1); }
private bool HandleClientEventLobbyEquipmentUpdated( NetworkCommunicator peer, RequestTroopIndexChange message) { MissionPeer component = peer.GetComponent <MissionPeer>(); if (component == null) { return(false); } SpawnComponent missionBehaviour = this.Mission.GetMissionBehaviour <SpawnComponent>(); if (missionBehaviour == null) { return(false); } if (missionBehaviour.AreAgentsSpawning() && component.SelectedTroopIndex != message.SelectedTroopIndex) { component.SelectedTroopIndex = message.SelectedTroopIndex; GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new UpdateSelectedTroopIndex(peer, message.SelectedTroopIndex)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, peer); if (this.OnEquipmentRefreshed != null) { this.OnEquipmentRefreshed(component); } } return(true); }
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(); } }
private void CheckMorales() { if ((double)this._nextTimeToCheckForMorales < 0.0) { this._nextTimeToCheckForMorales = this.Mission.Time + 1f; } if ((double)this.Mission.Time < (double)this._nextTimeToCheckForMorales) { return; } ++this._nextTimeToCheckForMorales; float moraleGain; if (!this.GetMoraleGain(out moraleGain)) { return; } this._morale += moraleGain; this._morale = MBMath.ClampFloat(this._morale, -1f, 1f); GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new FlagDominationMoraleChangeMessage(this.MoraleRounded)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); this._gameModeFlagDominationClient?.OnMoraleChanged(this.MoraleRounded); MPPerkObject.RaiseEventForAllPeers(MPPerkCondition.PerkEventFlags.MoraleChange); }
void IGameNetworkHandler.OnStartMultiplayer() { GameNetwork.AddNetworkComponent <BaseNetworkComponent>(); GameNetwork.AddNetworkComponent <LobbyNetworkComponent>(); GameNetwork.AddNetworkComponent <NetworkStatusReplicationComponent>(); GameManagerBase.Current.OnGameNetworkBegin(); }
//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 override void HandleNewClientAfterLoadingFinished(NetworkCommunicator networkPeer) { VirtualPlayer virtualPlayer1 = networkPeer.VirtualPlayer; GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new InitializeLobbyPeer(networkPeer, virtualPlayer1.Id, virtualPlayer1.BannerCode, virtualPlayer1.BodyProperties, virtualPlayer1.ChosenBadgeIndex, -1)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.AddToMissionRecord | GameNetwork.EventBroadcastFlags.DontSendToPeers); foreach (NetworkCommunicator networkPeer1 in GameNetwork.NetworkPeers) { if (networkPeer1.IsSynchronized || networkPeer1 == networkPeer) { if (networkPeer1 != networkPeer && networkPeer1 != GameNetwork.MyPeer) { GameNetwork.BeginModuleEventAsServer(networkPeer1); GameNetwork.WriteMessage((GameNetworkMessage) new InitializeLobbyPeer(networkPeer, virtualPlayer1.Id, virtualPlayer1.BannerCode, virtualPlayer1.BodyProperties, virtualPlayer1.ChosenBadgeIndex, -1)); GameNetwork.EndModuleEventAsServer(); } VirtualPlayer virtualPlayer2 = networkPeer1.VirtualPlayer; if (!networkPeer.IsServerPeer) { GameNetwork.BeginModuleEventAsServer(networkPeer); GameNetwork.WriteMessage((GameNetworkMessage) new InitializeLobbyPeer(networkPeer1, virtualPlayer2.Id, virtualPlayer2.BannerCode, virtualPlayer2.BodyProperties, virtualPlayer2.ChosenBadgeIndex, -1)); GameNetwork.EndModuleEventAsServer(); } } } }
private async void HandleServerStartMultiplayer() { GameNetwork.PreStartMultiplayerOnServer(); BannerlordNetwork.StartMultiplayerLobbyMission(LobbyMissionType.Custom); if (Module.CurrentModule.StartMultiplayerGame(this._gameClient.CustomGameType, this._gameClient.CustomGameScene)) { ; } while (Mission.Current == null || Mission.Current.CurrentState != Mission.State.Continuing) { await Task.Delay(1); } GameNetwork.StartMultiplayerOnServer(9999); if (!this._gameClient.IsInGame) { return; } BannerlordNetwork.CreateServerPeer(); MBDebug.Print("Server: I finished loading and I am now visible to clients in the server list.", debugFilter: 17179869184UL); if (GameNetwork.IsDedicatedServer) { return; } GameNetwork.ClientFinishedLoading(GameNetwork.MyPeer); }
public void OnDuelStarted(Agent requesterAgent, Agent requesteeAgent) { switch (this.PlayerType) { case MissionRepresentativeBase.PlayerTypes.Client: if (this.IsMine) { Action duelStartedEvent = this.OnDuelStartedEvent; if (duelStartedEvent == null) { break; } duelStartedEvent(); break; } GameNetwork.BeginModuleEventAsServer(this.Peer); GameNetwork.WriteMessage((GameNetworkMessage) new DuelStarted(requesterAgent, requesteeAgent)); GameNetwork.EndModuleEventAsServer(); break; case MissionRepresentativeBase.PlayerTypes.Server: Action duelStartedEvent1 = this.OnDuelStartedEvent; if (duelStartedEvent1 == null) { break; } duelStartedEvent1(); break; } }
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 override void HandleNewClientConnect(PlayerConnectionInfo playerConnectionInfo) { NetworkCommunicator networkPeer = playerConnectionInfo.NetworkPeer; if (networkPeer.IsServerPeer) { return; } GameNetwork.BeginModuleEventAsServer(networkPeer); GameNetwork.WriteMessage((GameNetworkMessage) new MultiplayerOptionsInitial()); GameNetwork.EndModuleEventAsServer(); GameNetwork.BeginModuleEventAsServer(networkPeer); GameNetwork.WriteMessage((GameNetworkMessage) new MultiplayerOptionsImmediate()); GameNetwork.EndModuleEventAsServer(); if (BannerlordNetwork.LobbyMissionType != LobbyMissionType.Custom) { return; } bool inMission = false; string map = ""; string gameType = ""; if (GameNetwork.IsDedicatedServer && Mission.Current != null || !GameNetwork.IsDedicatedServer) { inMission = true; MultiplayerOptions.Instance.GetOptionFromOptionType(MultiplayerOptions.OptionType.Map).GetValue(out map); MultiplayerOptions.Instance.GetOptionFromOptionType(MultiplayerOptions.OptionType.GameType).GetValue(out gameType); } GameNetwork.BeginModuleEventAsServer(networkPeer); GameNetwork.WriteMessage((GameNetworkMessage) new InitializeCustomGameMessage(inMission, gameType, map)); GameNetwork.EndModuleEventAsServer(); }
public static void ServerSendServerMessageToEveryone(string message) { ChatBox._chatBox.OnServerMessage(message); GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.ServerMessage(message)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); }
public Framework(SigScanner scanner, Dalamud dalamud) { Address = new FrameworkAddressResolver(); Address.Setup(scanner); Log.Verbose("Framework address {FrameworkAddress}", Address.BaseAddress); if (Address.BaseAddress == IntPtr.Zero) { throw new InvalidOperationException("Framework is not initalized yet."); } // Hook virtual functions HookVTable(); // Initialize subsystems Libc = new LibcFunction(scanner); Gui = new GameGui(Address.GuiManager, scanner, dalamud); Network = new GameNetwork(dalamud, scanner); //Resource = new ResourceManager(dalamud, scanner); this.antiDebug = new AntiDebug(); }
private void OnAgentWentInOrRemoved(Agent agent, bool isAgentRemoved) { if (GameNetwork.IsServer) { this._agentTimers.Remove(agent); if (!isAgentRemoved) { MissionPeer missionPeer = agent.MissionPeer; NetworkCommunicator communicator = missionPeer != null?missionPeer.GetNetworkPeer() : (NetworkCommunicator)null; if (communicator != null && !communicator.IsServerPeer) { GameNetwork.BeginModuleEventAsServer(communicator); GameNetwork.WriteMessage((GameNetworkMessage) new SetBoundariesState(false)); GameNetwork.EndModuleEventAsServer(); } } } if (this.Mission.MainAgent != agent) { return; } this._mainAgentLeaveTimer = (MissionTimer)null; Action stopTime = this.StopTime; if (stopTime == null) { return; } stopTime(); }
void Start() { networkDiscovery = FindObjectOfType <NetworkDiscovery>(); gameNetwork = FindObjectOfType <GameNetwork>(); networkDiscovery.OnServerFound.AddListener(OnDiscoveredServer); }
private void StartPlayerKickPollOnServer( NetworkCommunicator pollCreatorPeer, NetworkCommunicator peer, bool banPlayer) { if (this._runningPoll == null) { this._runningPoll = (object)new MultiplayerPollComponent.KickPlayer() { playerPeer = peer }; this._runningPollStartTime = new int?(Environment.TickCount); if (!GameNetwork.IsDedicatedServer) { this.ShowPlayerKickPoll(peer, banPlayer); } GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.KickPlayerPoll(peer, banPlayer)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); } else { this.RejectPollStartServer(pollCreatorPeer, MultiplayerPollComponent.PollRejectReason.APollIsAlreadyRunning); } }
private void StartGameChangePollOnServer( NetworkCommunicator pollCreatorPeer, string gameType, string scene) { if (this._runningPoll == null) { this._runningPoll = (object)new MultiplayerPollComponent.ChangeGame() { GameType = gameType, MapName = scene }; this._runningPollStartTime = new int?(Environment.TickCount); if (!GameNetwork.IsDedicatedServer) { this.ShowGameChangePoll(gameType, scene); } GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.ChangeGamePoll(gameType, scene)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); } else { this.RejectPollStartServer(pollCreatorPeer, MultiplayerPollComponent.PollRejectReason.APollIsAlreadyRunning); } }
public void HandleAgentVisualSpawning( NetworkCommunicator spawningNetworkPeer, AgentBuildData spawningAgentBuildData, int troopCountInFormation = 0) { MissionPeer component = spawningNetworkPeer.GetComponent <MissionPeer>(); component.HasSpawnedAgentVisuals = true; component.EquipmentUpdatingExpired = false; if (!this.IsGameModeHidingAllAgentVisuals) { GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new CreateAgentVisuals(spawningNetworkPeer, spawningAgentBuildData, component.SelectedTroopIndex, troopCountInFormation)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.ExcludeOtherTeamPlayers, spawningNetworkPeer); } else { if (spawningNetworkPeer.IsServerPeer) { return; } GameNetwork.BeginModuleEventAsServer(spawningNetworkPeer); GameNetwork.WriteMessage((GameNetworkMessage) new CreateAgentVisuals(spawningNetworkPeer, spawningAgentBuildData, component.SelectedTroopIndex, troopCountInFormation)); GameNetwork.EndModuleEventAsServer(); } }
private void UpdateRoundScores() { foreach (MissionScoreboardComponent.MissionScoreboardSide side in this._sides) { if (side != null && side.Side == this.RoundWinner) { this._roundWinnerList.Add(this.RoundWinner); if (this.RoundWinner != BattleSideEnum.None) { ++this._sides[(int)this.RoundWinner].SideScore; } } } if (this.OnRoundPropertiesChanged != null) { this.OnRoundPropertiesChanged(); } if (!GameNetwork.IsServer) { return; } int defenderTeamScore = this._scoreboardSides != MissionScoreboardComponent.ScoreboardSides.OneSide ? this._sides[0].SideScore : 0; GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new NetworkMessages.FromServer.UpdateRoundScores(this._sides[1].SideScore, defenderTeamScore)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.None); }
public virtual void TeleportUserAgentsToMachine(List <Agent> agentList) { int num1 = 0; bool flag; do { ++num1; flag = false; foreach (Agent agent in agentList) { if (agent.AIMoveToGameObjectIsEnabled()) { flag = true; WorldFrame userFrameForAgent = this.UsableMachine.GetTargetStandingPointOfAIAgent(agent).GetUserFrameForAgent(agent); userFrameForAgent.Rotation.f.z = 0.0f; double num2 = (double)userFrameForAgent.Rotation.f.Normalize(); if ((double)(agent.Position.AsVec2 - userFrameForAgent.Origin.AsVec2).LengthSquared > 9.99999974737875E-05 || (double)(agent.GetMovementDirection() - userFrameForAgent.Rotation.f).LengthSquared > 9.99999974737875E-05) { agent.TeleportToPosition(userFrameForAgent.Origin.GetGroundVec3()); agent.SetMovementDirection(ref userFrameForAgent.Rotation.f); if (GameNetwork.IsServerOrRecorder) { GameNetwork.BeginBroadcastModuleEvent(); GameNetwork.WriteMessage((GameNetworkMessage) new AgentTeleportToFrame(agent, userFrameForAgent.Origin.GetGroundVec3(), userFrameForAgent.Rotation.f.AsVec2)); GameNetwork.EndBroadcastModuleEvent(GameNetwork.EventBroadcastFlags.AddToMissionRecord); } } } } }while (flag && num1 < 10); }
public static bool Init() { if (Instance != null) { Log.LogError("GameNetwork already created"); return false; } Instance = new GameNetwork(); Instance.ReadTable = new List<MessageToRead>(); Instance.MessagesToRead = new LinkedList<ReceivedMessage>(); Instance.MessagesToSend = new LinkedList<SendingMessage>(); Instance.WriteMessages = new LinkedList<SendingMessage>(); Instance.ReadMessages = new LinkedList<ReceivedMessage>(); Instance.client = new TcpClient(); Instance.rand = new System.Random(); Instance.ReadLocker = new object(); Instance.WriteLocker = new object(); Instance.IsError = false; return true; }
public static void StopAndRelase() { Instance.Stop(); Instance=null; }