1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 20:53:28 +08:00

donet format

This commit is contained in:
2025-09-21 15:38:03 +08:00
parent 5f37b8b6d6
commit a25f74443d
32 changed files with 170 additions and 155 deletions

View File

@@ -3,7 +3,7 @@ using HarmonyLib;
namespace UXAssist.Common;
public class GameLogic: PatchImpl<GameLogic>
public class GameLogic : PatchImpl<GameLogic>
{
public static Action OnDataLoaded;
public static Action OnGameBegin;

View File

@@ -122,14 +122,14 @@ public static class I18N
_initialized = true;
Apply();
}
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(Localization), nameof(Localization.LoadLanguage))]
private static void Localization_LoadLanguage_Postfix(int index)
{
if (!_initialized) return;
ApplyLanguage(index);
}
[HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(Localization), nameof(Localization.NotifyLanguageChange))]
private static void Localization_NotifyLanguageChange_Postfix()
{

View File

@@ -36,13 +36,13 @@ public static class Util
tex.LoadImage(fileData);
return tex;
}
public static Sprite LoadSprite(string path)
{
var tex = LoadTexture(path);
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
}
public static Texture2D LoadEmbeddedTexture(string path, Assembly assembly = null)
{
var fileData = LoadEmbeddedResource(path, assembly);
@@ -50,12 +50,12 @@ public static class Util
tex.LoadImage(fileData);
return tex;
}
public static Sprite LoadEmbeddedSprite(string path, Assembly assembly = null)
{
var tex = LoadEmbeddedTexture(path, assembly);
return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
}
public static string PluginFolder(Assembly assembly = null) => Path.GetDirectoryName((assembly == null ? Assembly.GetCallingAssembly() : assembly).Location);
}

View File

@@ -127,7 +127,7 @@ public static class WinApi
[DllImport("user32", ExactSpelling = true)]
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
[DllImport("user32", ExactSpelling = true)]
public static extern IntPtr MonitorFromRect([In] ref Rect lpRect, uint dwFlags);
@@ -183,7 +183,7 @@ public static class WinApi
public ushort Reserved1;
public ushort Reserved3;
}
[StructLayout(LayoutKind.Sequential, Pack = 4)]
private struct PROCESSOR_RELATIONSHIP
{
@@ -207,7 +207,7 @@ public static class WinApi
public uint Size;
public PROCESSOR_RELATIONSHIP Processor;
}
[DllImport("kernel32", SetLastError = true)]
private static extern bool GetLogicalProcessorInformationEx(
LOGICAL_PROCESSOR_RELATIONSHIP relationshipType,

View File

@@ -13,7 +13,8 @@ public static class FactoryFunctions
// Clear entity connection
var factory = cargoTraffic.factory;
factory.ReadObjectConn(belt.entityId, 0, out var isOutput, out var otherObjId, out var otherSlot);
if (isOutput && factory.entityPool[otherObjId].beltId == belt.outputId) {
if (isOutput && factory.entityPool[otherObjId].beltId == belt.outputId)
{
factory.ClearObjectConnDirect(belt.entityId, 0);
factory.ClearObjectConnDirect(otherObjId, otherSlot);
}
@@ -194,7 +195,7 @@ public static class FactoryFunctions
bpBuildings.Add(new BPBuildingData { building = building, itemType = itemType, offset = offset });
}
}
HashSet<BlueprintBuilding> beltsWithInput = [..bpBelts.Select(pair => pair.Value.building.outputObj)];
HashSet<BlueprintBuilding> beltsWithInput = [.. bpBelts.Select(pair => pair.Value.building.outputObj)];
var beltHeads = bpBelts.Where(pair => !beltsWithInput.Contains(pair.Value.building)).ToDictionary(pair => pair.Key, pair => pair.Value);
// Sort belt buildings
List<BlueprintBuilding> sortedBpBelts = [];

View File

