Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: KSP-RO/RP-1
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f59753e5aac3
Choose a base ref
...
head repository: KSP-RO/RP-1
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6ac90bc70790
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Aug 5, 2017

  1. Fix new tank placement

    NathanKell committed Aug 5, 2017
    Copy the full SHA
    91879bd View commit details
  2. FIXED.

    NathanKell committed Aug 5, 2017
    Copy the full SHA
    6ac90bc View commit details
Showing with 53 additions and 14 deletions.
  1. BIN GameData/RP-0/Plugins/RP0.dll
  2. +6 −6 GameData/RP-0/Tree/TREE-Parts.cfg
  3. +8 −0 Source/Tooling/ModuleTooling.cs
  4. +39 −8 Source/Tooling/ToolingDatabase.cs
Binary file modified GameData/RP-0/Plugins/RP0.dll
Binary file not shown.
12 changes: 6 additions & 6 deletions GameData/RP-0/Tree/TREE-Parts.cfg
Original file line number Diff line number Diff line change
@@ -23859,7 +23859,7 @@
}
@PART[RFTank-IV]:FOR[xxxRP0]
{
%TechRequired = start
%TechRequired = materialsScienceLunar
%cost = 0.1
%entryCost = 2
RP0conf = true
@@ -23873,31 +23873,31 @@
RP0conf = true
@description ^=:$: From Procedural Parts mod
}
@PART[SM-I]:FOR[xxxRP0]
@PART[RFSM-I]:FOR[xxxRP0]
{
%TechRequired = earlyMaterialsScience
%TechRequired = postWarMaterialsScience
%cost = 0.1
%entryCost = 10000
RP0conf = true
@description ^=:$: From Procedural Parts mod
}
@PART[SM-II]:FOR[xxxRP0]
@PART[RFSM-II]:FOR[xxxRP0]
{
%TechRequired = materialsScienceHuman
%cost = 0.1
%entryCost = 20000
RP0conf = true
@description ^=:$: From Procedural Parts mod
}
@PART[SM-III]:FOR[xxxRP0]
@PART[RFSM-III]:FOR[xxxRP0]
{
%TechRequired = materialsScienceAdvCapsules
%cost = 0.1
%entryCost = 40000
RP0conf = true
@description ^=:$: From Procedural Parts mod
}
@PART[SM-IV]:FOR[xxxRP0]
@PART[RFSM-IV]:FOR[xxxRP0]
{
%TechRequired = materialsScienceLunar
%cost = 0.1
8 changes: 8 additions & 0 deletions Source/Tooling/ModuleTooling.cs
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ public virtual void ToolingEvent()
{
Funding.Instance.AddFunds(-toolingCost, TransactionReasons.RnDPartPurchase);
PurchaseTooling();
GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
Events["ToolingEvent"].guiActiveEditor = false;
}
}, 140.0f, 30.0f, true),
@@ -79,6 +80,13 @@ public virtual void ToolingEvent()

public abstract bool IsUnlocked();

public override void OnAwake()
{
base.OnAwake();

tEvent = Events["ToolingEvent"];
}

public override void OnLoad(ConfigNode node)
{
base.OnLoad(node);
47 changes: 39 additions & 8 deletions Source/Tooling/ToolingDatabase.cs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

namespace RP0
{
public struct ToolingDiameter
public class ToolingDiameter
{
public double diameter;

@@ -48,6 +48,7 @@ protected static int DiamIndex(double diam, List<ToolingDiameter> lst, out int m
do
{
int mid = (min + max) / 2;
Debug.Log("[ModuleTooling]: For diam " + diam + ", " + min + ", " + max + ", " + mid + ", count " + lst.Count);
switch (EpsilonCompare(diam, lst[mid].diameter))
{
case 0:
@@ -74,6 +75,7 @@ protected static int LengthIndex(double length, List<double> lst, out int min)
do
{
int mid = (min + max) / 2;
Debug.Log("[ModuleTooling]: For diam " + length + ", " + min + ", " + max + ", " + mid + ", count " + lst.Count);
switch (EpsilonCompare(length, lst[mid]))
{
case 0:
@@ -102,52 +104,81 @@ public enum ToolingLevel

public static ToolingLevel HasTooling(string type, double diam, double len)
{
//Debug.Log("[Tooling]: Looking for " + type + ", " + diam + " x " + len);

List<ToolingDiameter> lst;
if (toolings.TryGetValue(type, out lst))
{
if (lst.Count == 0)
return ToolingLevel.None;

int tmp;
int dIndex = DiamIndex(diam, lst, out tmp);
if (dIndex == -1)
{
//Debug.Log("Not found");
return ToolingLevel.None;
}

int lIndex = LengthIndex(len, lst[dIndex].lengths, out tmp);

return lIndex == -1 ? ToolingLevel.Diameter : ToolingLevel.Full;
if (lIndex == -1)
{
//Debug.Log("Found diameter");
return ToolingLevel.Diameter;
}
else
{
//Debug.Log("Found tooling");
return ToolingLevel.Full;
}
}

return ToolingLevel.None;
}

public static bool UnlockTooling(string type, double diam, double len)
{
//Debug.Log("[Tooling]: Purchasing " + type + ", " + diam + " x " + len);

List<ToolingDiameter> lst;
if (toolings.TryGetValue(type, out lst))
if (!toolings.TryGetValue(type, out lst))
{
lst = new List<ToolingDiameter>();
toolings[type] = lst;
}
if (lst.Count == 0)
{
lst.Add(new ToolingDiameter(diam, len));
return true;
}
else
{

int insertionIdx;
int dIndex = DiamIndex(diam, lst, out insertionIdx);
if (dIndex == -1)
{
ToolingDiameter d = new ToolingDiameter(diam, len);
lst.Insert(insertionIdx, d);
//Debug.Log("Inserting new diameter and length");
return true;
}

int lIndex = LengthIndex(len, lst[dIndex].lengths, out insertionIdx);

if (lIndex != -1)
{
//Debug.Log("Purchased already!!!");
return false;
}
else
{
ToolingDiameter d = lst[dIndex];
d.lengths.Insert(insertionIdx, len);
lst[dIndex] = d;
lst[dIndex].lengths.Insert(insertionIdx, len);
//Debug.Log("Inserting new length");
return true;
}
}
else
return false;
}