diff --git a/1.1/Assemblies/TurretExtensions.dll b/1.1/Assemblies/TurretExtensions.dll
index fb2892c..428a36d 100644
Binary files a/1.1/Assemblies/TurretExtensions.dll and b/1.1/Assemblies/TurretExtensions.dll differ
diff --git a/About/About.xml b/About/About.xml
index 09f47d6..183e889 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -8,18 +8,18 @@
1.0
1.1
- Current Version: v1.3.0 (29th February 2020)\n\nA resource which allows modders to create turret mods with more flair, as well as various bugfixes and quality-of-life improvements.
+ Current Version: v1.3.1 (2nd March 2020)\n\nA resource which allows modders to create turret mods with more flair, as well as various bugfixes and quality-of-life improvements.
- UnlimitedHugs.HugsLib
- HugsLib
- https://github.com/UnlimitedHugs/RimworldHugsLib/releases/latest
- https://steamcommunity.com/sharedfiles/filedetails/?id=818773962
+ brrainz.harmony
+ Harmony
+ https://github.com/pardeike/HarmonyRimWorld/releases/latest
+ https://steamcommunity.com/workshop/filedetails/?id=2009463077
Ludeon.RimWorld
Ludeon.RimWorld.Royalty
- UnlimitedHugs.HugsLib
+ brrainz.harmony
\ No newline at end of file
diff --git a/Source/TurretExtensions/.vs/TurretExtensions/v16/.suo b/Source/TurretExtensions/.vs/TurretExtensions/v16/.suo
index 3066980..ba509f3 100644
Binary files a/Source/TurretExtensions/.vs/TurretExtensions/v16/.suo and b/Source/TurretExtensions/.vs/TurretExtensions/v16/.suo differ
diff --git a/Source/TurretExtensions/.vs/TurretExtensions/v16/Server/sqlite3/storage.ide b/Source/TurretExtensions/.vs/TurretExtensions/v16/Server/sqlite3/storage.ide
index 239dc52..48559cb 100644
Binary files a/Source/TurretExtensions/.vs/TurretExtensions/v16/Server/sqlite3/storage.ide and b/Source/TurretExtensions/.vs/TurretExtensions/v16/Server/sqlite3/storage.ide differ
diff --git a/Source/TurretExtensions/TurretExtensions/AI/JobDriver_UpgradeTurret.cs b/Source/TurretExtensions/TurretExtensions/AI/JobDriver_UpgradeTurret.cs
index 2efc26e..081b96f 100644
--- a/Source/TurretExtensions/TurretExtensions/AI/JobDriver_UpgradeTurret.cs
+++ b/Source/TurretExtensions/TurretExtensions/AI/JobDriver_UpgradeTurret.cs
@@ -114,16 +114,7 @@ private void RefundResources(float yield)
t.stackCount = c;
else
t.Destroy();
- });
- //List ingredientCount = UpgradableComp.finalCostList;
- //foreach (ThingDefCountClass thing in ingredientCount)
- //{
- // int yieldCount = GenMath.RoundRandom(thing.count * yield);
- // Thing yieldItem = ThingMaker.MakeThing(thing.thingDef);
- // yieldItem.stackCount = yieldCount;
- // if (yieldCount > 0) { GenPlace.TryPlaceThing(yieldItem, TargetThingA.Position, TargetThingA.Map, ThingPlaceMode.Near); }
- //}
- }
+ }); }
private CompUpgradable UpgradableComp
{
diff --git a/Source/TurretExtensions/TurretExtensions/AI/WorkGiver_UpgradeTurret.cs b/Source/TurretExtensions/TurretExtensions/AI/WorkGiver_UpgradeTurret.cs
index e64fc8b..d0ac4fd 100644
--- a/Source/TurretExtensions/TurretExtensions/AI/WorkGiver_UpgradeTurret.cs
+++ b/Source/TurretExtensions/TurretExtensions/AI/WorkGiver_UpgradeTurret.cs
@@ -21,8 +21,12 @@ public override Danger MaxPathDanger(Pawn pawn)
public override IEnumerable PotentialWorkThingsGlobal(Pawn pawn)
{
- foreach (Designation des in pawn.Map.designationManager.SpawnedDesignationsOfDef(DesignationDefOf.UpgradeTurret))
+ var upgradeDesignations = pawn.Map.designationManager.SpawnedDesignationsOfDef(DesignationDefOf.UpgradeTurret).ToList();
+ for (int i = 0; i < upgradeDesignations.Count; i++)
+ {
+ var des = upgradeDesignations[i];
yield return des.target.Thing;
+ }
}
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
diff --git a/Source/TurretExtensions/TurretExtensions/Comps/CompUpgradable.cs b/Source/TurretExtensions/TurretExtensions/Comps/CompUpgradable.cs
index 7f81d1b..8997e2c 100644
--- a/Source/TurretExtensions/TurretExtensions/Comps/CompUpgradable.cs
+++ b/Source/TurretExtensions/TurretExtensions/Comps/CompUpgradable.cs
@@ -44,10 +44,12 @@ private void ResolveCostList()
{
if (parent.def.MadeFromStuff && Props.costStuffCount > 0)
finalCostList.Add(new ThingDefCountClass(parent.Stuff, Props.costStuffCount));
- if (Props.costList != null)
+ var costList = Props.costList;
+ if (costList != null)
{
- foreach (ThingDefCountClass thing in Props.costList)
+ for (int i = 0; i < costList.Count; i++)
{
+ var thing = costList[i];
var duplicate = finalCostList.FirstOrDefault(t => t.thingDef == thing.thingDef);
if (duplicate != null)
duplicate.count += thing.count;
@@ -77,8 +79,9 @@ public override void PostDestroy(DestroyMode mode, Map previousMap)
{
float resourceDropFraction = (mode == DestroyMode.KillFinalize) ? Props.destroyedResourceDropPct : Props.baseResourceDropPct;
- foreach (Thing thing in innerContainer)
+ for (int i = 0; i < innerContainer.Count; i++)
{
+ var thing = innerContainer[i];
thing.stackCount = GenMath.RoundRandom(thing.stackCount * resourceDropFraction);
if (thing.stackCount == 0)
thing.Destroy();
@@ -102,8 +105,9 @@ public override string CompInspectStringExtra()
if (!finalCostList.NullOrEmpty())
{
inspectBuilder.AppendLine($"{"ContainedResources".Translate()}:");
- foreach (var cost in finalCostList)
+ for (int i = 0; i < finalCostList.Count; i++)
{
+ var cost = finalCostList[i];
var costDef = cost.thingDef;
inspectBuilder.AppendLine($"{costDef.LabelCap}: {innerContainer.TotalStackCountOfDef(costDef)} / {cost.count}");
}
@@ -122,8 +126,9 @@ public bool SufficientMatsToUpgrade
{
get
{
- foreach (var cost in finalCostList)
+ for (int i = 0; i < finalCostList.Count; i++)
{
+ var cost = finalCostList[i];
int thingCount = innerContainer.TotalStackCountOfDef(cost.thingDef);
if (thingCount < cost.count)
return false;
@@ -186,8 +191,9 @@ public List MaterialsNeeded()
cachedMaterialsNeeded.Clear();
// Determine needed materials
- foreach (var cost in finalCostList)
+ for (int i = 0; i < finalCostList.Count; i++)
{
+ var cost = finalCostList[i];
int resourceCount = innerContainer.TotalStackCountOfDef(cost.thingDef);
int amountNeeded = cost.count - resourceCount;
if (amountNeeded > 0)
diff --git a/Source/TurretExtensions/TurretExtensions/Designators/Designator_UpgradeTurret.cs b/Source/TurretExtensions/TurretExtensions/Designators/Designator_UpgradeTurret.cs
index 601c602..3428336 100644
--- a/Source/TurretExtensions/TurretExtensions/Designators/Designator_UpgradeTurret.cs
+++ b/Source/TurretExtensions/TurretExtensions/Designators/Designator_UpgradeTurret.cs
@@ -45,12 +45,14 @@ public override AcceptanceReport CanDesignateThing(Thing t) =>
public override void DesignateSingleCell(IntVec3 c)
{
- foreach (Thing t in UpgradableTurretsInSelection(c))
+ var upgradableTurrets = UpgradableTurretsInSelection(c).ToList();
+ for (int i = 0; i < upgradableTurrets.Count; i++)
{
+ var turret = upgradableTurrets[i];
if (DebugSettings.godMode)
- t.TryGetComp().upgraded = true;
+ turret.TryGetComp().upgraded = true;
else
- DesignateThing(t);;
+ DesignateThing(turret);;
}
}
@@ -62,9 +64,16 @@ public override void DesignateThing(Thing t)
CompUpgradable upgradableComp = t.TryGetComp();
upgradableComp.Upgrade();
if (upgradableComp.finalCostList != null)
- foreach (ThingDefCountClass thing in upgradableComp.finalCostList)
- for (int i = 0; i < thing.count; i++)
+ {
+ for (int i = 0; i < upgradableComp.finalCostList.Count; i++)
+ {
+ var thing = upgradableComp.finalCostList[i];
+ var initThingCount = upgradableComp.innerContainer.TotalStackCountOfDef(thing.thingDef);
+ for (int j = initThingCount; j < thing.count; j++)
upgradableComp.innerContainer.TryAdd(ThingMaker.MakeThing(thing.thingDef));
+
+ }
+ }
}
else
@@ -77,11 +86,14 @@ public override void DesignateThing(Thing t)
protected override void FinalizeDesignationSucceeded()
{
if (!DebugSettings.godMode)
- foreach (Building_Turret turret in designatedTurrets)
+ {
+ for (int i = 0; i < designatedTurrets.Count; i++)
{
+ var turret = designatedTurrets[i];
NotifyPlayerOfInsufficientSkill(turret);
NotifyPlayerOfInsufficientResearch(turret);
}
+ }
designatedTurrets.Clear();
}
@@ -91,8 +103,10 @@ private void NotifyPlayerOfInsufficientSkill(Thing t)
{
bool meetsMinSkill = false;
int minimumSkill = t.TryGetComp().Props.constructionSkillPrerequisite;
- foreach (Pawn pawn in Find.CurrentMap.mapPawns.FreeColonists)
+ var freeColonists = Find.CurrentMap.mapPawns.FreeColonists;
+ for (int i = 0; i < freeColonists.Count; i++)
{
+ var pawn = freeColonists[i];
if (pawn.skills.GetSkill(SkillDefOf.Construction).Level >= minimumSkill)
{
meetsMinSkill = true;
@@ -112,8 +126,9 @@ private void NotifyPlayerOfInsufficientResearch(Thing t)
List researchProjectsUnfinished = new List();
if (researchRequirements != null)
{
- foreach (ResearchProjectDef research in researchRequirements)
+ for (int i = 0; i < researchRequirements.Count; i++)
{
+ var research = researchRequirements[i];
if (!research.IsFinished)
{
researchRequirementsMet = false;
diff --git a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/HarmonyPatches.cs b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/HarmonyPatches.cs
index 2e917f6..055d106 100644
--- a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/HarmonyPatches.cs
+++ b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/HarmonyPatches.cs
@@ -19,7 +19,10 @@ public static class HarmonyPatches
static HarmonyPatches()
{
- //Harmony.DEBUG = true;
+ #if DEBUG
+ Harmony.DEBUG = true;
+ #endif
+
TurretExtensions.harmonyInstance.PatchAll();
// Gizmo_RefuelableFuelStatus delegate
@@ -33,6 +36,10 @@ static HarmonyPatches()
Patch_ThingDef.manual_SpecialDisplayStats.enumeratorType = thingDefEnumeratorType;
TurretExtensions.harmonyInstance.Patch(thingDefEnumeratorType.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).First(m => m.Name == "MoveNext"),
transpiler: new HarmonyMethod(typeof(Patch_ThingDef.manual_SpecialDisplayStats), "Transpiler"));
+
+ // Fully refuel devmode gizmo
+ TurretExtensions.harmonyInstance.Patch(typeof(CompRefuelable).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Last(m => m.Name.Contains("CompGetGizmosExtra")),
+ transpiler: new HarmonyMethod(typeof(Patch_CompRefuelable), nameof(Patch_CompRefuelable.FuelCapacityTranspiler)));
}
diff --git a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Building_Turret.cs b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Building_Turret.cs
index c221b46..38c1731 100644
--- a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Building_Turret.cs
+++ b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Building_Turret.cs
@@ -36,6 +36,10 @@ public static class PreApplyDamage
public static IEnumerable Transpiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Building_Turret.PreApplyDamage (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
for (int i = 0; i < instructionList.Count; i++)
@@ -49,8 +53,12 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions, ILGenerator ilGen)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Building_TurretGun.DrawExtraSelectionOverlays (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
var drawRadiusRingInfo = AccessTools.Method(typeof(GenDraw), nameof(GenDraw.DrawRadiusRing), new Type[] { typeof(IntVec3), typeof(float) });
@@ -48,8 +52,12 @@ public static IEnumerable Transpiler(IEnumerable x
yield return new CodeInstruction(OpCodes.Ldarg_0); // this
yield return instructionList[i - 2].Clone(); // num
diff --git a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_CompRefuelable.cs b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_CompRefuelable.cs
index 0650b10..160b7b1 100644
--- a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_CompRefuelable.cs
+++ b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_CompRefuelable.cs
@@ -22,6 +22,10 @@ public static class Patch_CompRefuelable
// As of 25th July 2019, still haven't been able to top this one in terms of copypasta potential
public static IEnumerable FuelCapacityTranspiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: CompRefuelable.FuelCapacityTranspiler (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
var adjustedFuelCapacity = AccessTools.Method(typeof(TurretExtensionsUtility), nameof(TurretExtensionsUtility.AdjustedFuelCapacity));
@@ -32,10 +36,15 @@ public static IEnumerable FuelCapacityTranspiler(IEnumerable Transpiler(IEnumerable instructions)
{
- var instructionList = instructions.ToList();
-
- var adjustedFuelCapacity = AccessTools.Method(typeof(TurretExtensionsUtility), nameof(TurretExtensionsUtility.AdjustedFuelCapacity));
- var adjustedFuelCount = AccessTools.Method(typeof(GetFuelCountToFullyRefuel), nameof(AdjustedFuelCount));
-
- for (int i = 0; i < instructionList.Count; i++)
- {
- CodeInstruction instruction = instructionList[i];
-
- if (instruction.IsFuelCapacityInstruction())
- {
- yield return instruction;
- yield return new CodeInstruction(OpCodes.Ldarg_0);
- yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(CompRefuelable), nameof(CompRefuelable.parent)));
- instruction = new CodeInstruction(OpCodes.Call, adjustedFuelCapacity);
- }
-
- if (instruction.opcode == OpCodes.Stloc_0)
- {
- yield return instruction;
- yield return new CodeInstruction(OpCodes.Ldloc_0);
- yield return new CodeInstruction(OpCodes.Ldarg_0);
- yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(CompRefuelable), nameof(CompRefuelable.parent)));
- yield return new CodeInstruction(OpCodes.Call, adjustedFuelCount);
- instruction = new CodeInstruction(OpCodes.Stloc_0);
- }
-
- yield return instruction;
- }
+ return FuelCapacityTranspiler(instructions);
}
- private static float AdjustedFuelCount(float currentFuelCount, Thing thing) =>
- currentFuelCount / (thing.IsUpgraded(out CompUpgradable uC) ? uC.Props.fuelMultiplierFactor : 1f);
-
}
}
diff --git a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Gizmo_RefuelableFuelStatus.cs b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Gizmo_RefuelableFuelStatus.cs
index 7b2e6cf..2e11358 100644
--- a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Gizmo_RefuelableFuelStatus.cs
+++ b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_Gizmo_RefuelableFuelStatus.cs
@@ -24,6 +24,10 @@ public static class manual_GizmoOnGUI_Delegate
public static IEnumerable Transpiler(IEnumerable instructions, MethodBase method, ILGenerator ilGen)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Gizmo_RefuelableFuelStatus.manual_GizmoOnGUI_Delegate (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
// Add local
@@ -40,8 +44,12 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: JobDriver_ManTurret.FindAmmoForTurret (1 match)");
+ #endif
+
+
var instructionList = instructions.ToList();
var pawnInfo = typeof(JobDriver_ManTurret).GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Instance).
@@ -39,6 +44,10 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Pawn_RotationTracker.UpdateRotation (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
var draftedGetterInfo = AccessTools.Property(typeof(Pawn), nameof(Pawn.Drafted)).GetGetMethod();
var canRotateDraftedPawnInfo = AccessTools.Method(typeof(UpdateRotation), nameof(CanRotateDraftedPawn));
@@ -34,6 +38,10 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: ThingDef.manual_SpecialDisplayStats (1 match)");
+ #endif
+
// Runs inside MoveNext()
var instructionList = instructions.ToList();
var turretGunDefInfo = AccessTools.Field(typeof(BuildingProperties), nameof(BuildingProperties.turretGunDef));
@@ -39,6 +43,10 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions)
{
+ #if DEBUG
+ Log.Message("Transpiler start: TurretTop.DrawTurret (2 matches)");
+ #endif
+
var instructionList = instructions.ToList();
var turretTopOffsetToUse = AccessTools.Method(typeof(DrawTurret), nameof(TurretTopOffsetToUse));
var turretTopDrawSizeToUse = AccessTools.Method(typeof(DrawTurret), nameof(TurretTopDrawSizeToUse));
+ var turretTopOffsetInfo = AccessTools.Field(typeof(BuildingProperties), nameof(BuildingProperties.turretTopOffset));
+ var turretTopDrawSizeInfo = AccessTools.Field(typeof(BuildingProperties), nameof(BuildingProperties.turretTopDrawSize));
for (int i = 0; i < instructionList.Count; i++)
{
var instruction = instructionList[i];
- if (instruction.opcode == OpCodes.Ldflda && instruction.operand == AccessTools.Field(typeof(BuildingProperties), nameof(BuildingProperties.turretTopOffset)))
+ if (instruction.opcode == OpCodes.Ldflda && instruction.OperandIs(turretTopOffsetInfo))
{
+ #if DEBUG
+ Log.Message("TurretTop.DrawTurret match 1 of 2");
+ #endif
+
instruction.opcode = OpCodes.Ldfld;
yield return instruction;
yield return new CodeInstruction(OpCodes.Ldarg_0);
@@ -42,15 +52,16 @@ public static IEnumerable Transpiler(IEnumerable Transpiler(IEnumerable instructions, ILGenerator ilGen)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Verb.DrawHighlight (no matches)");
+ #endif
+
var instructionList = instructions.ToList();
var drawRadiusRingInfo = AccessTools.Method(typeof(VerbProperties), nameof(VerbProperties.DrawRadiusRing));
var tryDrawFiringConeInfo = AccessTools.Method(typeof(DrawHighlight), nameof(DrawHighlight.TryDrawFiringCone));
- var instructionToBranchTo = instructionList[instructionList.FirstIndexOf(i => i.operand == drawRadiusRingInfo) + 1];
+ var instructionToBranchTo = instructionList[instructionList.FirstIndexOf(i => i.OperandIs(drawRadiusRingInfo)) + 1];
var branchLabel = ilGen.DefineLabel();
instructionToBranchTo.labels.Add(branchLabel);
diff --git a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_WorkGiver_ConstructDeliverResources.cs b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_WorkGiver_ConstructDeliverResources.cs
index d778c6c..30920c9 100644
--- a/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_WorkGiver_ConstructDeliverResources.cs
+++ b/Source/TurretExtensions/TurretExtensions/HarmonyPatches/Patch_WorkGiver_ConstructDeliverResources.cs
@@ -20,6 +20,10 @@ public static class Patch_WorkGiver_ConstructDeliverResources
#region Shared Transpiler
public static IEnumerable IConstructibleCastCorrecterTranspiler(IEnumerable instructions, OpCode iConstructibleOpcode)
{
+ #if DEBUG
+ Log.Message("Transpiler start: Patch_WorkGiver_ConstructDeliverResources.IConstructibleCastCorrecterTranspiler (1 match)");
+ #endif
+
var instructionList = instructions.ToList();
var iConstructibleThingInfo = AccessTools.Method(typeof(Patch_WorkGiver_ConstructDeliverResources), nameof(IConstructibleThing));
@@ -34,6 +38,10 @@ public static IEnumerable IConstructibleCastCorrecterTranspiler
var nextInstruction = instructionList[i + 1];
if (nextInstruction.opcode == OpCodes.Castclass || nextInstruction.opcode == OpCodes.Isinst)
{
+ #if DEBUG
+ Log.Message("Patch_WorkGiver_ConstructDeliverResources.IConstructibleCastCorrecterTranspiler match 1 of 1");
+ #endif
+
yield return instruction; // c
instruction = new CodeInstruction(OpCodes.Call, iConstructibleThingInfo); // IConstructibleThing(c)
}
diff --git a/Source/TurretExtensions/TurretExtensions/Properties/AssemblyInfo.cs b/Source/TurretExtensions/TurretExtensions/Properties/AssemblyInfo.cs
index cf6f3f6..a693f48 100644
--- a/Source/TurretExtensions/TurretExtensions/Properties/AssemblyInfo.cs
+++ b/Source/TurretExtensions/TurretExtensions/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.3.0.1")]
-[assembly: AssemblyFileVersion("1.3.0.1")]
+[assembly: AssemblyVersion("1.3.1.0")]
+[assembly: AssemblyFileVersion("1.3.1.0")]
diff --git a/Source/TurretExtensions/TurretExtensions/StatParts/StatPart_ValueFromUpgrade.cs b/Source/TurretExtensions/TurretExtensions/StatParts/StatPart_ValueFromUpgrade.cs
index 181500f..f9565b5 100644
--- a/Source/TurretExtensions/TurretExtensions/StatParts/StatPart_ValueFromUpgrade.cs
+++ b/Source/TurretExtensions/TurretExtensions/StatParts/StatPart_ValueFromUpgrade.cs
@@ -13,11 +13,11 @@ public override void TransformValue(StatRequest req, ref float val)
{
if (req.Thing?.GetInnerIfMinified() is Building_Turret turret && turret.IsUpgradable(out CompUpgradable uC))
{
- //Log.Message(uC.ToStringSafe());
if (!uC.finalCostList.NullOrEmpty())
{
- foreach (Thing thing in uC.innerContainer)
+ for (int i = 0; i < uC.innerContainer.Count; i++)
{
+ var thing = uC.innerContainer[i];
val += thing.MarketValue * thing.stackCount;
}
}
diff --git a/Source/TurretExtensions/TurretExtensions/StaticConstructorClass.cs b/Source/TurretExtensions/TurretExtensions/StaticConstructorClass.cs
index 24fe424..78e4190 100644
--- a/Source/TurretExtensions/TurretExtensions/StaticConstructorClass.cs
+++ b/Source/TurretExtensions/TurretExtensions/StaticConstructorClass.cs
@@ -15,8 +15,11 @@ public static class StaticConstructorClass
static StaticConstructorClass()
{
- foreach (var tDef in DefDatabase.AllDefs)
+ var allThingDefs = DefDatabase.AllDefsListForReading;
+ for (int i = 0; i < allThingDefs.Count; i++)
{
+ var tDef = allThingDefs[i];
+
// Make sure that all turrets have accuracy readouts by defining ShootingAccuracyTurret
if (tDef.building != null && tDef.building.IsTurret && (tDef.statBases == null || !tDef.statBases.Any(s => s.stat == StatDefOf.ShootingAccuracyTurret)))
{
diff --git a/Source/TurretExtensions/TurretExtensions/TurretExtensions.cs b/Source/TurretExtensions/TurretExtensions/TurretExtensions.cs
index 5d6a4a2..ae3f148 100644
--- a/Source/TurretExtensions/TurretExtensions/TurretExtensions.cs
+++ b/Source/TurretExtensions/TurretExtensions/TurretExtensions.cs
@@ -15,6 +15,10 @@ public class TurretExtensions : Mod
public TurretExtensions(ModContentPack content) : base(content)
{
+ #if DEBUG
+ Log.Error("XeoNovaDan left debugging enabled in Turret Extensions - please let him know!");
+ #endif
+
harmonyInstance = new Harmony("XeoNovaDan.TurretExtensions");
}
diff --git a/Source/TurretExtensions/TurretExtensions/TurretExtensions.csproj b/Source/TurretExtensions/TurretExtensions/TurretExtensions.csproj
index 4063f0b..467dcab 100644
--- a/Source/TurretExtensions/TurretExtensions/TurretExtensions.csproj
+++ b/Source/TurretExtensions/TurretExtensions/TurretExtensions.csproj
@@ -18,7 +18,7 @@
none
false
..\..\..\1.1\Assemblies\
- DEBUG;TRACE
+ TRACE
prompt
4
AnyCPU
@@ -37,9 +37,8 @@
false
-
- False
- ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\workshop\content\294100\818773962\v1.1\Assemblies\0Harmony.dll
+
+ ..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\workshop\content\294100\2009463077\Assemblies\0Harmony.dll
False
diff --git a/Source/TurretExtensions/TurretExtensions/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/Source/TurretExtensions/TurretExtensions/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 70665ed..fdc4253 100644
Binary files a/Source/TurretExtensions/TurretExtensions/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/Source/TurretExtensions/TurretExtensions/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.csprojAssemblyReference.cache b/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.csprojAssemblyReference.cache
index d386c7a..ceb7d84 100644
Binary files a/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.csprojAssemblyReference.cache and b/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.csprojAssemblyReference.cache differ
diff --git a/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.dll b/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.dll
index fb2892c..428a36d 100644
Binary files a/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.dll and b/Source/TurretExtensions/TurretExtensions/obj/Debug/TurretExtensions.dll differ