RimWorld

RimWorld

Ancient mining industry
Fixes for ore dresser + gravship landing
Bug 1: the ore dresser machine bug
The cause is this line in StoneCutter.cs:
pickUpCells = GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize);
The problem is that AdjacentCells8Way() returns a reference to a static list, so pickUpCells contains the correct result at the beginning, but once something else uses AdjacentCells8Way() then pickUpCells contains the result given to the other thing and your ore dresser will look for rocks somewhere else on the map.

The fix is to replace the quoted line by:
pickUpCells = new List<IntVec3>(); GenAdjFast.AdjacentCells8Way(parent.Position, parent.Rotation, parent.RotatedSize).CopyToList(pickUpCells);


Bug 2: can't use gravships to go to mining missions
Solution: adding
<gravShipsCanLandOn>true</gravShipsCanLandOn>
inside all <SitePartDef> in Site_Cluster.xml


Bonus
You can remove the StoneCutterUtil class, the base game already has a cached list of all rock chunk defs. What you wanted to do can be done by replacing the inner foreach loop in TryFindChunk() by:
var thingsOnCell = cell.GetThingList(parent.Map); foreach (var thing in thingsOnCell) { if (thing is null) continue; if (ThingCategoryDefOf.StoneChunks.ContainedInThisOrDescendant(thing.def)) { return thing; } }
Internally, ContainedInThisOrDescendant() uses a cached HashSet so it's not rebuilding a list at every call.