XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

SpaceEngineersModDev/SpaceEngineersBlueprintEditorInWinUI

添加项目引用

bd47216
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

16 个文件 +1282 -30
Modified .gitignore +2 -1
@@ -360,4 +360,5 @@ MigrationBackup/
360 360 .ionide/
361 361
362 362 # Fody - auto-generated XML schema
363 FodyWeavers.xsd
363 FodyWeavers.xsd
364 /DLLReference
Deleted SpaceEngineersBlueprintEditor.SpaceEngineersCore/Class1.cs +0 -7
@@ -1,7 +0,0 @@
1 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore
2 {
3 public class Class1
4 {
5
6 }
7 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/Initializer.cs +166 -0
@@ -0,0 +1,166 @@
1 using log4net.Config;
2 using ParallelTasks;
3 using Sandbox;
4 using Sandbox.Definitions;
5 using Sandbox.Engine.Utils;
6 using Sandbox.Game;
7 using Sandbox.Game.Entities;
8 using Sandbox.Game.Entities.Planet;
9 using Sandbox.Game.GameSystems;
10 using Sandbox.Game.World;
11 using SpaceEngineers.Game;
12 using SpaceEngineersBlueprintEditor.SpaceEngineersCore.InnerModel;
13 using System.Reflection;
14 using System.Runtime.CompilerServices;
15 using System.Runtime.Serialization;
16 using VRage;
17 using VRage.Collections;
18 using VRage.FileSystem;
19 using VRage.Game;
20 using VRage.Game.ObjectBuilder;
21 using VRage.ObjectBuilders;
22 using VRage.Plugins;
23 using VRage.Utils;
24 using VRageMath;
25 using VRageRender;
26
27 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore;
28
29 public class Initializer
30 {
31 public static bool IsDefinitionsLoadComplete { get; private set; }
32 private static object GetUninitializedObject(Type type)
33 {
34 return FormatterServices.GetUninitializedObject(type);
35 }
36 public static void Initialize()
37 {
38 XmlConfigurator.Configure();
39 MyFileSystem.ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FastResourceLock))!.Location);
40 MyLog.Default = MySandboxGame.Log;
41 SpaceEngineersGame.SetupBasicGameInfo();
42 _ = new MyCommonProgramStartup([]);
43 MyFileSystem.Reset();
44 MyFileSystem.Init("D:\\SteamLibrary\\steamapps\\common\\SpaceEngineers\\Content", "C:\\Users\\XFEstudio\\AppData\\Roaming\\SpaceEngineers");
45 MyVRage.Init(new CorePlatform());
46 MyVRage.Platform.Init();
47 MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg");
48 MySandboxGame.Config.Load();
49 SpaceEngineersGame.SetupPerGameSettings();
50 MyPerGameSettings.UpdateOrchestratorType = null;
51 InitMultithreading();
52 MyRenderProxy.Initialize(new MyNullRender());
53 InitSandboxGame();
54 MySession obj = (MySession)GetUninitializedObject(typeof(MySession));
55 ConstructField(obj, "CreativeTools");
56 ConstructField(obj, "m_sessionComponents");
57 ConstructField(obj, "m_sessionComponentsForUpdate");
58 obj.Settings = new MyObjectBuilder_SessionSettings
59 {
60 EnableVoxelDestruction = true
61 };
62 MySession.Static = obj;
63 var myHeightMapLoadingSystem = new MyHeightMapLoadingSystem();
64 obj.RegisterComponent(myHeightMapLoadingSystem, myHeightMapLoadingSystem.UpdateOrder, myHeightMapLoadingSystem.Priority);
65 myHeightMapLoadingSystem.LoadData();
66 var myPlanets = new MyPlanets();
67 obj.RegisterComponent(myPlanets, myHeightMapLoadingSystem.UpdateOrder, myHeightMapLoadingSystem.Priority);
68 myPlanets.LoadData();
69 MyDefinitionManager.Static.PreloadDefinitions();
70 MyDefinitionManager.Static.LoadData([]);
71 IsDefinitionsLoadComplete = true;
72 }
73
74 private static void Preallocate()
75 {
76 ForceStaticCtor(
77 [
78 typeof(MyEntities),
79 typeof(MyObjectBuilder_Base),
80 typeof(MyMath)
81 ]);
82 static void ForceStaticCtor(IEnumerable<Type> types)
83 {
84 foreach (Type type in types)
85 {
86 RuntimeHelpers.RunClassConstructor(type.TypeHandle);
87 }
88 }
89 }
90 private static void InitMultithreading()
91 {
92 ParallelTasks.Parallel.Scheduler = new PrioritizedScheduler(Math.Max(Environment.ProcessorCount / 2, 1), amd: true, null);
93 }
94
95 private static void InitSandboxGame()
96 {
97 MySandboxGame.Static = (MySandboxGame)GetUninitializedObject(typeof(MySandboxGame));
98 MySandboxGame @static = MySandboxGame.Static;
99 object value = Activator.CreateInstance(typeof(MyConcurrentQueue<>).MakeGenericType(typeof(MySandboxGame).GetNestedType("MyInvokeData", BindingFlags.NonPublic)!), 32)!;
100 object value2 = Activator.CreateInstance(typeof(MyConcurrentQueue<>).MakeGenericType(typeof(MySandboxGame).GetNestedType("MyInvokeData", BindingFlags.NonPublic)!), 32)!;
101 typeof(MySandboxGame).GetField("m_invokeQueue", BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(@static, value);
102 typeof(MySandboxGame).GetField("m_invokeQueueExecuting", BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(@static, value2);
103 RegisterAssemblies();
104 MyGlobalTypeMetadata.Static.Init();
105 Preallocate();
106 }
107
108 private static void RegisterAssemblies()
109 {
110 MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly);
111 if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null)
112 {
113 MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly);
114 }
115
116 MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly);
117 MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly);
118 MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly);
119 MyPlugins.Load();
120 }
121
122 private static string GetBackingFieldName(string propertyName)
123 {
124 return $"<{propertyName}>k__BackingField";
125 }
126 private static FieldInfo GetFieldInfo(Type type, string fieldName)
127 {
128 FieldInfo field;
129 do
130 {
131 field = type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)!;
132 if (field == null)
133 {
134 field = type.GetField(GetBackingFieldName(fieldName), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)!;
135 }
136 type = type.BaseType!;
137 }
138 while (field == null && type != null);
139 return field!;
140 }
141 public static void SetFieldValue(Type type, string fieldName, object val)
142 {
143 FieldInfo fieldInfo = GetFieldInfo(type, fieldName) ?? throw new ArgumentOutOfRangeException(nameof(fieldName), "Couldn't find field " + fieldName + " in type " + type.FullName);
144 fieldInfo.SetValue(type, val);
145 }
146 public static object CreateInstance(Type type)
147 {
148 IEnumerable<object> source = from parameter in type.GetConstructors().First().GetParameters()
149 select CreateInstance(parameter.ParameterType);
150 return Activator.CreateInstance(type, source.ToArray<object>())!;
151 }
152 public static void ConstructField(object obj, string fieldName)
153 {
154 if (obj == null)
155 {
156 return;
157 }
158 FieldInfo field = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)!;
159 if (field == null)
160 {
161 return;
162 }
163 object value = CreateInstance(field.FieldType);
164 field.SetValue(obj, value);
165 }
166 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/InnerModel/CorePlatform.cs +145 -0
@@ -0,0 +1,145 @@
1 using VRage;
2 using VRage.Analytics;
3 using VRage.Audio;
4 using VRage.Http;
5 using VRage.Input;
6 using VRage.Scripting;
7 using VRage.Serialization;
8
9 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore.InnerModel;
10
11 public class CorePlatform : IVRagePlatform
12 {
13 public bool SessionReady { get; set; }
14
15 public IVRageWindows Windows
16 {
17 get
18 {
19 throw new NotImplementedException();
20 }
21 }
22
23 public IVRageHttp Http
24 {
25 get
26 {
27 throw new NotImplementedException();
28 }
29 }
30
31 public IVRageSystem System { get; } = new VRageSystemImpl();
32
33 public IVRageRender Render { get; } = new VRageRenderImpl();
34
35 public IAnsel Ansel
36 {
37 get
38 {
39 throw new NotImplementedException();
40 }
41 }
42
43 public IAfterMath AfterMath
44 {
45 get
46 {
47 throw new NotImplementedException();
48 }
49 }
50
51 public IVRageInput Input
52 {
53 get
54 {
55 throw new NotImplementedException();
56 }
57 }
58
59 public IVRageInput2 Input2
60 {
61 get
62 {
63 throw new NotImplementedException();
64 }
65 }
66
67 public IMyAudio Audio
68 {
69 get
70 {
71 throw new NotImplementedException();
72 }
73 }
74
75 public IMyImeProcessor ImeProcessor
76 {
77 get
78 {
79 throw new NotImplementedException();
80 }
81 }
82
83 public IMyCrashReporting CrashReporting
84 {
85 get
86 {
87 throw new NotImplementedException();
88 }
89 }
90
91 public IVRageScripting Scripting
92 {
93 get
94 {
95 throw new NotImplementedException();
96 }
97 }
98
99 public void Init()
100 {
101 this.typeModel = new DynamicTypeModel();
102 }
103
104 public bool CreateInput2()
105 {
106 throw new NotImplementedException();
107 }
108
109 public IVideoPlayer CreateVideoPlayer()
110 {
111 throw new NotImplementedException();
112 }
113
114 public void Done()
115 {
116 throw new NotImplementedException();
117 }
118
119 public IProtoTypeModel GetTypeModel()
120 {
121 return this.typeModel;
122 }
123
124 public IMyAnalytics InitAnalytics(string projectId, string version)
125 {
126 throw new NotImplementedException();
127 }
128
129 public IMyAnalytics InitAnalytics(string projectId, string version, bool idInited)
130 {
131 throw new NotImplementedException();
132 }
133
134 public void InitScripting(IVRageScripting scripting)
135 {
136 throw new NotImplementedException();
137 }
138
139 public void Update()
140 {
141 throw new NotImplementedException();
142 }
143
144 private IProtoTypeModel typeModel;
145 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/InnerModel/DynamicTypeModel.cs +66 -0
@@ -0,0 +1,66 @@
1 using ProtoBuf.Meta;
2 using System.Security.Cryptography;
3 using System.Text;
4 using VRage.Serialization;
5
6 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore.InnerModel;
7
8 public class DynamicTypeModel : IProtoTypeModel
9 {
10 private RuntimeTypeModel m_typeModel;
11
12 public TypeModel Model => m_typeModel;
13
14 public DynamicTypeModel()
15 {
16 CreateTypeModel();
17 }
18
19 private void CreateTypeModel()
20 {
21 m_typeModel = RuntimeTypeModel.Create(setDefault: true);
22 m_typeModel.AutoAddMissingTypes = true;
23 m_typeModel.UseImplicitZeroDefaults = false;
24 }
25
26 private static ushort Get16BitHash(string s)
27 {
28 using MD5 mD = MD5.Create();
29 return BitConverter.ToUInt16(mD.ComputeHash(Encoding.UTF8.GetBytes(s)), 0);
30 }
31
32 public void RegisterTypes(IEnumerable<Type> types)
33 {
34 HashSet<Type> registered = new HashSet<Type>();
35 foreach (Type type in types)
36 {
37 RegisterType(type);
38 }
39
40 void RegisterType(Type protoType)
41 {
42 if (!protoType.IsGenericType)
43 {
44 if (protoType.BaseType == typeof(object) || protoType.IsValueType)
45 {
46 m_typeModel.Add(protoType, applyDefaultBehaviour: true);
47 }
48 else
49 {
50 RegisterType(protoType.BaseType);
51 if (registered.Add(protoType))
52 {
53 int fieldNumber = Get16BitHash(protoType.Name) + 65535;
54 m_typeModel.Add(protoType, applyDefaultBehaviour: true);
55 m_typeModel[protoType.BaseType].AddSubType(fieldNumber, protoType);
56 }
57 }
58 }
59 }
60 }
61
62 public void FlushCaches()
63 {
64 CreateTypeModel();
65 }
66 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/InnerModel/VRageRenderImpl.cs +155 -0
@@ -0,0 +1,155 @@
1 using VRage;
2 using VRageRender;
3
4 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore.InnerModel;
5
6 internal class VRageRenderImpl : IVRageRender
7 {
8 public bool UseParallelRenderInit
9 {
10 get
11 {
12 throw new NotImplementedException();
13 }
14 }
15
16 public bool IsRenderOutputDebugSupported
17 {
18 get
19 {
20 throw new NotImplementedException();
21 }
22 }
23
24 public bool ForceClearGBuffer
25 {
26 get
27 {
28 throw new NotImplementedException();
29 }
30 }
31
32 public event Action OnResuming;
33
34 public event Action OnSuspending;
35
36 public void ApplyRenderSettings(MyRenderDeviceSettings? settings)
37 {
38 throw new NotImplementedException();
39 }
40
41 public object CreateRenderAnnotation(object deviceContext)
42 {
43 throw new NotImplementedException();
44 }
45
46 public void CreateRenderDevice(ref MyRenderDeviceSettings? settings, out object deviceInstance, out object swapChain)
47 {
48 throw new NotImplementedException();
49 }
50
51 public void DisposeRenderDevice()
52 {
53 throw new NotImplementedException();
54 }
55
56 public void FlushIndirectArgsFromComputeShader(object deviceContext)
57 {
58 throw new NotImplementedException();
59 }
60
61 public ulong GetMemoryBudgetForStreamedResources()
62 {
63 return 0UL;
64 }
65
66 public ulong GetMemoryBudgetForGeneratedTextures()
67 {
68 return 0UL;
69 }
70
71 public ulong GetMemoryBudgetForVoxelTextureArrays()
72 {
73 return 0UL;
74 }
75
76 public MyAdapterInfo[] GetRenderAdapterList()
77 {
78 throw new NotImplementedException();
79 }
80
81 public MyRenderPresetEnum GetRenderQualityHint()
82 {
83 throw new NotImplementedException();
84 }
85
86 public void ResumeRenderContext()
87 {
88 throw new NotImplementedException();
89 }
90
91 public void SetMemoryUsedForImprovedGFX(long bytes)
92 {
93 throw new NotImplementedException();
94 }
95
96 public void SuspendRenderContext()
97 {
98 throw new NotImplementedException();
99 }
100
101 public void RequestSuspendWait()
102 {
103 throw new NotImplementedException();
104 }
105
106 public void CustomUpdateForDeferredBuffer(object deviceContext, object buffer)
107 {
108 throw new NotImplementedException();
109 }
110
111 public void SubmitEmptyCustomContext(object deviceContext)
112 {
113 throw new NotImplementedException();
114 }
115
116 public void FastVSSetConstantBuffer(object deviceContext, int slot, object buffer)
117 {
118 throw new NotImplementedException();
119 }
120
121 public void FastGSSetConstantBuffer(object deviceContext, int slot, object buffer)
122 {
123 throw new NotImplementedException();
124 }
125
126 public void FastPSSetConstantBuffer(object deviceContext, int slot, object buffer)
127 {
128 throw new NotImplementedException();
129 }
130
131 public void FastCSSetConstantBuffer(object deviceContext, int slot, object buffer)
132 {
133 throw new NotImplementedException();
134 }
135
136 public void FastVSSetConstantBuffers1(object deviceContext, int slot, object buffer, int offset, int size, ref object constantBindingsCache)
137 {
138 throw new NotImplementedException();
139 }
140
141 public void FastPSSetConstantBuffers1(object deviceContext, int slot, object buffer, int offset, int size, ref object constantBindingsCache)
142 {
143 throw new NotImplementedException();
144 }
145
146 public void SetDepthTextureHint(VRageRender_DepthTextureHintType hint, object deviceContext = null, object texture = null)
147 {
148 throw new NotImplementedException();
149 }
150
151 public bool IsExclusiveTextureLoadRequired()
152 {
153 throw new NotImplementedException();
154 }
155 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/InnerModel/VRageSystemImpl.cs +381 -0
@@ -0,0 +1,381 @@
1 using ParallelTasks;
2 using System.Management;
3 using VRage;
4 using VRage.Library.Threading;
5 using VRage.Utils;
6
7 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore.InnerModel;
8
9 internal class VRageSystemImpl : IVRageSystem
10 {
11 public float CPUCounter
12 {
13 get
14 {
15 throw new NotImplementedException();
16 }
17 }
18
19 public float RAMCounter
20 {
21 get
22 {
23 throw new NotImplementedException();
24 }
25 }
26
27 public float GCMemory
28 {
29 get
30 {
31 throw new NotImplementedException();
32 }
33 }
34
35 public long RemainingMemoryForGame
36 {
37 get
38 {
39 throw new NotImplementedException();
40 }
41 }
42
43 public long ProcessPrivateMemory
44 {
45 get
46 {
47 throw new NotImplementedException();
48 }
49 }
50
51 public bool IsUsingGeforceNow
52 {
53 get
54 {
55 return false;
56 }
57 }
58
59 public bool IsScriptCompilationSupported
60 {
61 get
62 {
63 throw new NotImplementedException();
64 }
65 }
66
67 public string Clipboard
68 {
69 get
70 {
71 throw new NotImplementedException();
72 }
73 set
74 {
75 throw new NotImplementedException();
76 }
77 }
78
79 public bool IsAllocationProfilingReady
80 {
81 get
82 {
83 throw new NotImplementedException();
84 }
85 }
86
87 public bool IsSingleInstance
88 {
89 get
90 {
91 throw new NotImplementedException();
92 }
93 }
94
95 public bool IsRemoteDebuggingSupported
96 {
97 get
98 {
99 throw new NotImplementedException();
100 }
101 }
102
103 public SimulationQuality SimulationQuality
104 {
105 get
106 {
107 throw new NotImplementedException();
108 }
109 }
110
111 public bool IsDeprecatedOS
112 {
113 get
114 {
115 throw new NotImplementedException();
116 }
117 }
118
119 public bool IsMemoryLimited
120 {
121 get
122 {
123 throw new NotImplementedException();
124 }
125 }
126
127 public bool HasSwappedMouseButtons
128 {
129 get
130 {
131 throw new NotImplementedException();
132 }
133 }
134
135 public string ThreeLetterISORegionName
136 {
137 get
138 {
139 throw new NotImplementedException();
140 }
141 }
142
143 public string TwoLetterISORegionName
144 {
145 get
146 {
147 throw new NotImplementedException();
148 }
149 }
150
151 public string RegionLatitude
152 {
153 get
154 {
155 throw new NotImplementedException();
156 }
157 }
158
159 public string RegionLongitude
160 {
161 get
162 {
163 throw new NotImplementedException();
164 }
165 }
166
167 public string TempPath
168 {
169 get
170 {
171 throw new NotImplementedException();
172 }
173 }
174
175 public int? OptimalHavokThreadCount
176 {
177 get
178 {
179 throw new NotImplementedException();
180 }
181 }
182
183 public PrioritizedScheduler.ExplicitWorkerSetup? ExplicitWorkerSetup
184 {
185 get
186 {
187 return null;
188 }
189 }
190
191 public bool AreEnterBackButtonsSwapped
192 {
193 get
194 {
195 return false;
196 }
197 }
198
199 public float? ForcedUiRatio
200 {
201 get
202 {
203 throw new NotImplementedException();
204 }
205 }
206
207 public event Action<string> OnSystemProtocolActivated;
208
209 public event Action OnResuming;
210
211 public event Action LeaveSession;
212
213 public event Action OnSuspending;
214
215 public string GetRootPath()
216 {
217 throw new NotImplementedException();
218 }
219
220 public string GetAppDataPath()
221 {
222 throw new NotImplementedException();
223 }
224
225 public ulong GetGlobalAllocationsStamp()
226 {
227 throw new NotImplementedException();
228 }
229
230 public string GetInfoCPU(out uint frequency, out uint physicalCores)
231 {
232 if (this.m_cpuInfo.Item1 == null)
233 {
234 try
235 {
236 using (ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("select Name, MaxClockSpeed, NumberOfCores from Win32_Processor"))
237 {
238 foreach (ManagementBaseObject managementBaseObject in managementObjectSearcher.Get())
239 {
240 ManagementObject managementObject = (ManagementObject)managementBaseObject;
241 this.m_cpuInfo.Item1 = managementObject["Name"].ToString();
242 this.m_cpuInfo.Item3 = (uint)managementObject["NumberOfCores"];
243 this.m_cpuInfo.Item2 = (uint)managementObject["MaxClockSpeed"];
244 }
245 }
246 }
247 catch (Exception)
248 {
249 this.m_cpuInfo.Item1 = "UnknownCPU";
250 this.m_cpuInfo.Item3 = 0U;
251 this.m_cpuInfo.Item2 = 0U;
252 }
253 }
254 frequency = this.m_cpuInfo.Item2;
255 physicalCores = this.m_cpuInfo.Item3;
256 return this.m_cpuInfo.Item1;
257 }
258
259 public string GetOsName()
260 {
261 throw new NotImplementedException();
262 }
263
264 public List<string> GetProcessesLockingFile(string path)
265 {
266 throw new NotImplementedException();
267 }
268
269 public ulong GetThreadAllocationStamp()
270 {
271 throw new NotImplementedException();
272 }
273
274 public ulong GetTotalPhysicalMemory()
275 {
276 throw new NotImplementedException();
277 }
278
279 public void LogEnvironmentInformation()
280 {
281 throw new NotImplementedException();
282 }
283
284 public void LogToExternalDebugger(string message)
285 {
286 throw new NotImplementedException();
287 }
288
289 public bool OpenUrl(string url)
290 {
291 throw new NotImplementedException();
292 }
293
294 public void ResetColdStartRegister()
295 {
296 throw new NotImplementedException();
297 }
298
299 public void WriteLineToConsole(string msg)
300 {
301 Console.WriteLine(msg);
302 }
303
304 public void GetGCMemory(out float allocated, out float used)
305 {
306 throw new NotImplementedException();
307 }
308
309 public void OnThreadpoolInitialized()
310 {
311 throw new NotImplementedException();
312 }
313
314 public void LogRuntimeInfo(Action<string> log)
315 {
316 throw new NotImplementedException();
317 }
318
319 public void OnSessionStarted(SessionType sessionType)
320 {
321 throw new NotImplementedException();
322 }
323
324 public void OnSessionUnloaded()
325 {
326 throw new NotImplementedException();
327 }
328
329 public int? GetExperimentalPCULimit(int safePCULimit)
330 {
331 throw new NotImplementedException();
332 }
333
334 public void DebuggerBreak()
335 {
336 throw new NotImplementedException();
337 }
338
339 public void CollectGC(int generation, GCCollectionMode mode)
340 {
341 generation = Math.Min(generation, GC.MaxGeneration);
342 GC.Collect(generation, mode);
343 }
344
345 public void CollectGC(int generation, GCCollectionMode mode, bool blocking, bool compacting)
346 {
347 generation = Math.Min(generation, GC.MaxGeneration);
348 GC.Collect(generation, mode, blocking, compacting);
349 }
350
351 public bool OpenUrl(string url, bool predetermined = true)
352 {
353 throw new NotImplementedException();
354 }
355
356 public ISharedCriticalSection CreateSharedCriticalSection(bool spinLock)
357 {
358 if (spinLock)
359 {
360 return new MyCriticalSection_SpinLock();
361 }
362 return new MyCriticalSection_Mutex();
363 }
364
365 public DateTime GetNetworkTimeUTC()
366 {
367 throw new NotImplementedException();
368 }
369
370 public string GetPlatformSpecificCrashReport()
371 {
372 return null;
373 }
374
375 public string GetModsCachePath()
376 {
377 return null;
378 }
379
380 private ValueTuple<string, uint, uint> m_cpuInfo;
381 }
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/SpaceEngineerDefinitions.cs +13 -0
@@ -0,0 +1,13 @@
1 using VRage.ObjectBuilders;
2 using VRage.ObjectBuilders.Private;
3
4 namespace SpaceEngineersBlueprintEditor.SpaceEngineersCore;
5
6 public class SpaceEngineerDefinitions
7 {
8 public static T Load<T>(string path) where T : MyObjectBuilder_Base
9 {
10 MyObjectBuilderSerializerKeen.DeserializeXML(path, out T objectBuilder);
11 return objectBuilder;
12 }
13 }
Modified SpaceEngineersBlueprintEditor.SpaceEngineersCore/SpaceEngineersBlueprintEditor.SpaceEngineersCore.csproj +111 -0
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/VRage.Native.dll +0 -0
二进制文件已变更,无法进行逐行预览。
Added SpaceEngineersBlueprintEditor.SpaceEngineersCore/steam_api64.dll +0 -0
二进制文件已变更,无法进行逐行预览。
Modified SpaceEngineersBlueprintEditor.Test/Program.cs +14 -2
@@ -1,2 +1,14 @@
1 // See https://aka.ms/new-console-template for more information
2 Console.WriteLine("Hello, World!");
1 using Sandbox.Definitions;
2 using SpaceEngineersBlueprintEditor.SpaceEngineersCore;
3
4 namespace SpaceEngineersBlueprintEditor.Test;
5
6 internal class Program
7 {
8 [SMTest]
9 public static void TestMethod()
10 {
11 Initializer.Initialize();
12 var result = MyDefinitionManager.Static.GetAllDefinitions();
13 }
14 }
Modified SpaceEngineersBlueprintEditor.Test/SpaceEngineersBlueprintEditor.Test.csproj +111 -0
Modified SpaceEngineersBlueprintEditor.sln +7 -0
@@ -4,10 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
4 4 VisualStudioVersion = 17.12.35323.107
5 5 MinimumVisualStudioVersion = 10.0.40219.1
6 6 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpaceEngineersBlueprintEditor", "SpaceEngineersBlueprintEditor\SpaceEngineersBlueprintEditor.csproj", "{049E595C-0B3F-4586-A897-F480C611A95E}"
7 ProjectSection(ProjectDependencies) = postProject
8 {23F2F2BB-4AE7-4DEE-AF7D-CFF1470D5F3E} = {23F2F2BB-4AE7-4DEE-AF7D-CFF1470D5F3E}
9 EndProjectSection
7 10 EndProject
8 11 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpaceEngineersBlueprintEditor.SpaceEngineersCore", "SpaceEngineersBlueprintEditor.SpaceEngineersCore\SpaceEngineersBlueprintEditor.SpaceEngineersCore.csproj", "{23F2F2BB-4AE7-4DEE-AF7D-CFF1470D5F3E}"
9 12 EndProject
10 13 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpaceEngineersBlueprintEditor.Test", "SpaceEngineersBlueprintEditor.Test\SpaceEngineersBlueprintEditor.Test.csproj", "{74296AA0-AEBE-4139-9B23-4ACAF07F7101}"
14 ProjectSection(ProjectDependencies) = postProject
15 {049E595C-0B3F-4586-A897-F480C611A95E} = {049E595C-0B3F-4586-A897-F480C611A95E}
16 {23F2F2BB-4AE7-4DEE-AF7D-CFF1470D5F3E} = {23F2F2BB-4AE7-4DEE-AF7D-CFF1470D5F3E}
17 EndProjectSection
11 18 EndProject
12 19 Global
13 20 GlobalSection(SolutionConfigurationPlatforms) = preSolution
Modified SpaceEngineersBlueprintEditor/App.xaml.cs +13 -0
@@ -1,4 +1,5 @@
1 1 using SpaceEngineersBlueprintEditor.Interface.Services;
2 using SpaceEngineersBlueprintEditor.SpaceEngineersCore;
2 3 using SpaceEngineersBlueprintEditor.Utilities;
3 4 using SpaceEngineersBlueprintEditor.Views;
4 5
@@ -20,6 +21,18 @@ public partial class App : Application
20 21 PageManager.RegisterPage(typeof(BlueprintDetailPage));
21 22 PageManager.RegisterPage(typeof(SettingPage));
22 23 Task.Run(BlueprintsManager.LoadBlueprintsAsync);
24 Task.Run(() =>
25 {
26 try
27 {
28 Initializer.Initialize();
29 GlobalServiceManager.GetService<IMessageService>()?.ShowMessage("游戏集定义加载完成", "完成", InfoBarSeverity.Success);
30 }
31 catch (Exception ex)
32 {
33 GlobalServiceManager.GetService<IMessageService>()?.ShowMessage($"加载定义时发生错误:{ex.Message}", "未能加载定义", InfoBarSeverity.Error);
34 }
35 });
23 36 UnhandledException += App_UnhandledException;
24 37 }
25 38
Modified SpaceEngineersBlueprintEditor/SpaceEngineersBlueprintEditor.csproj +98 -20