ChrisViral / RealChute

Realistic parachutes for KSP
https://forum.kerbalspaceprogram.com/topic/52931-1
Other
47 stars 39 forks source link

Realchute and KIS compatability #87

Closed deadpoets closed 6 months ago

deadpoets commented 4 years ago

When deploying a real chute part via KIS, the placed part breaks and behaves badly. I reported this first at KIS, but did some digging and might have located the area that causes the incompatibility. You can see my initial report at https://github.com/ihsoft/KIS/issues/353 if you'd like.

In short, during initialization() in chutetemplate.cs, Initialize() is skipped when inflight, resulting in a chute placed by KIS returning -1 for GetModelIndex and GetCanopyIndex.

Starwaster commented 4 years ago

Real Chutes + KIS is going to be more problematic than stock chutes + KIS given that by its very nature, Real Chutes is designed to be customized by the player via the editor so there's an assumption there that it's always going through the editor.

I see that when you originally created this issue that you suggested a possible fix but that probably wouldn't have worked as suggested. I'll look into it when I have a chance but RC version 1 is pretty much in maintenance mode right now given that Chris is working on RC version 2. Version 1 will get updated for new KSP updates and KSP only bugs fixed but inter mod compatibility probably won't be. And inter mod compatibility with KIS has become especially problematic over the past few years many KIS updates ago.

deadpoets commented 4 years ago

I did realize that first proposal was probably going to cause issues. I came up with https://github.com/deadpoets/RealChute/commit/a9694c253dac4b60f659bfc4fa496066064d0cea which from within the game seems to work fine. a KIS attached chute is created with exactly the same parameters as a chute attached in VAB. It also functions the same in regards to deceleration and touchdown speeds. However, a look in the logs shows I'm not as smart as I wish I were: Condition:Module ProceduralChute threw during OnStart: System.NullReferenceException: Object reference not set to an instance of an object at RealChute.ChuteTemplate.Initialize () [0x00064] in <0980195774564296bca0048ed900eb03>:0 at RealChute.ProceduralChute+<>c.<OnStart>b__51_0 (RealChute.ChuteTemplate c) [0x00000] in <0980195774564296bca0048ed900eb03>:0 at System.Collections.Generic.List1[T].ForEach (System.Action1[T] action) [0x00024] in <ad04dee02e7e4a85a1299c7ee81c79f6>:0 at RealChute.ProceduralChute.OnStart (PartModule+StartState state) [0x000d5] in <0980195774564296bca0048ed900eb03>:0 at Part.ModulesOnStart () [0x00120] in <9d71e4043e394d78a6cf9193ad011698>:0 StackTrace: LogType: Error I'm fairly novice at this, but I am trying to get familiar with C# and Unity, and this seemed like a good way to get myself more acclimated. I'll keep plugging away, and if I should find an elegant solution, I'll post it here or submit a pull request.

Feel free to handle this any way you see fit. It certainly isn't game breaking, as you can run KIS and Real Chutes fine together, and deploy stock chutes via KIS as is and still get the 'default' Real Chute parameters attached to the stock chute.

Starwaster commented 4 years ago

That nullref is probably from trying to grab the value of vessel. You gave ChuteTemplate PartModule as a parent class but it's not going to be initializing the vessel field because it's not really a module on the vessel.

deadpoets commented 4 years ago

Maybe I can do something with a lambda there.

ChrisViral commented 6 months ago

Probably more work than it's worth for RC1, will not be attempting this