Bonus Eventus Posted July 29, 2017 Share Posted July 29, 2017 5 hours ago, TaxiService said: Hi, I am trying to find out if KSP has a GameEvent or some kind of notification on part deployment (can be antenna, solar panel, landing gear etc) and ActionGroup (eg toggle antenna extend/retract). The closest one I can find is `GameEvents.onPartActionUIDismiss` which is almost suitable for me. But I am not finding an easy way to hook to ActionGroup activation. The reason for this is to run some update codes on demand, rather than FixedUpdate() pulse to check and run if change is detected. Thanks! I haven't done this myself, but you can register your own custom games events now in 1.3. I would think you would have to check the state of any part modules on the vessel in question Quote Link to comment Share on other sites More sharing options...
xEvilReeperx Posted July 29, 2017 Share Posted July 29, 2017 8 hours ago, TaxiService said: But I am not finding an easy way to hook to ActionGroup activation. You could modify/replace Base[Action/Event] delegates to fire a custom GameEvent for you. That's how I'd do it Quote Link to comment Share on other sites More sharing options...
TaxiService Posted July 29, 2017 Share Posted July 29, 2017 (edited) @Bonus Eventus @xEvilReeperx Do you have some keywords/tips on BaseEvent, BaseAction and GameEvent for this functionality to help my learning? I am testing some of these things, included UIPartActionController. EDIT: Never mind, I found one easy way. ModuleDeployablePart has two EventData for moving and stop animations. I just add my own callback to these and both ActionGroup and extend/retract click call mine. Thanks for pointing me towards EventData! Edited July 29, 2017 by TaxiService Quote Link to comment Share on other sites More sharing options...
pydude Posted July 30, 2017 Share Posted July 30, 2017 Warning: Absolute n00b here. So, I'm having the following error: Error CS0103 The name 'RenderingManager' does not exist in the current context I can't figure out why this error is happening, I've added UnityEngine and Assembly-CSharp as references. How do I fix this? complete code, if needed: (This is taken from a sample plugin project) using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace SignalTracking { /// <summary> /// My first part! /// </summary> public class SelfDestruct : Part { protected Rect windowPos; private void WindowGUI(int windowID) { GUIStyle mySty = new GUIStyle(GUI.skin.button); mySty.normal.textColor = mySty.focused.textColor = Color.white; mySty.hover.textColor = mySty.active.textColor = Color.yellow; mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green; mySty.padding = new RectOffset(8, 8, 8, 8); GUILayout.BeginVertical(); if (GUILayout.Button("DESTROY", mySty, GUILayout.ExpandWidth(true)))//GUILayout.Button is "true" when clicked { this.explode(); this.onPartDestroy(); this.Die(); } GUILayout.EndVertical(); //DragWindow makes the window draggable. The Rect specifies which part of the window it can by dragged by, and is //clipped to the actual boundary of the window. You can also pass no argument at all and then the window can by //dragged by any part of it. Make sure the DragWindow command is AFTER all your other GUI input stuff, or else //it may "cover up" your controls and make them stop responding to the mouse. GUI.DragWindow(new Rect(0, 0, 10000, 20)); } private void drawGUI() { GUI.skin = HighLogic.Skin; windowPos = GUILayout.Window(1, windowPos, WindowGUI, "Self Destruct", GUILayout.MinWidth(100)); } protected override void onFlightStart() //Called when vessel is placed on the launchpad { RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));//start the GUI } protected override void onPartStart() { if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen { windowPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10); } } protected override void onPartDestroy() { RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI } } } Quote Link to comment Share on other sites More sharing options...
sarbian Posted July 30, 2017 Share Posted July 30, 2017 13 minutes ago, pydude said: How do I fix this? RenderingManager is not present in current KSP version. Have a look at that post to see how to replace it Quote Link to comment Share on other sites More sharing options...
pydude Posted July 30, 2017 Share Posted July 30, 2017 Thanks @sarbian, at least I can compile now. But it still is not working. I have changed the code to look like this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace SignalTracking { /// <summary> /// My first part! /// </summary> public class testMod : Part { protected Rect windowPos; bool g = true; private void WindowGUI(int windowID) { GUIStyle mySty = new GUIStyle(GUI.skin.button); mySty.normal.textColor = mySty.focused.textColor = Color.white; mySty.hover.textColor = mySty.active.textColor = Color.yellow; mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green; mySty.padding = new RectOffset(8, 8, 8, 8); GUILayout.BeginVertical(); if (GUILayout.Button("DESTROY", mySty, GUILayout.ExpandWidth(true)))//GUILayout.Button is "true" when clicked { this.explode(); this.onPartDestroy(); this.Die(); } GUILayout.EndVertical(); //DragWindow makes the window draggable. The Rect specifies which part of the window it can by dragged by, and is //clipped to the actual boundary of the window. You can also pass no argument at all and then the window can by //dragged by any part of it. Make sure the DragWindow command is AFTER all your other GUI input stuff, or else //it may "cover up" your controls and make them stop responding to the mouse. GUI.DragWindow(new Rect(0, 0, 10000, 20)); } private void drawGUI() { GUI.skin = HighLogic.Skin; windowPos = GUILayout.Window(1, windowPos, WindowGUI, "Self Destruct", GUILayout.MinWidth(100)); } private void OnGUI() { if (g) { drawGUI(); // Your current on postDrawQueue code } } protected override void onPartStart() { if ((windowPos.x == 0) && (windowPos.y == 0))//windowPos is used to position the GUI window, lets set it in the center of the screen { windowPos = new Rect(Screen.width / 2, Screen.height / 2, 10, 10); } } protected override void onPartDestroy() { g = false; } } } Also, I might be putting it in the cfg wrong. Do I just go MODULE { name = testMod } , or is that the wrong way to do it? Quote Link to comment Share on other sites More sharing options...
sarbian Posted July 31, 2017 Share Posted July 31, 2017 11 hours ago, pydude said: I have changed the code to look like this Oh, I did not saw the first line. it should be public class testMod : PartModule How old is the tutorial you are using ? Have a look at this one Quote Link to comment Share on other sites More sharing options...
Benjamin Kerman Posted July 31, 2017 Share Posted July 31, 2017 Does anyone have a tutorial dealing with the calling and handling of ConfigNode data? Quote Link to comment Share on other sites More sharing options...
pydude Posted August 1, 2017 Share Posted August 1, 2017 @Sarbian Thanks for that tutorial. The one I was using was 5 years old! Now, I have a few questions. 1. What is the scene for the map view? The one that comes up when you press "m" during flight. 2. How can I get the current CommNet signal strength of the active vessel? Thanks. Quote Link to comment Share on other sites More sharing options...
sarbian Posted August 1, 2017 Share Posted August 1, 2017 It's the normal flight scene. The difference is that MapView.MapIsEnabled is true vessel.connection.SignalStrength or vessel.connection.Signal depending if your need a state or a value. Quote Link to comment Share on other sites More sharing options...
pydude Posted August 1, 2017 Share Posted August 1, 2017 (edited) @sarbian Thanks! Finally my mod actually does something! Another question, however: How can I disable patched conics altogether? To make it look like before you upgrade the Tracking Station, just the grey lines? Edited August 4, 2017 by pydude Quote Link to comment Share on other sites More sharing options...
trias702 Posted August 2, 2017 Share Posted August 2, 2017 Does anyone happen to know how the game resolves PLANETARY_RESOURCE clashes between two different mods? If each mod has its own ResourceDef file, of the form: PLANETARY_RESOURCE { ResourceName = LqdDeuterium ResourceType = 2 PlanetName = Jool Distribution { PresenceChance = ... MinAbundance = ... MaxAbundance = ... Variance = ... } } Such that each mod is declaring a PLANETARY_RESOURCE for LqdDeuterium, ResourceType = 2, PlanetName = Jool, however each mod has different Distribution parameters. Looking at the ModuleManager.ConfigCache file, both entries are in the cache, however, does the game choose only one of them? If yes, then how does it choose? Quote Link to comment Share on other sites More sharing options...
Benjamin Kerman Posted August 3, 2017 Share Posted August 3, 2017 2 hours ago, trias702 said: Does anyone happen to know how the game resolves PLANETARY_RESOURCE clashes between two different mods? If each mod has its own ResourceDef file, of the form: PLANETARY_RESOURCE { ResourceName = LqdDeuterium ResourceType = 2 PlanetName = Jool Distribution { PresenceChance = ... MinAbundance = ... MaxAbundance = ... Variance = ... } } Such that each mod is declaring a PLANETARY_RESOURCE for LqdDeuterium, ResourceType = 2, PlanetName = Jool, however each mod has different Distribution parameters. Looking at the ModuleManager.ConfigCache file, both entries are in the cache, however, does the game choose only one of them? If yes, then how does it choose? I dont know how it handles it, but it is bad. Contact the mod authors to try and get it worked out. Quote Link to comment Share on other sites More sharing options...
sarbian Posted August 4, 2017 Share Posted August 4, 2017 On 8/1/2017 at 9:20 PM, pydude said: @sarbian Thanks! Finally my mod actually does something! Another question, however: How can I disable patched conics altogether? To make it look like before you upgrade the Tracking Station, just the grey lines? For a specific vessel / object or for all of them ? Have a look at vessel.discoveryInfo Quote Link to comment Share on other sites More sharing options...
pydude Posted August 7, 2017 Share Posted August 7, 2017 @sarbianI want to do this for a vessel. discoveryInfo seems to be for asteroids, not ships. Are there ways to disable patched conics for vessels? Quote Link to comment Share on other sites More sharing options...
0111narwhalz Posted August 7, 2017 Share Posted August 7, 2017 Just now, pydude said: I want to do this for a vessel. discoveryInfo seems to be for asteroids, not ships. Keep in mind that asteroids are a subset of vessels. Quote Link to comment Share on other sites More sharing options...
pydude Posted August 8, 2017 Share Posted August 8, 2017 How can I change discoveryInfo.trackingStatus? I assume that this the relevant property. If I do vessel.DiscoveryInfo.trackingStatus=1; for example, it says Error CS0029 Cannot implicitly convert type 'int' to 'KnowledgeItem<string>' How do I actually change this? Quote Link to comment Share on other sites More sharing options...
TheRagingIrishman Posted August 8, 2017 Share Posted August 8, 2017 (edited) 23 minutes ago, pydude said: How can I change discoveryInfo.trackingStatus? I assume that this the relevant property. If I do vessel.DiscoveryInfo.trackingStatus=1; for example, it says Error CS0029 Cannot implicitly convert type 'int' to 'KnowledgeItem<string>' How do I actually change this? vessel.DiscoveryInfo.trackingStatus is a string so you can only set it to strings. I don't know what the valid options for it but you could easily use Debug.Log(vessel.DiscoveryInfo.trackingStatus) to tell you what it's current value is and then figure out other accepted values from there. Edited August 8, 2017 by TheRagingIrishman Quote Link to comment Share on other sites More sharing options...
pydude Posted August 8, 2017 Share Posted August 8, 2017 @TheRagingIrishmanActually, I already tried this. It just says the same thing except "cannot convert type 'string'" instead of 'int'. vessel.DiscoveryInfo.trackingStatus is a type "KnowledgeItem<string>", but I have no idea how to use one. Quote Link to comment Share on other sites More sharing options...
HebaruSan Posted August 8, 2017 Share Posted August 8, 2017 Just now, pydude said: @TheRagingIrishmanActually, I already tried this. It just says the same thing except "cannot convert type 'string'" instead of 'int'. vessel.DiscoveryInfo.trackingStatus is a type "KnowledgeItem<string>", but I have no idea how to use one. Looks like the constructor takes quite a few parameters: https://kerbalspaceprogram.com/api/class_knowledge_item_3_01_t_01_4.html KnowledgeItem< T >.KnowledgeItem( DiscoveryInfo host, DiscoveryLevels itemLevel, string caption, string valueFallback, UpdateDataCallback updateValueCallback, string suffix = "", string format = "" ) ... but it's not clear that replacing the object is the right choice. What about something like this? vessel.DiscoveryInfo.trackingStatus.ItemLevel = DiscoveryLevels.Owned; Or possibly vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned); Quote Link to comment Share on other sites More sharing options...
pydude Posted August 8, 2017 Share Posted August 8, 2017 @HebaruSan vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned); does not work for my purposes because that method does not allow changing individual properties. vessel.DiscoveryInfo.trackingStatus.ItemLevel = DiscoveryLevels.Owned; just flat out doesn't work, saying Error CS1061 'KnowledgeItem<string>' does not contain a definition for 'ItemLevel' and no extension method 'ItemLevel' accepting a first argument of type 'KnowledgeItem<string>' could be found (are you missing a using directive or an assembly reference?) The whole reason I'm messing around with this is to try to disable patched conics for the vessel. I'm trying to make it like Tracking Station level 1, with just the grey orbit lines. Do you know of any other ways to do this? Quote Link to comment Share on other sites More sharing options...
HebaruSan Posted August 8, 2017 Share Posted August 8, 2017 9 minutes ago, pydude said: vessel.DiscoveryInfo.trackingStatus.ItemLevel = DiscoveryLevels.Owned; just flat out doesn't work, saying Error CS1061 'KnowledgeItem<string>' does not contain a definition for 'ItemLevel' and no extension method 'ItemLevel' accepting a first argument of type 'KnowledgeItem<string>' could be found (are you missing a using directive or an assembly reference?) Oh oops, that property is private. Which also rules out selectively copying the properties of the old object into a new object. 9 minutes ago, pydude said: @HebaruSan vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.Owned); does not work for my purposes because that method does not allow changing individual properties. 9 minutes ago, pydude said: The whole reason I'm messing around with this is to try to disable patched conics for the vessel. I'm trying to make it like Tracking Station level 1, with just the grey orbit lines. Do you know of any other ways to do this? The DiscoveryLevels enum is designed to allow multiple values, and I assume StateVectors and Appearance control the orbit lines and whether you're allowed to switch to it; what about leaving them out? vessel.DiscoveryInfo.SetLevel(DiscoveryLevels.Presence | DiscoveryLevels.Name); Quote Link to comment Share on other sites More sharing options...
pydude Posted August 8, 2017 Share Posted August 8, 2017 @HebaruSanThat did not work either. It changed the ship's icon to the question mark, but patched conics were still rendered. And, obviously, the icon should not change. Any other ideas? Quote Link to comment Share on other sites More sharing options...
HebaruSan Posted August 8, 2017 Share Posted August 8, 2017 Just now, pydude said: @HebaruSanThat did not work either. It changed the ship's icon to the question mark, but patched conics were still rendered. And, obviously, the icon should not change. Any other ideas? I don't know exactly what they mean (because there are no descriptions in the documentation), but there are several more values available in this enum. Try various combinations of them (combined with pipe characters as above) to see if you like the results. Presence|Name was just a guess based on what it sounds like you wanted. https://kerbalspaceprogram.com/api/_discovery_info_8cs.html Quote Link to comment Share on other sites More sharing options...
DeltaDizzy Posted August 9, 2017 Share Posted August 9, 2017 (edited) 1) How do I export an assetbundle from unity? I'm following this tutorial: 2) How can i alter MM configs from a dll?(I know it can be done, because that's what KittopiaTech does.) Edited August 9, 2017 by DeltaDizzy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.