SSTU - Shadow Space Technologies Unlimited

SSTU - Shadow Space Technologies Unlimited

98.5k Downloads

1.1 - To Investigate / Bugs to Report

shadowmage45 opened this issue ยท 9 comments

commented
  • MODEL node parent = specification not working -- does it work in 1.1?
    • Investigate this tonight; submit bug report if still not working
commented

IPartMassModifier should add the returned mass to the part prefab's mass. It seems to be working for me.

I was going to investigate the new UI controls too at some point ... will let you know if I find anything about it.

commented

More info on UI_ChooseOption - it looks like in order to detect changes you have to register an OnEditorShipWasModified event and either just update or check whether the index has changed.

commented

It still crashes though with a part with a mass of zero specified in the config, regardless of what mass the IPartMassModifier modules add.

Setting the mass in the config to even 0.001 fixes this crash.

Apparently it attempts to calculate the vehicle COM from a zero mass part and... well.. divides by zero. Need to apply the mass modifiers prior to calculating vehicle COM.

Nor does the modified mass show up on the editor-part-list prefab part.

Will open a proper bug report on this shortly; I believe you should be able to have the part mass determined completely from the modules, and that it should show up appropriately at all places where mass is used. Just gathering together all of my info :)

[EXC 17:11:17.834] NullReferenceException: Object reference not set to an instance of an object
    Vessel.findLocalCenterOfMass ()
    ProtoVessel..ctor (.Vessel VesselRef)
    Vessel.Initialize (Boolean fromShipAssembly)
    ShipConstruction.AssembleForLaunch (.ShipConstruct ship, System.String landedAt, System.String flagURL, .Game sceneState, .VesselCrewManifest crewManifest)
    FlightDriver.Start ()
[LOG 17:11:17.862] [FlightIntegrator]: Reloaded drag cube for zeroed cube root part SSTU-SC-GEN-RMB2 on vessel Untitled Space Craft
[EXC 17:11:17.884] NullReferenceException: Object reference not set to an instance of an object
    VesselAutopilotUI.LateUpdate ()
[EXC 17:11:17.886] NullReferenceException: Object reference not set to an instance of an object
    InternalSpace.InternalToWorld (Quaternion internalSpaceRotation)
    InternalSpace.WorldToInternal (Quaternion worldSpaceRotation)
    IVASun.LateUpdate ()
namespace SSTUTools
{
    public class SSTUMassTest : PartModule, IPartMassModifier
    {
        [KSPField(guiActive =true, guiActiveEditor = true, guiName ="mass")]
        public float mass = 1f;

        public float GetModuleMass(float defaultMass)
        {
            return mass;
        }
    }
}
commented

I should add that yes, it does appear to properly modify the parts mass (as long as the config mass > 0, and you don't mind the editor-part-list part's mass being incorrect).

Edit: I should also add that I can work around the zero-mass-part crashing easily enough by making one module zero out the parts mass (through the interface...) and any subsequent modules merely add mass. And this is what I will be doing for now; I'll just have to come up with a reasonable default prefab mass for these parts.

commented

Thanks for the info :)

Ouch... was really hoping to have a direct callback or delegate setup; using OnEditorShipModified is what I'm using for the existing UI detection methods... and it has issues.

User changes value -> event fires -> part responds, updates geometry, fires event again due to geometry changes -> all event subscribers get spammed with events (e.g. node-fairing rebuilds the fairing multiple times, airstream shield constantly re-checking when it doesn't need to).

Sounds like the first thing I'll be doing today will be seeing if I can use a derived custom class; there is a virtual void for 'updateField' or similar; hoping I can override that to call a delegate function.

Edit: Not going to work out as simply as it should; likely related to the annotations/attributes on the classes.

I can get it to compile, but of course the new class doesn't work as a UI control =\

...

Guess I'm just going to have to settle for using that event, as I cannot find a clean way to implement a basic derived class and have it work; they likely have some hard-coded references to their classes that I cannot override.


Also having difficulty getting UI_FloatEdit to work at all; it shows a slider, but the increment buttons do not show up (large = 1.25, small = 0.625, slide = 0.03125, min = 0.625, max = 10)


UI_ScaleEdit appears to work fine; is a bit more work to setup, but gives precisely the functionality I need for mount/tank sizes

commented

I'm honestly not sure at all how the part action items are set up - the decompiled code is not forthcoming at all. KSPAPIExtensions has some examples of custom UI controls though, and there's a good chance they'll still work.

commented

It looks like it's now possible to do this without going through onEditorShipModified. See this thread. I think this may have been added in a recent build.

commented

Very nice :) That will simplify... a ton of my modules; or at least make them a lot more clear and easier to debug. Increased performance from only necessary events being fired is always good too :)

commented

Also looks like they've changed the behaviour for IMassModifier modules; now it polls for mass on every tick in the editor as well as in flight.