Skip to content

Commit

Permalink
Rename KKLaunchSite Class to KKLanchSite to fix KCT integration
Browse files Browse the repository at this point in the history
  • Loading branch information
GER-Space committed Mar 9, 2018
1 parent 041a7ed commit c3f8df1
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 62 deletions.
Binary file modified GameData/KerbalKonstructs/KerbalKonstructs.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Core/LaunchSites/LaunchSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace KerbalKonstructs.Core
{
public class KKLaunchSite : KKFacility
public class LaunchSite : KKFacility
{
//public string OpenCloseState = "Closed";
//public float OpenCost;
Expand Down Expand Up @@ -61,7 +61,7 @@ public class KKLaunchSite : KKFacility

internal override KKFacility ParseConfig(ConfigNode node)
{
KKLaunchSite launchSite = base.ParseConfig(node) as KKLaunchSite;
LaunchSite launchSite = base.ParseConfig(node) as LaunchSite;
launchSite.lsGameObject = launchSite.gameObject;
// this is might be slow
launchSite.parentInstance = InstanceUtil.GetStaticInstanceForGameObject(lsGameObject);
Expand Down
73 changes: 42 additions & 31 deletions src/Core/LaunchSites/LaunchSiteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,32 @@ namespace KerbalKonstructs.Core
{
public class LaunchSiteManager
{
private static Dictionary<string,KKLaunchSite> launchSites = new Dictionary<string, KKLaunchSite>();
private static Dictionary<string,LaunchSite> launchSites = new Dictionary<string, LaunchSite>();
private static string currentLaunchSite = "Runway";
private static Texture defaultLaunchSiteLogo = GameDatabase.Instance.GetTexture("KerbalKonstructs/Assets/DefaultSiteLogo", false);
public static float rangeNearestOpenBase = 0f;
public static string nearestOpenBase = "";
public static float rangeNearestBase = 0f;
public static string nearestBase = "";

internal static KKLaunchSite runway = new KKLaunchSite();
internal static KKLaunchSite launchpad = new KKLaunchSite();
internal static LaunchSite runway = new LaunchSite();
internal static LaunchSite launchpad = new LaunchSite();



// Handy get of all launchSites
public static KKLaunchSite[] allLaunchSites = null;
public static LaunchSite[] allLaunchSites = null;


// API for Kerbal Construction Time not for internal use
public static List<LaunchSite> AllLaunchSites
{
get
{
return allLaunchSites.ToList();
}
}


private static float getKSCLon
{
Expand Down Expand Up @@ -151,7 +162,7 @@ internal static void AttachLaunchSite(StaticInstance instance, ConfigNode instan
/// <param name="cfgNode"></param>
internal static void CreateLaunchSite(StaticInstance instance, ConfigNode cfgNode)
{
KKLaunchSite newSite = (instance.gameObject.AddComponent<KKLaunchSite>()).ParseConfig(cfgNode) as KKLaunchSite;
LaunchSite newSite = (instance.gameObject.AddComponent<LaunchSite>()).ParseConfig(cfgNode) as LaunchSite;
instance.hasLauchSites = true;
instance.launchSite = newSite;
RegisterLaunchSite(newSite);
Expand All @@ -161,7 +172,7 @@ internal static void CreateLaunchSite(StaticInstance instance, ConfigNode cfgNod
/// Registers the a created LaunchSite to the PSystemSetup and LaunchSiteManager
/// </summary>
/// <param name="site"></param>
internal static void RegisterLaunchSite(KKLaunchSite site)
internal static void RegisterLaunchSite(LaunchSite site)
{
if (! string.IsNullOrEmpty(site.LaunchSiteName) && site.parentInstance.gameObject.transform.Find(site.LaunchPadTransform) != null)
{
Expand Down Expand Up @@ -216,7 +227,7 @@ internal static void RegisterLaunchSite(KKLaunchSite site)
}


internal static void DeleteLaunchSite (KKLaunchSite site2delete)
internal static void DeleteLaunchSite (LaunchSite site2delete)
{
if (launchSites.ContainsKey(site2delete.LaunchSiteName))
{
Expand All @@ -233,18 +244,18 @@ internal static void DeleteLaunchSite (KKLaunchSite site2delete)
}


internal static void AddLaunchSite(KKLaunchSite site2add)
internal static void AddLaunchSite(LaunchSite site2add)
{
launchSites.Add(site2add.LaunchSiteName, site2add);
List<KKLaunchSite> tmpList = launchSites.Values.ToList();
tmpList.Sort(delegate (KKLaunchSite a, KKLaunchSite b)
List<LaunchSite> tmpList = launchSites.Values.ToList();
tmpList.Sort(delegate (LaunchSite a, LaunchSite b)
{
return (a.LaunchSiteName).CompareTo(b.LaunchSiteName);
});
allLaunchSites = tmpList.ToArray();
}

internal static KKLaunchSite GetCurrentLaunchSite()
internal static LaunchSite GetCurrentLaunchSite()
{
return launchSites[currentLaunchSite];
}
Expand Down Expand Up @@ -317,7 +328,7 @@ public static void setSiteLocked(string siteName)
{
if (launchSites.ContainsKey(siteName))
{
KKLaunchSite site = launchSites[siteName];
LaunchSite site = launchSites[siteName];
launchSites[siteName].OpenCloseState = launchSites[siteName].OpenCloseState + "Locked";
}
}
Expand All @@ -330,7 +341,7 @@ public static void setSiteUnlocked(string siteName)
{
if (launchSites.ContainsKey(siteName))
{
KKLaunchSite site = launchSites[siteName];
LaunchSite site = launchSites[siteName];
if (site.OpenCloseState == "OpenLocked")
{
site.OpenCloseState = "Open";
Expand All @@ -352,7 +363,7 @@ public static void getSiteOpenCloseState(string siteName, out string sOpenCloseS
{
if (launchSites.ContainsKey(siteName))
{
KKLaunchSite site = launchSites[siteName];
LaunchSite site = launchSites[siteName];
sOpenCloseState = site.OpenCloseState;
fOpenCost = site.OpenCost;
}
Expand All @@ -370,7 +381,7 @@ public static bool getIsSiteLocked(string siteName)
{
if (launchSites.ContainsKey(siteName))
{
KKLaunchSite site = launchSites[siteName];
LaunchSite site = launchSites[siteName];
if (site.OpenCloseState == "OpenLocked" || site.OpenCloseState == "ClosedLocked")
{
return true;
Expand Down Expand Up @@ -426,7 +437,7 @@ public static bool checkLaunchSiteExists(string siteName)


// Returns a specific Launchsite, keyed by site.name
public static KKLaunchSite GetLaunchSiteByName(string siteName)
public static LaunchSite GetLaunchSiteByName(string siteName)
{

if (checkLaunchSiteExists(siteName))
Expand All @@ -441,22 +452,22 @@ public static KKLaunchSite GetLaunchSiteByName(string siteName)


// Returns the distance in m from a position to a specified Launchsite
public static float getDistanceToBase(Vector3 position, KKLaunchSite site)
public static float getDistanceToBase(Vector3 position, LaunchSite site)
{
return Vector3.Distance(position, site.lsGameObject.transform.position);
}

// Returns the nearest open Launchsite to a position and range to the Launchsite in m
// The basic ATC feature is in here for now
public static void GetNearestOpenBase(Vector3 position, out string sBase, out float flRange, out KKLaunchSite lNearest)
public static void GetNearestOpenBase(Vector3 position, out string sBase, out float flRange, out LaunchSite lNearest)
{
SpaceCenter KSC = SpaceCenter.Instance;
var smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
string sNearestBase = "";
KKLaunchSite lNearestBase = null;
KKLaunchSite lKSC = null;
LaunchSite lNearestBase = null;
LaunchSite lKSC = null;

foreach (KKLaunchSite site in allLaunchSites)
foreach (LaunchSite site in allLaunchSites)
{

if (site.isOpen)
Expand Down Expand Up @@ -527,19 +538,19 @@ public static void GetNearestOpenBase(Vector3 position, out string sBase, out fl
}

// Returns the nearest Launchsite to a position and range in m to the Launchsite, regardless of whether it is open or closed
public static void getNearestBase(Vector3 position, out string sBase, out string sBase2, out float flRange, out KKLaunchSite lSite, out KKLaunchSite lSite2)
public static void getNearestBase(Vector3 position, out string sBase, out string sBase2, out float flRange, out LaunchSite lSite, out LaunchSite lSite2)
{
SpaceCenter KSC = SpaceCenter.Instance;
var smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
var lastSmallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
string sNearestBase = "";
KKLaunchSite lTargetSite = null;
KKLaunchSite lLastSite = null;
KKLaunchSite lKSC = null;
LaunchSite lTargetSite = null;
LaunchSite lLastSite = null;
LaunchSite lKSC = null;
string sLastNearest = "";


foreach (KKLaunchSite site in allLaunchSites)
foreach (LaunchSite site in allLaunchSites)
{
if (site.lsGameObject == null) continue;

Expand Down Expand Up @@ -595,7 +606,7 @@ public static void getNearestBase(Vector3 position, out string sBase, out string
// Pokes KSP to change the launchsite to use. There's near hackery here again that may get broken by Squad
// This only works because they use multiple variables to store the same value, basically its black magic
// Original author: medsouz
public static void setLaunchSite(KKLaunchSite site)
public static void setLaunchSite(LaunchSite site)
{
if (site.facility != null)
{
Expand All @@ -617,7 +628,7 @@ public static void setLaunchSite(KKLaunchSite site)
// SetSpaceCenterCam(site);
}

internal static void SetSpaceCenterCam(KKLaunchSite site)
internal static void SetSpaceCenterCam(LaunchSite site)
{
SpaceCenterCamera2 scCam = Resources.FindObjectsOfTypeAll<SpaceCenterCamera2>().FirstOrDefault();
if (scCam != null)
Expand All @@ -637,7 +648,7 @@ public static string getCurrentLaunchSite()

}

internal static bool CheckLaunchSiteIsValid(KKLaunchSite site)
internal static bool CheckLaunchSiteIsValid(LaunchSite site)
{
if (!KerbalKonstructs.instance.launchFromAnySite && (EditorDriver.editorFacility == EditorFacility.VAB) && (site.LaunchSiteType == SiteType.SPH))
{
Expand All @@ -655,9 +666,9 @@ internal static bool CheckLaunchSiteIsValid(KKLaunchSite site)
/// Returns the currently available default LaunchSite in a editor
/// </summary>
/// <returns></returns>
internal static KKLaunchSite GetDefaultSite()
internal static LaunchSite GetDefaultSite()
{
KKLaunchSite defaultSite = null;
LaunchSite defaultSite = null;
if (EditorDriver.editorFacility == EditorFacility.VAB)
{
defaultSite = GetLaunchSiteByName(KerbalKonstructs.instance.defaultVABlaunchsite);
Expand Down
2 changes: 1 addition & 1 deletion src/Core/SpaceCenters/CustomSpaceCenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CustomSpaceCenter
internal StaticInstance staticInstance;
internal GameObject gameObject;

public static void CreateFromLaunchsite(KKLaunchSite site)
public static void CreateFromLaunchsite(LaunchSite site)
{
StaticInstance parentinstance = site.parentInstance;
if (parentinstance != null)
Expand Down
2 changes: 1 addition & 1 deletion src/Core/StaticObjects/StaticInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal HeightReference heighReference


public bool hasLauchSites = false;
public KKLaunchSite launchSite;
public LaunchSite launchSite;

public KKFacilityType facilityType = KKFacilityType.None;
public List<KKFacility> myFacilities = new List<KKFacility>();
Expand Down
2 changes: 1 addition & 1 deletion src/Editor/EditorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static EditorGUI instance

internal static StaticInstance selectedObject = null;
internal StaticInstance selectedObjectPrevious = null;
internal static KKLaunchSite lTargetSite = null;
internal static LaunchSite lTargetSite = null;

//internal static String facType = "None";
//internal static String sGroup = "Ungrouped";
Expand Down
2 changes: 1 addition & 1 deletion src/Editor/LaunchSiteEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ internal void SaveSettings()
if (!selectedObject.hasLauchSites)
{
Log.Normal("Creating LaunchSite");
KKLaunchSite lsite = new KKLaunchSite();
LaunchSite lsite = new LaunchSite();
selectedObject.launchSite = lsite;
Log.Normal("created; lsite = " + lsite + "; launch site = " + selectedObject.launchSite);
selectedObject.hasLauchSites = true;
Expand Down
4 changes: 2 additions & 2 deletions src/KerbalKonstructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void OnVesselLaunched(ShipConstruct vVessel)
if (sitename == "KSC") return;
if (sitename == "") return;

KKLaunchSite lsSite = LaunchSiteManager.GetLaunchSiteByName(sitename);
LaunchSite lsSite = LaunchSiteManager.GetLaunchSiteByName(sitename);
float fMissionCount = lsSite.MissionCount;
lsSite.MissionCount = fMissionCount + 1;
double dSecs = HighLogic.CurrentGame.UniversalTime;
Expand Down Expand Up @@ -332,7 +332,7 @@ void OnLevelWasLoaded(GameScenes data)
{
// Prevent abuse if selector left open when switching to from VAB and SPH
LaunchSiteSelectorGUI.instance.Close();
KKLaunchSite currentSite = LaunchSiteManager.GetCurrentLaunchSite();
LaunchSite currentSite = LaunchSiteManager.GetCurrentLaunchSite();

// Check if the selected LaunchSite is valid
if (LaunchSiteManager.CheckLaunchSiteIsValid(currentSite) == false)
Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Career/CareerState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static void SaveFacilities(ConfigNode facilityNodes)
/// </summary>
internal static void LoadLaunchSites(ConfigNode launchSiteNodes)
{
foreach (KKLaunchSite site in LaunchSiteManager.allLaunchSites)
foreach (LaunchSite site in LaunchSiteManager.allLaunchSites)
{
ConfigNode lsNode;
if (launchSiteNodes.HasNode(CareerUtils.LSKeyFromName(site.LaunchSiteName)))
Expand Down Expand Up @@ -119,7 +119,7 @@ internal static void SaveLaunchsites(ConfigNode launchSiteNode)
{
string name = null;

foreach (KKLaunchSite site in LaunchSiteManager.allLaunchSites)
foreach (LaunchSite site in LaunchSiteManager.allLaunchSites)
{
name = CareerUtils.LSKeyFromName(site.LaunchSiteName);
ConfigNode lsNode = launchSiteNode.AddNode(name);
Expand Down
10 changes: 5 additions & 5 deletions src/Modules/MapIcons/MapIconDraw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ internal static MapIconDraw instance
private Boolean displayingTooltip = false;
private Boolean displayingTooltip2 = false;

static KKLaunchSite selectedSite = null;
static LaunchSite selectedSite = null;
static StaticInstance selectedFacility = null;

internal static bool mapHideIconsBehindBody = true;

private static List<StaticInstance> groundStations;
private static KKLaunchSite[] lauchSites;
private static LaunchSite[] lauchSites;

private KKLaunchSite launchSite;
private LaunchSite launchSite;
private CelestialBody body;
private StaticInstance groundStation;
private bool display2 = false;
Expand Down Expand Up @@ -300,9 +300,9 @@ private bool IsOccluded(Vector3d loc, CelestialBody body)
return true;
}

public static KKLaunchSite getSelectedSite()
public static LaunchSite getSelectedSite()
{
KKLaunchSite thisSite = selectedSite;
LaunchSite thisSite = selectedSite;
return thisSite;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("1.3.0.2")]
[assembly: AssemblyInformationalVersion("1.3.0.2")]
[assembly: AssemblyFileVersion("1.3.0.3")]
[assembly: AssemblyInformationalVersion("1.3.0.3")]
[assembly: KSPAssembly("KerbalKonstructs", 0, 9)]
6 changes: 3 additions & 3 deletions src/UI/BaseBossFlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ internal static BaseBossFlight instance
internal string Base;
internal string Base2;
internal float Range;
internal KKLaunchSite lNearest;
internal KKLaunchSite lBase;
internal KKLaunchSite lBase2;
internal LaunchSite lNearest;
internal LaunchSite lBase;
internal LaunchSite lBase2;
internal string smessage = "";
internal string sClosed;
internal float fOpenCost;
Expand Down
8 changes: 4 additions & 4 deletions src/UI/BaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static BaseManager instance
public Texture tFolded = GameDatabase.Instance.GetTexture("KerbalKonstructs/Assets/foldout", false);


public static KKLaunchSite selectedSite = null;
public static LaunchSite selectedSite = null;

GUIStyle Yellowtext;
GUIStyle TextAreaNoBorder;
Expand Down Expand Up @@ -439,13 +439,13 @@ private void InitializeLayout()
}


public static KKLaunchSite getSelectedSite()
public static LaunchSite getSelectedSite()
{
KKLaunchSite thisSite = selectedSite;
LaunchSite thisSite = selectedSite;
return thisSite;
}

public static void setSelectedSite(KKLaunchSite soSite)
public static void setSelectedSite(LaunchSite soSite)
{
selectedSite = soSite;
}
Expand Down
Loading

0 comments on commit c3f8df1

Please sign in to comment.