Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected CBAttributeMap.MapAttribute Toadicus_GetAtt()
- {
- CBAttributeMap.MapAttribute mapAttribute;
- try
- {
- CBAttributeMap BiomeMap = vessel.mainBody.BiomeMap;
- double lat = vessel.latitude * Math.PI / 180d;
- double lon = vessel.longitude * Math.PI / 180d;
- lon -= Math.PI / 2d;
- if (lon < 0d)
- {
- lon += 2d * Math.PI;
- }
- float v = (float)(lat / Math.PI) + 0.5f;
- float u = (float)(lon / (2d * Math.PI));
- Color pixelBilinear = BiomeMap.Map.GetPixelBilinear (u, v);
- mapAttribute = BiomeMap.defaultAttribute;
- if (BiomeMap.Map != null)
- {
- if (BiomeMap.exactSearch)
- {
- for (int i = 0; i < BiomeMap.Attributes.Length; ++i)
- {
- if (pixelBilinear == BiomeMap.Attributes[i].mapColor)
- {
- mapAttribute = BiomeMap.Attributes[i];
- }
- }
- }
- else
- {
- float zero = 0;
- float num = 1 / zero;
- for (int j = 0; j < BiomeMap.Attributes.Length; ++j)
- {
- Color mapColor = BiomeMap.Attributes [j].mapColor;
- float sqrMagnitude = ((Vector4)(mapColor - pixelBilinear)).sqrMagnitude;
- if (sqrMagnitude < num)
- {
- bool testCase = true;
- if (BiomeMap.nonExactThreshold != -1)
- {
- testCase = (sqrMagnitude < BiomeMap.nonExactThreshold);
- }
- if (testCase)
- {
- mapAttribute = BiomeMap.Attributes[j];
- num = sqrMagnitude;
- }
- }
- }
- }
- }
- }
- catch (NullReferenceException)
- {
- mapAttribute = new CBAttributeMap.MapAttribute();
- mapAttribute.name = "N/A";
- }
- return mapAttribute;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement