Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API FrozenKerbals lists not working #71

Closed
GarwelGarwel opened this issue Mar 12, 2017 · 8 comments
Closed

API FrozenKerbals lists not working #71

GarwelGarwel opened this issue Mar 12, 2017 · 8 comments

Comments

@GarwelGarwel
Copy link

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. Referring DFWrapper.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

@GarwelGarwel
Copy link
Author

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.

@JPLRepo
Copy link
Owner

JPLRepo commented Mar 26, 2017

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?

@GarwelGarwel
Copy link
Author

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.

@JPLRepo
Copy link
Owner

JPLRepo commented Apr 8, 2017

Where do you initialize the Reflection wrapper class?
It's most likely a timing issue. Have you check that it initializes correctly?

@GarwelGarwel
Copy link
Author

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).

@JPLRepo
Copy link
Owner

JPLRepo commented Apr 9, 2017

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/

@GarwelGarwel
Copy link
Author

Thanks, will try.

@JPLRepo
Copy link
Owner

JPLRepo commented Jun 11, 2017

I know of two other mods that integrate with DF, and they are working fine.
Closing.

@JPLRepo JPLRepo closed this as completed Jun 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants