mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 06:13:36 +08:00
WIP
This commit is contained in:
@@ -28,6 +28,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
|
public static ConfigEntry<bool> DragBuildPowerPolesEnabled;
|
||||||
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
|
public static ConfigEntry<bool> BeltSignalsForBuyOutEnabled;
|
||||||
private static PressKeyBind _doNotRenderEntitiesKey;
|
private static PressKeyBind _doNotRenderEntitiesKey;
|
||||||
|
private static PressKeyBind _offgridfForPathsKey;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
@@ -40,6 +41,15 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
I18N.Add("KEYToggleDoNotRenderEntities", "Toggle Do Not Render Factory Entities", "切换不渲染工厂建筑实体");
|
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();
|
BeltSignalsForBuyOut.InitPersist();
|
||||||
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
UnlimitInteractiveEnabled.SettingChanged += (_, _) => UnlimitInteractive.Enable(UnlimitInteractiveEnabled.Value);
|
||||||
@@ -699,8 +709,8 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
var jmp0 = generator.DefineLabel();
|
var jmp0 = generator.DefineLabel();
|
||||||
var jmp1 = generator.DefineLabel();
|
var jmp1 = generator.DefineLabel();
|
||||||
matcher.InsertAndAdvance(
|
matcher.InsertAndAdvance(
|
||||||
new CodeInstruction(OpCodes.Ldc_I4, (int)KeyCode.LeftControl),
|
new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(FactoryPatch), nameof(_offgridfForPathsKey))),
|
||||||
new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Input), nameof(Input.GetKeyInt))),
|
new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PressKeyBind), nameof(PressKeyBind.keyValue))),
|
||||||
new CodeInstruction(OpCodes.Brfalse, jmp0),
|
new CodeInstruction(OpCodes.Brfalse, jmp0),
|
||||||
new CodeInstruction(OpCodes.Ldarg_0),
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
new CodeInstruction(OpCodes.Ldarg_0),
|
new CodeInstruction(OpCodes.Ldarg_0),
|
||||||
@@ -720,6 +730,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
return matcher.InstructionEnumeration();
|
return matcher.InstructionEnumeration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public static IEnumerable<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
public static IEnumerable<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||||
{
|
{
|
||||||
var matcher = new CodeMatcher(instructions, generator);
|
var matcher = new CodeMatcher(instructions, generator);
|
||||||
@@ -774,6 +785,7 @@ public class FactoryPatch: PatchImpl<FactoryPatch>
|
|||||||
instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees;
|
instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TreatStackingAsSingle: PatchImpl<TreatStackingAsSingle>
|
public class TreatStackingAsSingle: PatchImpl<TreatStackingAsSingle>
|
||||||
|
|||||||
@@ -94,22 +94,22 @@ public class PersistPatch : PatchImpl<PersistPatch>
|
|||||||
Array.Sort(buildings, (a, b) =>
|
Array.Sort(buildings, (a, b) =>
|
||||||
{
|
{
|
||||||
var tmpItemId = a.itemId - b.itemId;
|
var tmpItemId = a.itemId - b.itemId;
|
||||||
if (tmpItemId != 0)
|
if (tmpItemId != 0) return tmpItemId;
|
||||||
return tmpItemId;
|
|
||||||
var tmpModelIndex = a.modelIndex - b.modelIndex;
|
var tmpModelIndex = a.modelIndex - b.modelIndex;
|
||||||
if (tmpModelIndex != 0)
|
if (tmpModelIndex != 0) return tmpModelIndex;
|
||||||
return tmpModelIndex;
|
|
||||||
var tmpRecipeId = a.recipeId - b.recipeId;
|
var tmpRecipeId = a.recipeId - b.recipeId;
|
||||||
if (tmpRecipeId != 0)
|
if (tmpRecipeId != 0) return tmpRecipeId;
|
||||||
return tmpRecipeId;
|
|
||||||
var tmpAreaIndex = a.areaIndex - b.areaIndex;
|
var tmpAreaIndex = a.areaIndex - b.areaIndex;
|
||||||
if (tmpAreaIndex != 0)
|
if (tmpAreaIndex != 0) return tmpAreaIndex;
|
||||||
return tmpAreaIndex;
|
|
||||||
const double ky = 256.0;
|
var sign = Math.Sign(b.localOffset_y - a.localOffset_y);
|
||||||
const double kx = 1024.0;
|
if (sign != 0) return sign;
|
||||||
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;
|
sign = Math.Sign(b.localOffset_x - a.localOffset_x);
|
||||||
return scorePosA < scorePosB ? 1 : -1;
|
return sign != 0 ? sign : Math.Sign(b.localOffset_z - a.localOffset_z);
|
||||||
});
|
});
|
||||||
for (var i = buildings.Length - 1; i >= 0; i--)
|
for (var i = buildings.Length - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user