private IEnumerator <WaitCommand> OnEnter(PlayingEnvironment environment) { _environment = environment; _parachute = _data.ImmersionSpawner.Create(environment.ParachuteConfig, "ImmersionParachute"); _data.ParachuteController.Parachute = _parachute; _parachute.AttachToPilot(environment.Pilot, Parachute.InflightUnfoldOrientation, _data.GameSettingsProvider); // TODO This is a hack to compensate for the editor // that misuses the pilot for its own purposes. // We actually need a second pilot for editor purposes environment.Pilot.DisableWings(); environment.Pilot.SetPhysical(); environment.Pilot.PilotAnimator.SetState(PilotAnimatorState.Parachute); SwitchToMount(environment.SelectedCameraMount); _data.GameHud.SetTarget(_parachute.Pilot.FlightStatistics, AvatarType.Parachute); _data.GameHud.Activate(); _parachute.Deploy(); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; if (_data.CameraManager.Rig.Shake) { _data.CameraManager.Rig.Shake.enabled = true; } _data.GameClock.Resume(); _data.FixedClock.Resume(); _data.SoundMixer.Unpause(SoundLayer.GameEffects); // Indicate that we have unfolded the parachute once, i.e. the player know how to do it if (_data.GameSettingsProvider.ActiveSettings.Tutorial.HasUnfoldedParachute != true) { var gameSettings = _data.GameSettingsProvider.ActiveSettings; gameSettings.Tutorial.HasUnfoldedParachute = true; _data.GameSettingsProvider.UpdateGameSettings(gameSettings); } yield return(WaitCommand.DontWait); }
void CreateEditorChute(ParachuteConfig config, ImmutableTransform transform) { if (_editorParachute != null) { _editorParachute.DetachPilot(); GameObject.Destroy(_editorParachute.Root.gameObject); } _editorParachute = _data.EditorSpawner.Create(config, transform, "EditorParachute"); _environment.Pilot.SetKinematic(); _environment.Pilot.OnDespawn(); _environment.Pilot.transform.position = transform.Position; _environment.Pilot.transform.rotation = transform.Rotation; _environment.Pilot.OnSpawn(); _environment.Pilot.SetKinematic(); _editorParachute.AttachToPilot(_environment.Pilot, Parachute.DefaultUnfoldOrientation, _data.GameSettingsProvider); UnityParachuteFactory.SetKinematic(_editorParachute); _data.EditorCamera.SetTarget(_editorParachute); _editorParachuteChanges.OnNext(_editorParachute); }