Пример #1
0
 public PlayingEnvironment(SpawnpointLocation spawnpoint, Wingsuit pilot, ParachuteConfig parachuteConfig,
                           PilotCameraMountId selectedMount = PilotCameraMountId.Orbit)
 {
     Spawnpoint          = spawnpoint;
     Pilot               = pilot;
     ParachuteConfig     = parachuteConfig;
     SelectedCameraMount = selectedMount;
 }
Пример #2
0
    public void SetTarget(Wingsuit pilot)
    {
        // Unsubscribe from old player's events
        if (_target && _target.CollisionEventSource)
        {
            _target.CollisionEventSource.OnCollisionEntered -= OnPlayerCollisionEntered;
        }

        _target = pilot;

        // Subscribe to new player's events
        _target.CollisionEventSource.OnCollisionEntered += OnPlayerCollisionEntered;
    }
Пример #3
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);
    }
Пример #4
0
 public PlayerSpawned(Wingsuit player)
 {
     Player = player;
 }
Пример #5
0
 public PlayingEnvironment UpdatePilot(Wingsuit activePilot)
 {
     return(new PlayingEnvironment(Spawnpoint, activePilot, ParachuteConfig, SelectedCameraMount));
 }
Пример #6
0
    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;
        }
    }