1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 02:13:29 +08:00
This commit is contained in:
2024-09-19 01:39:11 +08:00
parent f5b98c1c48
commit 722c32fdd6
2 changed files with 27 additions and 15 deletions

View File

@@ -28,6 +28,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
private static PressKeyBind _doNotRenderEntitiesKey;
private static PressKeyBind _offgridfForPathsKey;
public static void Init()
{
@@ -40,6 +41,15 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
}
);
I18N.Add("KEYToggleDoNotRenderEntities", "Toggle Do Not Render Factory Entities", "切换不渲染工厂建筑实体");
_offgridfForPathsKey = KeyBindings.RegisterKeyBinding(new BuiltinKey
{
key = new CombineKey((int)KeyCode.LeftControl, 0, ECombineKeyAction.OnceClick, false),
conflictGroup = KeyBindConflict.MOVEMENT | KeyBindConflict.UI | KeyBindConflict.FLYING | KeyBindConflict.SAILING | KeyBindConflict.BUILD_MODE_1 | KeyBindConflict.KEYBOARD_KEYBIND,
name = "OffgridForPaths",
canOverride = true
}
);
I18N.Add("KEYOffgridForPaths", "Build belts offgrid", "脱离网格建造传送带");
BeltSignalsForBuyOut.InitPersist();
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
@@ -699,8 +709,8 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
var jmp0 = generator.DefineLabel();
var jmp1 = generator.DefineLabel();
matcher.InsertAndAdvance(
new CodeInstruction(OpCodes.Ldc_I4, (int)KeyCode.LeftControl),
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Input), nameof(Input.GetKeyInt))),
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryPatch), nameof(_offgridfForPathsKey))),
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PressKeyBind), nameof(PressKeyBind.keyValue))),
new CodeInstruction(OpCodes.Brfalse, jmp0),
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldarg_0),
@@ -720,6 +730,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
return matcher.InstructionEnumeration();
}
/*
public static IEnumerable<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
var matcher = new CodeMatcher(instructions, generator);
@@ -774,6 +785,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees;
}
}
*/
}
public class TreatStackingAsSingle: PatchImpl<TreatStackingAsSingle>

View File

@@ -94,22 +94,22 @@ public class PersistPatch : PatchImpl<PersistPatch>
Array.Sort(buildings, (a, b) =>
{
var tmpItemId = a.itemId - b.itemId;
if (tmpItemId != 0)
return tmpItemId;
if (tmpItemId != 0) return tmpItemId;
var tmpModelIndex = a.modelIndex - b.modelIndex;
if (tmpModelIndex != 0)
return tmpModelIndex;
if (tmpModelIndex != 0) return tmpModelIndex;
var tmpRecipeId = a.recipeId - b.recipeId;
if (tmpRecipeId != 0)
return tmpRecipeId;
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;
if (tmpAreaIndex != 0) return tmpAreaIndex;
var sign = Math.Sign(b.localOffset_y - a.localOffset_y);
if (sign != 0) return sign;
sign = Math.Sign(b.localOffset_x - a.localOffset_x);
return sign != 0 ? sign : Math.Sign(b.localOffset_z - a.localOffset_z);
});
for (var i = buildings.Length - 1; i >= 0; i--)
{