Jump to content

Biome detection help


jmbon

Recommended Posts

Hello, 

   I am trying to create my first addon for KSP and I am having problems detecting which biomes my active vessel is currently. I've looked through the API calls, class calls and some old code on Github but none of it has really helped. I feel like I am on the right track but hung up. Below is a snippet of my code where I am getting ready to detect the current biome my vessel is in. 

            CelestialBody Body = new CelestialBody();
            CBAttributeMapSO.MapAttribute[] biome = Body.BiomeMap.Attributes;

I feel like my Body variable is the right route or maybe my FlightGlobals.activevessel. As far as I can tell, biome above just gives me a list of the current CelestialBody biomes, is that correct?

In my code, I already have access to the Vessel class and the FlightGlobals class and my program is inheriting from : monobehavior.

Any help or hints you can give would be greatly appreciated. Thanks. 

Link to comment
Share on other sites

There are two simple ways of getting the biome for a location:

string biome = ScienceUtil.GetExperimentBiome(body, lat, long); //Returns the biome name

CBAttributeMapSO.MapAttribute biomeAtt = body.BiomeMap.GetAtt(lat, long) //(Coordinates in radians)  Returns the attribute

The attribute can be used to get the name, associated color, or the unused biome value (which I think is supposed to be some kind of science multiplier, but stock science methods don't use it).

Link to comment
Share on other sites

Thanks for the reply. Your second way is the one I was slowly heading towards. I really appreciate it. Is there a list of official biome names in the KSP API somewhere? I'm sure I can't do something like,

            if (biome.name == "my_biomeKSC")
            {
                // Do stuff
            }

I've looked through the latest Scansat source code but couldn't find a list of official c# biome names, enums, etc. Thanks again. 

Link to comment
Share on other sites

There isn't a list. Just the Body.BiomeMap.Attributes array for each planet.

Also, the KSC building biomes don't show up there. I'm not really sure how to get all of those, except for through Vessel.GetLandedAtString(vessel.landedAt), which will only tell you the specific KSC biome that you are in for that vessel.

Link to comment
Share on other sites

:blush:

Well crap. How would I tell if my craft were over the oceans biome or highlands biome? I know it's a noob question but without being able to do a logical on either a str compare or enum result, I'm temporarily in the weeds. I really do appreciate the help. Btw, huge fan of Orbital Science. It's one of my core mods where I don't even play KSP until Orbital Science is up and running for that version. :wink:

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...