diff --git a/Mods/Minerals/Source/Minerals/Minerals.csproj b/Mods/Minerals/Source/Minerals/Minerals.csproj
index 2e6ef06262..cdbf9ac57c 100644
--- a/Mods/Minerals/Source/Minerals/Minerals.csproj
+++ b/Mods/Minerals/Source/Minerals/Minerals.csproj
@@ -36,16 +36,16 @@
..\..\..\Hardcore-SK-Source\R1.1\Assemblies\0Harmony.dll
- references\Assembly-CSharp.dll
+ ..\..\..\Assemblies\Assembly-CSharp.dll
False
- ..\..\..\..\..\public\Hardcore-SK\Mods\Core_SK\Assemblies\Core_SK.dll
+ ..\..\..\Assemblies\Core_SK.dll
False
- references\UnityEngine.CoreModule.dll
+ ..\..\..\Assemblies\UnityEngine.CoreModule.dll
False
diff --git a/Mods/Minerals/Source/Minerals/Minerals.userprefs b/Mods/Minerals/Source/Minerals/Minerals.userprefs
deleted file mode 100644
index f81d925b6d..0000000000
--- a/Mods/Minerals/Source/Minerals/Minerals.userprefs
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Mods/Minerals/Source/Minerals/StaticMineral.cs b/Mods/Minerals/Source/Minerals/StaticMineral.cs
index b059cef792..8c32edb754 100644
--- a/Mods/Minerals/Source/Minerals/StaticMineral.cs
+++ b/Mods/Minerals/Source/Minerals/StaticMineral.cs
@@ -1,4 +1,4 @@
-
+
using System;
using System.Collections.Generic;
using System.Linq;
@@ -124,6 +124,7 @@ public virtual ThingDef_StaticMineral attributes
public virtual void incPctYeild(float amount, Pawn miner)
{
+ //Log.Message("incPctYeild Entered with Pawn: " + miner.def.defName + ". Amount: " + amount);
// Increase yeild for when it is destroyed
float minerYield = 1f;
if (miner.def.race.IsMechanoid)
@@ -172,6 +173,7 @@ public virtual void incPctYeild(float amount, Pawn miner)
{
minerSkill = miner.skills.GetSkill(SkillDefOf.Mining).Level;
}
+ //Log.Message("minerSkill is: " + minerSkill);
float proportionDamaged = (float) Mathf.Min(amount, HitPoints) / (float) MaxHitPoints;
float proportionMined = proportionDamaged * minerYield;
yieldPct += proportionMined;
diff --git a/Mods/Minerals/Source/Minerals/harmonyPatching.cs b/Mods/Minerals/Source/Minerals/harmonyPatching.cs
index 72c44781de..135cc873ae 100644
--- a/Mods/Minerals/Source/Minerals/harmonyPatching.cs
+++ b/Mods/Minerals/Source/Minerals/harmonyPatching.cs
@@ -9,6 +9,13 @@
using RimWorld; // RimWorld specific functions
using Verse; // RimWorld universal objects
using RimWorld.Planet;
+using System.Runtime.CompilerServices;
+using PatchOperationWhatHappened;
+using SK.Enlighten;
+using System.IO;
+using Verse.Noise;
+using Log = Verse.Log;
+using SK;
namespace Minerals
{
@@ -41,12 +48,29 @@ public static void MakeRocksAccordingToBiome(int tile, ref World __instance, ref
// Pick a set of random rocks
Rand.PushState();
Rand.Seed = tile;
- List list = (from d in DefDatabase.AllDefs
- where d.category == ThingCategory.Building && d.building.isNaturalRock && !d.building.isResourceRock &&
- !d.IsSmoothed && d.defName != "GU_RoseQuartz" && d.defName != "AB_SlimeStone" &&
- d.defName != "GU_AncientMetals" && d.defName != "AB_Cragstone" && d.defName != "AB_Obsidianstone" &&
- d.defName != "BiomesIslands_CoralRock" && d.defName != "LavaRock" && d.defName != "AB_Mudstone"
- select d).ToList();
+
+ // Disabled since found great impact on tps. Skyarkhangel. 01.04.2024.
+ // Made list of stones hardcoded, until not found solution.
+
+ //List list = (from d in DefDatabase.AllDefs
+ // where d.category == ThingCategory.Building && d.building.isNaturalRock && !d.building.isResourceRock &&
+ // !d.IsSmoothed && d.defName != "GU_RoseQuartz" && d.defName != "AB_SlimeStone" &&
+ // d.defName != "GU_AncientMetals" && d.defName != "AB_Cragstone" && d.defName != "AB_Obsidianstone" &&
+ // d.defName != "BiomesIslands_CoralRock" && d.defName != "LavaRock" && d.defName != "AB_Mudstone"
+ // select d).ToList();
+
+ List list = new List
+ {
+ ThingDefOf.Sandstone,
+ ThingDefOf.Granite,
+ ThingDef.Named("Slate"),
+ ThingDef.Named("Limestone"),
+ ThingDef.Named("Marble"),
+ ThingDef.Named("ZF_BasaltBase"),
+ ThingDef.Named("ZF_ClaystoneBase"),
+ ThingDef.Named("ZF_MudstoneBase")
+ };
+
int num = Rand.RangeInclusive(MineralsMain.Settings.terrainCountRangeSetting.min, MineralsMain.Settings.terrainCountRangeSetting.max);
if (num > list.Count)
{
@@ -135,7 +159,68 @@ public static void Prefix(ref IEnumerable things)
}
things = replacementList;
}
- }
+ }
+
+ [HarmonyPatch(typeof(GenStep_PreciousLump))]
+ [HarmonyPatch("Generate")]
+ [HarmonyPatch(new Type[] { typeof(Map), typeof(GenStepParams)})]
+ static class GenStep_PreciousLump_Patch
+ {
+ [HarmonyPrefix]
+ public static bool Prefix(GenStep_PreciousLump __instance, Map map, GenStepParams parms)
+ {
+ if (parms.sitePart != null && parms.sitePart.parms.preciousLumpResources != null)
+ __instance.forcedDefToScatter = parms.sitePart.parms.preciousLumpResources;
+ else
+ __instance.forcedDefToScatter = __instance.mineables.RandomElement();
+
+ if (__instance.forcedDefToScatter is ThingDef_StaticMineral)
+ {
+ ThingDef_StaticMineral mineral = __instance.forcedDefToScatter as ThingDef_StaticMineral;
+ float averageDropAmount = 0;
+ float averageMarketValue = 0;
+ foreach (var item in mineral.randomlyDropResources)
+ {
+ averageDropAmount += item.DropProbability * item.CountPerDrop;
+ averageMarketValue += (item.DropProbability * item.CountPerDrop) * DefDatabase.GetNamed(item.ResourceDefName).BaseMarketValue;
+ }
+ int count = mineral.randomlyDropResources.Count;
+ __instance.count = 1;
+ float randomRangeAmount = __instance.totalValueRange.RandomInRange;
+ int minimumLumps = Mathf.Max(Mathf.RoundToInt((averageMarketValue / __instance.totalValueRange.min) * 6),2);
+ __instance.forcedLumpSize = Mathf.Max(Mathf.RoundToInt(randomRangeAmount /
+ ((averageDropAmount / count) * (averageMarketValue / count))), 1) + Rand.Range(minimumLumps, minimumLumps * 2);
+
+ float preRoundedValue = randomRangeAmount / (averageDropAmount / count) * (averageMarketValue / count);
+
+ //Log.Message("Calculation: " + randomRangeAmount + " / (" + averageDropAmount + " / " + count +") * (" + averageMarketValue + " / " + count + ") = " + preRoundedValue);
+ //Log.Message("Spawning Precious Lumps for: " + __instance.forcedDefToScatter.defName + ". Forced Lump size is: " + __instance.forcedLumpSize);
+
+ GenStep_ScatterLumpsMineable gen = new GenStep_ScatterLumpsMineable
+ {
+ forcedDefToScatter = __instance.forcedDefToScatter,
+ count = __instance.count,
+ forcedLumpSize = __instance.forcedLumpSize
+ };
+
+ gen.Generate(map,parms);
+
+ return false;
+ }
+
+ return true;
+ }
+ }
+ [HarmonyPatch(typeof(CompLongRangeMineralScanner))]
+ [HarmonyPatch("SetDefaultTargetMineral")]
+ static class SetDefaultTargetMineral_Patch
+ {
+ [HarmonyPostfix]
+ public static void Postfix(CompLongRangeMineralScanner __instance)
+ {
+ Traverse.Create(__instance).Field("targetMineable").SetValue(DefDatabase.GetNamed("SolidOreGold"));
+ }
+ }
}
}
\ No newline at end of file