@@ -173,7 +173,8 @@ public static class PlanetFunctions
{
ref var warning = ref warningPool[i];
if (warning.id != i) continue;
switch (warning.factoryId) {
switch (warning.factoryId)
{
case -4:
if (warning.astroId == planetId)
warningSystem.RemoveWarningData(i);

View File

@@ -9,7 +9,7 @@ using GameLogic = UXAssist.Common.GameLogic;
namespace UXAssist.Patches;
public class DysonSpherePatch: PatchImpl<DysonSpherePatch>
public class DysonSpherePatch : PatchImpl<DysonSpherePatch>
{
public static ConfigEntry<bool> StopEjectOnNodeCompleteEnabled;
public static ConfigEntry<bool> OnlyConstructNodesEnabled;
@@ -261,7 +261,7 @@ public class DysonSpherePatch: PatchImpl<DysonSpherePatch>
return matcher.InstructionEnumeration();
}
private class StopEjectOnNodeComplete: PatchImpl<StopEjectOnNodeComplete>
private class StopEjectOnNodeComplete : PatchImpl<StopEjectOnNodeComplete>
{
private static HashSet<int>[] _nodeForAbsorb;
private static bool _initialized;
@@ -492,7 +492,7 @@ public class DysonSpherePatch: PatchImpl<DysonSpherePatch>
}
[PatchSetCallbackFlag(PatchCallbackFlag.CallOnDisableAfterUnpatch)]
private class OnlyConstructNodes: PatchImpl<OnlyConstructNodes>
private class OnlyConstructNodes : PatchImpl<OnlyConstructNodes>
{
protected override void OnEnable()
{

View File

@@ -80,7 +80,8 @@ public class GamePatch : PatchImpl<GamePatch>
I18N.Add("Logical frame rate: {0}x", "[UXA] Logical frame rate: {0}x", "[UXA] 逻辑帧速率: {0}x");
EnableWindowResizeEnabled.SettingChanged += (_, _) => EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
LoadLastWindowRectEnabled.SettingChanged += (_, _) => {
LoadLastWindowRectEnabled.SettingChanged += (_, _) =>
{
if (LoadLastWindowRectEnabled.Value)
{
FixLastWindowRect();

View File

@@ -298,7 +298,8 @@ public static class LogisticsPatch
new CodeMatch(OpCodes.Ldc_I4_1),
new CodeMatch(OpCodes.Call, AccessTools.PropertyGetter(typeof(GameMain), nameof(GameMain.mainPlayer)))
);
if (matcher.IsValid) {
if (matcher.IsValid)
{
matcher.RemoveInstructions(7).InsertAndAdvance(
new CodeInstruction(OpCodes.Ldc_I4_0)
);

View File

@@ -24,7 +24,7 @@ public static class PlanetPatch
PlayerActionsInGlobeView.Enable(false);
}
public class PlayerActionsInGlobeView: PatchImpl<PlayerActionsInGlobeView>
public class PlayerActionsInGlobeView : PatchImpl<PlayerActionsInGlobeView>
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(VFInput), nameof(VFInput.UpdateGameStates))]
@@ -48,7 +48,7 @@ public static class PlanetPatch
});
return matcher.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerController), nameof(PlayerController.GetInput))]
private static IEnumerable<CodeInstruction> PlayerController_GetInput_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)

View File

@@ -287,7 +287,7 @@ public static class TechPatch
}
}
private class BatchBuyoutTech: PatchImpl<BatchBuyoutTech>
private class BatchBuyoutTech : PatchImpl<BatchBuyoutTech>
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(UITechNode), nameof(UITechNode.UpdateInfoDynamic))]

View File

@@ -4,7 +4,7 @@ using Common;
using HarmonyLib;
[PatchGuid(PluginInfo.PLUGIN_GUID)]
public class UIPatch: PatchImpl<UIPatch>
public class UIPatch : PatchImpl<UIPatch>
{
public static void Start()
{

View File

@@ -17,12 +17,12 @@ public class MyCheckButton : MonoBehaviour
private static GameObject _baseObject;
private static Color openMouseOverColor;
private static Color openPressColor;
private static Color openNormalColor;
private static Color closeMouseOverColor;
private static Color closePressColor;
private static Color closeNormalColor;
private static Color openMouseOverColor;
private static Color openPressColor;
private static Color openNormalColor;
private static Color closeMouseOverColor;
private static Color closePressColor;
private static Color closeNormalColor;
public static void InitBaseObject()
{

View File

@@ -228,7 +228,7 @@ public class MyWindow : ManualBehaviour
return comboBox;
}
#region Slider
#region Slider
public class ValueMapper<T>
{
public virtual int Min => 1;
@@ -402,7 +402,7 @@ public class MyWindow : ManualBehaviour
{
return AddSideSlider(x, y, parent, config, new ArrayMapper<T>(valueList), format, width);
}
#endregion
#endregion
public InputField AddInputField(float x, float y, RectTransform parent, string text = "", int fontSize = 16, string objName = "input", UnityAction<string> onChanged = null,
UnityAction<string> onEditEnd = null)
@@ -593,7 +593,7 @@ public abstract class MyWindowManager
}
*/
public class Patch: PatchImpl<Patch>
public class Patch : PatchImpl<Patch>
{
protected override void OnEnable()
{