1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 21:33:28 +08:00
This commit is contained in:
2023-11-24 21:48:42 +08:00
parent 8dcccfc9df
commit 1118b97545

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Reflection.Emit;
using BepInEx;
using BepInEx.Configuration;
@@ -238,4 +239,39 @@ public class UXAssist : BaseUnityPlugin
);
return matcher.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(BlueprintUtils), nameof(BlueprintUtils.GenerateBlueprintData))]
private static void BlueprintUtils_GenerateBlueprintData_Postfix(BlueprintData _blueprintData)
{
var buildings = _blueprintData.buildings;
Array.Sort(buildings, (a, b) =>
{
var tmpItemId = a.itemId - b.itemId;
if(tmpItemId != 0)
return tmpItemId;
var tmpModelIndex = a.modelIndex - b.modelIndex;
if(tmpModelIndex != 0)
return tmpModelIndex;
var tmpRecipeId = a.recipeId - b.recipeId;
if(tmpRecipeId != 0)
return tmpRecipeId;
var tmpAreaIndex = a.areaIndex - b.areaIndex;
if(tmpAreaIndex != 0)
return tmpAreaIndex;
const double ky = 256.0;
const double kx = 1024.0;
var scorePosA = (a.localOffset_y * ky + a.localOffset_x) * kx + a.localOffset_z;
var scorePosB = (b.localOffset_y * ky + b.localOffset_x) * kx + b.localOffset_z;
return scorePosA < scorePosB ? 1 : -1;
});
for (var i = buildings.Length - 1; i >= 0; i--)
{
buildings[i].index = i;
}
}
}