public void CheckStowaways() { // Now we need to make sure that the list of portraits in the GUI conforms to what actually is in the active vessel. // This is important because IVA/EVA buttons clicked on kerbals that are not in the active vessel cause problems // that I can't readily debug, and it shouldn't happen anyway. // First, every pod should check through the list of portaits and remove everyone who is not from the active vessel, or NO vessel. var stowaways = new List <Kerbal>(); foreach (Kerbal thatKerbal in KerbalGUIManager.ActiveCrew) { if (thatKerbal.InPart == null) { stowaways.Add(thatKerbal); } else { if (thatKerbal.InVessel.id != FlightGlobals.ActiveVessel.id) { stowaways.Add(thatKerbal); } } } foreach (Kerbal thatKerbal in stowaways) { KerbalGUIManager.RemoveActiveCrew(thatKerbal); } // Only the pods in the active vessel should be doing this since the list refers to them. if (FlightGlobals.ActiveVessel.id == vessel.id) { // Then, every pod should check the list of seats in itself and see if anyone is missing who should be present. foreach (InternalSeat seat in part.internalModel.seats) { if (seat.kerbalRef != null && !KerbalGUIManager.ActiveCrew.Contains(seat.kerbalRef)) { if (seat.kerbalRef.protoCrewMember.rosterStatus != ProtoCrewMember.RosterStatus.Dead || seat.kerbalRef.protoCrewMember.type != ProtoCrewMember.KerbalType.Unowned) { KerbalGUIManager.AddActiveCrew(seat.kerbalRef); } } } } }
private void Start() { GameEvents.onVesselWasModified.Add(vesselCheck); GameEvents.onVesselChange.Add(vesselCheck); GameEvents.OnMapExited.Add(mapTimer); manager = findKerbalGUIManager(); careerMode = HighLogic.CurrentGame.Mode == Game.Modes.CAREER; if (manager == null) Destroy(this); reload = true; if (!loaded) { loaded = true; atlas = GameDatabase.Instance.GetTexture("PortraitStats/Icons/Atlas", false); settingsFile = GameDatabase.Instance.GetConfigNode("PortraitStats/Settings/Portrait_Stats_Config"); if (settingsFile != null) { if (settingsFile.HasValue("traitToolTip")) { if (!bool.TryParse(settingsFile.GetValue("traitToolTip"), out traitTooltip)) traitTooltip = true; } if (settingsFile.HasValue("expToolTip")) bool.TryParse(settingsFile.GetValue("expToolTip"), out expTooltip); if (settingsFile.HasValue("pilotColor")) pilotColor = parseColor(settingsFile, "pilotColor", pilotColor); if (settingsFile.HasValue("engineerColor")) engineerColor = parseColor(settingsFile, "engineerColor", engineerColor); if (settingsFile.HasValue("scientistColor")) scientistColor = parseColor(settingsFile, "scientistColor", scientistColor); if (settingsFile.HasValue("touristColor")) touristColor = parseColor(settingsFile, "touristColor", touristColor); if (settingsFile.HasValue("unknownClassColor")) unknownColor = parseColor(settingsFile, "unknownClassColor", unknownColor); } } RenderingManager.AddToPostDrawQueue(5, drawLabels); }
public override void OnUpdate() { // In the editor, none of this logic should matter, even though the IVA probably exists already. if (HighLogic.LoadedSceneIsEditor) { return; } // If the root part changed, or the IVA is mysteriously missing, we reset it and take note of where it ended up. if (vessel.rootPart != knownRootPart || lastActiveVessel != FlightGlobals.ActiveVessel || part.internalModel == null) { ResetIVA(); } // Now we need to make sure that the list of portraits in the GUI conforms to what actually is in the active vessel. // This is important because IVA/EVA buttons clicked on kerbals that are not in the active vessel cause problems // that I can't readily debug, and it shouldn't happen anyway. // Only the pods in the active vessel should be doing it since the list refers to them. if (vessel.isActiveVessel) { // First, every pod should check through the list of portaits and remove everyone who is from some other vessel, or NO vessel. var stowaways = new List <Kerbal>(); foreach (Kerbal thatKerbal in KerbalGUIManager.ActiveCrew) { if (thatKerbal.InPart == null) { stowaways.Add(thatKerbal); } else { if (thatKerbal.InVessel != vessel) { stowaways.Add(thatKerbal); } } } foreach (Kerbal thatKerbal in stowaways) { KerbalGUIManager.RemoveActiveCrew(thatKerbal); } // Then, every pod should check the list of seats in itself and see if anyone is missing who should be present. foreach (InternalSeat seat in part.internalModel.seats) { if (seat.kerbalRef != null && !KerbalGUIManager.ActiveCrew.Contains(seat.kerbalRef)) { if (seat.kerbalRef.protoCrewMember.rosterStatus != ProtoCrewMember.RosterStatus.Dead || seat.kerbalRef.protoCrewMember.type != ProtoCrewMember.KerbalType.Unowned) { KerbalGUIManager.AddActiveCrew(seat.kerbalRef); } } } } // So we do have an internal model, right? if (part.internalModel != null) { if (JUtil.IsInIVA()) { // If the user is IVA, we move the internals to the original position, // so that they show up correctly on InternalCamera. This particularly concerns // the pod the user is inside of. part.internalModel.transform.parent = originalParent; part.internalModel.transform.localRotation = originalRotation; part.internalModel.transform.localPosition = originalPosition; part.internalModel.transform.localScale = originalScale; if (!JUtil.UserIsInPod(part)) { // If the user is in some other pod than this one, we also hide our IVA to prevent them from being drawn above // everything else. part.internalModel.SetVisible(false); } // Unfortunately even if I do that, it means that at least one kerbal on the ship will see his own IVA twice in two different orientations, // one time through the InternalCamera (which I can't modify) and another through the Camera 00. // So we have to also undo the culling mask change as well. JUtil.SetMainCameraCullingMaskForIVA(false); // So once everything is hidden again, we undo the change in shaders to conceal the fact that you can't see other internals. SetShaders(false); } else { // If transparentPodSetting = OFF or AUTO and not the focused active part we treat the part like a non-transparent part. // and we turn off the shaders (if set) and exit OnUpdate. onGUI and LateUpdate will do the rest. if (transparentPodSetting == "OFF" || ((transparentPodSetting == "AUTO" && FlightGlobals.ActiveVessel.referenceTransformId != this.part.flightID) && (transparentPodSetting == "AUTO" && !mouseOver))) { SetShaders(false); JUtil.SetMainCameraCullingMaskForIVA(true); return; } // Otherwise, we're out of IVA, so we can proceed with setting up the pods for exterior view. JUtil.SetMainCameraCullingMaskForIVA(true); // Make the internal model visible... part.internalModel.SetVisible(true); // And for a good measure we make sure the shader change has been applied. SetShaders(true); // Now we attach the restored IVA directly into the pod at zero local coordinates and rotate it, // so that it shows up on the main outer view camera in the correct location. part.internalModel.transform.parent = part.transform; part.internalModel.transform.localRotation = MagicalVoodooRotation; part.internalModel.transform.localPosition = Vector3.zero; part.internalModel.transform.localScale = Vector3.one; } } }
private void Start() { if (atlas == null) atlas = GameDatabase.Instance.GetTexture("PortraitStats/Icons/Atlas", false); GameEvents.onVesselWasModified.Add(vesselCheck); GameEvents.onVesselChange.Add(vesselCheck); manager = findKerbalGUIManager(); if (manager == null) Destroy(this); reload = true; RenderingManager.AddToPostDrawQueue(5, drawLabels); }
private void Start() { GameEvents.onVesselWasModified.Add(vesselCheck); GameEvents.onVesselChange.Add(vesselCheck); GameEvents.OnMapExited.Add(mapTimer); manager = findKerbalGUIManager(); careerMode = HighLogic.CurrentGame.Mode == Game.Modes.CAREER; if (manager == null) { Destroy(this); } reload = true; if (!loaded) { loaded = true; atlas = GameDatabase.Instance.GetTexture("PortraitStats/Icons/Atlas", false); settingsFile = GameDatabase.Instance.GetConfigNode("PortraitStats/Settings/Portrait_Stats_Config"); if (settingsFile != null) { if (settingsFile.HasValue("traitToolTip")) { if (!bool.TryParse(settingsFile.GetValue("traitToolTip"), out traitTooltip)) { traitTooltip = true; } } if (settingsFile.HasValue("expToolTip")) { bool.TryParse(settingsFile.GetValue("expToolTip"), out expTooltip); } if (settingsFile.HasValue("pilotColor")) { pilotColor = parseColor(settingsFile, "pilotColor", pilotColor); } if (settingsFile.HasValue("engineerColor")) { engineerColor = parseColor(settingsFile, "engineerColor", engineerColor); } if (settingsFile.HasValue("scientistColor")) { scientistColor = parseColor(settingsFile, "scientistColor", scientistColor); } if (settingsFile.HasValue("touristColor")) { touristColor = parseColor(settingsFile, "touristColor", touristColor); } if (settingsFile.HasValue("unknownClassColor")) { unknownColor = parseColor(settingsFile, "unknownClassColor", unknownColor); } } } RenderingManager.AddToPostDrawQueue(5, drawLabels); }