Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.

Commit

Permalink
1.0 config pass, Check math
Browse files Browse the repository at this point in the history
  • Loading branch information
Crzyrndm committed May 1, 2015
1 parent b206c06 commit 055dbf7
Show file tree
Hide file tree
Showing 330 changed files with 175 additions and 2,776 deletions.
17 changes: 0 additions & 17 deletions .gitattributes

This file was deleted.

41 changes: 39 additions & 2 deletions FilterExtension/ConfigNodes/Check.cs → ConfigNodes/Check.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@ namespace FilterExtensions.ConfigNodes

public class Check
{
public enum Equality
{
Equals, // default
LessThan,
GreaterThan
}

public string type { get; set; } // type of check to perform (module, title/name, resource,...)
public string value { get; set; }
public bool invert { get; set; }
public bool contains { get; set; }
public Equality equality { get; set; }
public List<Check> checks { get; set; }

public Check(ConfigNode node)
Expand All @@ -38,6 +46,19 @@ public Check(ConfigNode node)
checks.Add(new Check(subNode));
}
}

switch (node.GetValue("equality"))
{
case "LessThan":
equality = Equality.LessThan;
break;
case "GreaterThan":
equality = Equality.GreaterThan;
break;
default:
equality = Equality.Equals;
break;
}
}

public Check(string type, string value, bool invert = false, bool contains = true)
Expand All @@ -56,6 +77,7 @@ public ConfigNode toConfigNode()
node.AddValue("value", this.value);
node.AddValue("invert", this.invert.ToString());
node.AddValue("contains", this.contains.ToString());
node.AddValue("equality", this.equality.ToString());

foreach (Check c in this.checks)
node.AddNode(c.toConfigNode());
Expand Down Expand Up @@ -106,14 +128,29 @@ public bool checkPart(AvailablePart part)
result = PartType.checkCategory(part, value);
break;
case "size": // check by largest stack node size
result = PartType.checkPartSize(part, value, contains);
result = PartType.checkPartSize(part, value, contains, equality);
break;
case "crew":
result = PartType.checkCrewCapacity(part, value);
result = PartType.checkCrewCapacity(part, value, equality);
break;
case "custom": // for when things get tricky
result = PartType.checkCustom(part, value);
break;
case "mass":
result = PartType.checkMass(part, value, equality);
break;
case "cost":
result = PartType.checkCost(part, value, equality);
break;
case "crash":
result = PartType.checkCrashTolerance(part, value, equality);
break;
case "maxTemp":
result = PartType.checkTemperature(part, value, equality);
break;
case "profile":
result = PartType.checkBulkHeadProfiles(part, value, contains);
break;
case "check":
foreach (Check c in checks)
{
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion FilterExtension/Core.cs → Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ private static void loadIcons()
RUI.Icons.Selectable.Icon icon = new RUI.Icons.Selectable.Icon(name, t.texture, selectedTex, false);
Instance.iconDict.Add(icon.name, icon);
}

}
}

Expand Down
1 change: 0 additions & 1 deletion FilterExtension/Editor.cs → Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace FilterExtensions
[KSPAddon(KSPAddon.Startup.EditorAny, false)]
class Editor : MonoBehaviour
{
List<Sorting> sorters = new List<Sorting>();
public static Editor instance;
void Start()
{
Expand Down
231 changes: 0 additions & 231 deletions FilterCreator/.gitignore

This file was deleted.

Loading

0 comments on commit 055dbf7

Please sign in to comment.