RimWorld

RimWorld

Ancient mining industry
Fixes for ore dresser + gravship landing + 2 more
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.


Bug 3: the tunnel boring machine's boringCells, dumpingCells, and wallCells are not updated when the machine is manually relocated.
By "manually relocated" I mean that the building is minified, hauled, then redeployed elsewhere.

This becomes a problem when the TBM meets a water tile, automatically stops, but the boringCells are over water. In this case the player will try to relocate the TBM, but it will refuse to start since its boringCells still touches water, meaning that the TBM is essentially bricked there.

Sometimes the TBM stops before moving boringCells over water, in which case it can be restarted, so the easiest way to reproduce the nasty case of the bug is to build the TBM with boringCells over water.

Anyway the fix is to move the GetBoringCells() and GetDumpingCells() calls from Building_BoringMachine::Tick() to the end of Building_BoringMachine::SpawnSetup() .


Bug 4: "Object reference not set to an instance of an object" error in minified TBM description
How to reproduce: build a TBM, uninstall it, SAVE, (restart game?,) LOAD your save, then select the minified TBM. The error will appear in the inspector window.

The problem is that Building_BoringMachine.progress accessors use this.progressTicks which needs this.extension, but extension is only set after being deployed, so it's null for minified buildings.

I suggest checking if .extension is null in .progress accessors and returning 0 / bailing if it is.


Bug 5: "Object reference not set to an instance of an object" error when selecting minified automatic drills
I have not investigated this one yet, but it looks similar to bug 4 for a different building.
Sidst redigeret af Insane Chainsaw; 11. okt. kl. 16:22