private void SetLaunchSite(string launchSite) { _currentLaunchSite = launchSite; EditorLogic.fetch.launchSiteName = launchSite; Extensions.WriteSetting("lastLaunchSite", launchSite); Extensions.PostScreenMessage("Launch Site set to: " + launchSite, 5); }
public static void RestoreCameraParent() { // Only execute if we're actually controlling the camera. if (!ManualControl) { return; } // Restore camera control to vessel. FlightCamera.fetch.transform.parent = _originalParentTransform; _originalParentTransform = null; ManualControl = false; ActiveFlightCamera.ActivateUpdate(); // Say something. Extensions.PostScreenMessage("[KerbTown] FlightCamera restored to vessel."); }
public static void SetCameraParent(Transform parentTransform) { // Assign FlightCamera instance to public var. ActiveFlightCamera = FlightCamera.fetch; // For replacing the camera when done editing. if (_originalParentTransform == null) { _originalParentTransform = ActiveFlightCamera.transform.parent; } // For translating the camera if (ActiveCameraPivot != null) { Object.Destroy(ActiveCameraPivot); } ActiveCameraPivot = new GameObject("KtCamPivot"); ActiveCameraPivot.transform.parent = parentTransform; ActiveCameraPivot.transform.localPosition = Vector3.zero; ActiveCameraPivot.transform.localRotation = Quaternion.identity; // Switch to active object. ActiveFlightCamera.transform.parent = ActiveCameraPivot.transform; // Use the FlightCamera sensitivity for the speed. CameraSpeed = ActiveFlightCamera.orbitSensitivity; // Take control of the flight camera. ActiveFlightCamera.DeactivateUpdate(); // Instruct LateUpdate that we're controlling the camera manually now. ManualControl = true; // Say something. Extensions.PostScreenMessage("[KerbTown] FlightCamera switched to: " + parentTransform.name); }
public void Manipulate(bool objectInactive, Color highlightColor) { if (StaticGameObject == null) { Extensions.LogWarning(NameID + " has no GameObject attached."); return; } #region Colliders if (_colliderComponents == null || _colliderComponents.Count == 0) { Collider[] colliderList = StaticGameObject.GetComponentsInChildren <Collider>(); if (colliderList.Length > 0) { _colliderComponents = new List <Collider>(colliderList); } else { Extensions.LogWarning(NameID + " has no collider components."); } } if (_colliderComponents != null && _colliderComponents.Count > 0) { foreach (Collider collider in _colliderComponents) { collider.enabled = !objectInactive; } } #endregion #region Highlight if ((_rendererComponents == null || _rendererComponents.Count == 0)) { Renderer[] rendererList = StaticGameObject.GetComponentsInChildren <Renderer>(); if (rendererList.Length == 0) { Extensions.PostScreenMessage("[KerbTown] Active Vessel not within visibility range."); Extensions.LogWarning(NameID + " has no renderer components."); return; } _rendererComponents = new List <Renderer>(rendererList); } if (!objectInactive) // Deactivate. { highlightColor = new Color(0, 0, 0, 0); KtCamera.RestoreCameraParent(); } else // Activate { if ( Vector3.Distance(PQSCityComponent.sphere.transform.position, PQSCityComponent.transform.position) >= PQSCityComponent.lod[0].visibleRange) { KtCamera.SetCameraParent(StaticGameObject.transform); } else { Extensions.PostScreenMessage( "[KerbTown] Ignoring camera switch. Static object is not within the visible range of your active vessel."); } } foreach (Renderer renderer in _rendererComponents) { renderer.material.SetFloat("_RimFalloff", 1.8f); renderer.material.SetColor("_RimColor", highlightColor); } #endregion }