public ThinClient() { m_StateMachine = new StateMachine <ClientState>(); m_StateMachine.Add(ClientState.Browsing, EnterBrowsingState, UpdateBrowsingState, LeaveBrowsingState); m_StateMachine.Add(ClientState.Connecting, EnterConnectingState, UpdateConnectingState, null); m_StateMachine.Add(ClientState.Loading, EnterLoadingState, UpdateLoadingState, null); m_StateMachine.Add(ClientState.Playing, EnterPlayingState, UpdatePlayingState, LeavePlayingState); m_StateMachine.SwitchTo(ClientState.Browsing); m_GameWorld = new GameWorld("ClientWorld"); m_Transport = new SocketTransport(); m_NetworkClient = new NetworkClient(m_Transport); if (Application.isEditor || Game.game.buildId == "AutoBuild") { NetworkClient.clientVerifyProtocol.Value = "0"; } m_NetworkClient.UpdateClientConfig(); m_NetworkStatistics = new NetworkStatisticsClient(m_NetworkClient); m_ChatSystem = new ChatSystemClient(m_NetworkClient); GameDebug.Log("Network client initialized"); m_requestedPlayerSettings.playerName = ClientGameLoop.clientPlayerName.Value; m_requestedPlayerSettings.teamId = -1; }
public ThinClientGameWorld(GameWorld world, NetworkClient networkClient, NetworkStatisticsClient networkStatistics) { m_NetworkClient = networkClient; m_NetworkStatistics = networkStatistics; m_NullSnapshotConsumer = new NullSnapshotConsumer(); m_GameWorld = world; }
public ClientGameWorld(GameWorld world, NetworkClient networkClient, NetworkStatisticsClient _networkStatistics, BundledResourceManager resourceSystem) { _gameWorld = world; _networkClient = networkClient; this._networkStatistics = _networkStatistics; m_CharacterModule = new CharacterModuleClient(_gameWorld, resourceSystem); m_PlayerModule = new PlayerModuleClient(_gameWorld); m_ReplicatedEntityModule = new ReplicatedEntityModuleClient(_gameWorld, resourceSystem); }
public bool Init(string[] args) { m_StateMachine = new StateMachine <ClientState>(); m_StateMachine.Add(ClientState.Browsing, EnterBrowsingState, UpdateBrowsingState, LeaveBrowsingState); m_StateMachine.Add(ClientState.Connecting, EnterConnectingState, UpdateConnectingState, null); m_StateMachine.Add(ClientState.Loading, EnterLoadingState, UpdateLoadingState, null); m_StateMachine.Add(ClientState.Playing, EnterPlayingState, UpdatePlayingState, LeavePlayingState); #if UNITY_EDITOR Game.game.levelManager.UnloadLevel(); World.DisposeAllWorlds(); #endif m_GameWorld = new GameWorld("ClientWorld"); m_NetworkTransport = new SocketTransport(); m_NetworkClient = new NetworkClient(m_NetworkTransport); if (Application.isEditor || Game.game.buildId == "AutoBuild") { NetworkClient.clientVerifyProtocol.Value = "0"; } m_NetworkClient.UpdateClientConfig(); m_NetworkStatistics = new NetworkStatisticsClient(m_NetworkClient); m_ChatSystem = new ChatSystemClient(m_NetworkClient); GameDebug.Log("Network client initialized"); m_requestedPlayerSettings.playerName = clientPlayerName.Value; m_requestedPlayerSettings.teamId = -1; Console.AddCommand("disconnect", CmdDisconnect, "Disconnect from server if connected", this.GetHashCode()); Console.AddCommand("prediction", CmdTogglePrediction, "Toggle prediction", this.GetHashCode()); Console.AddCommand("runatserver", CmdRunAtServer, "Run command at server", this.GetHashCode()); Console.AddCommand("respawn", CmdRespawn, "Force a respawn", this.GetHashCode()); Console.AddCommand("nextchar", CmdNextChar, "Select next character", this.GetHashCode()); Console.AddCommand("nc", CmdNextChar, "short version of nextchar", this.GetHashCode()); Console.AddCommand("nextteam", CmdNextTeam, "Select next team", this.GetHashCode()); Console.AddCommand("spectator", CmdSpectator, "Select spectator cam", this.GetHashCode()); Console.AddCommand("matchmake", CmdMatchmake, "matchmake <hostname[:port]/{projectid}>: Find and join a server", this.GetHashCode()); if (args.Length > 0) { targetServer = args[0]; m_StateMachine.SwitchTo(ClientState.Connecting); } else { m_StateMachine.SwitchTo(ClientState.Browsing); } GameDebug.Log("Client initialized"); return(true); }
public bool Init(string[] args) { _stateMachine = new StateMachine <ClientState>(); _stateMachine.Add(ClientState.Connecting, EnterConnectingState, UpdateConnectingState, null); _stateMachine.Add(ClientState.Loading, EnterLoadingState, UpdateLoadingState, null); _stateMachine.Add(ClientState.Playing, EnterPlayingState, UpdatePlayingState, null); _stateMachine.Add(ClientState.Leaving, EnterLeavingState, UpdateLeavingState, null); _networkClient = new NetworkClient(new ClientPhotonNetworkTransport()); _networkStatisticsClient = new NetworkStatisticsClient(_networkClient); _networkClient.UpdateClientConfig(); _stateMachine.SwitchTo(ClientState.Connecting); return(true); }
public ClientGameWorld(GameWorld world, NetworkClient networkClient, NetworkStatisticsClient networkStatistics, BundledResourceManager resourceSystem) { m_NetworkClient = networkClient; m_NetworkStatistics = networkStatistics; m_GameWorld = world; m_CharacterModule = new CharacterModuleClient(m_GameWorld, resourceSystem); m_ProjectileModule = new ProjectileModuleClient(m_GameWorld, resourceSystem); m_HitCollisionModule = new HitCollisionModule(m_GameWorld, 1, 1); m_PlayerModule = new PlayerModuleClient(m_GameWorld); m_SpectatorCamModule = new SpectatorCamModuleClient(m_GameWorld); m_EffectModule = new EffectModuleClient(m_GameWorld, resourceSystem); m_ReplicatedEntityModule = new ReplicatedEntityModuleClient(m_GameWorld, resourceSystem); m_ItemModule = new ItemModule(m_GameWorld); m_ragdollSystem = new RagdollModule(m_GameWorld); m_GameModeSystem = m_GameWorld.GetECSWorld().CreateManager <GameModeSystemClient>(m_GameWorld); m_ClientFrontendUpdate = m_GameWorld.GetECSWorld().CreateManager <ClientFrontendUpdate>(m_GameWorld); m_DestructiblePropSystemClient = m_GameWorld.GetECSWorld().CreateManager <DestructiblePropSystemClient>(m_GameWorld); m_ApplyGrenadePresentation = m_GameWorld.GetECSWorld().CreateManager <ApplyGrenadePresentation>(m_GameWorld); m_UpdatePresentationOwners = m_GameWorld.GetECSWorld().CreateManager <UpdatePresentationOwners>( m_GameWorld, resourceSystem); m_HandlePresentationOwnerDespawn = m_GameWorld.GetECSWorld().CreateManager <HandlePresentationOwnerDesawn>(m_GameWorld); m_moverUpdate = m_GameWorld.GetECSWorld().CreateManager <MoverUpdate>(m_GameWorld); m_TeleporterSystemClient = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemClient>(m_GameWorld); m_SpinSystem = m_GameWorld.GetECSWorld().CreateManager <SpinSystem>(m_GameWorld); m_HandleNamePlateOwnerSpawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateSpawn>(m_GameWorld); m_HandleNamePlateOwnerDespawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateDespawn>(m_GameWorld); m_UpdateNamePlates = m_GameWorld.GetECSWorld().CreateManager <UpdateNamePlates>(m_GameWorld); m_GameModeSystem.SetLocalPlayerId(m_NetworkClient.clientId); m_TwistSystem = new TwistSystem(m_GameWorld); m_FanSystem = new FanSystem(m_GameWorld); m_TranslateScaleSystem = new TranslateScaleSystem(m_GameWorld); }
public ClientGameWorld(GameWorld world, NetworkClient networkClient, NetworkStatisticsClient networkStatistics, BundledResourceManager resourceSystem) { m_NetworkClient = networkClient; m_NetworkStatistics = networkStatistics; m_GameWorld = world; m_CharacterModule = new CharacterModuleClient(m_GameWorld, resourceSystem); m_ProjectileModule = new ProjectileModuleClient(m_GameWorld, resourceSystem); m_HitCollisionModule = new HitCollisionModule(m_GameWorld, 1, 1); m_PlayerModule = new PlayerModuleClient(m_GameWorld); m_DebugPrimitiveModule = new DebugPrimitiveModule(m_GameWorld, 1.0f, 0); m_SpectatorCamModule = new SpectatorCamModuleClient(m_GameWorld); m_EffectModule = new EffectModuleClient(m_GameWorld, resourceSystem); m_ReplicatedEntityModule = new ReplicatedEntityModuleClient(m_GameWorld, resourceSystem); m_WeaponsModule = new WeaponsModule(m_GameWorld, resourceSystem, false); m_BonusModule = new BonusModuleClient(m_GameWorld, resourceSystem); m_ragdollSystem = new RagdollModule(m_GameWorld); m_GameModeSystem = m_GameWorld.GetECSWorld().CreateManager <GameModeSystemClient>(m_GameWorld, Game.game.clientFrontend.scoreboardPanel.uiBinding, Game.game.clientFrontend.gameScorePanel); m_ClientFrontendUpdate = m_GameWorld.GetECSWorld().CreateManager <ClientFrontendUpdate>(m_GameWorld); m_DestructiblePropSystemClient = m_GameWorld.GetECSWorld().CreateManager <DestructiblePropSystemClient>(m_GameWorld); m_InterpolateGrenadeSystem = m_GameWorld.GetECSWorld().CreateManager <InterpolateGrenadePresentation>(m_GameWorld); m_ApplyGrenadePresentation = m_GameWorld.GetECSWorld().CreateManager <ApplyGrenadePresentation>(m_GameWorld); m_moverUpdate = m_GameWorld.GetECSWorld().CreateManager <MoverUpdate>(m_GameWorld); m_TeleporterSystemClient = m_GameWorld.GetECSWorld().CreateManager <TeleporterSystemClient>(m_GameWorld); m_SpinSystem = m_GameWorld.GetECSWorld().CreateManager <SpinSystem>(m_GameWorld); m_HandleNamePlateOwnerSpawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateSpawn>(m_GameWorld); m_HandleNamePlateOwnerDespawn = m_GameWorld.GetECSWorld().CreateManager <HandleNamePlateDespawn>(m_GameWorld); m_UpdateNamePlates = m_GameWorld.GetECSWorld().CreateManager <UpdateNamePlates>(m_GameWorld); m_GameModeSystem.SetLocalPlayerId(m_NetworkClient.clientId); m_TwistSystem = new TwistSystem(m_GameWorld); m_FanSystem = new FanSystem(m_GameWorld); m_TranslateScaleSystem = new TranslateScaleSystem(m_GameWorld); }
public ThinClient() { m_StateMachine = new StateMachine <ClientState>(); m_StateMachine.Add(ClientState.Browsing, EnterBrowsingState, UpdateBrowsingState, LeaveBrowsingState); m_StateMachine.Add(ClientState.Connecting, EnterConnectingState, UpdateConnectingState, null); m_StateMachine.Add(ClientState.Loading, EnterLoadingState, UpdateLoadingState, null); m_StateMachine.Add(ClientState.Playing, EnterPlayingState, UpdatePlayingState, LeavePlayingState); m_StateMachine.SwitchTo(m_GameWorld, ClientState.Browsing); #pragma warning disable 618 // we're keeping World.Active until we can properly remove them all // TODO (timj) not compatible with dots netcode m_GameWorld = World.Active; World.Active.CreateSystem <GameTimeSystem>(); #pragma warning restore 618 m_Transport = new SocketTransport(); m_NetworkClient = new NetworkClient(m_Transport); if (Application.isEditor || Game.game.buildId == "AutoBuild") { NetworkClient.clientVerifyProtocol.Value = "0"; } m_NetworkClient.UpdateClientConfig(); m_NetworkStatistics = new NetworkStatisticsClient(m_NetworkClient); m_ChatSystem = new ChatSystemClient(); GameDebug.Log("Network client initialized"); m_requestedPlayerSettings.playerName = ClientGameLoop.clientPlayerName.Value; m_requestedPlayerSettings.teamId = -1; }
public bool Init(string[] args) { m_StateMachine = new StateMachine <ClientState>(); m_StateMachine.Add(ClientState.Browsing, EnterBrowsingState, UpdateBrowsingState, LeaveBrowsingState); m_StateMachine.Add(ClientState.Connecting, EnterConnectingState, UpdateConnectingState, null); m_StateMachine.Add(ClientState.Loading, EnterLoadingState, UpdateLoadingState, null); m_StateMachine.Add(ClientState.Playing, EnterPlayingState, UpdatePlayingState, LeavePlayingState); #if UNITY_EDITOR Game.game.levelManager.UnloadLevel(); #endif m_GameWorld = new GameWorld("ClientWorld"); m_NetworkTransport = new SocketTransport(); m_NetworkClient = new NetworkClient(m_NetworkTransport); if (Application.isEditor || Game.game.buildId == "AutoBuild") { NetworkClient.clientVerifyProtocol.Value = "0"; } m_NetworkClient.UpdateClientConfig(); m_NetworkStatistics = new NetworkStatisticsClient(m_NetworkClient); m_ChatSystem = new ChatSystemClient(m_NetworkClient); GameDebug.Log("Network client initialized"); m_requestedPlayerSettings.playerName = clientPlayerName.Value; m_requestedPlayerSettings.teamId = -1; Console.AddCommand("disconnect", CmdDisconnect, "Disconnect from server if connected", this.GetHashCode()); Console.AddCommand("prediction", CmdTogglePrediction, "Toggle prediction", this.GetHashCode()); Console.AddCommand("runatserver", CmdRunAtServer, "Run command at server", this.GetHashCode()); Console.AddCommand("respawn", CmdRespawn, "Force a respawn", this.GetHashCode()); Console.AddCommand("nextchar", CmdNextChar, "Select next character", this.GetHashCode()); Console.AddCommand("nextteam", CmdNextTeam, "Select next character", this.GetHashCode()); Console.AddCommand("spectator", CmdSpectator, "Select spectator cam", this.GetHashCode()); Console.AddCommand("matchmake", CmdMatchmake, "matchmake <hostname[:port]/{projectid}>: Find and join a server", this.GetHashCode()); if (args.Length > 0) { targetServer = args[0]; m_StateMachine.SwitchTo(ClientState.Connecting); } else { m_StateMachine.SwitchTo(ClientState.Browsing); } ReplicatedPrefabMgr.Initialize(); ClientServerSystemManager.InitClientSystems(); World.Active.GetExistingSystem <TickClientSimulationSystem>().Enabled = true; World.Active.GetExistingSystem <TickClientPresentationSystem>().Enabled = true; Unity.Networking.Transport.NetworkEndPoint ep = Unity.Networking.Transport.NetworkEndPoint.Parse(targetServer, (ushort)NetworkConfig.netcodeServerPort); World clientWorld = ClientServerSystemManager.clientWorld; EntityManager em = clientWorld.EntityManager; Entity ent = clientWorld.GetExistingSystem <NetworkStreamReceiveSystem>().Connect(ep); em.AddComponentData(ent, new NetworkStreamInGame()); GameDebug.Log("Client initialized"); return(true); }