Skip to content

Commit

Permalink
1.5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthPointer authored Aug 17, 2020
2 parents 9915c41 + fb12eec commit 42db164
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 25 deletions.
14 changes: 14 additions & 0 deletions GameData/PayToPlay/EngineTypes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
maxMassIgnitionsCoeff = 0.1
maxCostIgnitionsCoeff = 1
maxIgnitionRestoreCostCoeff = 0.1

maxFailureFixCostCoeff = 0.1
}
}

Expand All @@ -31,6 +33,8 @@
maxMassIgnitionsCoeff = 0.3
maxCostIgnitionsCoeff = 2
maxIgnitionRestoreCostCoeff = 0.1

maxFailureFixCostCoeff = 0.1
}
}

Expand All @@ -48,6 +52,8 @@
useSRBCost = true // Changes maintenance cost model, max as soon as ignitied once. Needed if topBaseRatedTime = -1, makes no sense if baseIgnitions = -1

subtractResourcesCost = true

maxFailureFixCostCoeff = 0.1
}
}

Expand All @@ -66,6 +72,8 @@
maxMassIgnitionsCoeff = 0.1
maxCostIgnitionsCoeff = 1
maxIgnitionRestoreCostCoeff = 0.1
maxFailureFixCostCoeff = 0.1
}
}
Expand All @@ -80,6 +88,8 @@
maxCostRatedTimeCoeff = 0.5
baseIgnitions = -1
maxFailureFixCostCoeff = 0.1
}
}
Expand All @@ -94,6 +104,8 @@
maxCostRatedTimeCoeff = 0.2
baseIgnitions = -1
maxFailureFixCostCoeff = 0.1
}
}
Expand All @@ -108,5 +120,7 @@
maxCostRatedTimeCoeff = 0.2
baseIgnitions = -1
maxFailureFixCostCoeff = 0.1
}
}
2 changes: 1 addition & 1 deletion GameData/PayToPlay/PayToPlay.version
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"NAME": "PayToPlay",
"URL": "https://raw.githubusercontent.com/DarthPointer/PayToPlay/master/GameData/PayToPlay/PayToPlay.version",
"DOWNLOAD": "https://github.com/DarthPointer/PayToPlay/releases",
"VERSION": {"MAJOR": 1, "MINOR": 5, "PATCH": 4, "BUILD": 0},
"VERSION": {"MAJOR": 1, "MINOR": 5, "PATCH": 4, "BUILD": 1},
"KSP_VERSION": {"MAJOR": 1, "MINOR": 8, "PATCH": 1},
"KSP_VERSION_MIN": {"MAJOR": 1, "MINOR": 8, "PATCH": 0},
"KSP_VERSION_MAX": {"MAJOR": 1, "MINOR": 10, "PATCH": 9}
Expand Down
Binary file modified GameData/PayToPlay/Plugins/EngineDecay.dll
Binary file not shown.
2 changes: 2 additions & 0 deletions GameData/PayToPlay/Support/Stock/RAPIER.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
decayRates = 0.01; 1
ignitionsOnSwitch = 0; 0
ignitionsUsage = 0; 1

