Jump to content

xEvilReeperx

Members
  • Posts

    894
  • Joined

  • Last visited

Everything posted by xEvilReeperx

  1. That's a good question! They're definitely different. How bizarre: PART { name = probeCoreCube uid = 1582019048 mid = 1339010955 [... snip] Results in [LOG 12:04:05.518] DebugTools, FlightId = 1582019048 [LOG 12:04:05.519] DebugTools, mid = 1339010955 [LOG 12:04:05.520] DebugTools, id = -2127700883 // was checking Vessel.id hashCode to see if it matches anything [LOG 12:04:05.520] DebugTools, uid = 4294732514 And there's absolutely nothing in the sfs that has "4294732514"
  2. It looks like flightID is uid (I mean the value in sfs is same as flightid, I didn't compare flightID to uid) and 'ref' in sfs is equivalent to the root part's flightID. But I don't get the same results as your tests. Part.mid looks to be somewhat similar to the vessel id but you might be able to make it work. Where an undocking vessel receives a brand new id, the parts of that vessel all keep the same mid values as the parent vessel. They'll be overwritten if they dock with a different parent though
  3. Each part should have a unique one; I used them in a mod I wrote for myself that made targets (docking nodes in particular) persistent It's just a persistent string each part has. I don't know of any mod that's used it so far but if you need to store part-relevant data without messing with them, it's an option. It can also be handy to store information per-part while in the editor since those parts don't get ids as I recall
  4. Aren't Part.flightIds persistent across games? If that doesn't work, there's always the ugly yet usable Part.customPartData
  5. It's working as intended (for now), then. ScienceAlert doesn't know what you're doing with the reports. It only knows that you have configured it to alert you whenever a report would generate science points and that you have an open experiment to use. You can see that taking a duplicate report would result in about 5.45 science. That you can't fit it into the command pod isn't taken into consideration at all
  6. You can put whatever you'd like in there. Here's a basic bug-filled (lots of edge cases need to be solved) version of what you want: [KSPAddon(KSPAddon.Startup.EditorAny, false)] class EditPartListPrefab : MonoBehaviour { class ClickListener : MonoBehaviour { AvailablePart myPart; EditorPartIcon icon; SpriteText text; int amount = 0; bool mouseFlag = false; void Start() { GetComponent<UIButton>().AddValueChangedDelegate(OnClick); GetComponent<UIButton>().AddInputDelegate(OnInput); myPart = GetComponent<EditorPartIcon>().partInfo; icon = GetComponent<EditorPartIcon>(); text = transform.Find("CounterLabel").GetComponent<SpriteText>(); amount = EditPartListPrefab.Instance.GetPartQuantity(myPart); UpdateCounter(); } void OnClick(IUIObject obj) { print("User clicked " + myPart.partPrefab.name); if (amount > 0) { --amount; EditPartListPrefab.Instance.SetPartQuantity(myPart, amount); UpdateCounter(); } } void UpdateCounter() { text.Text = amount.ToString(); if (amount == 0) icon.SetGrey("Ran out of this item"); } void OnInput(ref POINTER_INFO ptr) { switch (ptr.evt) { case POINTER_INFO.INPUT_EVENT.MOVE: if (!mouseFlag) { mouseFlag = true; print("User moused over " + myPart.partPrefab.name); } break; case POINTER_INFO.INPUT_EVENT.MOVE_OFF: mouseFlag = false; break; } } } public static EditPartListPrefab Instance { private set; get; } private Dictionary<AvailablePart, int> quantities = new Dictionary<AvailablePart, int>(); int GetPartQuantity(AvailablePart part) { return quantities[part]; } void SetPartQuantity(AvailablePart part, int qty) { quantities[part] = qty; } void Start() { Instance = this; // edit icon prefab var iconPrefab = EditorPartList.Instance.iconPrefab.gameObject; if (iconPrefab.GetComponent<ClickListener>() == null) { iconPrefab.AddComponent<ClickListener>(); GameObject labelHolder = new GameObject("CounterLabel"); var label = labelHolder.AddComponent<SpriteText>(); label.RenderCamera = Camera.allCameras.Where(c => (c.cullingMask & (1 << labelHolder.layer)) != 0).Single(); labelHolder.layer = LayerMask.NameToLayer("EzGUI_UI"); labelHolder.transform.parent = iconPrefab.transform; labelHolder.transform.localPosition = Vector3.zero; labelHolder.transform.Translate(new Vector3(EditorPartList.Instance.iconSize * 0.35f, EditorPartList.Instance.iconSize * -0.425f, label.RenderCamera.nearClipPlane - labelHolder.transform.position.z - 1f), Space.Self); label.Text = "[count]"; label.alignment = SpriteText.Alignment_Type.Right; label.font = UIManager.instance.defaultFont; label.renderer.sharedMaterial = UIManager.instance.defaultFontMaterial; label.SetColor(Color.white); label.SetAnchor(SpriteText.Anchor_Pos.Lower_Right); label.SetCharacterSize(12f); } // generate some random quantity for each part PartLoader.LoadedPartsList.ForEach(ap => quantities.Add(ap, UnityEngine.Random.Range(0, 15))); } }
  7. Yep, you can. The second part needs clarification: if you're creating a brand new third texture every frame, you'll end up uploading that texture data to the GPU on every frame which is wasteful although not necessarily a huge bottleneck. Here's somewhere to start: [KSPAddon(KSPAddon.Startup.Flight, false)] class DuplicateRepWidget : MonoBehaviour { Gauge gauge; IEnumerator Start() { var widget = FindObjectOfType<CurrencyWidgetsApp>(); while (!widget.widgetSpawner.Spawned) yield return 0; var stockRep = widget.widgetSpawner.transform.Find("RepWidget"); var newRep = (GameObject)Instantiate(stockRep.gameObject, stockRep.transform.position, stockRep.transform.rotation); newRep.SetActive(true); newRep.transform.Translate(new Vector3(-Screen.width * 0.5f, 0f, 0f)); Component.Destroy(newRep.GetComponent<ReputationWidget>()); gauge = newRep.GetComponentInChildren<Gauge>(); StartCoroutine(TickTock()); } IEnumerator TickTock() { gauge.minValue = 0f; gauge.maxValue = 100f; float delta = 33f; while (true) { float newValue = gauge.Value + delta * Time.deltaTime; if (newValue > 100f || newValue < 0f) delta = -delta; gauge.setValue(Mathf.Clamp(newValue, gauge.minValue, gauge.maxValue)); yield return 0; } } }
  8. Assuming you're talking about the stock editor part list and not some other list that's part of your inventory, the simplest way is to modify the prefab that gets used to create each part button. This should get you off the ground: [KSPAddon(KSPAddon.Startup.EditorAny, false)] class EditPartListPrefab : MonoBehaviour { class ClickListener : MonoBehaviour { AvailablePart myPart; EditorPartIcon icon; bool mouseFlag = false; void Start() { GetComponent<UIButton>().AddValueChangedDelegate(OnClick); GetComponent<UIButton>().AddInputDelegate(OnInput); myPart = GetComponent<EditorPartIcon>().partInfo; icon = GetComponent<EditorPartIcon>(); } void OnClick(IUIObject obj) { print("User clicked " + myPart.partPrefab.name); } void OnInput(ref POINTER_INFO ptr) { switch (ptr.evt) { case POINTER_INFO.INPUT_EVENT.MOVE: if (!mouseFlag) { mouseFlag = true; print("User moused over " + myPart.partPrefab.name); } break; case POINTER_INFO.INPUT_EVENT.MOVE_OFF: mouseFlag = false; break; } } } void Start() { EditorPartList.Instance.iconPrefab.gameObject.AddComponent<ClickListener>(); } }
  9. Have you tried GameEvents.OnVesselRecoveryRequested or GameEvents.OnVesselRecovered? That's where I'd start You might need to post more code. Nothing jumps out at me, although your if statement could be simplified with HighLogic.LoadedSceneIsEditor which will return true if the player is in the VAB or SPH
  10. It's a good candidate for an extension method also: public static class ConfigNodeExtensions { public static void Set(this ConfigNode node, string valueName, string value) { if (!node.SetValue(valueName, value)) node.SetValue(valueName, value); } } Node1.Set("Value1","Test1"); I have a set of source files shared between my projects for little fixes and snippets like this
  11. I was caught by the same thing. SetValue seems to modify existing values only, so I think the simplest you can make it is something like this: if (!node.SetValue("name", "value")) node.AddValue("name", "value");
  12. I'll check it out. What filter did you set for gravity scan? Do you have a lab on your vessel that you're using to reset the gravity scan, or modified cfg? I suspect you have the gravity scan filter set to something other than unresearched and that getting a second report (even though you can't store it in your command pod) is triggering an alert. ScienceAlert doesn't know that you're storing all the reports in a pod with a no duplicate restriction; all it knows is that you have x% of science for a particular subject (counting any science already gathered plus what you'll get for returning any science onboard), that percent is less than the filter %, you have an unused experiment of the right type available and that taking another report is worth at least whatever min threshold is set to You can enable report values in the options to see what the next report is worth, or open the log (Alt+F2) after the alert is triggered to see some details about why it was triggered. If this is not the case, I'd be very interested in seeing your logs. You've got me thinking about adding some visual cue as a warning that you'll have to leave the data in the experiment to retrieve it if there's nowhere else on the vessel you could store it. The more I think about it, the more sense it makes
  13. You're getting a NRE in the code you posted because you're trying to use SoundGroup, which was never created
  14. Most likely it's too far away to be heard by any AudioListener. If you don't need positional sound, you can disable it by setting panLevel to 0. Here's a complete example (excluding an actual clip) that will play a sound whenever the game is paused or the player decouples a stage: [KSPAddon(KSPAddon.Startup.Flight, false)] [RequireComponent(typeof(AudioSource))] // AddComponent works too class TestAudio : MonoBehaviour { void Start() { audio.clip = GameDatabase.Instance.GetAudioClip("folder/clip"); audio.panLevel = 0f; GameEvents.onStageSeparation.Add(StageSeparated); GameEvents.onGamePause.Add(OnPause); } void OnDestroy() { GameEvents.onStageSeparation.Remove(StageSeparated); GameEvents.onGamePause.Remove(OnPause); } void StageSeparated(EventReport report) { audio.Play(); } void OnPause() { audio.Play(); } }
  15. They can only be fired from the "available" tab -- you're trying it there? Press Alt+F2 and look at the log right after entering the astronaut complex and let me know if you see anything that sounds suspicious (or any null reference exceptions)
  16. This is with Blizzy's toolbar right? I've got that one on my list of bugs to exterminate. It'll be fixed in the next version
  17. I'm nearly 100% certain that the alpha values are unused. The stock biome maps are DXT1 which only supports 1 bit alpha at best (off or on). As for the second, those aren't found in the biome maps; they're actually the names of static objects in the scene. I forget the exact details
  18. Yes, this can be an option. I'll probably add a separate retired tab rather than relabel them in the "lost" panel. I thought about renaming it to "Lost & Retired" but it just doesn't sound right. Might as well go the extra mile to make it right, right?
  19. They're just gone, shame of failure. It may be possible to put them back into the applicant pool if that'd be preferable though. I'll add it as an option in the next version. It's as if they were never there, so it's possible you'll eventually come across a new one with a name you'd already seen (but new stats).
  20. A little mod to address a little problem You can now fire, retire or retrain unassigned crew members through the Astronaut Complex interface. If you need to dismiss a lot of them, you can press the control key and click the associated button to bypass the confirmation dialog. Retired crew can be brought back out of retirement at any time Configuration By default, FireCrew will use the "MultiOption" setting in the screenshot as shown above; each crew entry will have all three options displayed. You can alternately use a single-option style which will limit you to a single option that can be configured for one of the three choices. Edit config.cfg if you prefer the second style Download Source License: Public Domain Important Note: The way crew are actually fired has been changed. Due to some technical reasons, outright deleting crew as the first version did can cause problems saving the game if the crew in question had an achievements-type entry (first EVA etc). This has been changed so that "fired" crew are considered by the game to be dead and the user interface will hide them from you. Let me know if you encounter any issues Changelog: Version 1.3.0 (October 28) Fixed a bug that would cause Kerbals from rescue contracts to appear in "assigned" list Fixed a bug that prevented the astronaut complex from working properly when accessed within the editor scenes Version 1.2.0 (October 20) Updated for 0.25
  21. Do your other science experiments work normally? Usually when the button doesn't appear it's because something broke in initialization and it's almost always due to duplicate experimentids. I'm writing in some checks against this in the next version that should let you know whenever this is the case
  22. Right camera, wrong position. The problem is that the NavBall's position is defined in world space, whereas GUIText's position is expected to be in normalized screen space. You need to convert it: Camera cam = Camera.allCameras.FirstOrDefault(c => (c.cullingMask & (1 << 12)) != 0); if (cam != null) t.transform.position = cam.WorldToViewportPoint(/* navball position here */);
  23. You should be able to reload the game's textures in the debug menu (in the space center). This mod was originally just a proof of concept to see if it could be done so it lacks some polish
×
×
  • Create New...