Skip to content

Commit

Permalink
omnitech
Browse files Browse the repository at this point in the history
  • Loading branch information
Denadan committed Dec 9, 2018
1 parent ebbb847 commit cef7dd2
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
11 changes: 7 additions & 4 deletions mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@
"G": 180,
"B": 180,
"A": 10
},
"DefaultFlagOverlayCColor": {
},
"DefaultFlagOverlayCColor": {
"R": 180,
"G": 255,
"B": 180,
"A": 10
},
},

"TestEnableAllTags": false
"TestEnableAllTags": false,
"OmniTechFlag" = "cc_omnitech",
"OmniTechCostBySize" = false,
"OmniTechInstallCost" = 1
},

"Manifest": [ ]
Expand Down
18 changes: 13 additions & 5 deletions source/CCLight/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ internal static void ProcessCustomFactories(object target, Dictionary<string, ob
return;
}

//Control.Logger.LogDebug($"ProcessCustomCompontentFactories for {target.GetType()} ({target.GetHashCode()})");
//Control.Logger.LogDebug($"- {identifier}");

#if CCDEBUG
Control.Logger.LogDebug($"ProcessCustomCompontentFactories for {target.GetType()} ({target.GetHashCode()})");
Control.Logger.LogDebug($"- {identifier}");
#endif
foreach (var preProcessor in PreProcessors)
{
preProcessor.PreProcess(target, values);
Expand All @@ -110,17 +111,24 @@ internal static void ProcessCustomFactories(object target, Dictionary<string, ob
continue;
}

#if CCDEBUG
Control.Logger.Log($"Created {factory} for {identifier}");

#endif
Database.SetCustomWithIdentifier(identifier, component);

if (component is IAfterLoad load)
{
//Control.Logger.LogDebug($"IAfterLoad: {identifier}");
#if CCDEBUG
Control.Logger.LogDebug($"IAfterLoad: {identifier}");
#endif
load.OnLoaded(values);
}
}

//Control.Logger.LogDebug("- done");
#if CCDEBUG
Control.Logger.LogDebug("- done");
#endif
}
}
}
2 changes: 1 addition & 1 deletion source/Control.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void Init(string directory, string settingsJSON)
Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
Validator.RegisterMechValidator(CategoryController.ValidateMech, CategoryController.ValidateMechCanBeFielded);

Logger.Log("Loaded CustomComponents v0.8.3.1 for bt 1.3");
Logger.Log("Loaded CustomComponents v0.8.4.0 for bt 1.3");
#if CCDEBUG
Logger.LogDebug("Loading Categories");
#endif
Expand Down
3 changes: 3 additions & 0 deletions source/CustomComponentSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class CustomComponentSettings
[JsonIgnore] public Dictionary<string, Color> ColorTagsDictionary;

public bool TestEnableAllTags = false;
public string OmniTechFlag = "cc_omnitech";
public bool OmniTechCostBySize = false;
public int OmniTechInstallCost = 1;

public void Complete()
{
Expand Down
17 changes: 17 additions & 0 deletions source/Fixes/SimGameState_CreateComponentInstallWorkOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static void FixCost(
MechComponentRef mechComponent,
ChassisLocations newLocation,
ChassisLocations previousLocation,
string mechSimGameUID,
WorkOrderEntry_InstallComponent __result)
{
#if CCDEBUG
Expand Down Expand Up @@ -44,6 +45,22 @@ public static void FixCost(
return;

}
MechDef mechByID = __instance.GetMechByID(mechSimGameUID);
#if CCDEBUG
if (mechByID == null)
Control.Logger.LogDebug("-- no mech found!");
#endif
if (mechByID != null && mechByID.Chassis.ChassisTags.Contains(Control.Settings.OmniTechFlag))
{
#if CCDEBUG
if (mechByID == null)
Control.Logger.LogDebug("-- mech is omni!");
#endif

tr.Value = (Control.Settings.OmniTechCostBySize ? mechComponent.Def.InventorySize / 2 : 1) * Control.Settings.OmniTechInstallCost;
}


if (tr.Value == 0)
tr.Value = 1;
}
Expand Down

0 comments on commit cef7dd2

Please sign in to comment.