maxFailureFixCostCoeff = 0.1
}
}
2 changes: 1 addition & 1 deletion GameData/PayToPlay/Support/Stock/SettingCategories.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@PART[toroidalAerospike,liquidEngine,liquidEngine2,liquidEngine1-2,radialLiquidEngine1-2,engineLargeSkipper,SSME,Size2LFB,Size3EngineCluster]:BEFORE[PayToPlay]
@PART[toroidalAerospike,liquidEngine,liquidEngine2,liquidEngine1-2,radialLiquidEngine1-2,engineLargeSkipper,engineLargeSkipper_v2,SSME,Size2LFB,Size3EngineCluster,liquidEngineMainsail_v2]:BEFORE[PayToPlay]
{
MODULE
{
Expand Down
Binary file modified Source/EngineDecay/.vs/EngineDecay/v16/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
99 changes: 76 additions & 23 deletions Source/EngineDecay/EngineDecay/EngineDecay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public class EngineDecay : PartModule, IPartMassModifier, IPartCostModifier

List<bool> ignitionsOnSwitchList = new List<bool>();

[KSPField(isPersistant = true, guiActive = false)]
float maxFailureFixCostCoeff = 0.1f;

[KSPField(isPersistant = true, guiActive = false)]
int currentFailureFixCost = 0;

[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Extra Burn Time Percent", guiFormat = "D"),
UI_FloatEdit(scene = UI_Scene.Editor, minValue = 0, maxValue = 100, incrementLarge = 20, incrementSmall = 5, incrementSlide = 1)]
public float extraBurnTimePercent = 0;
Expand Down Expand Up @@ -187,7 +193,7 @@ public class EngineDecay : PartModule, IPartMassModifier, IPartCostModifier
float holdIndicatorsTill = 0;
int partSymmetryCounterpartsCount = -1;

List<ModuleEngines> decayingEngines;
List<ModuleEngines> decayingEngines = new List<ModuleEngines>();
MultiModeEngine modeSwitcher;

PartModule procSRBCylinder;
Expand Down Expand Up @@ -271,6 +277,7 @@ void Maintenance()
UpdateReplaceCost();

maintenanceCost = 0;
currentFailureFixCost = 0;
Events["MaintenanceEvent"].guiActiveEditor = false;
}

Expand Down Expand Up @@ -331,6 +338,8 @@ void CounterpartMaintenance(int cost)

int UpdateMaintenanceCost()
{
maintenanceCost = 0;

if (!useSRBCost)
{
maintenanceCost = (int)(knownPartCost * (1f + extraBurnTimePercent * maxCostRatedTimeCoeff / 100f) * maintenanceAtRatedTimeCoeff * usedBurnTime / setBurnTime);
Expand All @@ -352,6 +361,15 @@ int UpdateMaintenanceCost()
maintenanceCost += UpdateIgnitionRestoreCost();
}

if (issueCode == 1)
{
if (currentFailureFixCost == 0)
{
currentFailureFixCost = (int)(fullPartCost * UnityEngine.Random.Range(maxFailureFixCostCoeff / 2, maxFailureFixCostCoeff));
}
maintenanceCost += currentFailureFixCost;
}

if (maintenanceCost > 0 || issueCode != 0)
{
Events["MaintenanceEvent"].guiActiveEditor = true;
Expand All @@ -362,7 +380,7 @@ int UpdateMaintenanceCost()
Events["MaintenanceEvent"].guiActiveEditor = false;
}

//maintenanceCost = maintenanceCost < fullPartCost ? maintenanceCost : (int)fullPartCost;
Lib.Log($"Maintenance Cost is set to {maintenanceCost}");

return maintenanceCost;
}
Expand Down Expand Up @@ -400,6 +418,7 @@ void ReplaceEvent()
}

maintenanceCost = 0;
currentFailureFixCost = 0;
Events["MaintenanceEvent"].guiActiveEditor = false;

