From 98abc31c6fb22a5748711337faaf64e594cddeab Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Wed, 28 Jan 2026 20:27:15 +0800 Subject: [PATCH] format code --- CompressSave/I18N.cs | 2 +- CompressSave/PatchUILoadGame.cs | 2 +- CompressSave/PatchUISaveGame.cs | 2 +- CompressSave/SaveUtil.cs | 4 +- CompressSave/Wrapper/BlackHoleStream.cs | 2 +- CompressSave/Wrapper/BufferWriter.cs | 2 +- CompressSave/Wrapper/CompressionStream.cs | 8 +- CompressSave/Wrapper/LZ4Wrapper.cs | 2 +- CompressSave/Wrapper/NoneWrapper.cs | 2 +- CompressSave/Wrapper/PeekableReader.cs | 2 +- CompressSave/Wrapper/WinApi.cs | 4 +- CompressSave/Wrapper/WrapperDefines.cs | 2 +- CompressSave/Wrapper/ZstdWrapper.cs | 2 +- XianTu/AssetsLoader/ABEmbeddedAssetsLoad.cs | 80 +- XianTu/AssetsLoader/ABFileLoad.cs | 16 +- XianTu/AssetsLoader/ABLoad.cs | 136 +-- XianTu/AssetsLoader/ABLoader.cs | 40 +- XianTu/AssetsLoader/ILoad.cs | 10 +- XianTu/AssetsLoader/ResourceLoad.cs | 22 +- XianTu/BlueTuUIData.cs | 242 +++--- XianTu/EmbeddedFileLoad.cs | 50 +- XianTu/FileLoad.cs | 22 +- .../DataController/BlueTuController.cs | 730 ++++++++-------- .../Scripts/DataController/BlueTuDatabase.cs | 60 +- XianTu/ToolScripts/EventTriggerExpand.cs | 30 +- XianTu/ToolScripts/GameObjectExpand.cs | 134 +-- .../ToolScripts/_BlueprintBuildingExpands.cs | 40 +- XianTu/UI/BasePanel.cs | 56 +- XianTu/UI/BlueTuPatchUI.cs | 626 +++++++------- XianTu/UI/CanvasMonoEvent.cs | 32 +- XianTu/UI/PanelManager.cs | 158 ++-- XianTu/UI/UIManager.cs | 110 +-- XianTu/UI/UITool.cs | 266 +++--- XianTu/UI/UIType.cs | 20 +- XianTu/UI/UIValue.cs | 782 +++++++++--------- XianTu/UI/XianTuBasePanel.cs | 260 +++--- XianTu/XianTuPlugin.cs | 50 +- XianTu/XianTuTest.cs | 78 +- 38 files changed, 2043 insertions(+), 2043 deletions(-) diff --git a/CompressSave/I18N.cs b/CompressSave/I18N.cs index eaa43cb..88111c3 100644 --- a/CompressSave/I18N.cs +++ b/CompressSave/I18N.cs @@ -118,7 +118,7 @@ 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) { diff --git a/CompressSave/PatchUILoadGame.cs b/CompressSave/PatchUILoadGame.cs index caf84b1..55101e1 100644 --- a/CompressSave/PatchUILoadGame.cs +++ b/CompressSave/PatchUILoadGame.cs @@ -73,7 +73,7 @@ class PatchUILoadGame _decompressButton.button.interactable = false; _decompressButton.gameObject.SetActive(false); } - + public static void OnDestroy() { if (_decompressButton) diff --git a/CompressSave/PatchUISaveGame.cs b/CompressSave/PatchUISaveGame.cs index 779a7d7..44d09ed 100644 --- a/CompressSave/PatchUISaveGame.cs +++ b/CompressSave/PatchUISaveGame.cs @@ -39,7 +39,7 @@ static class PatchUISaveGame //Console.WriteLine("OnCreate"); _context = new UIContext(); } - + [HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.OnSaveClick)), HarmonyReversePatch] private static void OSaveGameAs(this UISaveGameWindow ui, int data) { } diff --git a/CompressSave/SaveUtil.cs b/CompressSave/SaveUtil.cs index c515ad9..89ab486 100644 --- a/CompressSave/SaveUtil.cs +++ b/CompressSave/SaveUtil.cs @@ -24,9 +24,9 @@ public static class SaveUtil fullPath = filename + GameSave.saveExt; if (dir != null) fullPath = Path.Combine(dir, fullPath); var i = 0; - while(File.Exists(fullPath)) + while (File.Exists(fullPath)) { - fullPath = $"{filename}[{i++}]{GameSave.saveExt}"; + fullPath = $"{filename}[{i++}]{GameSave.saveExt}"; if (dir != null) fullPath = Path.Combine(dir, fullPath); } var buffer = new byte[1024 * 1024]; diff --git a/CompressSave/Wrapper/BlackHoleStream.cs b/CompressSave/Wrapper/BlackHoleStream.cs index cf9cf9d..131311a 100644 --- a/CompressSave/Wrapper/BlackHoleStream.cs +++ b/CompressSave/Wrapper/BlackHoleStream.cs @@ -19,7 +19,7 @@ class BlackHoleStream : Stream public override void Flush() { - + } public override int Read(byte[] buffer, int offset, int count) diff --git a/CompressSave/Wrapper/BufferWriter.cs b/CompressSave/Wrapper/BufferWriter.cs index 91da4c7..f6d67e0 100644 --- a/CompressSave/Wrapper/BufferWriter.cs +++ b/CompressSave/Wrapper/BufferWriter.cs @@ -46,7 +46,7 @@ public unsafe class BufferWriter : BinaryWriter } - private BufferWriter(DoubleBuffer buffer , UTF8Encoding encoding, CompressionStream outStream) : base(Stream.Null, encoding) + private BufferWriter(DoubleBuffer buffer, UTF8Encoding encoding, CompressionStream outStream) : base(Stream.Null, encoding) { _baseStream = outStream; _swapedBytes = 0; diff --git a/CompressSave/Wrapper/CompressionStream.cs b/CompressSave/Wrapper/CompressionStream.cs index 98789a9..560c90e 100644 --- a/CompressSave/Wrapper/CompressionStream.cs +++ b/CompressSave/Wrapper/CompressionStream.cs @@ -76,7 +76,7 @@ public class CompressionStream : Stream } return new CompressBuffer(); } - + public BufferWriter BufferWriter { get; private set; } public CompressionStream(WrapperDefines wrap, int compressionLevel, Stream outputStream, CompressBuffer compressBuffer, bool multiThread) @@ -98,13 +98,13 @@ public class CompressionStream : Stream { _doubleBuffer = new DoubleBuffer(readBuffer ?? new byte[4 * Mb], writeBuffer ?? new byte[4 * Mb], Compress); _outBuffer = outputBuffer ?? new byte[_wrapper.CompressBufferBound(writeBuffer?.Length ?? 4 * Mb)]; - BufferWriter = new BufferWriter(_doubleBuffer,this); + BufferWriter = new BufferWriter(_doubleBuffer, this); } public override void Flush() { _doubleBuffer.SwapBuffer(); - if(_useMultiThread) + if (_useMultiThread) { _doubleBuffer.WaitReadEnd(); } @@ -151,7 +151,7 @@ public class CompressionStream : Stream private void CompressAsync() { - while(!_stopWorker) + while (!_stopWorker) { Compress_Internal(); } diff --git a/CompressSave/Wrapper/LZ4Wrapper.cs b/CompressSave/Wrapper/LZ4Wrapper.cs index 3f1a0c3..f72b79f 100644 --- a/CompressSave/Wrapper/LZ4Wrapper.cs +++ b/CompressSave/Wrapper/LZ4Wrapper.cs @@ -2,7 +2,7 @@ using System; namespace CompressSave.Wrapper; -public class LZ4API: WrapperDefines +public class LZ4API : WrapperDefines { public static readonly bool Avaliable; public static readonly LZ4API Instance = new(); diff --git a/CompressSave/Wrapper/NoneWrapper.cs b/CompressSave/Wrapper/NoneWrapper.cs index 52630e2..a06e191 100644 --- a/CompressSave/Wrapper/NoneWrapper.cs +++ b/CompressSave/Wrapper/NoneWrapper.cs @@ -2,7 +2,7 @@ namespace CompressSave.Wrapper; -public class NoneAPI: WrapperDefines +public class NoneAPI : WrapperDefines { public static readonly bool Avaliable; public static readonly NoneAPI Instance = new(); diff --git a/CompressSave/Wrapper/PeekableReader.cs b/CompressSave/Wrapper/PeekableReader.cs index 04a2a78..a1e6d93 100644 --- a/CompressSave/Wrapper/PeekableReader.cs +++ b/CompressSave/Wrapper/PeekableReader.cs @@ -5,7 +5,7 @@ namespace CompressSave.Wrapper; internal class PeekableReader(DecompressionStream input) : BinaryReader(input) { public override int PeekChar() - { + { return input.PeekByte(); } } \ No newline at end of file diff --git a/CompressSave/Wrapper/WinApi.cs b/CompressSave/Wrapper/WinApi.cs index 1aab66c..c66d1a3 100644 --- a/CompressSave/Wrapper/WinApi.cs +++ b/CompressSave/Wrapper/WinApi.cs @@ -8,10 +8,10 @@ public static class WinApi // LoadLibrary, GetProcAddress, FreeLibrary [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] public static extern IntPtr LoadLibrary(string dllToLoad); - + [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)] public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); - + [DllImport("kernel32.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool FreeLibrary(IntPtr hModule); diff --git a/CompressSave/Wrapper/WrapperDefines.cs b/CompressSave/Wrapper/WrapperDefines.cs index 1c4be96..2b30de1 100644 --- a/CompressSave/Wrapper/WrapperDefines.cs +++ b/CompressSave/Wrapper/WrapperDefines.cs @@ -25,7 +25,7 @@ public class WrapperDefines long srcSize); protected unsafe delegate long DecompressUpdateFunc(IntPtr dctx, byte* dstBuffer, ref long dstCapacity, byte* srcBuffer, ref long srcSize); - + public CompressBufferBoundFunc CompressBufferBound; public CompressBeginFunc CompressBegin; public CompressEndFunc CompressEnd; diff --git a/CompressSave/Wrapper/ZstdWrapper.cs b/CompressSave/Wrapper/ZstdWrapper.cs index 5f7f80d..77e38ec 100644 --- a/CompressSave/Wrapper/ZstdWrapper.cs +++ b/CompressSave/Wrapper/ZstdWrapper.cs @@ -2,7 +2,7 @@ using System; namespace CompressSave.Wrapper; -public class ZstdAPI: WrapperDefines +public class ZstdAPI : WrapperDefines { public static readonly bool Avaliable; public static readonly ZstdAPI Instance = new(); diff --git a/XianTu/AssetsLoader/ABEmbeddedAssetsLoad.cs b/XianTu/AssetsLoader/ABEmbeddedAssetsLoad.cs index bdfe4be..e17bf24 100644 --- a/XianTu/AssetsLoader/ABEmbeddedAssetsLoad.cs +++ b/XianTu/AssetsLoader/ABEmbeddedAssetsLoad.cs @@ -5,46 +5,46 @@ using Debug = UnityEngine.Debug; namespace AssetsLoader { - internal class ABEmbeddedAssetsLoad : ABLoad - { - public ABEmbeddedAssetsLoad(string filename, string assetsNamespace = null) - { - var stackTrace = new StackTrace(); - var frame = stackTrace.GetFrame(1); - var assembly = frame.GetMethod().DeclaringType.Assembly; - var flag = assetsNamespace == null; - if (flag) - { - assetsNamespace = assembly.FullName.Split([','])[0]; - } - LoadAssetsFromEmbedded(filename, assetsNamespace, assembly); - } + internal class ABEmbeddedAssetsLoad : ABLoad + { + public ABEmbeddedAssetsLoad(string filename, string assetsNamespace = null) + { + var stackTrace = new StackTrace(); + var frame = stackTrace.GetFrame(1); + var assembly = frame.GetMethod().DeclaringType.Assembly; + var flag = assetsNamespace == null; + if (flag) + { + assetsNamespace = assembly.FullName.Split([','])[0]; + } + LoadAssetsFromEmbedded(filename, assetsNamespace, assembly); + } - private void LoadAssetsFromEmbedded(string filename, string assetsNamespace, Assembly assembly) - { - var text = assetsNamespace + "." + filename; - var manifestResourceStream = assembly.GetManifestResourceStream(text); - var flag = manifestResourceStream == null; - if (flag) - { - Debug.Log(string.Concat(["在", assembly.FullName, "找不到内嵌的资源", text, ",请检查内嵌资源中是否有它:"])); - foreach (var text2 in assembly.GetManifestResourceNames()) - { - Debug.Log(text2); - } - Debug.Log("------------------------"); - } - else - { - Ab = AssetBundle.LoadFromStream(manifestResourceStream); - Init(); - } - } + private void LoadAssetsFromEmbedded(string filename, string assetsNamespace, Assembly assembly) + { + var text = assetsNamespace + "." + filename; + var manifestResourceStream = assembly.GetManifestResourceStream(text); + var flag = manifestResourceStream == null; + if (flag) + { + Debug.Log(string.Concat(["在", assembly.FullName, "找不到内嵌的资源", text, ",请检查内嵌资源中是否有它:"])); + foreach (var text2 in assembly.GetManifestResourceNames()) + { + Debug.Log(text2); + } + Debug.Log("------------------------"); + } + else + { + Ab = AssetBundle.LoadFromStream(manifestResourceStream); + Init(); + } + } - public ABEmbeddedAssetsLoad(string filename, string dllFilepath, string dllNamespace) - { - var assembly = Assembly.LoadFrom(dllFilepath); - LoadAssetsFromEmbedded(filename, dllNamespace, assembly); - } - } + public ABEmbeddedAssetsLoad(string filename, string dllFilepath, string dllNamespace) + { + var assembly = Assembly.LoadFrom(dllFilepath); + LoadAssetsFromEmbedded(filename, dllNamespace, assembly); + } + } } diff --git a/XianTu/AssetsLoader/ABFileLoad.cs b/XianTu/AssetsLoader/ABFileLoad.cs index 498e5a7..0976b40 100644 --- a/XianTu/AssetsLoader/ABFileLoad.cs +++ b/XianTu/AssetsLoader/ABFileLoad.cs @@ -2,12 +2,12 @@ namespace AssetsLoader { - internal class ABFileLoad : ABLoad - { - public ABFileLoad(string filepath) - { - Ab = AssetBundle.LoadFromFile(filepath); - Init(); - } - } + internal class ABFileLoad : ABLoad + { + public ABFileLoad(string filepath) + { + Ab = AssetBundle.LoadFromFile(filepath); + Init(); + } + } } diff --git a/XianTu/AssetsLoader/ABLoad.cs b/XianTu/AssetsLoader/ABLoad.cs index c6294b9..66d8d54 100644 --- a/XianTu/AssetsLoader/ABLoad.cs +++ b/XianTu/AssetsLoader/ABLoad.cs @@ -4,77 +4,77 @@ using UnityEngine; namespace AssetsLoader { - public abstract class ABLoad : ILoad - { - protected void Init() - { - foreach (var text in Ab.GetAllAssetNames()) - { - var flag = text.Contains("prefabs"); - if (flag) - { - PrefabPath = text.Substring(0, text.IndexOf("prefabs", StringComparison.OrdinalIgnoreCase)); - break; - } - } - } + public abstract class ABLoad : ILoad + { + protected void Init() + { + foreach (var text in Ab.GetAllAssetNames()) + { + var flag = text.Contains("prefabs"); + if (flag) + { + PrefabPath = text.Substring(0, text.IndexOf("prefabs", StringComparison.OrdinalIgnoreCase)); + break; + } + } + } - public GameObject LoadPrefab(string path) - { - var flag = Ab == null; - GameObject gameObject; - if (flag) - { - Debug.Log("内嵌的AB包没有找到"); - gameObject = null; - } - else - { - var flag2 = path.Contains("/"); - if (flag2) - { - path = Path.Combine(PrefabPath, path); - var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase); - if (flag3) - { - path += ".prefab"; - } - } - gameObject = Ab.LoadAsset(path); - } - return gameObject; - } + public GameObject LoadPrefab(string path) + { + var flag = Ab == null; + GameObject gameObject; + if (flag) + { + Debug.Log("内嵌的AB包没有找到"); + gameObject = null; + } + else + { + var flag2 = path.Contains("/"); + if (flag2) + { + path = Path.Combine(PrefabPath, path); + var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase); + if (flag3) + { + path += ".prefab"; + } + } + gameObject = Ab.LoadAsset(path); + } + return gameObject; + } - public string LoadText(string path) - { - var flag = Ab == null; - string text; - if (flag) - { - Debug.Log("内嵌的AB包没有找到"); - text = null; - } - else - { - var flag2 = path.Contains("/"); - if (flag2) - { - path = Path.Combine(_txtPath, path); - var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase); - if (flag3) - { - path += ".prefab"; - } - } - text = Ab.LoadAsset(path).text; - } - return text; - } + public string LoadText(string path) + { + var flag = Ab == null; + string text; + if (flag) + { + Debug.Log("内嵌的AB包没有找到"); + text = null; + } + else + { + var flag2 = path.Contains("/"); + if (flag2) + { + path = Path.Combine(_txtPath, path); + var flag3 = !path.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase); + if (flag3) + { + path += ".prefab"; + } + } + text = Ab.LoadAsset(path).text; + } + return text; + } - protected string PrefabPath; + protected string PrefabPath; - protected AssetBundle Ab; + protected AssetBundle Ab; - private string _txtPath; - } + private string _txtPath; + } } diff --git a/XianTu/AssetsLoader/ABLoader.cs b/XianTu/AssetsLoader/ABLoader.cs index 42327cf..5f13d1c 100644 --- a/XianTu/AssetsLoader/ABLoader.cs +++ b/XianTu/AssetsLoader/ABLoader.cs @@ -2,27 +2,27 @@ namespace AssetsLoader { - public static class ABLoader - { - public static ABLoad LoadFromFile(string abFilename, string dir) - { - var text = Path.Combine(dir, abFilename); - return new ABFileLoad(text); - } + public static class ABLoader + { + public static ABLoad LoadFromFile(string abFilename, string dir) + { + var text = Path.Combine(dir, abFilename); + return new ABFileLoad(text); + } - public static ABLoad LoadFromFile(string filepath) - { - return new ABFileLoad(filepath); - } + public static ABLoad LoadFromFile(string filepath) + { + return new ABFileLoad(filepath); + } - public static ABLoad LoadFromEmbeddedAssets(string abFilename, string defaultNamespace = null) - { - return new ABEmbeddedAssetsLoad(abFilename, defaultNamespace); - } + public static ABLoad LoadFromEmbeddedAssets(string abFilename, string defaultNamespace = null) + { + return new ABEmbeddedAssetsLoad(abFilename, defaultNamespace); + } - public static ABLoad LoadFromDll(string abFilename, string dllFilepath, string dllDefaultNameSpace) - { - return new ABEmbeddedAssetsLoad(abFilename, dllFilepath, dllDefaultNameSpace); - } - } + public static ABLoad LoadFromDll(string abFilename, string dllFilepath, string dllDefaultNameSpace) + { + return new ABEmbeddedAssetsLoad(abFilename, dllFilepath, dllDefaultNameSpace); + } + } } diff --git a/XianTu/AssetsLoader/ILoad.cs b/XianTu/AssetsLoader/ILoad.cs index 20570b1..53d440f 100644 --- a/XianTu/AssetsLoader/ILoad.cs +++ b/XianTu/AssetsLoader/ILoad.cs @@ -2,10 +2,10 @@ namespace AssetsLoader { - public interface ILoad - { - GameObject LoadPrefab(string path); + public interface ILoad + { + GameObject LoadPrefab(string path); - string LoadText(string path); - } + string LoadText(string path); + } } diff --git a/XianTu/AssetsLoader/ResourceLoad.cs b/XianTu/AssetsLoader/ResourceLoad.cs index 5fc3f35..bb929d1 100644 --- a/XianTu/AssetsLoader/ResourceLoad.cs +++ b/XianTu/AssetsLoader/ResourceLoad.cs @@ -2,16 +2,16 @@ namespace AssetsLoader { - public class ResourceLoad : ILoad - { - public GameObject LoadPrefab(string path) - { - return Resources.Load(path); - } + public class ResourceLoad : ILoad + { + public GameObject LoadPrefab(string path) + { + return Resources.Load(path); + } - public string LoadText(string path) - { - return Resources.Load(path).text; - } - } + public string LoadText(string path) + { + return Resources.Load(path).text; + } + } } diff --git a/XianTu/BlueTuUIData.cs b/XianTu/BlueTuUIData.cs index ee84def..9336f13 100644 --- a/XianTu/BlueTuUIData.cs +++ b/XianTu/BlueTuUIData.cs @@ -4,153 +4,153 @@ using UnityEngine; namespace XianTu { - public class BlueTuUIData - { - [field: DebuggerBrowsable(DebuggerBrowsableState.Never)] - public event Action OnValueChange; + public class BlueTuUIData + { + [field: DebuggerBrowsable(DebuggerBrowsableState.Never)] + public event Action OnValueChange; - public static BlueTuUIData Instance { get; } = new(); + public static BlueTuUIData Instance { get; } = new(); - public Vector3 Bias - { - get => _bias; + public Vector3 Bias + { + get => _bias; set - { - _bias = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _bias = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public Vector3 Scale - { - get => _scale; + public Vector3 Scale + { + get => _scale; set - { - _scale = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _scale = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public Vector3 Pivot - { - get => _pivot; + public Vector3 Pivot + { + get => _pivot; set - { - _pivot = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _pivot = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public float LayerHeight - { - get => _layerHeight; + public float LayerHeight + { + get => _layerHeight; set - { - _layerHeight = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _layerHeight = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public float Rotate - { - get => _rotate; + public float Rotate + { + get => _rotate; set - { - _rotate = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _rotate = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public int LayerNumber - { - get => _layerNumber; + public int LayerNumber + { + get => _layerNumber; set - { - var flag = LayerNumber < 1; - if (!flag) - { - _layerNumber = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } - } + { + var flag = LayerNumber < 1; + if (!flag) + { + _layerNumber = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } + } - public bool Enable - { - get => _enable; + public bool Enable + { + get => _enable; set - { - _enable = value; - var onValueChange = OnValueChange; - if (onValueChange != null) - { - onValueChange(); - } - } - } + { + _enable = value; + var onValueChange = OnValueChange; + if (onValueChange != null) + { + onValueChange(); + } + } + } - public BlueTuUIData Clone() - { - var blueTuUIData = (BlueTuUIData)MemberwiseClone(); - blueTuUIData.OnValueChange = null; - return blueTuUIData; - } + public BlueTuUIData Clone() + { + var blueTuUIData = (BlueTuUIData)MemberwiseClone(); + blueTuUIData.OnValueChange = null; + return blueTuUIData; + } - public void Reset() - { - var blueTuUIData = new BlueTuUIData(); - _bias = blueTuUIData._bias; - _scale = blueTuUIData._scale; - _pivot = blueTuUIData._pivot; - _layerHeight = blueTuUIData._layerHeight; - _layerNumber = blueTuUIData._layerNumber; - _rotate = blueTuUIData._rotate; - _enable = true; - } + public void Reset() + { + var blueTuUIData = new BlueTuUIData(); + _bias = blueTuUIData._bias; + _scale = blueTuUIData._scale; + _pivot = blueTuUIData._pivot; + _layerHeight = blueTuUIData._layerHeight; + _layerNumber = blueTuUIData._layerNumber; + _rotate = blueTuUIData._rotate; + _enable = true; + } - private Vector3 _bias = new(0f, 0f, 0f); + private Vector3 _bias = new(0f, 0f, 0f); - private Vector3 _scale = new(1f, 1f, 1f); + private Vector3 _scale = new(1f, 1f, 1f); - private Vector3 _pivot = new(0f, 0f, 0f); + private Vector3 _pivot = new(0f, 0f, 0f); - private float _layerHeight = 5f; + private float _layerHeight = 5f; - private int _layerNumber = 1; + private int _layerNumber = 1; - private float _rotate; + private float _rotate; - private bool _enable = true; + private bool _enable = true; - public Action OnBuildBtn; + public Action OnBuildBtn; - public Action OnResetBtn; + public Action OnResetBtn; - public Action OnCopyBtn; - } + public Action OnCopyBtn; + } } diff --git a/XianTu/EmbeddedFileLoad.cs b/XianTu/EmbeddedFileLoad.cs index 54ab9ea..3ebf551 100644 --- a/XianTu/EmbeddedFileLoad.cs +++ b/XianTu/EmbeddedFileLoad.cs @@ -6,36 +6,36 @@ using UnityEngine; namespace XianTu { - internal class EmbeddedFileLoad : ILoad - { - public EmbeddedFileLoad(string assetsNamespace = null) - { - var stackTrace = new StackTrace(); - var frame = stackTrace.GetFrame(1); - var assembly = frame.GetMethod().DeclaringType.Assembly; - var flag = assetsNamespace == null; - if (flag) - { - assetsNamespace = assembly.FullName.Split([','])[0]; - } - this._assetsNamespace = assetsNamespace; - this._assembly = assembly; - } + internal class EmbeddedFileLoad : ILoad + { + public EmbeddedFileLoad(string assetsNamespace = null) + { + var stackTrace = new StackTrace(); + var frame = stackTrace.GetFrame(1); + var assembly = frame.GetMethod().DeclaringType.Assembly; + var flag = assetsNamespace == null; + if (flag) + { + assetsNamespace = assembly.FullName.Split([','])[0]; + } + this._assetsNamespace = assetsNamespace; + this._assembly = assembly; + } - public GameObject LoadPrefab(string path) - { - return null; - } + public GameObject LoadPrefab(string path) + { + return null; + } - public string LoadText(string path) - { + public string LoadText(string path) + { using var manifestResourceStream = _assembly.GetManifestResourceStream(_assetsNamespace + "." + path.Replace('/', '.')); using var streamReader = new StreamReader(manifestResourceStream); return streamReader.ReadToEnd(); - } + } - private readonly string _assetsNamespace; + private readonly string _assetsNamespace; - private readonly Assembly _assembly; - } + private readonly Assembly _assembly; + } } diff --git a/XianTu/FileLoad.cs b/XianTu/FileLoad.cs index cba24ff..c3f8202 100644 --- a/XianTu/FileLoad.cs +++ b/XianTu/FileLoad.cs @@ -4,19 +4,19 @@ using UnityEngine; namespace XianTu { - internal class FileLoad(string dirPath) : ILoad + internal class FileLoad(string dirPath) : ILoad { - public GameObject LoadPrefab(string path) - { - return null; - } + public GameObject LoadPrefab(string path) + { + return null; + } - public string LoadText(string path) - { - return File.ReadAllText(Path.Combine(_dirPath, path)); - } + public string LoadText(string path) + { + return File.ReadAllText(Path.Combine(_dirPath, path)); + } - private readonly string _dirPath = dirPath ?? ""; - } + private readonly string _dirPath = dirPath ?? ""; + } } diff --git a/XianTu/Scripts/DataController/BlueTuController.cs b/XianTu/Scripts/DataController/BlueTuController.cs index 8d66f08..ac2c1f8 100644 --- a/XianTu/Scripts/DataController/BlueTuController.cs +++ b/XianTu/Scripts/DataController/BlueTuController.cs @@ -5,376 +5,376 @@ using XianTu.UI; namespace XianTu.Scripts.DataController { - internal class BlueTuController - { - public BlueTuController() - { - _oldData = BlueTuUIData.Instance.Clone(); - _data = BlueTuUIData.Instance; - Init_OnUIOpen(); - _data.OnValueChange += OnUserChangeData; - var blueTuUIData = _data; - blueTuUIData.OnBuildBtn = (Action)Delegate.Combine(blueTuUIData.OnBuildBtn, new Action(OnUserBuildDetermine)); - var blueTuUIData2 = _data; - blueTuUIData2.OnCopyBtn = (Action)Delegate.Combine(blueTuUIData2.OnCopyBtn, new Action(OnUserCopy)); - var blueTuUIData3 = _data; - blueTuUIData3.OnResetBtn = (Action)Delegate.Combine(blueTuUIData3.OnResetBtn, new Action(OnReset)); - var blueprintData = BlueTuDatabase.Load("FoundationBlueTu"); - _foundation = blueprintData.buildings[0]; - } + internal class BlueTuController + { + public BlueTuController() + { + _oldData = BlueTuUIData.Instance.Clone(); + _data = BlueTuUIData.Instance; + Init_OnUIOpen(); + _data.OnValueChange += OnUserChangeData; + var blueTuUIData = _data; + blueTuUIData.OnBuildBtn = (Action)Delegate.Combine(blueTuUIData.OnBuildBtn, new Action(OnUserBuildDetermine)); + var blueTuUIData2 = _data; + blueTuUIData2.OnCopyBtn = (Action)Delegate.Combine(blueTuUIData2.OnCopyBtn, new Action(OnUserCopy)); + var blueTuUIData3 = _data; + blueTuUIData3.OnResetBtn = (Action)Delegate.Combine(blueTuUIData3.OnResetBtn, new Action(OnReset)); + var blueprintData = BlueTuDatabase.Load("FoundationBlueTu"); + _foundation = blueprintData.buildings[0]; + } - private void OnUserCopy() - { - _actionBuild.blueprintClipboard = _bPaste.blueprint; - ResetBuildDuiDie(); - _bPaste.RefreshBlueprintUI(); - } + private void OnUserCopy() + { + _actionBuild.blueprintClipboard = _bPaste.blueprint; + ResetBuildDuiDie(); + _bPaste.RefreshBlueprintUI(); + } - private void Init_OnUIOpen() - { - UIManager.Instance.CanvasMonoEvent.onEnableEvent.AddListener(OnReset); - } + private void Init_OnUIOpen() + { + UIManager.Instance.CanvasMonoEvent.onEnableEvent.AddListener(OnReset); + } - private void OnReset() - { - Player = GameMain.mainPlayer; - var flag = Player == null; - if (flag) - { - _data.Enable = false; - } - else - { - _playerController = Player.controller; - _actionBuild = PlayerController.actionBuild; - var flag2 = _actionBuild != null; - if (flag2) - { - _activeTool = _actionBuild.activeTool; - var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste; - var flag3 = buildToolBlueprintPaste != null; - if (flag3) - { - _bPaste = buildToolBlueprintPaste; - var mouseRay = _actionBuild.activeTool.mouseRay; - _defaultMouseRay = new Ray(mouseRay.origin, mouseRay.direction); - var flag4 = buildToolBlueprintPaste.blueprint != _blueprint; - if (flag4) - { - _templateBlueTu = buildToolBlueprintPaste.blueprint.Clone(); - _blueprint = buildToolBlueprintPaste.blueprint; - } - _oldData = new BlueTuUIData(); - _data.Reset(); - _data.Enable = true; - return; - } - } - _data.Enable = false; - } - } + private void OnReset() + { + Player = GameMain.mainPlayer; + var flag = Player == null; + if (flag) + { + _data.Enable = false; + } + else + { + _playerController = Player.controller; + _actionBuild = PlayerController.actionBuild; + var flag2 = _actionBuild != null; + if (flag2) + { + _activeTool = _actionBuild.activeTool; + var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste; + var flag3 = buildToolBlueprintPaste != null; + if (flag3) + { + _bPaste = buildToolBlueprintPaste; + var mouseRay = _actionBuild.activeTool.mouseRay; + _defaultMouseRay = new Ray(mouseRay.origin, mouseRay.direction); + var flag4 = buildToolBlueprintPaste.blueprint != _blueprint; + if (flag4) + { + _templateBlueTu = buildToolBlueprintPaste.blueprint.Clone(); + _blueprint = buildToolBlueprintPaste.blueprint; + } + _oldData = new BlueTuUIData(); + _data.Reset(); + _data.Enable = true; + return; + } + } + _data.Enable = false; + } + } private Player Player { get; set; } - private void OnUserBuildDetermine() - { - var flag = _actionBuild.activeTool != null; - if (flag) - { - var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste; - var flag2 = buildToolBlueprintPaste != null; - if (flag2) - { - var flag3 = buildToolBlueprintPaste.CheckBuildConditionsPrestage(); - if (flag3) - { - ResetBuildDuiDie(); - Build(buildToolBlueprintPaste); - } - } - } - } + private void OnUserBuildDetermine() + { + var flag = _actionBuild.activeTool != null; + if (flag) + { + var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste; + var flag2 = buildToolBlueprintPaste != null; + if (flag2) + { + var flag3 = buildToolBlueprintPaste.CheckBuildConditionsPrestage(); + if (flag3) + { + ResetBuildDuiDie(); + Build(buildToolBlueprintPaste); + } + } + } + } - private void ResetBuildDuiDie() - { - var buildToolBlueprintPaste = _bPaste; - BlueprintBuilding blueprintBuilding = null; - foreach (var blueprintBuilding2 in buildToolBlueprintPaste.blueprint.buildings) - { - var flag = Math.Abs(blueprintBuilding2.localOffset_z) < 1.5f; - if (flag) - { - var itemProto = LDB.items.Select(blueprintBuilding2.itemId); - Debug.Log($"基底查验:{itemProto.name}.{itemProto.ID}:{blueprintBuilding2.localOffset_x:2f}, {blueprintBuilding2.localOffset_y:2f}, {blueprintBuilding2.localOffset_z:2f}"); - blueprintBuilding = blueprintBuilding2; - break; - } - } - var flag2 = blueprintBuilding == null; - if (flag2) - { - Debug.Log("没有基底"); - } - var flag3 = blueprintBuilding == null; - if (flag3) - { - var buildings2 = _bPaste.blueprint.buildings; - var array = new BlueprintBuilding[_bPaste.blueprint.buildings.Length + 1]; - _bPaste.blueprint.buildings = array; - buildings2.CopyTo(array, 0); - blueprintBuilding = _foundation; - blueprintBuilding.index = buildings2.Length; - blueprintBuilding.localOffset_z = -0.5f; - array[buildings2.Length] = blueprintBuilding; - } - foreach (var blueprintBuilding3 in _bPaste.blueprint.buildings) - { - var flag4 = blueprintBuilding3.IsBelt(); - if (!flag4) - { - var flag5 = blueprintBuilding3.IsSlot(); - if (!flag5) - { - var flag6 = blueprintBuilding3 == blueprintBuilding; - if (!flag6) - { - blueprintBuilding3.inputToSlot = 14; - blueprintBuilding3.outputFromSlot = 15; - blueprintBuilding3.inputFromSlot = 15; - blueprintBuilding3.outputToSlot = 14; - blueprintBuilding3.inputObj = blueprintBuilding; - blueprintBuilding3.inputFromSlot = -1; - } - } - } - } - _bPaste.bpCursor = _bPaste.blueprint.buildings.Length; - _bPaste.buildPreviews.Clear(); - _bPaste.ResetStates(); - _BuildTool_BluePrint_OnTick(); - } + private void ResetBuildDuiDie() + { + var buildToolBlueprintPaste = _bPaste; + BlueprintBuilding blueprintBuilding = null; + foreach (var blueprintBuilding2 in buildToolBlueprintPaste.blueprint.buildings) + { + var flag = Math.Abs(blueprintBuilding2.localOffset_z) < 1.5f; + if (flag) + { + var itemProto = LDB.items.Select(blueprintBuilding2.itemId); + Debug.Log($"基底查验:{itemProto.name}.{itemProto.ID}:{blueprintBuilding2.localOffset_x:2f}, {blueprintBuilding2.localOffset_y:2f}, {blueprintBuilding2.localOffset_z:2f}"); + blueprintBuilding = blueprintBuilding2; + break; + } + } + var flag2 = blueprintBuilding == null; + if (flag2) + { + Debug.Log("没有基底"); + } + var flag3 = blueprintBuilding == null; + if (flag3) + { + var buildings2 = _bPaste.blueprint.buildings; + var array = new BlueprintBuilding[_bPaste.blueprint.buildings.Length + 1]; + _bPaste.blueprint.buildings = array; + buildings2.CopyTo(array, 0); + blueprintBuilding = _foundation; + blueprintBuilding.index = buildings2.Length; + blueprintBuilding.localOffset_z = -0.5f; + array[buildings2.Length] = blueprintBuilding; + } + foreach (var blueprintBuilding3 in _bPaste.blueprint.buildings) + { + var flag4 = blueprintBuilding3.IsBelt(); + if (!flag4) + { + var flag5 = blueprintBuilding3.IsSlot(); + if (!flag5) + { + var flag6 = blueprintBuilding3 == blueprintBuilding; + if (!flag6) + { + blueprintBuilding3.inputToSlot = 14; + blueprintBuilding3.outputFromSlot = 15; + blueprintBuilding3.inputFromSlot = 15; + blueprintBuilding3.outputToSlot = 14; + blueprintBuilding3.inputObj = blueprintBuilding; + blueprintBuilding3.inputFromSlot = -1; + } + } + } + } + _bPaste.bpCursor = _bPaste.blueprint.buildings.Length; + _bPaste.buildPreviews.Clear(); + _bPaste.ResetStates(); + _BuildTool_BluePrint_OnTick(); + } - private void Build(BuildTool_BlueprintPaste bp) - { - if (bp.CheckBuildConditionsPrestage()) - { - PlayerController.cmd.stage = 1; - bp.GenerateBlueprintGratBoxes(); - bp.DeterminePreviewsPrestage(true, false); - bp.ActiveColliders(_actionBuild.model); - var buildCondition = bp.CheckBuildConditions(); - bp.DeterminePreviews(); - bp.result = (buildCondition ? (bp.result & ~EBlueprintPasteResult.HasError) : (bp.result | EBlueprintPasteResult.HasError)); - bp.DeactiveColliders(_actionBuild.model); - bp.CalculateReformData(); - if (buildCondition && bp.quickPaste && (bp.result & EBlueprintPasteResult.HasReform) == EBlueprintPasteResult.None) - { - bp.CreatePrebuilds(); - bp.ResetStates(); - } - } - bp.isDragging = false; - bp.startGroundPosSnapped = bp.castGroundPosSnapped; - bp.ErrorGridClustering(); - _BuildTool_BluePrint_OnTick(); - } + private void Build(BuildTool_BlueprintPaste bp) + { + if (bp.CheckBuildConditionsPrestage()) + { + PlayerController.cmd.stage = 1; + bp.GenerateBlueprintGratBoxes(); + bp.DeterminePreviewsPrestage(true, false); + bp.ActiveColliders(_actionBuild.model); + var buildCondition = bp.CheckBuildConditions(); + bp.DeterminePreviews(); + bp.result = (buildCondition ? (bp.result & ~EBlueprintPasteResult.HasError) : (bp.result | EBlueprintPasteResult.HasError)); + bp.DeactiveColliders(_actionBuild.model); + bp.CalculateReformData(); + if (buildCondition && bp.quickPaste && (bp.result & EBlueprintPasteResult.HasReform) == EBlueprintPasteResult.None) + { + bp.CreatePrebuilds(); + bp.ResetStates(); + } + } + bp.isDragging = false; + bp.startGroundPosSnapped = bp.castGroundPosSnapped; + bp.ErrorGridClustering(); + _BuildTool_BluePrint_OnTick(); + } - private void OnUserChangeData() - { - var flag = !_data.Enable; - if (!flag) - { - var flag2 = PlayerController == null; - if (!flag2) - { - var flag3 = _actionBuild == null; - if (!flag3) - { - var flag4 = _bPaste == null; - if (!flag4) - { - var vector = _data.Bias - _oldData.Bias; + private void OnUserChangeData() + { + var flag = !_data.Enable; + if (!flag) + { + var flag2 = PlayerController == null; + if (!flag2) + { + var flag3 = _actionBuild == null; + if (!flag3) + { + var flag4 = _bPaste == null; + if (!flag4) + { + var vector = _data.Bias - _oldData.Bias; var num = _data.LayerHeight - _oldData.LayerHeight; - var num2 = _data.LayerNumber - _oldData.LayerNumber; - var num3 = _data.Rotate - _oldData.Rotate; - var flag5 = _actionBuild != null; - if (flag5) - { - CtrlLayerNumber(num2); - CtrlLayerHeight(num); - CtrlRotate(num3); - CtrlBiasData(vector); - CtrlScale(); - _BuildTool_BluePrint_OnTick(); - } - _oldData.Scale = _data.Scale; - _oldData.Pivot = _data.Pivot; - _oldData.LayerHeight = _data.LayerHeight; - _oldData.LayerNumber = _data.LayerNumber; - _oldData.Rotate = _data.Rotate; - _oldData.Bias = _data.Bias; - } - } - } - } - } + var num2 = _data.LayerNumber - _oldData.LayerNumber; + var num3 = _data.Rotate - _oldData.Rotate; + var flag5 = _actionBuild != null; + if (flag5) + { + CtrlLayerNumber(num2); + CtrlLayerHeight(num); + CtrlRotate(num3); + CtrlBiasData(vector); + CtrlScale(); + _BuildTool_BluePrint_OnTick(); + } + _oldData.Scale = _data.Scale; + _oldData.Pivot = _data.Pivot; + _oldData.LayerHeight = _data.LayerHeight; + _oldData.LayerNumber = _data.LayerNumber; + _oldData.Rotate = _data.Rotate; + _oldData.Bias = _data.Bias; + } + } + } + } + } - private void CtrlLayerNumber(int bLayerNumber) - { - var flag = bLayerNumber == 0; - if (!flag) - { - var num = _data.LayerNumber * _templateBlueTu.buildings.Length; - var buildings = _bPaste.blueprint.buildings; - var array = new BlueprintBuilding[num]; - var flag2 = buildings.Length > num; - if (flag2) - { - Array.Copy(buildings, array, num); - } - else - { - buildings.CopyTo(array, 0); - var num2 = _templateBlueTu.buildings.Length; - for (var i = _bPaste.bpCursor; i < array.Length; i += num2) - { - _templateBlueTu.Clone().buildings.CopyTo(array, i); - } - for (var j = _bPaste.bpCursor; j < array.Length; j++) - { - array[j].localOffset_z = array[j - num2].localOffset_z + _data.LayerHeight; - array[j].localOffset_z2 = array[j - num2].localOffset_z2 + _data.LayerHeight; - } - for (var k = _bPaste.bpCursor; k < array.Length; k++) - { - array[k].index = k; - } - } - _bPaste.blueprint.buildings = array; - _bPaste.bpCursor = _bPaste.blueprint.buildings.Length; - _bPaste.buildPreviews.Clear(); - _bPaste.ResetStates(); - } - } + private void CtrlLayerNumber(int bLayerNumber) + { + var flag = bLayerNumber == 0; + if (!flag) + { + var num = _data.LayerNumber * _templateBlueTu.buildings.Length; + var buildings = _bPaste.blueprint.buildings; + var array = new BlueprintBuilding[num]; + var flag2 = buildings.Length > num; + if (flag2) + { + Array.Copy(buildings, array, num); + } + else + { + buildings.CopyTo(array, 0); + var num2 = _templateBlueTu.buildings.Length; + for (var i = _bPaste.bpCursor; i < array.Length; i += num2) + { + _templateBlueTu.Clone().buildings.CopyTo(array, i); + } + for (var j = _bPaste.bpCursor; j < array.Length; j++) + { + array[j].localOffset_z = array[j - num2].localOffset_z + _data.LayerHeight; + array[j].localOffset_z2 = array[j - num2].localOffset_z2 + _data.LayerHeight; + } + for (var k = _bPaste.bpCursor; k < array.Length; k++) + { + array[k].index = k; + } + } + _bPaste.blueprint.buildings = array; + _bPaste.bpCursor = _bPaste.blueprint.buildings.Length; + _bPaste.buildPreviews.Clear(); + _bPaste.ResetStates(); + } + } - private void CtrlLayerHeight(float bLayerHeight) - { - var flag = bLayerHeight == 0f; - if (!flag) - { - var num = _templateBlueTu.buildings.Length; - var num2 = 0; - var buildings = _bPaste.blueprint.buildings; - for (var i = 0; i < _bPaste.bpCursor; i++) - { - var flag2 = i == num * (num2 + 1); - if (flag2) - { - num2++; - } - buildings[i].localOffset_z += bLayerHeight * num2; - buildings[i].localOffset_z2 += bLayerHeight * num2; - } - } - } + private void CtrlLayerHeight(float bLayerHeight) + { + var flag = bLayerHeight == 0f; + if (!flag) + { + var num = _templateBlueTu.buildings.Length; + var num2 = 0; + var buildings = _bPaste.blueprint.buildings; + for (var i = 0; i < _bPaste.bpCursor; i++) + { + var flag2 = i == num * (num2 + 1); + if (flag2) + { + num2++; + } + buildings[i].localOffset_z += bLayerHeight * num2; + buildings[i].localOffset_z2 += bLayerHeight * num2; + } + } + } - private void CtrlScale() - { - var flag = _oldData.Scale == _data.Scale; - if (!flag) - { - var buildings = _templateBlueTu.buildings; - var vector = _data.Scale - _oldData.Scale; - var pivot = _data.Pivot; - var num = 0; - for (var i = 0; i < _bPaste.bpCursor; i++) - { - var flag2 = num == buildings.Length; - if (flag2) - { - num = 0; - } - var blueprintBuilding = buildings[num]; - var blueprintBuilding2 = _bPaste.blueprint.buildings[i]; - blueprintBuilding2.localOffset_x += (blueprintBuilding.localOffset_x - pivot.x) * vector.x + pivot.x; - blueprintBuilding2.localOffset_y += (blueprintBuilding.localOffset_y - pivot.y) * vector.y + pivot.y; - blueprintBuilding2.localOffset_z += blueprintBuilding.localOffset_z * vector.z; - blueprintBuilding2.localOffset_x2 += (blueprintBuilding.localOffset_x2 - pivot.x) * vector.x + pivot.x; - blueprintBuilding2.localOffset_y2 += (blueprintBuilding.localOffset_y2 - pivot.y) * vector.y + pivot.y; - blueprintBuilding2.localOffset_z2 += blueprintBuilding.localOffset_z2 * vector.z; - num++; - } - } - } + private void CtrlScale() + { + var flag = _oldData.Scale == _data.Scale; + if (!flag) + { + var buildings = _templateBlueTu.buildings; + var vector = _data.Scale - _oldData.Scale; + var pivot = _data.Pivot; + var num = 0; + for (var i = 0; i < _bPaste.bpCursor; i++) + { + var flag2 = num == buildings.Length; + if (flag2) + { + num = 0; + } + var blueprintBuilding = buildings[num]; + var blueprintBuilding2 = _bPaste.blueprint.buildings[i]; + blueprintBuilding2.localOffset_x += (blueprintBuilding.localOffset_x - pivot.x) * vector.x + pivot.x; + blueprintBuilding2.localOffset_y += (blueprintBuilding.localOffset_y - pivot.y) * vector.y + pivot.y; + blueprintBuilding2.localOffset_z += blueprintBuilding.localOffset_z * vector.z; + blueprintBuilding2.localOffset_x2 += (blueprintBuilding.localOffset_x2 - pivot.x) * vector.x + pivot.x; + blueprintBuilding2.localOffset_y2 += (blueprintBuilding.localOffset_y2 - pivot.y) * vector.y + pivot.y; + blueprintBuilding2.localOffset_z2 += blueprintBuilding.localOffset_z2 * vector.z; + num++; + } + } + } - private void CtrlRotate(float bRotate) - { - var flag = Math.Abs(bRotate) < 0.001f; - if (!flag) - { - var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste; - var flag2 = buildToolBlueprintPaste != null; - if (flag2) - { - var pivot = _data.Pivot; - var buildings = buildToolBlueprintPaste.blueprint.buildings; - var quaternion = Quaternion.AngleAxis(bRotate, Vector3.forward); - for (var i = 0; i < _bPaste.bpCursor; i++) - { - var blueprintBuilding = buildings[i]; - var vector = new Vector3(blueprintBuilding.localOffset_x - pivot.x, blueprintBuilding.localOffset_y - pivot.y, 0f); - vector = quaternion * vector; - blueprintBuilding.localOffset_x = vector.x + pivot.x; - blueprintBuilding.localOffset_y = vector.y + pivot.y; - blueprintBuilding.yaw -= bRotate; + private void CtrlRotate(float bRotate) + { + var flag = Math.Abs(bRotate) < 0.001f; + if (!flag) + { + var buildToolBlueprintPaste = _actionBuild.activeTool as BuildTool_BlueprintPaste; + var flag2 = buildToolBlueprintPaste != null; + if (flag2) + { + var pivot = _data.Pivot; + var buildings = buildToolBlueprintPaste.blueprint.buildings; + var quaternion = Quaternion.AngleAxis(bRotate, Vector3.forward); + for (var i = 0; i < _bPaste.bpCursor; i++) + { + var blueprintBuilding = buildings[i]; + var vector = new Vector3(blueprintBuilding.localOffset_x - pivot.x, blueprintBuilding.localOffset_y - pivot.y, 0f); + vector = quaternion * vector; + blueprintBuilding.localOffset_x = vector.x + pivot.x; + blueprintBuilding.localOffset_y = vector.y + pivot.y; + blueprintBuilding.yaw -= bRotate; vector = new Vector3(blueprintBuilding.localOffset_x2 - pivot.x, blueprintBuilding.localOffset_y2 - pivot.y, 0f); - vector = quaternion * vector; - blueprintBuilding.localOffset_x2 = vector.x + pivot.x; - blueprintBuilding.localOffset_y2 = vector.y + pivot.y; - blueprintBuilding.yaw2 -= bRotate; - } - } - } - } + vector = quaternion * vector; + blueprintBuilding.localOffset_x2 = vector.x + pivot.x; + blueprintBuilding.localOffset_y2 = vector.y + pivot.y; + blueprintBuilding.yaw2 -= bRotate; + } + } + } + } private PlayerController PlayerController => _playerController; - private void CtrlBiasData(Vector3 bBias) - { - var flag = bBias == Vector3.zero; - if (!flag) - { - var playerActionBuild = _actionBuild; - var buildTool = playerActionBuild.activeTool; - var buildToolBlueprintPaste = buildTool as BuildTool_BlueprintPaste; - var flag2 = buildToolBlueprintPaste != null; - if (flag2) - { - for (var i = 0; i < buildToolBlueprintPaste.bpCursor; i++) - { - var blueprintBuilding = buildToolBlueprintPaste.blueprint.buildings[i]; - blueprintBuilding.localOffset_x += bBias.x; - blueprintBuilding.localOffset_x2 += bBias.x; - blueprintBuilding.localOffset_y += bBias.y; - blueprintBuilding.localOffset_y2 += bBias.y; - blueprintBuilding.localOffset_z += bBias.z; - blueprintBuilding.localOffset_z2 += bBias.z; - } - } - } - } + private void CtrlBiasData(Vector3 bBias) + { + var flag = bBias == Vector3.zero; + if (!flag) + { + var playerActionBuild = _actionBuild; + var buildTool = playerActionBuild.activeTool; + var buildToolBlueprintPaste = buildTool as BuildTool_BlueprintPaste; + var flag2 = buildToolBlueprintPaste != null; + if (flag2) + { + for (var i = 0; i < buildToolBlueprintPaste.bpCursor; i++) + { + var blueprintBuilding = buildToolBlueprintPaste.blueprint.buildings[i]; + blueprintBuilding.localOffset_x += bBias.x; + blueprintBuilding.localOffset_x2 += bBias.x; + blueprintBuilding.localOffset_y += bBias.y; + blueprintBuilding.localOffset_y2 += bBias.y; + blueprintBuilding.localOffset_z += bBias.z; + blueprintBuilding.localOffset_z2 += bBias.z; + } + } + } + } - private void _BuildTool_BluePrint_OnTick() - { - VFInput.onGUI = false; - _bPaste.mouseRay = _defaultMouseRay; - var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste; - var flag = buildToolBlueprintPaste != null; - if (flag) - { - buildToolBlueprintPaste.ClearErrorMessage(); - buildToolBlueprintPaste.UpdateRaycast(); - buildToolBlueprintPaste.CheckBuildConditionsPrestage(); + private void _BuildTool_BluePrint_OnTick() + { + VFInput.onGUI = false; + _bPaste.mouseRay = _defaultMouseRay; + var buildToolBlueprintPaste = _activeTool as BuildTool_BlueprintPaste; + var flag = buildToolBlueprintPaste != null; + if (flag) + { + buildToolBlueprintPaste.ClearErrorMessage(); + buildToolBlueprintPaste.UpdateRaycast(); + buildToolBlueprintPaste.CheckBuildConditionsPrestage(); switch (PlayerController.cmd.stage) { case 0: @@ -385,28 +385,28 @@ namespace XianTu.Scripts.DataController break; } buildToolBlueprintPaste.UpdatePreviewModels(_actionBuild.model); - buildToolBlueprintPaste.TranslateErrorType(false); - } - } + buildToolBlueprintPaste.TranslateErrorType(false); + } + } - private readonly BlueTuUIData _data; + private readonly BlueTuUIData _data; - private BlueTuUIData _oldData; + private BlueTuUIData _oldData; - private PlayerController _playerController; + private PlayerController _playerController; - private Ray _defaultMouseRay; + private Ray _defaultMouseRay; - private BlueprintData _templateBlueTu; + private BlueprintData _templateBlueTu; - private PlayerAction_Build _actionBuild; + private PlayerAction_Build _actionBuild; - private BuildTool _activeTool; + private BuildTool _activeTool; - private BuildTool_BlueprintPaste _bPaste; + private BuildTool_BlueprintPaste _bPaste; - private readonly BlueprintBuilding _foundation; + private readonly BlueprintBuilding _foundation; - private BlueprintData _blueprint; - } + private BlueprintData _blueprint; + } } diff --git a/XianTu/Scripts/DataController/BlueTuDatabase.cs b/XianTu/Scripts/DataController/BlueTuDatabase.cs index cb474f5..2f04e1f 100644 --- a/XianTu/Scripts/DataController/BlueTuDatabase.cs +++ b/XianTu/Scripts/DataController/BlueTuDatabase.cs @@ -2,34 +2,34 @@ namespace XianTu.Scripts.DataController { - internal static class BlueTuDatabase - { - public static BlueprintData Load(string path) - { - var flag = !path.EndsWith(".txt"); - if (flag) - { - path += ".txt"; - } - var text = Singleton.Instance.LoadText(path); - var flag2 = text == ""; - BlueprintData blueprintData; - if (flag2) - { - Debug.Log("没有找到蓝图文件"); - blueprintData = null; - } - else - { - var blueprintData2 = BlueprintData.CreateNew(text); - var flag3 = blueprintData2 == null; - if (flag3) - { - Debug.Log("蓝图文件加载失败"); - } - blueprintData = blueprintData2; - } - return blueprintData; - } - } + internal static class BlueTuDatabase + { + public static BlueprintData Load(string path) + { + var flag = !path.EndsWith(".txt"); + if (flag) + { + path += ".txt"; + } + var text = Singleton.Instance.LoadText(path); + var flag2 = text == ""; + BlueprintData blueprintData; + if (flag2) + { + Debug.Log("没有找到蓝图文件"); + blueprintData = null; + } + else + { + var blueprintData2 = BlueprintData.CreateNew(text); + var flag3 = blueprintData2 == null; + if (flag3) + { + Debug.Log("蓝图文件加载失败"); + } + blueprintData = blueprintData2; + } + return blueprintData; + } + } } diff --git a/XianTu/ToolScripts/EventTriggerExpand.cs b/XianTu/ToolScripts/EventTriggerExpand.cs index c765521..e552e67 100644 --- a/XianTu/ToolScripts/EventTriggerExpand.cs +++ b/XianTu/ToolScripts/EventTriggerExpand.cs @@ -3,19 +3,19 @@ using UnityEngine.EventSystems; namespace ToolScripts { - internal static class EventTriggerExpand - { - public static void Add(this EventTrigger trigger, EventTriggerType eventID, UnityAction callback) - { - var flag = trigger.triggers == null; - if (flag) - { - trigger.triggers = []; - } - var entry = new EventTrigger.Entry(); - entry.eventID = eventID; - entry.callback.AddListener(callback); - trigger.triggers.Add(entry); - } - } + internal static class EventTriggerExpand + { + public static void Add(this EventTrigger trigger, EventTriggerType eventID, UnityAction callback) + { + var flag = trigger.triggers == null; + if (flag) + { + trigger.triggers = []; + } + var entry = new EventTrigger.Entry(); + entry.eventID = eventID; + entry.callback.AddListener(callback); + trigger.triggers.Add(entry); + } + } } diff --git a/XianTu/ToolScripts/GameObjectExpand.cs b/XianTu/ToolScripts/GameObjectExpand.cs index a49450e..5f8f412 100644 --- a/XianTu/ToolScripts/GameObjectExpand.cs +++ b/XianTu/ToolScripts/GameObjectExpand.cs @@ -2,74 +2,74 @@ namespace ToolScripts { - public static class GameObjectExpand - { - public static T Find(this GameObject obj, string name) where T : class - { - var gameObject = GameObject.Find(name); - bool flag = gameObject; - T t; - if (flag) - { - t = gameObject.GetComponent(); - } - else - { - t = default(T); - } - return t; - } + public static class GameObjectExpand + { + public static T Find(this GameObject obj, string name) where T : class + { + var gameObject = GameObject.Find(name); + bool flag = gameObject; + T t; + if (flag) + { + t = gameObject.GetComponent(); + } + else + { + t = default(T); + } + return t; + } - public static T Find(this Transform obj, string name) where T : class - { - var transform = obj.Find(name); - bool flag = transform; - T t; - if (flag) - { - t = transform.GetComponent(); - } - else - { - t = default(T); - } - return t; - } + public static T Find(this Transform obj, string name) where T : class + { + var transform = obj.Find(name); + bool flag = transform; + T t; + if (flag) + { + t = transform.GetComponent(); + } + else + { + t = default(T); + } + return t; + } - public static bool TryFind(this GameObject obj, string name, out T result) where T : class - { - var gameObject = GameObject.Find(name); - bool flag = gameObject; - bool flag2; - if (flag) - { - result = gameObject.GetComponent(); - flag2 = true; - } - else - { - result = default(T); - flag2 = false; - } - return flag2; - } + public static bool TryFind(this GameObject obj, string name, out T result) where T : class + { + var gameObject = GameObject.Find(name); + bool flag = gameObject; + bool flag2; + if (flag) + { + result = gameObject.GetComponent(); + flag2 = true; + } + else + { + result = default(T); + flag2 = false; + } + return flag2; + } - public static bool TryFind(this Transform obj, string name, out T result) where T : class - { - var transform = obj.Find(name); - bool flag = transform; - bool flag2; - if (flag) - { - result = transform.GetComponent(); - flag2 = true; - } - else - { - result = default(T); - flag2 = false; - } - return flag2; - } - } + public static bool TryFind(this Transform obj, string name, out T result) where T : class + { + var transform = obj.Find(name); + bool flag = transform; + bool flag2; + if (flag) + { + result = transform.GetComponent(); + flag2 = true; + } + else + { + result = default(T); + flag2 = false; + } + return flag2; + } + } } diff --git a/XianTu/ToolScripts/_BlueprintBuildingExpands.cs b/XianTu/ToolScripts/_BlueprintBuildingExpands.cs index d6dc32e..21faccb 100644 --- a/XianTu/ToolScripts/_BlueprintBuildingExpands.cs +++ b/XianTu/ToolScripts/_BlueprintBuildingExpands.cs @@ -2,31 +2,31 @@ namespace ToolScripts { - public static class _BlueprintBuildingExpands - { - static _BlueprintBuildingExpands() - { - BeltProtoDict.Add(2001, null); - BeltProtoDict.Add(2002, null); - BeltProtoDict.Add(2003, null); - SoltProtoDict.Add(2011, null); - SoltProtoDict.Add(2012, null); - SoltProtoDict.Add(2013, null); + public static class _BlueprintBuildingExpands + { + static _BlueprintBuildingExpands() + { + BeltProtoDict.Add(2001, null); + BeltProtoDict.Add(2002, null); + BeltProtoDict.Add(2003, null); + SoltProtoDict.Add(2011, null); + SoltProtoDict.Add(2012, null); + SoltProtoDict.Add(2013, null); SoltProtoDict.Add(2014, null); - } + } - public static bool IsBelt(this BlueprintBuilding bb) - { - return BeltProtoDict.ContainsKey(bb.itemId); - } + public static bool IsBelt(this BlueprintBuilding bb) + { + return BeltProtoDict.ContainsKey(bb.itemId); + } - public static bool IsSlot(this BlueprintBuilding bb) - { - return SoltProtoDict.ContainsKey(bb.itemId); - } + public static bool IsSlot(this BlueprintBuilding bb) + { + return SoltProtoDict.ContainsKey(bb.itemId); + } private static readonly Dictionary BeltProtoDict = new(); private static readonly Dictionary SoltProtoDict = new(); - } + } } diff --git a/XianTu/UI/BasePanel.cs b/XianTu/UI/BasePanel.cs index f0c35c6..9053778 100644 --- a/XianTu/UI/BasePanel.cs +++ b/XianTu/UI/BasePanel.cs @@ -2,39 +2,39 @@ namespace XianTu.UI { - internal class BasePanel : MonoBehaviour - { - public virtual void OnEnter() - { - } + internal class BasePanel : MonoBehaviour + { + public virtual void OnEnter() + { + } - public virtual void OnPause() - { - UITool.GameObject.SetActive(false); - } + public virtual void OnPause() + { + UITool.GameObject.SetActive(false); + } - public virtual void OnResume() - { - UITool.GameObject.SetActive(true); - } + public virtual void OnResume() + { + UITool.GameObject.SetActive(true); + } - public virtual void OnExit() - { - Destroy(UITool.GameObject); - } + public virtual void OnExit() + { + Destroy(UITool.GameObject); + } - public void Init(PanelManager panelManager) - { - PanelManager = panelManager; - } + public void Init(PanelManager panelManager) + { + PanelManager = panelManager; + } - public PanelManager PanelManager { get; private set; } + public PanelManager PanelManager { get; private set; } - public void Init(UITool uiTool) - { - UITool = uiTool; - } + public void Init(UITool uiTool) + { + UITool = uiTool; + } - public UITool UITool { get; private set; } - } + public UITool UITool { get; private set; } + } } diff --git a/XianTu/UI/BlueTuPatchUI.cs b/XianTu/UI/BlueTuPatchUI.cs index e45921b..936e562 100644 --- a/XianTu/UI/BlueTuPatchUI.cs +++ b/XianTu/UI/BlueTuPatchUI.cs @@ -6,339 +6,339 @@ using Debug = UnityEngine.Debug; namespace XianTu.UI { - internal class BlueTuPatchUI : XianTuBasePanel - { - public BlueTuUIData Data { get; private set; } + internal class BlueTuPatchUI : XianTuBasePanel + { + public BlueTuUIData Data { get; private set; } - public static BlueTuPatchUI Instance { get; private set; } + public static BlueTuPatchUI Instance { get; private set; } - public override void OnEnter() - { - base.OnEnter(); - Data = BlueTuUIData.Instance; - enableToggle = UITool.GetComponentInChild("XianTuEnableTg"); - enableToggle.isOn = Data.Enable; - enableToggle.onValueChanged.AddListener(delegate(bool value) - { - Data.Enable = value; - }); - _tipText = UITool.GetComponentInChild