post-kerbin-mining-corporation / SpaceDust

Adds atmospheric and exoatmospheric resource discovery and extraction to Kerbal Space Program.
9 stars 12 forks source link

Adding to CactEye Optics causes animations to stop working #21

Closed linuxgurugamer closed 3 years ago

linuxgurugamer commented 3 years ago

I added the patch below to the CactEye Optics mod. I updated the ScanAnimationName to be the telescope apeture. When it was running, and I used the CactEye ModuleAnimateGeneric's startEventGUIName event, the event just disappeared from the PAW and was unable to be used again.

Not sure if I did something wrong. Also, the SLOTs, what are they and how do they get populated? I assume it's a part, but haven't had a chance to dig into the Spacedust mod yet.

`@PART[tele_body]:NEEDS[SpaceDust] {
MODULE { name = ModuleSpaceDustTelescope // Power cost per second when scanning PowerCost = 12 // Animation ScanAnimationName = tele_openaperture // Size of the lens/mirror, for calcuations ObjectiveSize = 1.8 // FOV (radians) FieldOfView = 0.000969627362992369

    SLOT 
    { 
        name = slot1 
        Instrument = None 
    } 
    SLOT 
    { 
        name = slot2 
        Instrument = None 
    } 
}  

}

@PART[tele_body2]:NEEDS[SpaceDust] {
MODULE { name = ModuleSpaceDustTelescope // Power cost per second when scanning PowerCost = 12 // Animation ScanAnimationName = body2_open // Size of the lens/mirror, for calcuations ObjectiveSize = 1.8 // FOV (radians) FieldOfView = 0.000969627362992369

    SLOT 
    { 
        name = slot1 
        Instrument = None 
    } 
    SLOT 
    { 
        name = slot2 
        Instrument = None 
    } 
}  

}

@PART[tele_body,tele_body2]:NEEDS[SpaceDust] { MODULE { name = ModuleB9PartSwitch moduleID = instrumentSlot1 switcherDescription = #LOC_SpaceDust_switcher_instrument_slot1_title

    SUBTYPE 
    { 
        name = None 
        title = #LOC_SpaceDust_switcher_instrument_none 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_none_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_none_detail 
        primaryColor = #111111 
        secondaryColor = #111111 
        addedMass = 0 
        addedCost = 0 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = None 
                } 
            } 
        } 
    } 
    // 
    SUBTYPE 
    { 
        name = XeInstrument 
        title = #LOC_SpaceDust_switcher_instrument_xe 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_xe_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_xe_detail 
        primaryColor = #60a7be 
        secondaryColor = #60a7be 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = XenonSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = OxInstrument 
        title = #LOC_SpaceDust_switcher_instrument_ox 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_ox_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_ox_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = OxidizerSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = LFInstrument 
        title = #LOC_SpaceDust_switcher_instrument_lf 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_lf_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_lf_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot1 
                    Instrument = LiquidFuelSpectrometer 
                } 
            } 
        } 
    } 
} 
MODULE 
{ 
    name = ModuleB9PartSwitch 
    moduleID = instrumentSlot2 
    switcherDescription = #LOC_SpaceDust_switcher_instrument_slot2_title 

    SUBTYPE 
    { 
        name = None 
        title = #LOC_SpaceDust_switcher_instrument_none 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_none_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_none_detail 
        primaryColor = #111111 
        secondaryColor = #111111 
        addedMass = 0 
        addedCost = 0 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = None 
                } 
            } 
        } 
    } 
    // 
    SUBTYPE 
    { 
        name = XeInstrument 
        title = #LOC_SpaceDust_switcher_instrument_xe 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_xe_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_xe_detail 
        primaryColor = #60a7be 
        secondaryColor = #60a7be 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = XenonSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = OxInstrument 
        title = #LOC_SpaceDust_switcher_instrument_ox 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_ox_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_ox_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = OxidizerSpectrometer 
                } 
            } 
        } 
    } 
    SUBTYPE 
    { 
        name = LFInstrument 
        title = #LOC_SpaceDust_switcher_instrument_lf 
        descriptionSummary = #LOC_SpaceDust_switcher_instrument_lf_summary 
        descriptionDetail = #LOC_SpaceDust_switcher_instrument_lf_detail 
        primaryColor = #3399cc 
        secondaryColor = #3399cc 
        addedMass = 0.2 
        addedCost = 50000 

        MODULE 
        { 
            IDENTIFIER 
            { 
                name = ModuleSpaceDustTelescope 
            } 
            DATA 
            { 
                SLOT 
                { 
                    name = slot2 
                    Instrument = LiquidFuelSpectrometer 
                } 
            } 
        } 
    }       
}

}

@PART[tele_body]:NEEDS[SpaceDust] {

@MODULE[ModuleSpaceDustTelescope]
{ 
    @PowerCost = 16
    @ScanAnimationName = tele_openaperture 
    @ObjectiveSize = 2.5
    @FieldOfView = 0.000969627362992369 
} 

}

@PART[tele_body2]:NEEDS[SpaceDust] {

@MODULE[ModuleSpaceDustTelescope]
{ 
    @PowerCost = 10
    @ScanAnimationName = body2_open 
    @ObjectiveSize = 1.6
    @FieldOfView = 0.000969627362992369 
} 

}

`

ChrisAdderley commented 3 years ago

It doesn't look like this patch is removing the (presumed) ModuleAnimateGeneric on the cacteye parts. I would guess that they are conflicting because both modules would try to manage the animation.

The slots are set up by the B9PS module, they allow players to pick what instruments go on the telescope. Instruments are defined here - they're not real parts.

linuxgurugamer commented 3 years ago

Correct, I wasn't removing the ModuleAnimateGeneric. Ok, thank you, I'll make the fixes and try it out

linuxgurugamer commented 3 years ago

So I have that working, but removing the MOduleAnimateGeneric broke some of the functionality, since I directly call the Toggle() method in ModuleanimateGeneric when a button is clicked in the GUI

Do you have a wrapper I could use to call the appropriate method in your mod? I'd prefer the wrapper not require a hard compile dependency, if possible.

Specifically, the Start Survey/Stop Survey. If necessary, I can code around this, just need to know where and what the proper calls are.

ChrisAdderley commented 3 years ago

You could try using reflection or monobehaviour Invoke to call DisableTelescope() and EnableTelescope()

linuxgurugamer commented 3 years ago

I'll have to use Reflection, I also need to know the state of the animation.

ChrisAdderley commented 3 years ago

So, what do I need to do to help you here then?

linuxgurugamer commented 3 years ago

Just one more question: How can I tell if it's working? I decided to do a hard dependency, simpler than doing reflection. So it's done, I just want to test it.

I did have a small issue which I ignored, CactEye uses the animTime of ModuleAnimateGeneric to determine if it's open or closed, I used the ModuleSpaceDustTelescope.Enabled for now. The animation is less than a second, I can ignore it

ChrisAdderley commented 3 years ago

Start a new game, create a ship with the part, pick the Xenon spectrometer. Teleport to orbit, cheat electricity, target Eve. Timewarp for a while, you should eventually see a screenmessage about 'xenon discovered at eve' get posted.

linuxgurugamer commented 3 years ago

Great, thank you