

xEvilReeperx
Members-
Posts
894 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by xEvilReeperx
-
The short answer is that reverting to the VAB causes the editor to load from a ConfigNode that was created when the fairing module's fields weren't set to persistent. This happens because when you enter flight, the vessel gets created from the various part prefabs which wipe your persistence changes, and then that instance of the vessel is saved before any OnStarts run. Why doesn't the game just use the ConfigNode it must have loaded from disk instead? I have no idea That's not what persistent means. Persistence simply means "write this value to the disk when object is saved". All KSPFields will load data from a ConfigNode if it contains a name-value key for it. Non-persistent fields won't normally have this value saved in a ConfigNode and instead will end up with whatever their clone-source field value is. Anyway, to solve your problem, move your persistent attribute changes into OnAwake and set your slider initial values in OnLoad (instead of alongside your persistence changes).
-
I'm in the midst of a rewrite and one of the things I hope to write in is being able to alert on contract conditions, regardless of the current science filter. Admittedly I haven't reached this part and don't have any experience dealing with the contract system so I can't guarantee it can be done but if it's possible I'll make it happen
-
This is your main problem. Your code works in the editor because the changes it makes to persistence are in effect every time the craft gets saved there. But they're lost whenever a part is instantiated (until your OnStart runs). You might think you could just edit the ModuleProceduralFairings field persistence on the part prefab but unfortunately each module seems to recreate its own fields when instantiated and any changes to the prefab's fields are lost. That's why you're seeing oddness in revert. When the vessel gets loaded in flight, a snapshot is created before any PartModule OnStarts are run and saved to ShipConstruction.ShipConfig which is what gets used when reverting to VAB. Since your code hasn't run yet, the fields you want to save aren't yet persistent and don't get saved to this config so when the player reverts, any changes are lost
-
There isn't anything in the API accessible that I know of but it's easy enough to set up yourself. Example: [KSPAddon(KSPAddon.Startup.MainMenu, true)] public class PartModelPreviewer : MonoBehaviour { private const int PreviewWidth = 200; private const int PreviewHeight = 200; private const int RenderLayer = 8; private const float PreviewTime = 2f; private const float PreviewRevolutionRate = 180f; private const float TargetPreviewSize = 0.7f; // size 1 would take up the whole vertical camera space private string _current = "<None>"; private void Start() { gameObject.AddComponent<Camera>(); camera.cullingMask = (1 << RenderLayer); camera.clearFlags = ~CameraClearFlags.Nothing; camera.nearClipPlane = 0.1f; camera.farClipPlane = 10f; camera.orthographic = true; camera.backgroundColor = new Color(0f, .7f, 0f, 0f); camera.orthographicSize = 0.5f; camera.pixelRect = new Rect(0f, Screen.height - PreviewHeight, PreviewWidth, PreviewHeight); transform.position = new Vector3(0f, 0f, -8f); transform.LookAt(Vector3.zero, Vector3.up); StartCoroutine(Cycle()); } private IEnumerator Cycle() { while (true) { foreach (var part in PartLoader.LoadedPartsList.Where(ap => ap.iconPrefab != null)) { _current = part.name; var go = (GameObject) Instantiate(part.iconPrefab); go.SetLayerRecursive(RenderLayer); go.SetActive(true); var bounds = go.GetRendererBounds(); float multiplier = TargetPreviewSize / Mathf.Max(bounds.size.x, bounds.size.y, bounds.size.z); go.transform.localScale = Vector3.one*multiplier; go.transform.rotation = Quaternion.AngleAxis(-30f, Vector3.right); transform.position = new Vector3(transform.position.x, bounds.center.y, transform.position.z); go.transform.parent = transform; yield return StartCoroutine(Preview(go)); Destroy(go); } } } private IEnumerator Preview(GameObject previewObject) { float start = Time.time; while (Time.time - start < PreviewTime) { yield return 0; previewObject.transform.Rotate(Vector3.up, Time.deltaTime * PreviewRevolutionRate); } } private void OnGUI() { GUI.Label(new Rect(0, 0, 200f, 20f), "Displaying " + _current); } }
-
[1.0.4] Stock Clamshell Fairings (June 1)
xEvilReeperx replied to xEvilReeperx's topic in KSP1 Mod Releases
It should be (KerbalStuff handles this for me right?) Not especially difficult. I'm surprised not to see it coming in 1.0.3 for sure It wouldn't be too hard to make them stay attached as a pure visual effect. You'd still have to "stage" to be able to activate engines and you'd lose the aerodynamic advantage of the fairing the moment it's staged but if that's acceptable, I could investigate -
Proper Fairings ASAP
xEvilReeperx replied to GusTurbo's topic in KSP1 Suggestions & Development Discussion
A wrote a little fix for the confetti problem over the weekend since I couldn't find any mod that had done it already -
I finally had a chance to really sit down and play this weekend and my goodness, those stock fairings... I haven't seen this fix for them yet so here it is Features Fairing bases now have a toggle option. If set to Clamshell, all vertical groups of the panel will be merged together when jettisoned I haven't included any tweakable options since I've seen at least two other mods that already add that. Those will work just fine with this plugin. Download from KerbalStuff Download from BitBucket License: MIT Source: BitBucket Donations are always welcome! Changelog: 1.0 (June 1) Initial release
- 100 replies
-
- 62
-
-
Human Friendly Landing Zone Title
xEvilReeperx replied to Zeenobit's topic in KSP1 C# Plugin Development Help and Support
Use Vessel.GetLandedAtString with vessel.landedAt if it's not null or empty -
I had a look but couldn't find a ship that matched the conditions in your screen shot. Mainly I'm interested in the ship's exact location. I'm fairly certain I know exactly what the issue is but I haven't been able to replicate it so far. Can you replicate it by leaving the scene and going to the space center, then jumping back into the ship? If it's suddenly correct for 10-40 seconds but then stops being correct, that'll confirm my suspicions
-
Hi, thanks for the repro steps -- it made this very easy to hunt. There's a oversight in ScienceAlert that resulted in the NullReferenceException you see thanks to the way Impact handles its science container compared to stock. It's fixed in the next version which I'll release tomorrow (I want to fix the EVA-report-on-top option and add the RemoteTech support that was asked for) which are both quick and relatively easy
-
Misses places such as what? A description of the orbit and which report is being missed would be helpful though it's most likely the error ones like getting tundra while in an equatorial orbit. The biome map blends colors which sometimes tricks the game into picking the wrong biome. The blending between grasslands and shores (or shores and water? I forget exactly which two) will cause certain points on the equator to seem like they're tundra (for example), even though the nearest actual tundra is hundreds or thousands of km away. I suspect [x] is just constantly running and sweeps those up. If this isn't the case, I'd be interested in hearing more This kind of exception is usually caused by duplicate experimentIDs. What does your full mod list look like? Most of the stock science experiments will be broken when this happens so check them out and we'll be able to tell easily if that's the case What was your filter method set to? If it's sufficiently high, it could very well be that a second report is desirable if you had space to store it. ScienceAlert doesn't currently check whether it's possible to have duplicates, only that you should take a second sample if you can
-
Replacing the panel with your own is a lot easier than trying to modify the existing one, which I can tell you from experience is a maintenance nightmare. Here's a rough mockup that should get you started: [KSPAddon(KSPAddon.Startup.SpaceCentre, false)] public class ReprogramAstronautComplex : MonoBehaviour { private readonly ILog _log = new DebugLog("Reprogrammer"); private Rect _windowRect = default(Rect); private AstronautComplexApplicantPanel _applicantPanel; private void Start() { try { SetupSkin(); var complex = UIManager.instance.transform.Find("panel_AstronautComplex"); #if DEBUG //DumpAssetBaseTextures(); //complex.gameObject.PrintComponents(new DebugLog("Complex")); #endif _applicantPanel = new AstronautComplexApplicantPanel(complex); _windowRect = _applicantPanel.PanelArea; _applicantPanel.Hide(); GameEvents.onGUIAstronautComplexSpawn.Add(AstronautComplexShown); GameEvents.onGUIAstronautComplexDespawn.Add(AstronautComplexHidden); enabled = false; } catch (Exception e) { _log.Error("Error: Encountered unhandled exception: " + e); Destroy(this); } } private void AstronautComplexShown() { enabled = true; } private void AstronautComplexHidden() { enabled = false; } private void OnDestroy() { GameEvents.onGUIAstronautComplexDespawn.Remove(AstronautComplexHidden); GameEvents.onGUIAstronautComplexSpawn.Remove(AstronautComplexShown); } private void SetupSkin() { _customWindowSkin = new GUIStyle(HighLogic.Skin.window) { contentOffset = Vector2.zero, padding = new RectOffset() { left = 0, right = HighLogic.Skin.window.padding.right, top = 0, bottom = 0} }; } private void DumpAssetBaseTextures() { // note: there are apparently null entries in this list for some reason, hence the check FindObjectOfType<AssetBase>().textures.Where(t => t != null).ToList().ForEach(t => _log.Debug("AssetBase: " + t.name)); } private Vector2 _scroll = default(Vector2); private GUIStyle _customWindowSkin; private readonly Texture2D _portraitMale = AssetBase.GetTexture("kerbalicon_recruit"); private readonly Texture2D _portraitFemale = AssetBase.GetTexture("kerbalicon_recruit_female"); private void OnGUI() { GUI.skin = HighLogic.Skin; var roster = HighLogic.CurrentGame.CrewRoster; GUILayout.BeginArea(_windowRect, _customWindowSkin); { GUILayout.Label("Candidates"); _scroll = GUILayout.BeginScrollView(_scroll, _customWindowSkin); { foreach (var applicant in roster.Applicants) DrawListItem(applicant); } GUILayout.EndScrollView(); } GUILayout.EndArea(); } private void DrawListItem(ProtoCrewMember crew) { GUILayout.BeginVertical(_customWindowSkin, GUILayout.ExpandHeight(false)); { GUILayout.BeginHorizontal(GUILayout.ExpandHeight(true), GUILayout.MaxHeight(_portraitMale.height), GUILayout.ExpandWidth(true)); { GUILayout.Label(crew.gender == ProtoCrewMember.Gender.Male ? _portraitMale : _portraitFemale); GUILayout.BeginVertical(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true)); { GUILayout.BeginHorizontal(); GUILayout.Label(crew.name); GUILayout.FlexibleSpace(); GUILayout.Label("Trained " + crew.experienceTrait.Title); GUILayout.EndHorizontal(); GUILayout.Label("More info here"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Button("Hire Applicant", GUILayout.MaxWidth(100f)); // todo: hire logic GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); } } public class AstronautComplexApplicantPanel { private readonly Transform _applicantPanel; public AstronautComplexApplicantPanel(Transform astronautComplex) { if (astronautComplex == null) throw new ArgumentNullException("astronautComplex"); _applicantPanel = astronautComplex.Find("CrewPanels/panel_applicants"); if (_applicantPanel == null) throw new ArgumentException("No applicant panel found on " + astronautComplex.name); } public void Hide(bool tf = true) { _applicantPanel.gameObject.SetActive(!tf); } public Rect PanelArea { get { // whole panel is an EzGUI BTButton and we'll be needing to know about its renderer to come up // with screen coordinates var button = _applicantPanel.GetComponent<BTButton>() as SpriteRoot; if (button == null) throw new Exception("AstronautComplexApplicantPanel: Couldn't find BTButton on " + _applicantPanel.name); var uiCam = UIManager.instance.uiCameras.FirstOrDefault(uic => (uic.mask & (1 << _applicantPanel.gameObject.layer)) != 0); if (uiCam == null) throw new Exception("AstronautComplexApplicantPanel: Couldn't find a UICamera for panel"); var screenPos = uiCam.camera.WorldToScreenPoint(_applicantPanel.position); return new Rect(screenPos.x, Screen.height - screenPos.y, button.PixelSize.x, button.PixelSize.y); } } }
-
Can you be more specific as to what you're trying to do? Prevent player from opening astronaut complex? (and/or open your custom window instead) Detect when the player is viewing (has entered) the AC? Edit text on AC building description when left/right-clicked? Modify GUI of AC itself (change button conditions etc)? The first three are straightforward, the last item can be done but is somewhat tedious
-
TextureReplacer just replaces the material's main texture. The iva NavBall sphere material uses KSP's specular shader by default so technically it would work but you won't have any way to modify the shader's other properties (primarily specular color, shininess, and opacity). You might need to write yourself a quick plugin to do that
-
I'm pretty sure I know what's causing this. The next time it happens, could you get a savegame to me? I wanted to do something like this but couldn't figure out a clear way to add it to the UI without it being confusing RE: EVA, whoops. The code's actually in there (and you can enable it by modifying the cfg) but it appears I either forgot to write the UI option or it was accidentally removed at some point
-
This might be a bug with KER. I can replicate your problem by creating a new career game, entering VAB, creating a vessel with just a mk1pod, and launching it. The KER button is blacked out with and without ScienceAlert and there aren't any exceptions thrown by SA that might have interfered. I suggest asking in the KER thread and including your game log and reproduction steps
-
I was thinking of it in broader terms -- contracts for every planet, including mod planets, edited biomes and stuff like that. But I realize I'm ahead of myself and right now getting the basics working should be the priority and not worrying that a few percent of the offered contracts might not be completable edit: I mean in context of achievable contract requirements