Skip to content

Commit

Permalink
Merge pull request #32 from Sigma88/Development
Browse files Browse the repository at this point in the history
v0.7.4
  • Loading branch information
Sigma88 committed Dec 16, 2016
2 parents fd943b8 + aec49ee commit 44098ad
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 44 deletions.
7 changes: 7 additions & 0 deletions Changelog.txt
@@ -1,3 +1,10 @@
**v0.7.4**

- Fixed a bug that made atmoTopLayer apply multiple times
- Tweaked PQSCity_Groups loader for better compatibility
- PQSCity_Groups centered on the KSC will be moved if KSC is moved


**v0.7.3**

- Time warp limits and other parameters now account for atmoTopLayer
Expand Down
2 changes: 1 addition & 1 deletion GameData/Sigma/Dimensions/Configs/Sigma-Dimensions.version
Expand Up @@ -13,7 +13,7 @@
{
"MAJOR": 0,
"MINOR": 7,
"PATCH": 3,
"PATCH": 4,
"BUILD": 0
},
"KSP_VERSION":
Expand Down
Binary file modified GameData/Sigma/Dimensions/Plugins/SigmaDimensions.dll
Binary file not shown.
Binary file modified [Source]/Distribution/SigmaDimensions.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion [Source]/SigmaDimensions/AtmosphereTopLayer.cs
Expand Up @@ -7,7 +7,7 @@

namespace SigmaDimensionsPlugin
{
[KSPAddon(KSPAddon.Startup.MainMenu, false)]
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class AtmosphereTopLayer : MonoBehaviour
{
Ktype curve = Ktype.Exponential;
Expand Down
51 changes: 31 additions & 20 deletions [Source]/SigmaDimensions/PQSCityGroupsLoader.cs
Expand Up @@ -7,53 +7,56 @@
namespace SigmaDimensionsPlugin
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class PQSCityGroupsLoader : MonoBehaviour
public class PQSCityGroups : MonoBehaviour
{
public static Dictionary<string, ConfigNode> GroupList = new Dictionary<string, ConfigNode>();
Dictionary<string, ConfigNode> GroupsList = new Dictionary<string, ConfigNode>();
public static List<ConfigNode> ExternalGroups = new List<ConfigNode>();

void Start()
{
foreach (ConfigNode GroupLoader in GameDatabase.Instance.GetConfigNodes("PQSCity_Groups"))
foreach (ConfigNode GroupsLoader in GameDatabase.Instance.GetConfigNodes("PQSCity_Groups"))
{
PQSCityGroups.AddGroups(GroupLoader.GetNodes("Group"));
AddGroups(GroupsLoader.GetNodes("Group"));
}
PQSCityGroups.SaveGroups();
AddGroups(ExternalGroups.ToArray());

SaveGroups();
}
}

public static class PQSCityGroups
{
public static void AddGroups(ConfigNode[] Groups)
void AddGroups(ConfigNode[] Groups)
{
foreach (ConfigNode Group in Groups)
{
string name = Group.GetValue("name");
if (string.IsNullOrEmpty(name)) continue;
if (PQSCityGroupsLoader.GroupList.ContainsKey(name))
PQSCityGroupsLoader.GroupList[name].AddData(Group);
if (GroupsList.ContainsKey(name))
GroupsList[name].AddData(Group);
else
PQSCityGroupsLoader.GroupList.Add(name, Group);
GroupsList.Add(name, Group);
}
}

public static void SaveGroups()
void SaveGroups()
{
foreach (ConfigNode Group in PQSCityGroupsLoader.GroupList.Values)
foreach (ConfigNode Group in GroupsList.Values)
{
string name = Group.GetValue("name");
CelestialBody body = FlightGlobals.Bodies.First(b => b.transform.name == Group.GetValue("body"));
if (string.IsNullOrEmpty(name) || body == null) continue;

Vector3Parser center = new Vector3Parser();
if (Group.HasValue("CentralPQSCity"))
{
center = body.GetComponentsInChildren<PQSCity>(true).FirstOrDefault(p => p.name == Group.GetValue("CentralPQSCity")).repositionRadial;
}
else if (Group.HasValue("CentralPQSCity2"))
{
PQSCity2 city2 = body.GetComponentsInChildren<PQSCity2>(true).First(p => p.name == Group.GetValue("CentralPQSCity2"));
center = Utility.LLAtoECEF(city2.lat, city2.lon, 1, 1);
center = (Vector3)body.GetComponentsInChildren<PQSCity2>(true).First(p => p.name == Group.GetValue("CentralPQSCity2")).PlanetRelativePosition;
}
else if (Group.HasValue("CentralPosition"))
{
center.SetFromString(Group.GetValue("CentralPosition"));
}
else if (Group.HasValue("CentralLAT") && Group.HasValue("CentralLON"))
{
EnumParser<double> LAT = new EnumParser<double>();
Expand All @@ -62,21 +65,29 @@ public static void SaveGroups()
LON.SetFromString(Group.GetValue("CentralLON"));
center = Utility.LLAtoECEF(LAT, LON, 1, 1);
}
else if (Group.HasValue("PQSCity"))
{
center = body.GetComponentsInChildren<PQSCity>(true).FirstOrDefault(p => p.name == Group.GetValue("PQSCity")).repositionRadial;
}
else if (Group.HasValue("PQSCity2"))
{
center = (Vector3)body.GetComponentsInChildren<PQSCity2>(true).First(p => p.name == Group.GetValue("CentralPQSCity2")).PlanetRelativePosition;
}
else continue;

if (!body.Has("PQSCityGroups"))
body.Set("PQSCityGroups", new Dictionary<object, Vector3>());
Dictionary<object, Vector3> PQSList = body.Get<Dictionary<object, Vector3>>("PQSCityGroups");

foreach (string pqs in Group.GetValues("PQSCity"))
foreach (string city in Group.GetValues("PQSCity"))
{
PQSCity mod = body.GetComponentsInChildren<PQSCity>(true).First(m => m.name == pqs);
PQSCity mod = body.GetComponentsInChildren<PQSCity>(true).First(m => m.name == city);
if (mod != null && !PQSList.ContainsKey(mod))
PQSList.Add(mod, center);
}
foreach (string pqs in Group.GetValues("PQSCity2"))
foreach (string city2 in Group.GetValues("PQSCity2"))
{
PQSCity2 mod = body.GetComponentsInChildren<PQSCity2>(true).First(m => m.name == pqs);
PQSCity2 mod = body.GetComponentsInChildren<PQSCity2>(true).First(m => m.name == city2);
if (mod != null && !PQSList.ContainsKey(mod))
PQSList.Add(mod, center);
}
Expand Down

0 comments on commit 44098ad

Please sign in to comment.