Closed GarwelGarwel closed 7 years ago
I can only assume that the reason is that FrozenKerbalsListMethod.Invoke(actualDFAPI, null)
in FrozenKerbalsList property doesn't return List<KeyValuePair<string, KerbalInfo>>
. But I have no idea why.
I know of several mods that do. Including two of my own. Can you supply a link to your source so I can take a look?
This is what I use (the code is here in IsKerbalFrozen
function):
if (!DFWrapper.APIReady) return false;
foreach (KeyValuePair<string, DFWrapper.KerbalInfo> el in DFWrapper.DeepFreezeAPI.FrozenKerbalsList)
if (el.Key == name) return true;
Whether I use FrozenKerbals or FrozenKerbalsList, it doesn't work. The former returns an empty Vocabulary, the latter returns null.
Where do you initialize the Reflection wrapper class? It's most likely a timing issue. Have you check that it initializes correctly?
I do it in a method called by Start(), FixedUpdate() and OnSave(). The initializer works ok and DFWrapper.APIReady() then returns true, but the frozen kerbals collections are either empty or null.
I will try it all again when 1.3 comes out (and DF is updated).
I don't think that will change anything to be honest. There are several mods using it. Wondering if you are having a timing issue or similar. Might be worth looking at one of those to compare. I doubt anything in 1.3 will change it. You could use my GameEvent I created as well. https://github.com/JPLRepo/DeepFreeze/blob/master/Source/APIs/DFGameEvents.cs
and refer to here on how it works: http://forum.kerbalspaceprogram.com/index.php?/topic/153112-ksp-122-gameevents-extension/
Thanks, will try.
I know of two other mods that integrate with DF, and they are working fine. Closing.
It looks like you can't access DF's FrozenKerbals list through the DFWrapper class.
When using
DFWrapper.DeepFreezeAPI.FrozenKerbals
(the dictionary), it always has 0 members. ReferringDFWrapper.DeepFreezeAPI.FrozenKerbalsList
causes an exception like this:InvalidCastException: Cannot cast from source type to destination type. at DeepFreezeWrapper.DFWrapper+DFAPI.get_FrozenKerbalsList () [0x00000] in <filename unknown>:0