if (baseIgnitions != -1 && !useSRBCost)
Expand Down Expand Up @@ -456,6 +475,7 @@ void SymmetryReplace()
void ReplaceFromCounterpart()
{
maintenanceCost = 0;
currentFailureFixCost = 0;
symmetryMaintenanceCost = 0;
Events["MaintenanceEvent"].guiActiveEditor = false;
Events["SymmetryMaintenance"].guiActiveEditor = false;
Expand Down Expand Up @@ -557,6 +577,8 @@ void IgnitionRestoreEvent()
if (i != null)
{
engineDecay.CounterpartIgnitionRestore(ignitionRestoreCost);
engineDecay.CounterpartMaintenance(ignitionRestoreCost);
engineDecay.CounterpartReplace(ignitionRestoreCost);
}
else
{
Expand All @@ -567,6 +589,8 @@ void IgnitionRestoreEvent()
Lib.Log($"Separately Ign-Restored part keeps Symm Ign Restore Cost {symmetryIgnitionRestoreCost}, Ign Restore Cost is {ignitionRestoreCost}");
CounterpartIgnitionRestore(ignitionRestoreCost);
Lib.Log($"Resulting Symm Ign Restore Cost is {symmetryIgnitionRestoreCost}");
CounterpartMaintenance(ignitionRestoreCost);
CounterpartReplace(ignitionRestoreCost);

IgnitionRestore();

Expand Down Expand Up @@ -636,9 +660,6 @@ void IgnitionRestoreFromCounterpart()

void CounterpartIgnitionRestore(int cost)
{
CounterpartMaintenance(cost);
CounterpartReplace(cost);

if (symmetryIgnitionRestoreCost != 0)
{
symmetryIgnitionRestoreCost -= cost;
Expand Down Expand Up @@ -778,39 +799,39 @@ public override void OnCopy(PartModule fromModule)
{
base.OnCopy(fromModule);
UpdateModelState();
/*UpdateReliabilityProgress();
usedBurnTime = -1;
knownPartCost = -1;
if (baseIgnitions != -1)
{
ignitionsLeft = setIgnitions;
}*/
}

public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
if (node.HasValue("nominal")) // Support for pre-1.5.4.0 saves (noncritical, to be removed at some point)
if (node != null)
{
if (!bool.Parse(node.GetValue("nominal")))
if (node.HasValue("nominal")) // Support for pre-1.5.4.0 saves (noncritical, to be removed at some point)
{
if (node.HasValue("reliabilityStatus"))
if (!bool.Parse(node.GetValue("nominal")))
{
if (node.GetValue("reliabilityStatus") == "out of ignitions")
if (node.HasValue("reliabilityStatus"))
{
issueCode = 2;
if (node.GetValue("reliabilityStatus") == "out of ignitions")
{
issueCode = 2;
}
else
{
issueCode = 1;
}
}
else
{
issueCode = 1;
}
}
else
{
issueCode = 1;
}
}
}
else
{
Lib.Log("Loaded from null Node");
}
}

public override void OnStart(StartState state)
Expand Down Expand Up @@ -1018,8 +1039,24 @@ public void Update()
}
}

void ReviewSymmetryCosts(List<Part> counterparts)
void ReviewSymmetryCosts(List<Part> counterparts) // Returns true if succeeds
{
if (counterparts == null)
{
return;
}
foreach (Part i in counterparts)
{
if (i == null)
{
return;
}
else
{
Lib.Log($"Counterpart {i.name}, not null");
}
}

if (baseIgnitions != -1 && !useSRBCost)
{
symmetryIgnitionRestoreCost = UpdateIgnitionRestoreCost();
Expand All @@ -1032,12 +1069,14 @@ void ReviewSymmetryCosts(List<Part> counterparts)
EngineDecay engineDecay = i.FindModuleImplementing<EngineDecay>();
if (engineDecay != null)
{
Lib.Log("Found an non-null EngineDecay, updating costs");
if (baseIgnitions != -1 && !useSRBCost)
{
symmetryIgnitionRestoreCost += engineDecay.UpdateIgnitionRestoreCost();
}
symmetryMaintenanceCost += engineDecay.UpdateMaintenanceCost();
symmetryReplaceCost += engineDecay.UpdateReplaceCost();
Lib.Log("Costs updating complete");
}
else
{
Expand Down Expand Up @@ -1097,7 +1136,18 @@ void ReviewSymmetryCosts(List<Part> counterparts)

partSymmetryCounterpartsCount = counterparts.Count();

foreach (Part i in counterparts)
{
EngineDecay engineDecay = i.FindModuleImplementing<EngineDecay>();
if(engineDecay != null)
{
engineDecay.partSymmetryCounterpartsCount = partSymmetryCounterpartsCount;
}
}

GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);

Lib.Log($"Costs reviewing complete, found {partSymmetryCounterpartsCount} counterparts");
}

public void FixedUpdate()
Expand Down Expand Up @@ -1135,7 +1185,10 @@ public void FixedUpdate()
Events["SymmetryMaintenance"].guiActiveEditor = false;
Events["SymmetryReplace"].guiActiveEditor = false;

part.PartActionWindow.displayDirty = true;
if (part.PartActionWindow != null)
{
part.PartActionWindow.displayDirty = true;
}

partSymmetryCounterpartsCount = 0;
}
Expand Down
Binary file modified Source/EngineDecay/EngineDecay/bin/Debug/EngineDecay.dll
Binary file not shown.
Binary file modified Source/EngineDecay/EngineDecay/bin/Debug/EngineDecay.pdb
Binary file not shown.
Binary file not shown.
Binary file modified Source/EngineDecay/EngineDecay/obj/Debug/EngineDecay.dll
Binary file not shown.
Binary file modified Source/EngineDecay/EngineDecay/obj/Debug/EngineDecay.pdb
Binary file not shown.

0 comments on commit 42db164

Please sign in to comment.