mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 02:13:29 +08:00
CheatEnabler v2.1.0
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
@@ -14,6 +13,7 @@ public static class BuildPatch
|
||||
public static ConfigEntry<bool> ArchitectModeEnabled;
|
||||
public static ConfigEntry<bool> NoConditionEnabled;
|
||||
public static ConfigEntry<bool> NoCollisionEnabled;
|
||||
public static ConfigEntry<bool> BeltSignalGeneratorEnabled;
|
||||
|
||||
private static Harmony _patch;
|
||||
private static Harmony _noConditionPatch;
|
||||
@@ -25,10 +25,12 @@ public static class BuildPatch
|
||||
ArchitectModeEnabled.SettingChanged += (_, _) => ArchitectModeValueChanged();
|
||||
NoConditionEnabled.SettingChanged += (_, _) => NoConditionValueChanged();
|
||||
NoCollisionEnabled.SettingChanged += (_, _) => NoCollisionValueChanged();
|
||||
BeltSignalGeneratorEnabled.SettingChanged += (_, _) => BeltSignalGeneratorValueChanged();
|
||||
ImmediateValueChanged();
|
||||
ArchitectModeValueChanged();
|
||||
NoConditionValueChanged();
|
||||
NoCollisionValueChanged();
|
||||
BeltSignalGeneratorValueChanged();
|
||||
_patch = Harmony.CreateAndPatchAll(typeof(BuildPatch));
|
||||
}
|
||||
|
||||
@@ -39,13 +41,16 @@ public static class BuildPatch
|
||||
_patch.UnpatchSelf();
|
||||
_patch = null;
|
||||
}
|
||||
|
||||
if (_noConditionPatch != null)
|
||||
{
|
||||
_noConditionPatch.UnpatchSelf();
|
||||
_noConditionPatch = null;
|
||||
}
|
||||
|
||||
ImmediateBuild.Enable(false);
|
||||
ArchitectMode.Enable(false);
|
||||
BeltSignalGenerator.Enable(false);
|
||||
NightLightEnd();
|
||||
}
|
||||
|
||||
@@ -53,6 +58,7 @@ public static class BuildPatch
|
||||
{
|
||||
ImmediateBuild.Enable(ImmediateEnabled.Value);
|
||||
}
|
||||
|
||||
private static void ArchitectModeValueChanged()
|
||||
{
|
||||
ArchitectMode.Enable(ArchitectModeEnabled.Value);
|
||||
@@ -86,6 +92,11 @@ public static class BuildPatch
|
||||
obj.gameObject.SetActive(!NoCollisionEnabled.Value);
|
||||
}
|
||||
|
||||
private static void BeltSignalGeneratorValueChanged()
|
||||
{
|
||||
BeltSignalGenerator.Enable(BeltSignalGeneratorEnabled.Value);
|
||||
}
|
||||
|
||||
public static void ArrivePlanet(PlanetFactory factory)
|
||||
{
|
||||
var imm = ImmediateEnabled.Value;
|
||||
@@ -111,9 +122,10 @@ public static class BuildPatch
|
||||
factory.BuildFinally(GameMain.mainPlayer, i, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (imm) factory.EndFlattenTerrain();
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(PlanetData), nameof(PlanetData.NotifyFactoryLoaded))]
|
||||
private static void PlanetData_NotifyFactoryLoaded_Postfix(PlanetData __instance)
|
||||
@@ -137,12 +149,13 @@ public static class BuildPatch
|
||||
NightlightEnabled = _mechaOnEarth;
|
||||
return;
|
||||
}
|
||||
|
||||
NightlightEnabled = false;
|
||||
if (_sunlight == null) return;
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
}
|
||||
|
||||
public static void NightLightLateUpdate()
|
||||
public static void NightLightLateUpdate()
|
||||
{
|
||||
switch (_nightlightInitialized)
|
||||
{
|
||||
@@ -155,8 +168,8 @@ public static class BuildPatch
|
||||
}
|
||||
}
|
||||
|
||||
private static void NightLightReady()
|
||||
{
|
||||
private static void NightLightReady()
|
||||
{
|
||||
if (!GameMain.isRunning || !GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
|
||||
if (_sail == null)
|
||||
{
|
||||
@@ -166,15 +179,15 @@ public static class BuildPatch
|
||||
_nightlightInitialized = true;
|
||||
}
|
||||
|
||||
private static void NightLightGo()
|
||||
{
|
||||
if (!GameMain.isRunning)
|
||||
{
|
||||
NightLightEnd();
|
||||
private static void NightLightGo()
|
||||
{
|
||||
if (!GameMain.isRunning)
|
||||
{
|
||||
NightLightEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
if (_sail.enabled)
|
||||
if (_sail.enabled)
|
||||
{
|
||||
_mechaOnEarth = false;
|
||||
NightlightEnabled = false;
|
||||
@@ -191,31 +204,35 @@ public static class BuildPatch
|
||||
_sunlight = GameMain.universeSimulator.LocalStarSimulator().sunLight;
|
||||
if (_sunlight == null) return;
|
||||
}
|
||||
|
||||
_mechaOnEarth = true;
|
||||
NightlightEnabled = ArchitectModeEnabled.Value;
|
||||
}
|
||||
|
||||
if (NightlightEnabled)
|
||||
{
|
||||
_sunlight.transform.rotation =
|
||||
Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX / 10f + GameMain.mainPlayer.transform.right * NightLightAngleY / 10f);
|
||||
Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX / 10f +
|
||||
GameMain.mainPlayer.transform.right * NightLightAngleY / 10f);
|
||||
}
|
||||
}
|
||||
|
||||
private static void NightLightEnd()
|
||||
{
|
||||
_mechaOnEarth = false;
|
||||
private static void NightLightEnd()
|
||||
{
|
||||
_mechaOnEarth = false;
|
||||
NightlightEnabled = false;
|
||||
if (_sunlight != null)
|
||||
{
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
}
|
||||
_sail = null;
|
||||
_nightlightInitialized = false;
|
||||
}
|
||||
if (_sunlight != null)
|
||||
{
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
|
||||
_sail = null;
|
||||
_nightlightInitialized = false;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
|
||||
private static IEnumerable<CodeInstruction> StarSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
// var vec = NightlightEnabled ? GameMain.mainPlayer.transform.up : __instance.transform.forward;
|
||||
@@ -241,8 +258,8 @@ public static class BuildPatch
|
||||
return matcher.InstructionEnumeration();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")]
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlanetSimulator), "LateUpdate")]
|
||||
private static IEnumerable<CodeInstruction> PlanetSimulator_LateUpdate_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
|
||||
{
|
||||
// var vec = (NightlightEnabled ? GameMain.mainPlayer.transform.up : (Quaternion.Inverse(localPlanet.runtimeRotation) * (__instance.planetData.star.uPosition - __instance.planetData.uPosition).normalized));
|
||||
@@ -344,10 +361,12 @@ public static class BuildPatch
|
||||
_architectPatch = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new [] { typeof(int), typeof(int), typeof(int), typeof(bool) }, new[] {ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Out, ArgumentType.Normal})]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new [] { typeof(int), typeof(int), typeof(int[]), typeof(int), typeof(bool) }, new[] {ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal})]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new[] { typeof(int), typeof(int), typeof(int), typeof(bool) },
|
||||
new[] { ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Out, ArgumentType.Normal })]
|
||||
[HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.TakeTailItems), new[] { typeof(int), typeof(int), typeof(int[]), typeof(int), typeof(bool) },
|
||||
new[] { ArgumentType.Ref, ArgumentType.Ref, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal })]
|
||||
public static bool TakeTailItemsPatch(StorageComponent __instance, int itemId)
|
||||
{
|
||||
if (__instance == null || __instance.id != GameMain.mainPlayer.package.id) return true;
|
||||
@@ -356,8 +375,10 @@ public static class BuildPatch
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
|
||||
return itemId >= 12000 || !_canBuildItems[itemId];
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageComponent), "GetItemCount", new Type[] { typeof(int) })]
|
||||
public static void GetItemCountPatch(StorageComponent __instance, int itemId, ref int __result)
|
||||
@@ -369,8 +390,10 @@ public static class BuildPatch
|
||||
{
|
||||
DoInit();
|
||||
}
|
||||
|
||||
if (itemId < 12000 && _canBuildItems[itemId]) __result = 100;
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(PlayerAction_Inspect), nameof(PlayerAction_Inspect.GetObjectSelectDistance))]
|
||||
private static IEnumerable<CodeInstruction> PlayerAction_Inspect_GetObjectSelectDistance_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
@@ -401,6 +424,7 @@ public static class BuildPatch
|
||||
yield return new CodeInstruction(OpCodes.Ldc_I4_1);
|
||||
yield return new CodeInstruction(OpCodes.Ret);
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(BuildTool_Click), nameof(BuildTool_Click.CheckBuildConditions))]
|
||||
private static IEnumerable<CodeInstruction> BuildTool_Click_CheckBuildConditions_Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
@@ -419,7 +443,348 @@ public static class BuildPatch
|
||||
if (desc == null) continue;
|
||||
if (desc.veinMiner || desc.oilMiner) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class BeltSignalGenerator
|
||||
{
|
||||
private static Harmony _beltSignalPatch;
|
||||
private static Dictionary<int, BeltSignal>[] _signalBelts;
|
||||
private static Dictionary<long, int> _portalFrom;
|
||||
private static Dictionary<int, HashSet<long>> _portalTo;
|
||||
private static int _signalBeltsCapacity;
|
||||
private static bool _initialized;
|
||||
|
||||
private class BeltSignal
|
||||
{
|
||||
public int SignalId;
|
||||
public int SpeedLimit;
|
||||
public byte Stack;
|
||||
public byte Inc;
|
||||
public int Progress;
|
||||
}
|
||||
|
||||
public static void Enable(bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
InitSignalBelts();
|
||||
_beltSignalPatch ??= Harmony.CreateAndPatchAll(typeof(BeltSignalGenerator));
|
||||
}
|
||||
else
|
||||
{
|
||||
_beltSignalPatch?.UnpatchSelf();
|
||||
_initialized = false;
|
||||
_signalBelts = null;
|
||||
_signalBeltsCapacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void InitSignalBelts()
|
||||
{
|
||||
if (!GameMain.isRunning) return;
|
||||
_signalBelts = new Dictionary<int, BeltSignal>[64];
|
||||
_signalBeltsCapacity = 64;
|
||||
_portalFrom = new Dictionary<long, int>();
|
||||
_portalTo = new Dictionary<int, HashSet<long>>();
|
||||
|
||||
foreach (var factory in GameMain.data.factories)
|
||||
{
|
||||
var entitySignPool = factory?.entitySignPool;
|
||||
if (entitySignPool == null) continue;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
var beltPool = cargoTraffic.beltPool;
|
||||
for (var i = cargoTraffic.beltCursor - 1; i > 0; i--)
|
||||
{
|
||||
if (beltPool[i].id != i) continue;
|
||||
ref var signal = ref entitySignPool[beltPool[i].entityId];
|
||||
var signalId = signal.iconId0;
|
||||
if (signalId == 0U) continue;
|
||||
var number = Mathf.RoundToInt(signal.count0);
|
||||
switch (signalId)
|
||||
{
|
||||
case 404:
|
||||
SetSignalBelt(factory.index, i, (int)signalId, 0);
|
||||
continue;
|
||||
case >= 1000 and < 20000:
|
||||
if (number > 0)
|
||||
SetSignalBelt(factory.index, i, (int)signalId, number);
|
||||
continue;
|
||||
case 600:
|
||||
if (number > 0)
|
||||
SetSignalBelt(factory.index, i, (int)signalId, number);
|
||||
continue;
|
||||
case >= 601 and <= 609:
|
||||
if (number > 0)
|
||||
SetSignalBeltPortalTo(factory.index, i, (int)signalId, number);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
private static Dictionary<int, BeltSignal> GetOrCreateSignalBelts(int index)
|
||||
{
|
||||
Dictionary<int, BeltSignal> obj;
|
||||
if (index < 0) return null;
|
||||
if (index >= _signalBeltsCapacity)
|
||||
{
|
||||
var newCapacity = _signalBeltsCapacity * 2;
|
||||
var newSignalBelts = new Dictionary<int, BeltSignal>[newCapacity];
|
||||
Array.Copy(_signalBelts, newSignalBelts, _signalBeltsCapacity);
|
||||
_signalBelts = newSignalBelts;
|
||||
_signalBeltsCapacity = newCapacity;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj = _signalBelts[index];
|
||||
if (obj != null) return obj;
|
||||
}
|
||||
|
||||
obj = new Dictionary<int, BeltSignal>();
|
||||
_signalBelts[index] = obj;
|
||||
return obj;
|
||||
}
|
||||
|
||||
private static Dictionary<int, BeltSignal> GetSignalBelts(int index)
|
||||
{
|
||||
return index >= 0 && index < _signalBeltsCapacity ? _signalBelts[index] : null;
|
||||
}
|
||||
|
||||
private static void SetSignalBelt(int factory, int beltId, int signalId, int number)
|
||||
{
|
||||
int stack;
|
||||
int inc;
|
||||
int speedLimit;
|
||||
if (signalId >= 1000)
|
||||
{
|
||||
stack = Mathf.Clamp(number % 10, 1, 4);
|
||||
inc = number / 10 % 10 * stack;
|
||||
speedLimit = number / 100 % 4000;
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = 0;
|
||||
inc = 0;
|
||||
speedLimit = number;
|
||||
}
|
||||
GetOrCreateSignalBelts(factory)[beltId] = new BeltSignal { SignalId = signalId, SpeedLimit = speedLimit, Stack = (byte)stack, Inc = (byte)inc, Progress = 0 };
|
||||
}
|
||||
|
||||
private static void SetSignalBeltPortalTo(int factory, int beltId, int signalId, int number)
|
||||
{
|
||||
var v = ((long)factory << 32) | (long)beltId;
|
||||
_portalFrom[v] = number;
|
||||
if (!_portalTo.TryGetValue(number, out var set))
|
||||
{
|
||||
set = new HashSet<long>();
|
||||
_portalTo[number] = set;
|
||||
}
|
||||
set.Add(v);
|
||||
}
|
||||
|
||||
private static void RemoveSignalBelt(int factory, int beltId)
|
||||
{
|
||||
GetSignalBelts(factory)?.Remove(beltId);
|
||||
}
|
||||
|
||||
private static void RemoveSignalBeltPortalEnd(int factory, int beltId)
|
||||
{
|
||||
var v = ((long)factory << 32) | (long)beltId;
|
||||
if (!_portalFrom.TryGetValue(v, out var number)) return;
|
||||
_portalFrom.Remove(beltId);
|
||||
if (!_portalTo.TryGetValue(number, out var set)) return;
|
||||
set.Remove(v);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
{
|
||||
InitSignalBelts();
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.RemoveBeltComponent))]
|
||||
public static void CargoTraffic_RemoveBeltComponent_Prefix(int id)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
RemoveSignalBeltPortalEnd(planet.factoryIndex, id);
|
||||
RemoveSignalBelt(planet.factoryIndex, id);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.SetBeltSignalIcon))]
|
||||
public static void CargoTraffic_SetBeltSignalIcon_Postfix(CargoTraffic __instance, int signalId, int entityId)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
var factory = __instance.factory;
|
||||
int number;
|
||||
var needAdd = false;
|
||||
switch (signalId)
|
||||
{
|
||||
case 404:
|
||||
number = 0;
|
||||
needAdd = true;
|
||||
break;
|
||||
case >= 1000 and < 20000:
|
||||
number = Mathf.RoundToInt(factory.entitySignPool[entityId].count0);
|
||||
if (number > 0)
|
||||
needAdd = true;
|
||||
break;
|
||||
case 600:
|
||||
number = Mathf.RoundToInt(factory.entitySignPool[entityId].count0);
|
||||
if (number > 0)
|
||||
needAdd = true;
|
||||
break;
|
||||
case >= 601 and <= 609:
|
||||
number = Mathf.RoundToInt(factory.entitySignPool[entityId].count0);
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
if (number > 0)
|
||||
SetSignalBeltPortalTo(factoryIndex, beltId, signalId, number);
|
||||
RemoveSignalBelt(factoryIndex, beltId);
|
||||
return;
|
||||
default:
|
||||
number = 0;
|
||||
break;
|
||||
}
|
||||
{
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
if (needAdd)
|
||||
{
|
||||
SetSignalBelt(factoryIndex, beltId, signalId, number);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveSignalBelt(factoryIndex, beltId);
|
||||
}
|
||||
RemoveSignalBeltPortalEnd(factoryIndex, beltId);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CargoTraffic), nameof(CargoTraffic.SetBeltSignalNumber))]
|
||||
public static void CargoTraffic_SetBeltSignalNumber_Postfix(CargoTraffic __instance, float number, int entityId)
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var planet = GameMain.localPlanet;
|
||||
if (planet == null) return;
|
||||
var factory = __instance.factory;
|
||||
var entitySignPool = factory.entitySignPool;
|
||||
uint signalId;
|
||||
if (entitySignPool[entityId].iconType == 0U || (signalId = entitySignPool[entityId].iconId0) == 0U) return;
|
||||
switch (signalId)
|
||||
{
|
||||
case 404:
|
||||
return;
|
||||
case 600:
|
||||
case >= 1000 and < 20000:
|
||||
break;
|
||||
case >= 601 and <= 609:
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
RemoveSignalBeltPortalEnd(factoryIndex, beltId);
|
||||
SetSignalBeltPortalTo(factoryIndex, beltId, (int)signalId, Mathf.RoundToInt(number));
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
{
|
||||
var factoryIndex = planet.factoryIndex;
|
||||
var beltId = factory.entityPool[entityId].beltId;
|
||||
var n = Mathf.RoundToInt(number);
|
||||
if (n == 0)
|
||||
{
|
||||
RemoveSignalBelt(factoryIndex, beltId);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSignalBelt(factoryIndex, beltId, (int)signalId, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameData), "GameTick")]
|
||||
public static void GameData_GameTick_Prefix()
|
||||
{
|
||||
if (!_initialized) return;
|
||||
var factories = GameMain.data?.factories;
|
||||
if (factories == null) return;
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
if (factory == null) continue;
|
||||
var belts = GetSignalBelts(factory.index);
|
||||
if (belts == null) continue;
|
||||
foreach (var pair in belts)
|
||||
{
|
||||
var beltSignal = pair.Value;
|
||||
var signalId = beltSignal.SignalId;
|
||||
switch (signalId)
|
||||
{
|
||||
case 404:
|
||||
{
|
||||
var beltId = pair.Key;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
var belt = cargoTraffic.beltPool[beltId];
|
||||
var cargoPath = cargoTraffic.GetCargoPath(belt.segPathId);
|
||||
cargoPath.TryPickItem(belt.segIndex + belt.segPivotOffset - 5, 12, out _, out _);
|
||||
continue;
|
||||
}
|
||||
case 600:
|
||||
{
|
||||
if (!_portalTo.TryGetValue(beltSignal.SpeedLimit, out var set)) continue;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
var beltId = pair.Key;
|
||||
ref var belt = ref cargoTraffic.beltPool[beltId];
|
||||
var cargoPath = cargoTraffic.GetCargoPath(belt.segPathId);
|
||||
var segIndex = belt.segIndex + belt.segPivotOffset;
|
||||
if (!cargoPath.GetCargoAtIndex(segIndex, out var cargo, out var cargoId, out var offset)) break;
|
||||
var itemId = cargo.item;
|
||||
var cargoPool = cargoPath.cargoContainer.cargoPool;
|
||||
var inc = cargoPool[cargoId].inc;
|
||||
var stack = cargoPool[cargoId].stack;
|
||||
foreach (var n in set)
|
||||
{
|
||||
var cargoTraffic1 = factories[(int)(n >> 32)].cargoTraffic;
|
||||
ref var belt1 = ref cargoTraffic1.beltPool[(int)(n & 0x7FFFFFFF)];
|
||||
if (!cargoTraffic1.GetCargoPath(belt1.segPathId).TryInsertItem(belt1.segIndex + belt1.segPivotOffset, itemId, stack, inc)) continue;
|
||||
cargoPath.TryPickItem(segIndex - 5, 12, out var stack1, out var inc1);
|
||||
if (inc1 != inc || stack1 != stack)
|
||||
cargoPath.TryPickItem(segIndex - 5, 12, out _, out _);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
case >= 1000 and < 20000:
|
||||
{
|
||||
if (beltSignal.SpeedLimit > 0)
|
||||
{
|
||||
beltSignal.Progress += beltSignal.SpeedLimit;
|
||||
if (beltSignal.Progress < 3600) continue;
|
||||
beltSignal.Progress -= 3600;
|
||||
}
|
||||
var beltId = pair.Key;
|
||||
var cargoTraffic = factory.cargoTraffic;
|
||||
ref var belt = ref cargoTraffic.beltPool[beltId];
|
||||
var stack = beltSignal.Stack;
|
||||
var inc = beltSignal.Inc;
|
||||
cargoTraffic.GetCargoPath(belt.segPathId).TryInsertItem(belt.segIndex + belt.segPivotOffset, signalId, stack, inc);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection.Emit;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
@@ -41,6 +39,8 @@ public class CheatEnabler : BaseUnityPlugin
|
||||
"Build without condition");
|
||||
BuildPatch.NoCollisionEnabled = Config.Bind("Build", "NoCollision", false,
|
||||
"No collision");
|
||||
BuildPatch.BeltSignalGeneratorEnabled = Config.Bind("Build", "BeltSignalGenerator", false,
|
||||
"Belt signal generator");
|
||||
ResourcePatch.InfiniteEnabled = Config.Bind("Planet", "AlwaysInfiniteResource", false,
|
||||
"always infinite natural resource");
|
||||
ResourcePatch.FastEnabled = Config.Bind("Planet", "FastMining", false,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<BepInExPluginGuid>org.soardev.cheatenabler</BepInExPluginGuid>
|
||||
<Description>DSP MOD - CheatEnabler</Description>
|
||||
<Version>2.0.0</Version>
|
||||
<Version>2.1.0</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageId>CheatEnabler</PackageId>
|
||||
|
||||
@@ -246,20 +246,13 @@ public static class DysonSpherePatch
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.NewGame))]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.Import))]
|
||||
private static void GameData_NewGame_Postfix()
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))]
|
||||
private static void GameMain_Begin_Postfix()
|
||||
{
|
||||
UpdateSailsCacheForThisGame();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.SetForNewGame))]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.Import))]
|
||||
private static void GameHistoryData_SetForNewGame_Postfix()
|
||||
{
|
||||
UpdateSailLifeTime();
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameHistoryData), nameof(GameHistoryData.UnlockTechFunction))]
|
||||
private static void GameHistoryData_SetForNewGame_Postfix(int func)
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
* [Dyson Sphere Program](https://store.steampowered.com/app/1366540): The great game
|
||||
* [BepInEx](https://bepinex.dev/): Base modding framework
|
||||
* [Multifunction_mod](https://github.com/blacksnipebiu/Multifunction_mod): Some cheat functions
|
||||
* [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implemnetations
|
||||
* [LSTM](https://github.com/hetima/DSP_LSTM) & [PlanetFinder](https://github.com/hetima/DSP_PlanetFinder): UI implementations
|
||||
|
||||
## 更新日志
|
||||
* 2.0.0
|
||||
|
||||
@@ -16,15 +16,18 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
I18N.Add("Hotkey", "Hotkey", "快捷键");
|
||||
I18N.Add("Unlock Tech with Key-Modifiers", "Unlock Tech with Key-Modifiers", "使用组合键点击解锁科技");
|
||||
I18N.Add("Dev Shortcuts", "Dev Shortcuts", "开发模式快捷键");
|
||||
I18N.Add("Dev Shortcuts Tips", "Caution: Some function may trigger abnormal check!\nNumpad 1: Gets all items and extends bag.\nNumpad 2: Boosts walk speed, gathering speed and mecha energy restoration.\nNumpad 3: Fills planet with foundations and bury all veins.\nNumpad 4: +1 construction drone.\nNumpad 5: Upgrades drone engine tech to full.\nNumpad 6: Unlocks researching tech.\nNumpad 7: Unlocks Drive Engine 1.\nNumpad 8: Unlocks Drive Engine 2 and maximize energy.\nNumpad 9: Unlocks ability to warp.\nNumpad 0: No costs for Logistic Storages' output.\nLCtrl + T: Unlocks all techs (not upgrades).\nLCtrl + A: Resets all local achievements.\nLCtrl + Q: Adds 10000 to every metadata.\nLCtrl + W: Enters Sandbox Mode.\nLCtrl + Shift + W: Leaves Sandbox Mode.\nNumpad *: Proliferates items on hand.\nNumpad /: Removes proliferations from items on hand.\nPageDown: Remembers Pose of game camera.\nPageUp: Locks game camera using remembered Pose.",
|
||||
I18N.Add("Dev Shortcuts Tips",
|
||||
"Caution: Some function may trigger abnormal check!\nNumpad 1: Gets all items and extends bag.\nNumpad 2: Boosts walk speed, gathering speed and mecha energy restoration.\nNumpad 3: Fills planet with foundations and bury all veins.\nNumpad 4: +1 construction drone.\nNumpad 5: Upgrades drone engine tech to full.\nNumpad 6: Unlocks researching tech.\nNumpad 7: Unlocks Drive Engine 1.\nNumpad 8: Unlocks Drive Engine 2 and maximize energy.\nNumpad 9: Unlocks ability to warp.\nNumpad 0: No costs for Logistic Storages' output.\nLCtrl + T: Unlocks all techs (not upgrades).\nLCtrl + A: Resets all local achievements.\nLCtrl + Q: Adds 10000 to every metadata.\nLCtrl + W: Enters Sandbox Mode.\nLCtrl + Shift + W: Leaves Sandbox Mode.\nNumpad *: Proliferates items on hand.\nNumpad /: Removes proliferations from items on hand.\nPageDown: Remembers Pose of game camera.\nPageUp: Locks game camera using remembered Pose.",
|
||||
"警告:某些功能可能触发异常检查!\n小键盘1:获得所有物品并扩展背包\n小键盘2:加快行走速度及采集速度,加快能量恢复速度\n小键盘3:将地基铺设整个星球并掩埋所有矿物\n小键盘4:建设机器人 +1\n小键盘5:建设机器人满级\n小键盘6:解锁当前科技\n小键盘7:解锁驱动技术I\n小键盘8:解锁驱动技术II 最大化能量\n小键盘9:机甲曲速解锁\n小键盘0:物流站通过传送带出物品无消耗\n左Ctrl + T:解锁所有非升级科技\n左Ctrl + A:重置所有本地成就\n左Ctrl + Q:增加各项元数据10000点\n左Ctrl + W:进入沙盒模式\n左Ctrl + Shift + W:离开沙盒模式\n小键盘乘号 *:给手上物品喷涂增产剂\n小键盘除号 /:清除手上物品的增产剂\nPageDown:记录摄像机当前的Pose\nPageUp:用记录的Pose锁定摄像机");
|
||||
I18N.Add("Unlock Tech with Key-Modifiers Tips", "Click tech on tree while holding:\n Shift: Tech level + 1\n Ctrl: Tech level + 10\n Ctrl + Shift: Tech level + 100\n Alt: Tech level to MAX\n\nNote: all direct prerequisites will be unlocked as well.",
|
||||
I18N.Add("Unlock Tech with Key-Modifiers Tips",
|
||||
"Click tech on tree while holding:\n Shift: Tech level + 1\n Ctrl: Tech level + 10\n Ctrl + Shift: Tech level + 100\n Alt: Tech level to MAX\n\nNote: all direct prerequisites will be unlocked as well.",
|
||||
"按住以下组合键点击科技树:\n Shift:科技等级+1\n Ctrl:科技等级+10\n Ctrl+Shift:科技等级+100\n Alt:科技等级升到最大\n\n注意:所有直接前置科技也会被解锁");
|
||||
I18N.Add("Build", "Build", "建造");
|
||||
I18N.Add("Finish build immediately", "Finish build immediately", "建造秒完成");
|
||||
I18N.Add("Architect mode", "Architect mode", "建筑师模式");
|
||||
I18N.Add("Build without condition", "Build without condition check", "无条件建造");
|
||||
I18N.Add("No collision", "No collision", "无碰撞");
|
||||
I18N.Add("Belt signal generator", "Belt signal generator", "传送带信号物品生成");
|
||||
I18N.Add("Planet", "Planet", "行星");
|
||||
I18N.Add("Infinite Natural Resources", "Infinite Natural Resources", "自然资源采集不消耗");
|
||||
I18N.Add("Fast Mining", "Fast Mining", "高速采集");
|
||||
@@ -98,6 +101,8 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.NoConditionEnabled, "Build without condition");
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.NoCollisionEnabled, "No collision");
|
||||
y += 36f;
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab2, BuildPatch.BeltSignalGeneratorEnabled, "Belt signal generator");
|
||||
|
||||
// Planet Tab
|
||||
var tab3 = AddTab(236f, 2, _windowTrans, "Planet");
|
||||
@@ -112,15 +117,9 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab3, TerraformPatch.Enabled, "Terraform without enough sands");
|
||||
x = 300f;
|
||||
y = 10f;
|
||||
AddButton(x, y, tab3, "矿物掩埋标题", 16, "button-bury-all", () =>
|
||||
{
|
||||
PlanetFunctions.BuryAllVeins(true);
|
||||
});
|
||||
AddButton(x, y, tab3, "矿物掩埋标题", 16, "button-bury-all", () => { PlanetFunctions.BuryAllVeins(true); });
|
||||
y += 36f;
|
||||
AddButton(x, y, tab3, "矿物还原标题", 16, "button-bury-restore-all", () =>
|
||||
{
|
||||
PlanetFunctions.BuryAllVeins(false);
|
||||
});
|
||||
AddButton(x, y, tab3, "矿物还原标题", 16, "button-bury-restore-all", () => { PlanetFunctions.BuryAllVeins(false); });
|
||||
y += 36f;
|
||||
AddButton(x, y, tab3, "铺满地基提示", 16, "button-reform-all", () =>
|
||||
{
|
||||
@@ -139,15 +138,9 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
GameMain.localPlanet.factory.PlanetReformRevert();
|
||||
});
|
||||
y += 36f;
|
||||
AddButton(x, y, tab3, "Initialize This Planet", 16, "button-init-planet", () =>
|
||||
{
|
||||
PlanetFunctions.RecreatePlanet(true);
|
||||
});
|
||||
AddButton(x, y, tab3, "Initialize This Planet", 16, "button-init-planet", () => { PlanetFunctions.RecreatePlanet(true); });
|
||||
y += 36f;
|
||||
AddButton(x, y, tab3, "Dismantle All Buildings", 16, "button-dismantle-all", () =>
|
||||
{
|
||||
PlanetFunctions.DismantleAll(false);
|
||||
});
|
||||
AddButton(x, y, tab3, "Dismantle All Buildings", 16, "button-dismantle-all", () => { PlanetFunctions.DismantleAll(false); });
|
||||
|
||||
var tab4 = AddTab(336f, 3, _windowTrans, "Dyson Sphere");
|
||||
x = 0f;
|
||||
@@ -165,10 +158,7 @@ public class UIConfigWindow : UI.MyWindowWithTabs
|
||||
UI.MyCheckBox.CreateCheckBox(x, y, tab4, DysonSpherePatch.OverclockSiloEnabled, "Overclock Silos");
|
||||
x = 300f;
|
||||
y = 10f;
|
||||
AddButton(x, y, tab4, "Initialize Dyson Sphere", 16, "init-dyson-sphere", () =>
|
||||
{
|
||||
DysonSpherePatch.InitCurrentDysonSphere(-1);
|
||||
});
|
||||
AddButton(x, y, tab4, "Initialize Dyson Sphere", 16, "init-dyson-sphere", () => { DysonSpherePatch.InitCurrentDysonSphere(-1); });
|
||||
y += 36f;
|
||||
AddText(x, y, tab4, "Click to dismantle selected layer", 16, "text-dismantle-layer");
|
||||
y += 26f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "CheatEnabler",
|
||||
"version_number": "2.0.0",
|
||||
"version_number": "2.1.0",
|
||||
"website_url": "https://github.com/soarqin/DSP_Mods/tree/master/CheatEnabler",
|
||||
"description": "Add various cheat functions while disabling abnormal determinants / 添加一些作弊功能,同时屏蔽异常检测",
|
||||
"dependencies": [
|
||||
|
||||
Reference in New Issue
Block a user