public void Awake() { _currentPlayer = null; _playerActionMap = _pilotActionMapProvider.ActionMapRef; if (_gameSettingsProvider != null) { _gameSettingsProvider.SettingChanges.Subscribe(ApplySettings); } }
void RaceStarted(RaceMessage.RaceStarted message) { ResetState(); _database.FindObjects(ObjectTypes.Player, _racers); _ownRacer = _database.FindObject(ObjectTypes.Player, ObjectRole.Owner); // Position all racers for (int i = 0; i < message.RacerPositions.Count; i++) { var racerPosition = message.RacerPositions[i]; var racer = _database.Find(racerPosition.RacerId); racer.GameObject.transform.position = racerPosition.Position; racer.GameObject.transform.rotation = racerPosition.Rotation; } // Highlight first ring HighlightCheckpoint(0); }
public IEnumerator <WaitCommand> Despawn() { var networkSystems = _activeNetwork.NetworkSystems; if (_onReplicatedObjectRemoved == null) { _onReplicatedObjectRemoved = new Event(networkSystems.ObjectStore, "ObjectRemoved"); } var despawnRequest = networkSystems.MessagePool.GetMessage <GameMessages.DespawnPlayerRequest>(); _activeNetwork.SendToAuthority(despawnRequest); _currentPlayer = null; _wingsuit = null; //yield return asyncDespawn.WaitUntilReady; // TODO This is a hack, we actually have to wait until the despawn is confirmed // in a multiplayer setting before we can continue yield return(WaitCommand.DontWait); }
public IEnumerator <WaitCommand> Respawn(SpawnpointLocation spawnpoint) { if (!_isRespawning) { _isRespawning = true; if (_currentPlayer != null && _currentPlayer.GameObject.activeInHierarchy) { _currentPlayer = null; _wingsuit = null; } var networkSystems = _activeNetwork.NetworkSystems; if (_onReplicatedObjectAdded == null) { _onReplicatedObjectAdded = new Event(networkSystems.ObjectStore, "ObjectAdded"); } // Wait until a player has been created by the replicated object store var asyncPlayer = AsyncResult <ReplicatedObject> .SingleResultFromEvent( _onReplicatedObjectAdded, IsOwnedPilot); var respawnRequest = networkSystems.MessagePool.GetMessage <GameMessages.RespawnPlayerRequest>(); respawnRequest.Content.Spawnpoint = spawnpoint.AsWingsuitLocation(); respawnRequest.Content.InputPitch = _playerActionMap.V.PollAxis(WingsuitAction.Pitch) + _playerActionMap.V.PollMouseAxis(WingsuitAction.Pitch); respawnRequest.Content.InputRoll = _playerActionMap.V.PollAxis(WingsuitAction.Roll) + _playerActionMap.V.PollMouseAxis(WingsuitAction.Roll); _activeNetwork.SendToAuthority(respawnRequest); yield return(asyncPlayer.WaitUntilReady); _currentPlayer = asyncPlayer.Result; var playerDeps = new DependencyContainer(); playerDeps.AddDependency("gameClock", _gameClock); DependencyInjector.Default.Inject(_currentPlayer.GameObject, playerDeps, overrideExisting: true); _wingsuit = _currentPlayer.GameObject.GetComponent <Wingsuit>(); _wingsuit.AlphaManager.SetAlpha(1f); // if (_activeNetwork.AuthorityConnectionId != ConnectionId.Self) // { // SwitchToActiveMount(); // } // else // { // Debug.Log("Ain't gonna switch no mount for yourself yo, you be dedicated!"); // } if (_gameSettingsProvider != null) { ApplySettings(_gameSettingsProvider.ActiveSettings); } var pilot = _currentPlayer.GameObject.GetComponent <Wingsuit>(); _eventSystem.Emit(new Events.PlayerSpawned(pilot)); _isRespawning = false; } }