Skip to content

Commit

Permalink
Implement functionality of custom ground stations and add default gro…
Browse files Browse the repository at this point in the history
…und stations for starting new game in setting file
  • Loading branch information
KSP-TaxiService committed May 4, 2020
1 parent 291df61 commit 7315e69
Show file tree
Hide file tree
Showing 12 changed files with 464 additions and 40 deletions.
1 change: 1 addition & 0 deletions GameData/CommNetConstellation/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Localization
#CNC_Constellation_getName = Not-Found
#CNC_CNCCommNetHome_freqlist = Broadcasting in
#CNC_CNCCommNetHome_frequency = ~ frequency
#CNC_CNCCommNetHome_nostation = Build a ground station

#CNC_ToolsNames_UpdateList = Update List
#CNC_ToolsNames_AntennaSelection = Antenna Selection
Expand Down
1 change: 1 addition & 0 deletions GameData/CommNetConstellation/Localization/zh-cn.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Localization
#CNC_Constellation_getName = 未找到
#CNC_CNCCommNetHome_freqlist = 广播
#CNC_CNCCommNetHome_frequency = ~ 频段
#CNC_CNCCommNetHome_nostation = Build a ground station

#CNC_ToolsNames_UpdateList = 更新列表
#CNC_ToolsNames_AntennaSelection = 天线选择
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
160 changes: 160 additions & 0 deletions GameData/CommNetConstellation/cnc_settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,177 @@ CommNetConstellationSettings
color = 0.65, 0.65, 0.65, 1
}
}
//Default list of ground stations
UpgradeableGroundStationCosts = 100000;300000;900000
UpgradeableGroundStationPowers = 3.1E+06;2E+07;6E+07
KSCMissionControlPowers = 4E+06;3.0E+07;7.5E+07
GroundStations
{
GroundStation
{
ID = Kerbin: KSC
Color = 1,0,0,1
OptionalName = Kerbal Space Center
TechLevel = 1
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
Frequency = 0
}
}
GroundStation
{
ID = Namsan
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = True
CustomLatitude = 10
CustomLongitude = -40
CustomAltitude = 10
CustomCelestialBody = Kerbin
Frequencies
{
}
}
GroundStation
{
ID = Zvezda Base
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = True
CustomLatitude = -10
CustomLongitude = -140
CustomAltitude = 10
CustomCelestialBody = Mun
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Baikerbanur
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Crater Rim
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Harvester Massif
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Mesa South
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: North Station One
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Nye Island
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Desert Launch Facility
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
GroundStation
{
ID = Kerbin: Larkes
Color = 1,0,0,1
OptionalName =
TechLevel = 0
OverrideLatLongAlt = False
CustomLatitude = 0
CustomLongitude = 0
CustomAltitude = 0
CustomCelestialBody =
Frequencies
{
}
}
}
}
40 changes: 40 additions & 0 deletions src/CommNetConstellation/CNCSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CommNetConstellation.CommNetLayer;
using System;
using System.Collections.Generic;
using UnityEngine;

Expand Down Expand Up @@ -48,8 +49,46 @@ public class Settings
[Persistent] public bool LegacyOrbitLineColor;
[Persistent(collectionIndex = "Constellation")] public List<Constellation> Constellations;
[Persistent(collectionIndex = "GroundStation")] public List<CNCCommNetHome> GroundStations;
[Persistent] private string UpgradeableGroundStationCosts = String.Empty;
[Persistent] private string UpgradeableGroundStationPowers = String.Empty;
[Persistent] private string KSCMissionControlPowers = String.Empty;
//-----

public int[] GroundStationUpgradeableCosts;
public double[] GroundStationUpgradeablePowers;
public double[] KSCStationPowers;

public void postprocess()
{
if (UpgradeableGroundStationCosts != String.Empty)
{
var tokens = UpgradeableGroundStationCosts.Split(';');
GroundStationUpgradeableCosts = new int[tokens.Length];
for (int i = 0; i < tokens.Length; i++)
{
int.TryParse(tokens[i], out GroundStationUpgradeableCosts[i]);
}
}
if (UpgradeableGroundStationPowers != String.Empty)
{
var tokens = UpgradeableGroundStationPowers.Split(';');
GroundStationUpgradeablePowers = new double[tokens.Length];
for (int i = 0; i < tokens.Length; i++)
{
double.TryParse(tokens[i], out GroundStationUpgradeablePowers[i]);
}
}
if (KSCMissionControlPowers != String.Empty)
{
var tokens = KSCMissionControlPowers.Split(';');
KSCStationPowers = new double[tokens.Length];
for (int i = 0; i < tokens.Length; i++)
{
double.TryParse(tokens[i], out KSCStationPowers[i]);
}
}
}

public static Settings Load()
{
// Create a blank object of settings
Expand Down Expand Up @@ -101,6 +140,7 @@ public static Settings Load()
}

settings.SettingsLoaded = true;
settings.postprocess();
return settings;
}
}
Expand Down
Loading

0 comments on commit 7315e69

Please sign in to comment.