Fixed plants clipping against vertical hydroponics, clarified fishery version message further

This commit is contained in:
bbradson
2024-04-28 23:05:56 +02:00
parent 052425a1f0
commit 1ca55fc7b8
7 changed files with 20 additions and 19 deletions
@@ -99,11 +99,11 @@ public sealed class PrintImprovements : ClassWithFishPrepatches
if (printPlaneIndex < 0)
{
throw new InvalidOperationException(
ThrowHelper.ThrowInvalidOperationException(
"Failed to find center variable load instruction for PrintPlane call");
}
ilProcessor.InsertAt(printPlaneIndex + 1, (OpCodes.Call, methodof(AdjustCenter)));
ilProcessor.InsertRange(printPlaneIndex + 1, OpCodes.Ldarg_0, (OpCodes.Call, methodof(AdjustCenter)));
}
finally
{
@@ -111,11 +111,21 @@ public sealed class PrintImprovements : ClassWithFishPrepatches
}
}
public static Vector3 AdjustCenter(Vector3 center)
public static Vector3 AdjustCenter(Vector3 center, Plant plant)
{
if (Math.Abs(center.y - LowPlantAltitude) <= 0.001f)
center.y += 0.005f;
if (Math.Abs(center.y - LowPlantAltitude) > 0.001f)
return center;
var plantPosition = plant.PositionHeld;
var map = plant.MapHeld;
if (map.edificeGrid[plantPosition.CellToIndex(map)] is
{
def.altitudeLayer: AltitudeLayer.LowPlant
} building)
{
center.y += ((plantPosition.z - building.OccupiedRect().minZ) * 0.01f) + 0.005f;
}
return center;
}