From 9b1e2548d1c2ba3f82d2356d25921efadb588118 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 14 Jun 2020 21:40:47 +0200 Subject: [PATCH 01/98] Attempts to create custom block types It can load certain assets (a Cube from a sample) but fails because of missing shaders My own Cube doesn't even get that far --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 159 ++++++++++++++++++ .../Tests/GamecraftModdingAPIPluginTest.cs | 19 +++ 2 files changed, 178 insertions(+) create mode 100644 GamecraftModdingAPI/Blocks/CustomBlock.cs diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs new file mode 100644 index 0000000..9801e40 --- /dev/null +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using System.Text.Formatting; +using DataLoader; +using GamecraftModdingAPI.Utility; +using GPUInstancer; +using HarmonyLib; +using RobocraftX.Common; +using RobocraftX.Schedulers; +using Svelto.Tasks; +using Svelto.Tasks.ExtraLean; +using UnityEngine; +using UnityEngine.AddressableAssets; + +namespace GamecraftModdingAPI.Blocks +{ + public class CustomBlock + { + private static ushort nextID = 500; + public static void RegisterCustomBlock(string path) + { + var prefabData = new List(); + //category ID: + //0 - regular + //1 - joint + //2 - controller + uint prefabId = PrefabsID.FetchNewPrefabID(PrefabsID.GenerateDBID(0, nextID++)); + prefabData.Add(new PrefabData() + { + prefabName = path, + prefabId = prefabId + }); + var loadTask = Addressables.LoadAssetAsync(path); + AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab") + .Invoke(ECSGPUIResourceManager.Instance, new object[] {prefabId, loadTask.Result, 1}); + } + + [HarmonyPatch] + public static class Patch + { + /*public static IEnumerable Transpiler(IEnumerable instructions) + { + var list = new List(instructions); + try + { + *int index = -1; + CodeInstruction loadTask = null; + for (var i = 0; i < list.Count - 1; i++) + { + if (list[i].opcode == OpCodes.Ldfld + && ((string) list[i].operand).Contains("renderingWorld") + && list[i + 1].opcode == OpCodes.Brfalse_S) + index = i - 1; //It loads 'this' first + if (list[i].opcode == OpCodes.Ldflda + && ((string) list[i].operand).Contains("loadTask")) + loadTask = new CodeInstruction(list[i]); + }* + + var array = new[] + { + //Set Yield.It to be returned (current) + new CodeInstruction(OpCodes.Ldarg_0), // this + new CodeInstruction(OpCodes.Ldsfld, + typeof(Yield).GetField("It", BindingFlags.Public | BindingFlags.Static)), + new CodeInstruction(OpCodes.Stfld, "object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current'"), + + //Set which yield return we're at (state) + new CodeInstruction(OpCodes.Ldarg_0), // this + new CodeInstruction(OpCodes.Ldc_I4_1), + //new CodeInstruction(OpCodes.Call, ((Action)AddInfo).Method) + }; + list.InsertRange(index, array); + * + IL_00ad: ldarg.0 // this + IL_00ae: ldsfld class [Svelto.Tasks]Svelto.Tasks.Yield [Svelto.Tasks]Svelto.Tasks.Yield::It + IL_00b3: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current' + + IL_0072: ldarg.0 // this + IL_0073: ldnull + IL_0074: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current' + IL_0079: ldarg.0 // this + IL_007a: ldc.i4.2 + IL_007b: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>1__state' + IL_0080: ldc.i4.1 + IL_0081: ret + * + yield break; + } + catch (Exception e) + { + Logging.LogWarning("Failed to inject AddInfo method for the debug display!\n" + e); + } + }*/ + + public static void Prefix(ref Dictionary blocks) + { + /*foreach (var block in blocks.Values.Cast()) + { + Console.WriteLine("Block info: " + block); + }*/ + + /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); + while (!res.IsDone) yield return Yield.It;*/ + + blocks.Add("modded_ConsoleBlock", new CubeListData + { + cubeType = CubeType.Block, + cubeCategory = CubeCategory.ConsoleBlock, + inventoryCategory = InventoryCategory.Logic, + ID = 500, + Path = "Assets/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) + SpriteName = "CTR_CommandBlock", + CubeNameKey = "strConsoleBlock", + SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, + GridScale = new[] {1, 1, 1}, + Mass = 1, + JointBreakAngle = 1 + }); + } + + public static MethodBase TargetMethod() + { //General block registration + return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + } + } + + [HarmonyPatch] + public static class GOPatch + { + public static void Prefix(uint prefabID, GameObject gameObject) + { + Console.WriteLine("ID: " + prefabID + " - Name: " + gameObject.name); + if (gameObject.name == "Cube") + ECSGPUIResourceManager.Instance.RegisterRuntimePrefabs( + new[] {new PrefabData {prefabId = 500, prefabName = "Assets/Cube.prefab"}}, + new List {gameObject}, 1).Complete(); + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", + new[] {typeof(uint), typeof(GameObject), typeof(uint)}); + } + } + + public static IEnumerator Prep() + { + Console.WriteLine("Loading custom catalog..."); + var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); + while (!res.IsDone) yield return Yield.It; + Console.WriteLine("Loaded custom catalog: " + res.Result.LocatorId); + Addressables.AddResourceLocator(res.Result); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index dc07e1e..c4077d0 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -13,6 +13,9 @@ using RobocraftX.Common; using RobocraftX.SimulationModeState; using RobocraftX.FrontEnd; using Unity.Mathematics; +using RobocraftX.Schedulers; +using Svelto.Tasks.ExtraLean; +using uREPL; using GamecraftModdingAPI.Commands; using GamecraftModdingAPI.Events; @@ -283,6 +286,22 @@ namespace GamecraftModdingAPI.Tests { Logging.Log("Compatible GamecraftScripting detected"); } + + CommandBuilder.Builder("enableCompletions") + .Action(() => + { + var p = Window.selected.main.parameters; + p.useCommandCompletion = true; + p.useMonoCompletion = true; + p.useGlobalClassCompletion = true; + Log.Output("Submitted: " + Window.selected.submittedCode); + }) + .Build(); + /*JObject o1 = JObject.Parse(File.ReadAllText(@"Gamecraft_Data\StreamingAssets\aa\Windows\catalog.json")); + JObject o2 = JObject.Parse(File.ReadAllText(@"customCatalog.json")); + o1.Merge(o2, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Union}); + File.WriteAllText(@"Gamecraft_Data\StreamingAssets\aa\Windows\catalog.json", o1.ToString());*/ + CustomBlock.Prep().RunOn(ExtraLean.UIScheduler); } private string modsString; From c06ed340a255030be8480a7033c347a0c3f491bd Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 17 Sep 2020 23:08:26 +0200 Subject: [PATCH 02/98] Using the console block's material Progressed a lot --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 46 +++++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 9801e40..bc67fe9 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -13,6 +13,7 @@ using RobocraftX.Common; using RobocraftX.Schedulers; using Svelto.Tasks; using Svelto.Tasks.ExtraLean; +using Unity.Entities; using UnityEngine; using UnityEngine.AddressableAssets; @@ -112,7 +113,7 @@ namespace GamecraftModdingAPI.Blocks cubeCategory = CubeCategory.ConsoleBlock, inventoryCategory = InventoryCategory.Logic, ID = 500, - Path = "Assets/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) + Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) SpriteName = "CTR_CommandBlock", CubeNameKey = "strConsoleBlock", SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, @@ -131,19 +132,51 @@ namespace GamecraftModdingAPI.Blocks [HarmonyPatch] public static class GOPatch { + private static Material[] materials; public static void Prefix(uint prefabID, GameObject gameObject) { Console.WriteLine("ID: " + prefabID + " - Name: " + gameObject.name); if (gameObject.name == "Cube") + { + //Console.WriteLine("Length: " + gameObject.GetComponentsInChildren().Length); + if (materials != null) + gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; ECSGPUIResourceManager.Instance.RegisterRuntimePrefabs( - new[] {new PrefabData {prefabId = 500, prefabName = "Assets/Cube.prefab"}}, - new List {gameObject}, 1).Complete(); + new[] {new PrefabData {prefabId = 500, prefabName = "Assets/Prefabs/Cube.prefab"}}, + new List {gameObject}).Complete(); + GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(ECSGPUIResourceManager.Instance.prefabManager, + gameObject.GetComponent().prefabPrototype, new[] {gameObject}); + Console.WriteLine("Registered prefab to instancer"); + + var register = AccessTools.Method("RobocraftX.Common.ECSPhysicResourceManager:RegisterPrefab", + new[] {typeof(uint), typeof(GameObject), typeof(World), typeof(BlobAssetStore)}); + register.Invoke(ECSPhysicResourceManager.Instance, + new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2}); + Console.WriteLine("Registered prefab to physics"); + } + else if (gameObject.name == "CTR_CommandBlock") + materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; } public static MethodBase TargetMethod() { return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", - new[] {typeof(uint), typeof(GameObject), typeof(uint)}); + new[] {typeof(uint), typeof(GameObject)}); + } + } + + [HarmonyPatch] + public static class MGPatch + { + internal static (World, BlobAssetStore) data; + public static void Prefix(World physicsWorld, BlobAssetStore blobStore) + { + data = (physicsWorld, blobStore); + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method("RobocraftX.CR.MainGame.MainGameCompositionRoot:Init"); } } @@ -154,6 +187,11 @@ namespace GamecraftModdingAPI.Blocks while (!res.IsDone) yield return Yield.It; Console.WriteLine("Loaded custom catalog: " + res.Result.LocatorId); Addressables.AddResourceLocator(res.Result); + /*Console.WriteLine("Loading Cube asset..."); + var loadTask = Addressables.LoadAssetAsync("Assets/Cube.prefab"); + while (!loadTask.IsDone) yield return Yield.It; + Console.WriteLine("Exception: "+loadTask.OperationException); + Console.WriteLine("Result: " + loadTask.Result.name);*/ } } } \ No newline at end of file From b0b496f22f40d0ff4a841cb77de2062c4072b58c Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 22 Oct 2020 02:34:59 +0200 Subject: [PATCH 03/98] Fix ConcurrentModificationException and some attempts --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 170 ++++++++++++------ .../GamecraftModdingAPI.csproj | 4 + 2 files changed, 122 insertions(+), 52 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index bc67fe9..b960101 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -9,13 +9,21 @@ using DataLoader; using GamecraftModdingAPI.Utility; using GPUInstancer; using HarmonyLib; +using RobocraftX.Blocks.Ghost; using RobocraftX.Common; using RobocraftX.Schedulers; +using Svelto.DataStructures; +using Svelto.ECS.Extensions.Unity; using Svelto.Tasks; using Svelto.Tasks.ExtraLean; using Unity.Entities; +using Unity.Entities.Conversion; +using Unity.Physics; using UnityEngine; using UnityEngine.AddressableAssets; +using BoxCollider = UnityEngine.BoxCollider; +using Collider = UnityEngine.Collider; +using Material = UnityEngine.Material; namespace GamecraftModdingAPI.Blocks { @@ -106,7 +114,116 @@ namespace GamecraftModdingAPI.Blocks /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It;*/ + } + public static MethodBase TargetMethod() + { //General block registration + return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + } + } + + [HarmonyPatch] + public static class RendererPatch + { + private static Material[] materials; + public static void Prefix(uint prefabID, GameObject gameObject) + { + Console.WriteLine("ID: " + prefabID + " - Name: " + gameObject.name); + if (gameObject.name == "Cube") + { + //Console.WriteLine("Length: " + gameObject.GetComponentsInChildren().Length); + if (materials != null) + gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; + ECSGPUIResourceManager.Instance.RegisterRuntimePrefabs( + new[] {new PrefabData {prefabId = prefabID, prefabName = "Assets/Prefabs/Cube.prefab"}}, + new List {gameObject}).Complete(); + GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(ECSGPUIResourceManager.Instance.prefabManager, + gameObject.GetComponent().prefabPrototype, new[] {gameObject}); + Console.WriteLine("Registered prefab to instancer"); + + /*var register = AccessTools.Method("RobocraftX.Common.ECSPhysicResourceManager:RegisterPrefab", + new[] {typeof(uint), typeof(GameObject), typeof(World), typeof(BlobAssetStore)}); + register.Invoke(ECSPhysicResourceManager.Instance, + new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2});*/ + /*Console.WriteLine( + "Entity: " + ECSPhysicResourceManager.Instance.GetUECSPhysicEntityPrefab(prefabID)); + Console.WriteLine("Prefab ID: " + PrefabsID.DBIDMAP[500]); + PhysicsCollider componentData = MGPatch.data.Item1.EntityManager.GetComponentData(ECSPhysicResourceManager.Instance.GetUECSPhysicEntityPrefab(prefabID)); + Console.WriteLine("Collider valid: " + componentData.IsValid); + unsafe + { + Console.WriteLine("Collider type: " + componentData.ColliderPtr->Type); + CollisionFilter filter = componentData.Value.Value.Filter; + Console.WriteLine("Filter not empty: " + !filter.IsEmpty); + }*/ + //MGPatch.data.Item1.EntityManager.GetComponentData<>() + gameObject.AddComponent(); + gameObject.AddComponent(); + Console.WriteLine("Registered prefab to physics"); + } + else if (gameObject.name == "CTR_CommandBlock") + materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", + new[] {typeof(uint), typeof(GameObject)}); + } + } + + [HarmonyPatch] + public static class RMPatch + { + public static void Prefix(World physicsWorld, + GameObjectConversionSystem getExistingSystem, + FasterList gos, + List prefabData) + { + for (var index = 0; index < prefabData.Count; index++) + { + var data = prefabData[index]; + if (!data.prefabName.EndsWith("Cube.prefab")) continue; + //getExistingSystem.DeclareLinkedEntityGroup(gos[index]); + /*Entity entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(gos[index], + GameObjectConversionSettings.FromWorld(physicsWorld, MGPatch.data.Item2));*/ + Console.WriteLine("Transform: " + gos[index].transform.childCount); + Entity primaryEntity = getExistingSystem.GetPrimaryEntity(gos[index]); + MultiListEnumerator entities = getExistingSystem.GetEntities(gos[index]); + Console.WriteLine("ID: " + data.prefabId + " - Name: " + data.prefabName); + Console.WriteLine("Primary entity: " + primaryEntity); + EntityManager entityManager = physicsWorld.EntityManager; + Console.WriteLine("Has collider: " + entityManager.HasComponent(primaryEntity)); + while (entities.MoveNext()) + { + Entity current = entities.Current; + Console.WriteLine("Entity " + current + " has collider: " + + entityManager.HasComponent(current)); + } + } + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method("RobocraftX.Common.ECSResourceManagerUtility:RelinkEntities", + new[] + { + typeof(World), + typeof(GameObjectConversionSystem), + typeof(FasterList), + typeof(List) + }); + } + } + + [HarmonyPatch] + public static class MGPatch + { + internal static (World, BlobAssetStore) data; + public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB) + { + data = (physicsWorld, blobStore); + var blocks = dataDB.GetValues(); blocks.Add("modded_ConsoleBlock", new CubeListData { cubeType = CubeType.Block, @@ -123,57 +240,6 @@ namespace GamecraftModdingAPI.Blocks }); } - public static MethodBase TargetMethod() - { //General block registration - return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); - } - } - - [HarmonyPatch] - public static class GOPatch - { - private static Material[] materials; - public static void Prefix(uint prefabID, GameObject gameObject) - { - Console.WriteLine("ID: " + prefabID + " - Name: " + gameObject.name); - if (gameObject.name == "Cube") - { - //Console.WriteLine("Length: " + gameObject.GetComponentsInChildren().Length); - if (materials != null) - gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; - ECSGPUIResourceManager.Instance.RegisterRuntimePrefabs( - new[] {new PrefabData {prefabId = 500, prefabName = "Assets/Prefabs/Cube.prefab"}}, - new List {gameObject}).Complete(); - GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(ECSGPUIResourceManager.Instance.prefabManager, - gameObject.GetComponent().prefabPrototype, new[] {gameObject}); - Console.WriteLine("Registered prefab to instancer"); - - var register = AccessTools.Method("RobocraftX.Common.ECSPhysicResourceManager:RegisterPrefab", - new[] {typeof(uint), typeof(GameObject), typeof(World), typeof(BlobAssetStore)}); - register.Invoke(ECSPhysicResourceManager.Instance, - new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2}); - Console.WriteLine("Registered prefab to physics"); - } - else if (gameObject.name == "CTR_CommandBlock") - materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; - } - - public static MethodBase TargetMethod() - { - return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", - new[] {typeof(uint), typeof(GameObject)}); - } - } - - [HarmonyPatch] - public static class MGPatch - { - internal static (World, BlobAssetStore) data; - public static void Prefix(World physicsWorld, BlobAssetStore blobStore) - { - data = (physicsWorld, blobStore); - } - public static MethodBase TargetMethod() { return AccessTools.Method("RobocraftX.CR.MainGame.MainGameCompositionRoot:Init"); @@ -181,7 +247,7 @@ namespace GamecraftModdingAPI.Blocks } public static IEnumerator Prep() - { + { //TODO: Don't let the game load until this finishes Console.WriteLine("Loading custom catalog..."); var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It; diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 8be57a7..ee28a68 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -113,6 +113,10 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll From 987fbe673aca7f3a94c58c39626bd9839f1193ae Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 29 Oct 2020 00:37:47 +0100 Subject: [PATCH 04/98] Fix initial issues and add error on patch fail Fixed compilation and loading issues for 2020.10.27.17.13 --- Automation/gen_csproj.py | 0 GamecraftModdingAPI/Blocks/BlockEngine.cs | 2 +- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 4 +-- GamecraftModdingAPI/Blocks/RemovalEngine.cs | 5 ++- GamecraftModdingAPI/Input/FakeInput.cs | 4 +-- .../HotbarSlotSelectionHandlerEnginePatch.cs | 4 +-- GamecraftModdingAPI/Main.cs | 31 ++++++++++++++----- .../Tests/GamecraftModdingAPIPluginTest.cs | 5 --- 8 files changed, 33 insertions(+), 22 deletions(-) mode change 100644 => 100755 Automation/gen_csproj.py diff --git a/Automation/gen_csproj.py b/Automation/gen_csproj.py old mode 100644 new mode 100755 diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 929a65f..e39a3e8 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Linq; +using Gamecraft.ColourPalette; using Gamecraft.Wires; using RobocraftX.Blocks; using RobocraftX.Common; -using RobocraftX.GUI.Hotbar.Colours; using RobocraftX.Physics; using RobocraftX.Scene.Simulation; using Svelto.DataStructures; diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index e111598..cb1cdee 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -70,9 +70,7 @@ namespace GamecraftModdingAPI.Blocks DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid}; BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct { - blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale, - snapGridScale = uscale, - unitSnapOffset = 0, isUsingUnitSize = true + blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale }; EquippedColourStruct colour = new EquippedColourStruct {indexInPalette = color}; diff --git a/GamecraftModdingAPI/Blocks/RemovalEngine.cs b/GamecraftModdingAPI/Blocks/RemovalEngine.cs index 629fd7e..c27c339 100644 --- a/GamecraftModdingAPI/Blocks/RemovalEngine.cs +++ b/GamecraftModdingAPI/Blocks/RemovalEngine.cs @@ -20,8 +20,11 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(target)) return false; var connections = entitiesDB.QueryEntity(target); + var groups = entitiesDB.FindGroups(); + var connStructMapper = + entitiesDB.QueryNativeMappedEntities(groups); for (int i = connections.connections.Count() - 1; i >= 0; i--) - _connectionFactory.RemoveConnection(connections, i, entitiesDB); + _connectionFactory.RemoveConnection(connections, i, connStructMapper); _entityFunctions.RemoveEntity(target); return true; } diff --git a/GamecraftModdingAPI/Input/FakeInput.cs b/GamecraftModdingAPI/Input/FakeInput.cs index df6c3ce..8cab6f5 100644 --- a/GamecraftModdingAPI/Input/FakeInput.cs +++ b/GamecraftModdingAPI/Input/FakeInput.cs @@ -76,7 +76,7 @@ namespace GamecraftModdingAPI.Input case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_9; break; default: break; } - if (commandLine) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleCommandLine; + //if (commandLine) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleCommandLine; - TODO if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape; if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return; if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay; @@ -125,7 +125,7 @@ namespace GamecraftModdingAPI.Input if (tertiary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.TertiaryAction; if (primaryHeld) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.PrimaryActionHeld; if (secondaryHeld) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SecondaryActionHeld; - if (toggleUnitGrid) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleUnitGrid; + //if (toggleUnitGrid) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleUnitGrid; if (ctrl) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.CtrlAction; if (toggleColourMode) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleColourMode; if (scaleBlockUp) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ScaleBlockUp; diff --git a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs index dd8a375..9a81f99 100644 --- a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs +++ b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs @@ -1,8 +1,6 @@ using System; using System.Reflection; -using RobocraftX.GUI; -using RobocraftX.GUI.Hotbar; using Svelto.ECS; using HarmonyLib; @@ -17,7 +15,7 @@ namespace GamecraftModdingAPI.Inventory public static BlockIDs EquippedPartID { get => (BlockIDs)selectedBlockInt; } - private static MethodInfo PatchedMethod { get; } = AccessTools.Method(AccessTools.TypeByName("RobocraftX.GUI.Hotbar.HotbarSlotSelectionHandlerEngine"), "ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int), typeof(ExclusiveGroupStruct) }); + private static MethodInfo PatchedMethod { get; } = AccessTools.Method("Gamecraft.GUI.Hotbar.Blocks.SyncHotbarSlotSelectedToEquipedPartEngine:ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int), typeof(ExclusiveGroupStruct) }); public static void Prefix(uint playerID, int selectedDBPartID, ExclusiveGroupStruct groupID) { diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 4a8cf24..98fb6f6 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -1,17 +1,15 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Reflection; using GamecraftModdingAPI.Blocks; using HarmonyLib; +using RobocraftX; +using RobocraftX.Services; +using Svelto.Context; + using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Events; -using GamecraftModdingAPI.Players; using GamecraftModdingAPI.Tasks; -using uREPL; namespace GamecraftModdingAPI { @@ -46,7 +44,20 @@ namespace GamecraftModdingAPI Logging.MetaDebugLog($"Patching Gamecraft"); var currentAssembly = Assembly.GetExecutingAssembly(); harmony = new Harmony(currentAssembly.GetName().Name); - harmony.PatchAll(currentAssembly); + try + { + harmony.PatchAll(currentAssembly); + } + catch (Exception e) + { //Can't use ErrorBuilder or Logging.LogException (which eventually uses ErrorBuilder) yet + Logging.Log(e.ToString()); + Logging.LogWarning("Failed to patch Gamecraft. Attempting to patch to display error..."); + harmony.Patch(AccessTools.Method(typeof(FullGameCompositionRoot), "OnContextInitialized") + .MakeGenericMethod(typeof(UnityContext)), + new HarmonyMethod(((Action) OnPatchError).Method)); //Can't use lambdas here :( + return; + } + // init utility Logging.MetaDebugLog($"Initializing Utility"); #pragma warning disable 0612,0618 @@ -102,5 +113,11 @@ namespace GamecraftModdingAPI Logging.MetaLog($"{currentAssembly.GetName().Name} v{currentAssembly.GetName().Version} shutdown"); } } + + private static void OnPatchError() + { + ErrorBuilder.DisplayMustQuitError("Failed to patch Gamecraft!\n" + + "Make sure you're using the latest version of GamecraftModdingAPI or disable mods if the API isn't released yet."); + } } } diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 4a5547f..f0334aa 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -173,11 +173,6 @@ namespace GamecraftModdingAPI.Tests Logging.CommandLog("Finished in " + sw.ElapsedMilliseconds + "ms"); }) .Build(); - //With Sync(): 1135ms - //Without Sync(): 134ms - //Async: 348 794ms, doesn't freeze game - //Without Sync() but wait for submission: 530ms - //With Sync() at the end: 380ms Block b = null; CommandBuilder.Builder("moveBlockInSim", "Run in build mode first while looking at a block, then in sim to move it up") From 08138e3589d5e7f69b75cdbd93a1786286655cba Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 9 Nov 2020 16:18:25 -0500 Subject: [PATCH 05/98] Fix build errors from beta hotfix 1 --- GamecraftModdingAPI/App/AppEngine.cs | 5 +- GamecraftModdingAPI/App/GameGameEngine.cs | 6 +-- GamecraftModdingAPI/App/GameMenuEngine.cs | 10 ++-- GamecraftModdingAPI/Block.cs | 42 ++++++++-------- GamecraftModdingAPI/Blocks/BlockEngine.cs | 49 ++++++++++++------- GamecraftModdingAPI/Blocks/BlockEngineInit.cs | 4 +- GamecraftModdingAPI/Blocks/ConsoleBlock.cs | 2 +- GamecraftModdingAPI/Blocks/DampedSpring.cs | 2 +- GamecraftModdingAPI/Blocks/LogicGate.cs | 2 +- GamecraftModdingAPI/Blocks/Motor.cs | 2 +- GamecraftModdingAPI/Blocks/MusicBlock.cs | 2 +- .../Blocks/ObjectIdentifier.cs | 2 +- GamecraftModdingAPI/Blocks/Piston.cs | 2 +- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 3 +- GamecraftModdingAPI/Blocks/Servo.cs | 2 +- GamecraftModdingAPI/Blocks/SfxBlock.cs | 2 +- GamecraftModdingAPI/Blocks/SignalEngine.cs | 44 +++++++++++------ GamecraftModdingAPI/Blocks/SpawnPoint.cs | 2 +- GamecraftModdingAPI/Blocks/TextBlock.cs | 2 +- GamecraftModdingAPI/Blocks/Timer.cs | 2 +- GamecraftModdingAPI/Inventory/HotbarEngine.cs | 8 +-- GamecraftModdingAPI/Players/PlayerEngine.cs | 8 +-- GamecraftModdingAPI/Tests/TestRoot.cs | 2 +- 23 files changed, 119 insertions(+), 86 deletions(-) diff --git a/GamecraftModdingAPI/App/AppEngine.cs b/GamecraftModdingAPI/App/AppEngine.cs index 4f20b7e..9cc454d 100644 --- a/GamecraftModdingAPI/App/AppEngine.cs +++ b/GamecraftModdingAPI/App/AppEngine.cs @@ -46,11 +46,12 @@ namespace GamecraftModdingAPI.App public Game[] GetMyGames() { EntityCollection mgsevs = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.MyGames); + var mgsevsB = mgsevs.ToBuffer().buffer; Game[] games = new Game[mgsevs.count]; for (int i = 0; i < mgsevs.count; i++) { - Utility.Logging.MetaDebugLog($"Found game named {mgsevs[i].GameName}"); - games[i] = new Game(mgsevs[i].ID); + Utility.Logging.MetaDebugLog($"Found game named {mgsevsB[i].GameName}"); + games[i] = new Game(mgsevsB[i].ID); } return games; } diff --git a/GamecraftModdingAPI/App/GameGameEngine.cs b/GamecraftModdingAPI/App/GameGameEngine.cs index a616df5..dea3821 100644 --- a/GamecraftModdingAPI/App/GameGameEngine.cs +++ b/GamecraftModdingAPI/App/GameGameEngine.cs @@ -52,7 +52,7 @@ namespace GamecraftModdingAPI.App { if (async) { - ExitCurrentGameAsync().RunOn(Lean.EveryFrameStepRunner_RUNS_IN_TIME_STOPPED_AND_RUNNING); + ExitCurrentGameAsync().RunOn(Lean.EveryFrameStepRunner_TimeRunningAndStopped); } else { @@ -102,14 +102,14 @@ namespace GamecraftModdingAPI.App if (filter == BlockIDs.Invalid) { foreach (var (blocks, _) in allBlocks) - foreach (var block in blocks) + foreach (var block in blocks.ToBuffer().buffer.ToManagedArray()) blockEGIDs.Add(block.ID); return blockEGIDs.ToArray(); } else { foreach (var (blocks, _) in allBlocks) - foreach (var block in blocks) + foreach (var block in blocks.ToBuffer().buffer.ToManagedArray()) if (block.DBID == (ulong) filter) blockEGIDs.Add(block.ID); return blockEGIDs.ToArray(); diff --git a/GamecraftModdingAPI/App/GameMenuEngine.cs b/GamecraftModdingAPI/App/GameMenuEngine.cs index 74bc42a..efcb73e 100644 --- a/GamecraftModdingAPI/App/GameMenuEngine.cs +++ b/GamecraftModdingAPI/App/GameMenuEngine.cs @@ -61,12 +61,13 @@ namespace GamecraftModdingAPI.App public uint HighestID() { EntityCollection games = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.MyGames); + var gamesB = games.ToBuffer().buffer; uint max = 0; for (int i = 0; i < games.count; i++) { - if (games[i].ID.entityID > max) + if (gamesB[i].ID.entityID > max) { - max = games[i].ID.entityID; + max = gamesB[i].ID.entityID; } } return max; @@ -118,11 +119,12 @@ namespace GamecraftModdingAPI.App { EntityCollection entities = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.GameSlotGuiEntities); + var entitiesB = entities.ToBuffer().buffer; for (int i = 0; i < entities.count; i++) { - if (entities[i].ID.entityID == id.entityID) + if (entitiesB[i].ID.entityID == id.entityID) { - return ref entities[i]; + return ref entitiesB[i]; } } MyGamesSlotEntityViewStruct[] defRef = new MyGamesSlotEntityViewStruct[1]; diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 408304d..81d6439 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -116,32 +116,32 @@ namespace GamecraftModdingAPI private static Dictionary typeToGroup = new Dictionary { - {typeof(ConsoleBlock), new[] {CommonExclusiveGroups.BUILD_CONSOLE_BLOCK_GROUP}}, - {typeof(LogicGate), new [] {CommonExclusiveGroups.BUILD_LOGIC_BLOCK_GROUP}}, - {typeof(Motor), new[] {CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP}}, - {typeof(MusicBlock), new[] {CommonExclusiveGroups.BUILD_MUSIC_BLOCK_GROUP}}, - {typeof(ObjectIdentifier), new[]{CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP}}, - {typeof(Piston), new[] {CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP}}, - {typeof(Servo), new[] {CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP}}, + {typeof(ConsoleBlock), new[] {CommonExclusiveGroups.CONSOLE_BLOCK_GROUP}}, + {typeof(LogicGate), new [] {CommonExclusiveGroups.LOGIC_BLOCK_GROUP}}, + {typeof(Motor), new[] {CommonExclusiveGroups.MOTOR_BLOCK_GROUP}}, + {typeof(MusicBlock), new[] {CommonExclusiveGroups.MUSIC_BLOCK_GROUP}}, + {typeof(ObjectIdentifier), new[]{CommonExclusiveGroups.OBJID_BLOCK_GROUP}}, + {typeof(Piston), new[] {CommonExclusiveGroups.PISTON_BLOCK_GROUP}}, + {typeof(Servo), new[] {CommonExclusiveGroups.SERVO_BLOCK_GROUP}}, { typeof(SpawnPoint), new[] { - CommonExclusiveGroups.BUILD_SPAWNPOINT_BLOCK_GROUP, - CommonExclusiveGroups.BUILD_BUILDINGSPAWN_BLOCK_GROUP + CommonExclusiveGroups.SPAWNPOINT_BLOCK_GROUP, + CommonExclusiveGroups.BUILDINGSPAWN_BLOCK_GROUP } }, { typeof(SfxBlock), new[] { - CommonExclusiveGroups.BUILD_SIMPLESFX_BLOCK_GROUP, - CommonExclusiveGroups.BUILD_LOOPEDSFX_BLOCK_GROUP + CommonExclusiveGroups.SIMPLESFX_BLOCK_GROUP, + CommonExclusiveGroups.LOOPEDSFX_BLOCK_GROUP } }, - {typeof(DampedSpring), new [] {CommonExclusiveGroups.BUILD_DAMPEDSPRING_BLOCK_GROUP}}, - {typeof(TextBlock), new[] {CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP}}, - {typeof(Timer), new[] {CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP}} + {typeof(DampedSpring), new [] {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP}}, + {typeof(TextBlock), new[] {CommonExclusiveGroups.TEXT_BLOCK_GROUP}}, + {typeof(Timer), new[] {CommonExclusiveGroups.TIMER_BLOCK_GROUP}} }; /// @@ -312,8 +312,9 @@ namespace GamecraftModdingAPI BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, BlockColor val) => { color.indexInPalette = (byte) (val.Color + val.Darkness * 10); - color.overridePaletteColour = false; - color.needsUpdate = true; + //color.overridePaletteColour = false; + //color.needsUpdate = true; + color.hasNetworkChange = true; color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); }, value); } @@ -324,14 +325,15 @@ namespace GamecraftModdingAPI /// public float4 CustomColor { - get => BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.overriddenColour); + get => BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.paletteColour); set { BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) => { - color.overriddenColour = val; - color.overridePaletteColour = true; - color.needsUpdate = true; + color.paletteColour = val; + //color.overridePaletteColour = true; + //color.needsUpdate = true; + color.hasNetworkChange = true; }, value); } } diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index e39a3e8..5566525 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using Gamecraft.ColourPalette; +using Gamecraft.TimeRunning; using Gamecraft.Wires; using RobocraftX.Blocks; using RobocraftX.Common; @@ -43,8 +44,14 @@ namespace GamecraftModdingAPI.Blocks FasterList cubes = new FasterList(10); var coll = entitiesDB.QueryEntities(); foreach (var (ecoll, _) in coll) - foreach (ref var conn in ecoll) - conn.isProcessed = false; + { + var ecollB = ecoll.ToBuffer(); + for(int i = 0; i < ecoll.count; i++) + { + ref var conn = ref ecollB.buffer[i]; + conn.isProcessed = false; + } + } ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID, cubeStack, cubes, (in GridConnectionsEntityStruct g) => { return false; }); @@ -68,17 +75,17 @@ namespace GamecraftModdingAPI.Blocks return ref structHolder[0]; //Gets a default value automatically } - public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityComponent + public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityViewComponent { if (entitiesDB.Exists(blockID)) { // TODO: optimize by using EntitiesDB internal calls instead of iterating over everything - EntityCollection entities = entitiesDB.QueryEntities(blockID.groupID); + BT> entities = entitiesDB.QueryEntities(blockID.groupID).ToBuffer(); for (int i = 0; i < entities.count; i++) { - if (entities[i].ID == blockID) + if (entities.buffer[i].ID == blockID) { - return ref entities[i]; + return ref entities.buffer[i]; } } } @@ -160,12 +167,13 @@ namespace GamecraftModdingAPI.Blocks public SimBody[] GetSimBodiesFromID(byte id) { var ret = new FasterList(4); - if (!entitiesDB.HasAny(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP)) + if (!entitiesDB.HasAny(CommonExclusiveGroups.OBJID_BLOCK_GROUP)) return new SimBody[0]; - var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP); - var connections = entitiesDB.QueryMappedEntities(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP); - foreach (ref ObjectIdEntityStruct oid in oids) + var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP).ToBuffer(); + var connections = entitiesDB.QueryMappedEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP); + for (int i = 0; i < oids.count; i++) { + ref ObjectIdEntityStruct oid = ref oids.buffer[i]; if (oid.objectId != id) continue; var rid = connections.Entity(oid.ID.entityID).machineRigidBodyId; foreach (var rb in ret) @@ -182,21 +190,26 @@ namespace GamecraftModdingAPI.Blocks public ObjectIdentifier[] GetObjectIDsFromID(byte id, bool sim) { var ret = new FasterList(4); - if (!entitiesDB.HasAny(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP)) + if (!entitiesDB.HasAny(CommonExclusiveGroups.OBJID_BLOCK_GROUP)) return new ObjectIdentifier[0]; - var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP); - foreach (ref ObjectIdEntityStruct oid in oids) + var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP).ToBuffer(); + for (int i = 0; i < oids.count; i++) + { + ref ObjectIdEntityStruct oid = ref oids.buffer[i]; if (sim ? oid.simObjectId == id : oid.objectId == id) ret.Add(new ObjectIdentifier(oid.ID)); + } + return ret.ToArray(); } public SimBody[] GetConnectedSimBodies(uint id) { - var joints = entitiesDB.QueryEntities(MachineSimulationGroups.JOINTS_GROUP); + var joints = entitiesDB.QueryEntities(MachineSimulationGroups.JOINTS_GROUP).ToBuffer(); var list = new FasterList(4); - foreach (var joint in joints) + for (int i = 0; i < joints.count; i++) { + ref var joint = ref joints.buffer[i]; if (joint.jointState == JointState.Broken) continue; if (joint.connectedEntityA == id) list.Add(new SimBody(joint.connectedEntityB)); else if (joint.connectedEntityB == id) list.Add(new SimBody(joint.connectedEntityA)); @@ -211,7 +224,7 @@ namespace GamecraftModdingAPI.Blocks var bodies = new HashSet(); foreach (var (coll, _) in groups) { - foreach (var conn in coll) + foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) { if (conn.clusterId == cid) bodies.Add(conn.machineRigidBodyId); @@ -238,7 +251,7 @@ namespace GamecraftModdingAPI.Blocks var groups = entitiesDB.QueryEntities(); foreach (var (coll, _) in groups) { - foreach (var conn in coll) + foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) { //Static blocks don't have a cluster ID but the cluster destruction manager should have one if (conn.machineRigidBodyId == sbid && conn.clusterId != uint.MaxValue) return new Cluster(conn.clusterId); @@ -254,7 +267,7 @@ namespace GamecraftModdingAPI.Blocks var set = new HashSet(); foreach (var (coll, _) in groups) { - foreach (var conn in coll) + foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) { if (conn.machineRigidBodyId == sbid) set.Add(new Block(conn.ID)); diff --git a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs index 70f713a..1bf6c15 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs @@ -14,10 +14,10 @@ namespace GamecraftModdingAPI.Blocks /// internal struct BlockInitData { - public FasterDictionary, ITypeSafeDictionary> Group; + public FasterDictionary Group; } - internal delegate FasterDictionary, ITypeSafeDictionary> GetInitGroup( + internal delegate FasterDictionary GetInitGroup( EntityComponentInitializer initializer); /// diff --git a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs b/GamecraftModdingAPI/Blocks/ConsoleBlock.cs index c8982e4..e696fca 100644 --- a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs +++ b/GamecraftModdingAPI/Blocks/ConsoleBlock.cs @@ -16,7 +16,7 @@ namespace GamecraftModdingAPI.Blocks { } - public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_CONSOLE_BLOCK_GROUP)) + public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.CONSOLE_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/DampedSpring.cs b/GamecraftModdingAPI/Blocks/DampedSpring.cs index 96e628d..5a5a936 100644 --- a/GamecraftModdingAPI/Blocks/DampedSpring.cs +++ b/GamecraftModdingAPI/Blocks/DampedSpring.cs @@ -10,7 +10,7 @@ namespace GamecraftModdingAPI.Blocks { } - public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_DAMPEDSPRING_BLOCK_GROUP)) + public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/LogicGate.cs b/GamecraftModdingAPI/Blocks/LogicGate.cs index 124bc10..2ec4cef 100644 --- a/GamecraftModdingAPI/Blocks/LogicGate.cs +++ b/GamecraftModdingAPI/Blocks/LogicGate.cs @@ -9,7 +9,7 @@ namespace GamecraftModdingAPI.Blocks { } - public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_LOGIC_BLOCK_GROUP)) + public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) { } } diff --git a/GamecraftModdingAPI/Blocks/Motor.cs b/GamecraftModdingAPI/Blocks/Motor.cs index 3c38a52..0a69d27 100644 --- a/GamecraftModdingAPI/Blocks/Motor.cs +++ b/GamecraftModdingAPI/Blocks/Motor.cs @@ -15,7 +15,7 @@ namespace GamecraftModdingAPI.Blocks { } - public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP)) + public Motor(uint id): base(new EGID(id, CommonExclusiveGroups.MOTOR_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/MusicBlock.cs b/GamecraftModdingAPI/Blocks/MusicBlock.cs index fc3c880..6b99b6f 100644 --- a/GamecraftModdingAPI/Blocks/MusicBlock.cs +++ b/GamecraftModdingAPI/Blocks/MusicBlock.cs @@ -20,7 +20,7 @@ namespace GamecraftModdingAPI.Blocks { } - public MusicBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_MUSIC_BLOCK_GROUP)) + public MusicBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.MUSIC_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs b/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs index 0dc835a..1233343 100644 --- a/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs +++ b/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs @@ -10,7 +10,7 @@ namespace GamecraftModdingAPI.Blocks { } - public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP)) + public ObjectIdentifier(uint id) : base(new EGID(id, CommonExclusiveGroups.OBJID_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/Piston.cs b/GamecraftModdingAPI/Blocks/Piston.cs index c3f2497..04b3aeb 100644 --- a/GamecraftModdingAPI/Blocks/Piston.cs +++ b/GamecraftModdingAPI/Blocks/Piston.cs @@ -15,7 +15,7 @@ namespace GamecraftModdingAPI.Blocks { } - public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP)) + public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index cb1cdee..cf9a80f 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -16,6 +16,7 @@ using UnityEngine; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Engines; using GamecraftModdingAPI.Players; +using RobocraftX.Rendering.GPUI; namespace GamecraftModdingAPI.Blocks { @@ -81,7 +82,7 @@ namespace GamecraftModdingAPI.Blocks structInitializer.Init(new ColourParameterEntityStruct { indexInPalette = colour.indexInPalette, - needsUpdate = true + hasNetworkChange = true }); uint prefabId = PrefabsID.GetPrefabId(dbid, 0); structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); diff --git a/GamecraftModdingAPI/Blocks/Servo.cs b/GamecraftModdingAPI/Blocks/Servo.cs index 1177fb6..606a48a 100644 --- a/GamecraftModdingAPI/Blocks/Servo.cs +++ b/GamecraftModdingAPI/Blocks/Servo.cs @@ -15,7 +15,7 @@ namespace GamecraftModdingAPI.Blocks { } - public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP)) + public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/SfxBlock.cs b/GamecraftModdingAPI/Blocks/SfxBlock.cs index f7efe6d..88d69d2 100644 --- a/GamecraftModdingAPI/Blocks/SfxBlock.cs +++ b/GamecraftModdingAPI/Blocks/SfxBlock.cs @@ -14,7 +14,7 @@ namespace GamecraftModdingAPI.Blocks { } - public SfxBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SIMPLESFX_BLOCK_GROUP /* This could also be BUILD_LOOPEDSFX_BLOCK_GROUP */)) + public SfxBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.SIMPLESFX_BLOCK_GROUP /* This could also be BUILD_LOOPEDSFX_BLOCK_GROUP */)) { } diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs index 763a1a1..0980d79 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs @@ -115,7 +115,8 @@ namespace GamecraftModdingAPI.Blocks public bool SetSignal(uint signalID, float signal, bool input = true) { var array = GetSignalStruct(signalID, out uint index, input); - if (array.count > 0) array[index].valueAsFloat = signal; + var arrayB = array.ToBuffer(); + if (array.count > 0) arrayB.buffer[index].valueAsFloat = signal; return false; } @@ -128,9 +129,10 @@ namespace GamecraftModdingAPI.Blocks public float AddSignal(uint signalID, float signal, bool clamp = true, bool input = true) { var array = GetSignalStruct(signalID, out uint index, input); + var arrayB = array.ToBuffer(); if (array.count > 0) { - ref var channelData = ref array[index]; + ref var channelData = ref arrayB.buffer[index]; channelData.valueAsFloat += signal; if (clamp) { @@ -159,7 +161,8 @@ namespace GamecraftModdingAPI.Blocks public float GetSignal(uint signalID, bool input = true) { var array = GetSignalStruct(signalID, out uint index, input); - return array.count > 0 ? array[index].valueAsFloat : 0f; + var arrayB = array.ToBuffer(); + return array.count > 0 ? arrayB.buffer[index].valueAsFloat : 0f; } public uint[] GetSignalIDs(EGID blockID, bool input = true) @@ -244,13 +247,14 @@ namespace GamecraftModdingAPI.Blocks { ref PortEntityStruct port = ref entitiesDB.QueryEntity(portID); var wires = entitiesDB.QueryEntities(NamedExclusiveGroup.Group); + var wiresB = wires.ToBuffer().buffer; for (uint i = 0; i < wires.count; i++) { - if ((wires[i].destinationPortUsage == port.usage && wires[i].destinationBlockEGID == blockID) - || (wires[i].sourcePortUsage == port.usage && wires[i].sourceBlockEGID == blockID)) + if ((wiresB[i].destinationPortUsage == port.usage && wiresB[i].destinationBlockEGID == blockID) + || (wiresB[i].sourcePortUsage == port.usage && wiresB[i].sourceBlockEGID == blockID)) { exists = true; - return ref wires[i]; + return ref wiresB[i]; } } exists = false; @@ -286,6 +290,7 @@ namespace GamecraftModdingAPI.Blocks } EntityCollection wires = entitiesDB.QueryEntities(NamedExclusiveGroup.Group); + var wiresB = wires.ToBuffer().buffer; for (int endIndex = 0; endIndex < endPorts.Length; endIndex++) { PortEntityStruct endPES = entitiesDB.QueryEntity(endPorts[endIndex]); @@ -294,11 +299,11 @@ namespace GamecraftModdingAPI.Blocks PortEntityStruct startPES = entitiesDB.QueryEntity(startPorts[startIndex]); for (int w = 0; w < wires.count; w++) { - if ((wires[w].destinationPortUsage == endPES.usage && wires[w].destinationBlockEGID == endBlock) - && (wires[w].sourcePortUsage == startPES.usage && wires[w].sourceBlockEGID == startBlock)) + if ((wiresB[w].destinationPortUsage == endPES.usage && wiresB[w].destinationBlockEGID == endBlock) + && (wiresB[w].sourcePortUsage == startPES.usage && wiresB[w].sourceBlockEGID == startBlock)) { exists = true; - return ref wires[w]; + return ref wiresB[w]; } } } @@ -313,10 +318,11 @@ namespace GamecraftModdingAPI.Blocks { ref PortEntityStruct port = ref entitiesDB.QueryEntity(portID); var channels = entitiesDB.QueryEntities(NamedExclusiveGroup.Group); + var channelsB = channels.ToBuffer(); if (port.firstChannelIndexCachedInSim < channels.count) { exists = true; - return ref channels[port.firstChannelIndexCachedInSim]; + return ref channelsB.buffer[port.firstChannelIndexCachedInSim]; } exists = false; ChannelDataStruct[] defRef = new ChannelDataStruct[1]; @@ -327,8 +333,15 @@ namespace GamecraftModdingAPI.Blocks { var res = new FasterList(); foreach (var (coll, _) in entitiesDB.QueryEntities()) - foreach (ref BlockPortsStruct s in coll) - res.Add(s.ID); + { + var collB = coll.ToBuffer(); + for (int i = 0; i < coll.count; i++) + { + ref BlockPortsStruct s = ref collB.buffer[i]; + res.Add(s.ID); + } + } + return res.ToArray(); } @@ -358,15 +371,16 @@ namespace GamecraftModdingAPI.Blocks return result; } - private T[] Search(ExclusiveGroup group, Func isMatch) where T : struct, IEntityComponent + private T[] Search(ExclusiveGroup group, Func isMatch) where T : unmanaged, IEntityComponent { FasterList results = new FasterList(); EntityCollection components = entitiesDB.QueryEntities(group); + var componentsB = components.ToBuffer(); for (uint i = 0; i < components.count; i++) { - if (isMatch(components[i])) + if (isMatch(componentsB.buffer[i])) { - results.Add(components[i]); + results.Add(componentsB.buffer[i]); } } return results.ToArray(); diff --git a/GamecraftModdingAPI/Blocks/SpawnPoint.cs b/GamecraftModdingAPI/Blocks/SpawnPoint.cs index 7616acb..17bffd9 100644 --- a/GamecraftModdingAPI/Blocks/SpawnPoint.cs +++ b/GamecraftModdingAPI/Blocks/SpawnPoint.cs @@ -17,7 +17,7 @@ namespace GamecraftModdingAPI.Blocks { } - public SpawnPoint(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_SPAWNPOINT_BLOCK_GROUP)) + public SpawnPoint(uint id) : base(new EGID(id, CommonExclusiveGroups.SPAWNPOINT_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/TextBlock.cs b/GamecraftModdingAPI/Blocks/TextBlock.cs index 895494d..d7d620a 100644 --- a/GamecraftModdingAPI/Blocks/TextBlock.cs +++ b/GamecraftModdingAPI/Blocks/TextBlock.cs @@ -16,7 +16,7 @@ namespace GamecraftModdingAPI.Blocks { } - public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP)) + public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.TEXT_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Blocks/Timer.cs b/GamecraftModdingAPI/Blocks/Timer.cs index 1aeecd9..0bbd302 100644 --- a/GamecraftModdingAPI/Blocks/Timer.cs +++ b/GamecraftModdingAPI/Blocks/Timer.cs @@ -17,7 +17,7 @@ namespace GamecraftModdingAPI.Blocks { } - public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP)) + public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.TIMER_BLOCK_GROUP)) { } diff --git a/GamecraftModdingAPI/Inventory/HotbarEngine.cs b/GamecraftModdingAPI/Inventory/HotbarEngine.cs index d5eb2d8..34cdf12 100644 --- a/GamecraftModdingAPI/Inventory/HotbarEngine.cs +++ b/GamecraftModdingAPI/Inventory/HotbarEngine.cs @@ -36,13 +36,13 @@ namespace GamecraftModdingAPI.Inventory public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false) { - var inputs = entitiesDB.QueryEntities(InputExclusiveGroups.LocalPlayers); + var inputs = entitiesDB.QueryEntities(InputExclusiveGroups.LocalPlayers).ToBuffer(); if (inputs.count == 0) return false; for (int i = 0; i < inputs.count; i++) { - if (inputs[i].ID.entityID == playerID) { - inputs[i].cubeSelectedByPick = cubeSelectedByPick; - inputs[i].selectedCube = block; + if (inputs.buffer[i].ID.entityID == playerID) { + inputs.buffer[i].cubeSelectedByPick = cubeSelectedByPick; + inputs.buffer[i].selectedCube = block; return true; } } diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index 6d461f2..e253eac 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -50,10 +50,10 @@ namespace GamecraftModdingAPI.Players public uint GetLocalPlayer() { if (!isReady) return uint.MaxValue; - var localPlayers = entitiesDB.QueryEntities(PlayersExclusiveGroups.LocalPlayers); + var localPlayers = entitiesDB.QueryEntities(PlayersExclusiveGroups.LocalPlayers).ToBuffer(); if (localPlayers.count > 0) { - return localPlayers[0].ID.entityID; + return localPlayers.buffer[0].ID.entityID; } return uint.MaxValue; } @@ -61,10 +61,10 @@ namespace GamecraftModdingAPI.Players public uint GetRemotePlayer() { if (!isReady) return uint.MaxValue; - var localPlayers = entitiesDB.QueryEntities(PlayersExclusiveGroups.RemotePlayers); + var localPlayers = entitiesDB.QueryEntities(PlayersExclusiveGroups.RemotePlayers).ToBuffer(); if (localPlayers.count > 0) { - return localPlayers[0].ID.entityID; + return localPlayers.buffer[0].ID.entityID; } return uint.MaxValue; } diff --git a/GamecraftModdingAPI/Tests/TestRoot.cs b/GamecraftModdingAPI/Tests/TestRoot.cs index 6acb51c..22f3035 100644 --- a/GamecraftModdingAPI/Tests/TestRoot.cs +++ b/GamecraftModdingAPI/Tests/TestRoot.cs @@ -65,7 +65,7 @@ namespace GamecraftModdingAPI.Tests _testsCountPassed = 0; _testsCountFailed = 0; // flow control - Game.Enter += (sender, args) => { GameTests().RunOn(RobocraftX.Schedulers.Lean.EveryFrameStepRunner_RUNS_IN_TIME_STOPPED_AND_RUNNING); }; + Game.Enter += (sender, args) => { GameTests().RunOn(RobocraftX.Schedulers.Lean.EveryFrameStepRunner_TimeRunningAndStopped); }; Game.Exit += (s, a) => state = "ReturningFromGame"; Client.EnterMenu += (sender, args) => { From 8eec1358e936e6132d8a1edf350ec11a29290d68 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 9 Nov 2020 16:33:12 -0500 Subject: [PATCH 06/98] Fix harmony patch error due to fixed name --- .../Inventory/HotbarSlotSelectionHandlerEnginePatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs index 9a81f99..a0ad5c1 100644 --- a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs +++ b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs @@ -15,7 +15,7 @@ namespace GamecraftModdingAPI.Inventory public static BlockIDs EquippedPartID { get => (BlockIDs)selectedBlockInt; } - private static MethodInfo PatchedMethod { get; } = AccessTools.Method("Gamecraft.GUI.Hotbar.Blocks.SyncHotbarSlotSelectedToEquipedPartEngine:ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int), typeof(ExclusiveGroupStruct) }); + private static MethodInfo PatchedMethod { get; } = AccessTools.Method("Gamecraft.GUI.Hotbar.Blocks.SyncHotbarSlotSelectedToEquippedPartEngine:ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int), typeof(ExclusiveGroupStruct) }); public static void Prefix(uint playerID, int selectedDBPartID, ExclusiveGroupStruct groupID) { From 4f8feaa24ba942fe5d550621ad63553959994d89 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 10 Nov 2020 16:37:20 +0100 Subject: [PATCH 07/98] Add new blocks and some blueprint/block group support --- GamecraftModdingAPI/Block.cs | 13 +++- GamecraftModdingAPI/BlockGroup.cs | 46 +++++++++++ GamecraftModdingAPI/Blocks/BlockIDs.cs | 2 + GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 77 +++++++++++++++++++ GamecraftModdingAPI/Blueprint.cs | 20 +++++ GamecraftModdingAPI/Main.cs | 1 + 6 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 GamecraftModdingAPI/BlockGroup.cs create mode 100644 GamecraftModdingAPI/Blocks/BlueprintEngine.cs create mode 100644 GamecraftModdingAPI/Blueprint.cs diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 81d6439..862db3f 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -3,12 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; +using Gamecraft.Blocks.BlockGroups; using Svelto.ECS; using Svelto.ECS.EntityStructs; using RobocraftX.Common; using RobocraftX.Blocks; using Unity.Mathematics; -using Unity.Entities; using Gamecraft.Blocks.GUI; using GamecraftModdingAPI.Blocks; @@ -354,6 +354,17 @@ namespace GamecraftModdingAPI } } + /// + /// Returns the block group this block is a part of. Block groups can be placed using blueprints. + /// Returns null if not part of a group. + /// + public BlockGroup BlockGroup + { + get => BlockEngine.GetBlockInfo(this, + (BlockGroupEntityComponent bgec) => + bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this)); + } + /// /// Whether the block exists. The other properties will return a default value if the block doesn't exist. /// If the block was just placed, then this will also return false but the properties will work correctly. diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs new file mode 100644 index 0000000..2cd0f42 --- /dev/null +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -0,0 +1,46 @@ +using Gamecraft.Blocks.BlockGroups; +using GamecraftModdingAPI.Blocks; +using GamecraftModdingAPI.Utility; + +namespace GamecraftModdingAPI +{ + /// + /// A group of blocks that can be selected together. The placed version of blueprints. + /// + public class BlockGroup + { + internal static BlueprintEngine _engine = new BlueprintEngine(); + public int Id { get; } + private Block _sourceBlock; + + internal BlockGroup(int id, Block block) + { + if (id == BlockGroupUtility.GROUP_UNASSIGNED) + throw new BlockException("Cannot create a block group for blocks without a group!"); + Id = id; + _sourceBlock = block; + } + + /// + /// Collects each block that is a part of this group. + /// + /// An array of blocks + public Block[] GetBlocks() + { + return _engine.GetBlocksFromGroup(_sourceBlock.Id); + } + + /// + /// Removes all of the blocks in this group from the world. + /// + public void Remove() + { + _engine.RemoveBlockGroup(Id); + } + + public static void Init() + { + GameEngineManager.AddGameEngine(_engine); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index d867ce0..1d55b29 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -327,6 +327,8 @@ namespace GamecraftModdingAPI.Blocks SpotLightInvisible, UnlitSlope, UnlitGlowSlope, + Fog, + Sky, MagmaRockCube = 777, MagmaRockCubeSliced, MagmaRockSlope, diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs new file mode 100644 index 0000000..7f0a616 --- /dev/null +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -0,0 +1,77 @@ +using System.Reflection; +using Gamecraft.Blocks.BlockGroups; +using Gamecraft.GUI.Blueprints; +using GamecraftModdingAPI.Engines; +using HarmonyLib; +using RobocraftX.Blocks; +using Svelto.DataStructures; +using Svelto.ECS; +using Svelto.ECS.DataStructures; +using Unity.Collections; + +namespace GamecraftModdingAPI.Blocks +{ + public class BlueprintEngine : IApiEngine + { + private readonly MethodInfo getBlocksFromGroup = + AccessTools.Method("RobocraftX.CR.MachineEditing.PlaceBlockUtility:GetBlocksSharingBlockgroup"); + private readonly NativeDynamicArray selectedBlocksInGroup = new NativeDynamicArray(); + private readonly NativeHashSet removedConnections = new NativeHashSet(); + + private static NativeEntityRemove nativeRemove; + private static MachineGraphConnectionEntityFactory connectionFactory; + + public void Ready() + { + } + + public EntitiesDB entitiesDB { get; set; } + public void Dispose() + { + } + + public Block[] GetBlocksFromGroup(EGID blockID) + { + var list = new FasterList(); + object blockPos = null, blockRot = null; + getBlocksFromGroup.Invoke(null, new[] {blockID, selectedBlocksInGroup, entitiesDB, blockPos, blockRot}); + for (uint i = 0; i < selectedBlocksInGroup.Count(); i++) + list.Add(new Block(selectedBlocksInGroup.Get(i))); + selectedBlocksInGroup.FastClear(); + return list.ToArray(); + } + + public void RemoveBlockGroup(int id) + { + BlockGroupUtility.RemoveAllBlocksInBlockGroup(id, entitiesDB, removedConnections, nativeRemove, + connectionFactory, default).Complete(); + } + + public void SelectBlueprint(uint resourceID) + { + BlueprintUtil.SelectBlueprint(null, new BlueprintInventoryItemEntityStruct + { + blueprintResourceId = resourceID, + }); + } + + public string Name { get; } = "GamecraftModdingAPIBlueprintGameEngine"; + public bool isRemovable { get; } + + [HarmonyPatch] + private static class RemoveEnginePatch + { + public static void Prefix(IEntityFunctions entityFunctions, + MachineGraphConnectionEntityFactory machineGraphConnectionEntityFactory) + { + nativeRemove = entityFunctions.ToNativeRemove("GCAPI" + nameof(BlueprintEngine)); + connectionFactory = machineGraphConnectionEntityFactory; + } + + public static MethodBase TargetMethod() + { + return AccessTools.Constructor(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.RemoveBlockEngine")); + } + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Blueprint.cs b/GamecraftModdingAPI/Blueprint.cs new file mode 100644 index 0000000..de6d65e --- /dev/null +++ b/GamecraftModdingAPI/Blueprint.cs @@ -0,0 +1,20 @@ +using Gamecraft.GUI.Blueprints; + +namespace GamecraftModdingAPI +{ + /// + /// Represents a blueprint in the inventory. When placed it becomes a block group. + /// + public class Blueprint + { + public uint Id { get; } + + /*public static void SelectBlueprint(Blueprint blueprint) + { + BlueprintUtil.SelectBlueprint(null, new BlueprintInventoryItemEntityStruct + { + blueprintResourceId = blueprint.Id + }); + }*/ + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 98fb6f6..584ae90 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -83,6 +83,7 @@ namespace GamecraftModdingAPI // init object-oriented classes Player.Init(); Block.Init(); + BlockGroup.Init(); Wire.Init(); GameClient.Init(); AsyncUtils.Init(); From 1c4e2a0db215c6824500d685be7a9d3b4d70f99f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 10 Nov 2020 19:28:36 +0100 Subject: [PATCH 08/98] Add support for setting and placing blueprints --- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 145 +++++++++++++++++- GamecraftModdingAPI/Blueprint.cs | 48 +++++- GamecraftModdingAPI/Utility/FullGameFields.cs | 9 ++ 3 files changed, 199 insertions(+), 3 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index 7f0a616..f2f0bef 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -1,13 +1,22 @@ -using System.Reflection; +using System; +using System.Reflection; using Gamecraft.Blocks.BlockGroups; using Gamecraft.GUI.Blueprints; using GamecraftModdingAPI.Engines; +using GamecraftModdingAPI.Utility; using HarmonyLib; using RobocraftX.Blocks; +using RobocraftX.Common; +using RobocraftX.CR.MachineEditing.BoxSelect; +using RobocraftX.CR.MachineEditing.BoxSelect.ClipboardOperations; using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.DataStructures; +using Svelto.ECS.EntityStructs; +using Svelto.ECS.Serialization; using Unity.Collections; +using Unity.Mathematics; +using UnityEngine; namespace GamecraftModdingAPI.Blocks { @@ -18,8 +27,20 @@ namespace GamecraftModdingAPI.Blocks private readonly NativeDynamicArray selectedBlocksInGroup = new NativeDynamicArray(); private readonly NativeHashSet removedConnections = new NativeHashSet(); + private static readonly Type PlaceBlueprintUtilityType = + AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceBlueprintUtility"); + private static readonly FieldInfo LocalBlockMap = + AccessTools.DeclaredField(PlaceBlueprintUtilityType, "_localBlockMap"); + private static readonly MethodInfo BuildBlock = AccessTools.Method(PlaceBlueprintUtilityType, "BuildBlock"); + private static readonly MethodInfo BuildWires = AccessTools.Method(PlaceBlueprintUtilityType, "BuildWires"); + private static NativeEntityRemove nativeRemove; private static MachineGraphConnectionEntityFactory connectionFactory; + private static IEntityFunctions entityFunctions; + private static ClipboardSerializationDataResourceManager clipboardManager; + private static IEntitySerialization entitySerialization; + private static IEntityFactory entityFactory; + private static FasterList globalBlockMap; public void Ready() { @@ -55,6 +76,109 @@ namespace GamecraftModdingAPI.Blocks }); } + public uint CreateBlueprint() + { + uint index = clipboardManager.AllocateSerializationData(); + return index; + } + + public void ReplaceBlueprint(uint playerID, uint blueprintID, Block[] selected, float3 pos, quaternion rot) + { + var blockIDs = new EGID[selected.Length]; + for (var i = 0; i < selected.Length; i++) + { + var block = selected[i]; + blockIDs[i] = block.Id; + } + + var serializationData = clipboardManager.GetSerializationData(blueprintID); + SelectionSerializationUtility.ClearClipboard(playerID, entitiesDB, entityFunctions, serializationData.blueprintData); + if (selected.Length == 0) + return; + //ref BlockGroupTransformEntityComponent groupTransform = ref EntityNativeDBExtensions.QueryEntity(entitiesDb, (uint) local1.currentBlockGroup, BlockGroupExclusiveGroups.BlockGroupEntityGroup); + //ref ColliderAabb collider = ref EntityNativeDBExtensions.QueryEntity(entitiesDB, (uint) groupID, BlockGroupExclusiveGroups.BlockGroupEntityGroup); + //float3 bottomOffset = PlaceBlockUtility.GetBottomOffset(collider); + //var rootPosition = math.mul(groupTransform.blockGroupGridRotation, bottomOffset) + groupTransform.blockGroupGridPosition; + //var rootRotation = groupTransform.blockGroupGridRotation; + if (math.all(pos == default)) + pos = selected[0].Position; + if (math.all(rot.value == default)) + rot = Quaternion.Euler(selected[0].Rotation); + + clipboardManager.SetGhostSerialized(blueprintID, false); + SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, + serializationData.blueprintData, entitySerialization, entityFactory, blockIDs, + (uint) blockIDs.Length, pos, rot); + } + + public Block[] PlaceBlueprintBlocks(uint blueprintID, uint playerID, float3 pos, float3 rot) + { //RobocraftX.CR.MachineEditing.PlaceBlueprintUtility.PlaceBlocksFromSerialisedData + var serializationData = clipboardManager.GetSerializationData(blueprintID); + var blueprintData = serializationData.blueprintData; + blueprintData.dataPos = 0U; + uint selectionSize; + PositionEntityStruct selectionPosition; + RotationEntityStruct selectionRotation; + uint version; + BoxSelectSerializationUtilities.ReadClipboardHeader(blueprintData, out selectionSize, out selectionPosition, out selectionRotation, out version); + ((FasterList) LocalBlockMap.GetValue(null)).Clear(); + if (version <= 1U) + { + uint groupsCount; + BoxSelectSerializationUtilities.ReadBlockGroupData(blueprintData, out groupsCount); + for (int index = 0; (long) index < (long) groupsCount; ++index) + { + int nextFilterId = BlockGroupUtility.NextFilterId; + entitySerialization.DeserializeNewEntity(new EGID((uint) nextFilterId, BlockGroupExclusiveGroups.BlockGroupEntityGroup), blueprintData, 1); + } + } + int nextFilterId1 = BlockGroupUtility.NextFilterId; + entityFactory.BuildEntity(new EGID((uint) nextFilterId1, BlockGroupExclusiveGroups.BlockGroupEntityGroup)).Init(new BlockGroupTransformEntityComponent + { + blockGroupGridPosition = selectionPosition.position, + blockGroupGridRotation = selectionRotation.rotation + }); + var frot = Quaternion.Euler(rot); + var grid = new GridRotationStruct {position = pos, rotation = frot}; + var poss = new PositionEntityStruct {position = pos}; + var rots = new RotationEntityStruct {rotation = frot}; + for (int index = 0; (long) index < (long) selectionSize; ++index) + BuildBlock.Invoke(null, + new object[] + { + playerID, grid, poss, rots, selectionPosition, selectionRotation, blueprintData, + entitiesDB, entitySerialization, nextFilterId1 + }); + /* + uint playerId, in GridRotationStruct ghostParentGrid, + in PositionEntityStruct ghostParentPosition, in RotationEntityStruct ghostParentRotation, + in PositionEntityStruct selectionPosition, in RotationEntityStruct selectionRotation, + ISerializationData serializationData, EntitiesDB entitiesDb, + IEntitySerialization entitySerialization, int blockGroupId + */ + if (globalBlockMap == null) + globalBlockMap = FullGameFields._deserialisedBlockMap; + var placedBlocks = (FasterList) LocalBlockMap.GetValue(null); + globalBlockMap.Clear(); + globalBlockMap.AddRange(placedBlocks); + BuildWires.Invoke(null, + new object[] {playerID, blueprintData, entitySerialization, entitiesDB, entityFactory}); + var blocks = new Block[placedBlocks.count]; + for (int i = 0; i < blocks.Length; i++) + blocks[i] = new Block(placedBlocks[i]); + return blocks; + } + + public void InitBlueprint(uint blueprintID) + { + clipboardManager.IncrementRefCount(blueprintID); + } + + public void DisposeBlueprint(uint blueprintID) + { + clipboardManager.DecrementRefCount(blueprintID); + } + public string Name { get; } = "GamecraftModdingAPIBlueprintGameEngine"; public bool isRemovable { get; } @@ -66,6 +190,7 @@ namespace GamecraftModdingAPI.Blocks { nativeRemove = entityFunctions.ToNativeRemove("GCAPI" + nameof(BlueprintEngine)); connectionFactory = machineGraphConnectionEntityFactory; + BlueprintEngine.entityFunctions = entityFunctions; } public static MethodBase TargetMethod() @@ -73,5 +198,23 @@ namespace GamecraftModdingAPI.Blocks return AccessTools.Constructor(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.RemoveBlockEngine")); } } + + [HarmonyPatch] + private static class SelectEnginePatch + { + public static void Prefix(ClipboardSerializationDataResourceManager clipboardSerializationDataResourceManager, + IEntitySerialization entitySerialization, + IEntityFactory entityFactory) + { + clipboardManager = clipboardSerializationDataResourceManager; + BlueprintEngine.entitySerialization = entitySerialization; + BlueprintEngine.entityFactory = entityFactory; + } + + public static MethodBase TargetMethod() + { + return AccessTools.Constructor(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.SelectBlockEngine")); + } + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blueprint.cs b/GamecraftModdingAPI/Blueprint.cs index de6d65e..26876f6 100644 --- a/GamecraftModdingAPI/Blueprint.cs +++ b/GamecraftModdingAPI/Blueprint.cs @@ -1,13 +1,20 @@ -using Gamecraft.GUI.Blueprints; +using System; +using Unity.Mathematics; namespace GamecraftModdingAPI { /// /// Represents a blueprint in the inventory. When placed it becomes a block group. /// - public class Blueprint + public class Blueprint : IDisposable { public uint Id { get; } + + internal Blueprint(uint id) + { + Id = id; + BlockGroup._engine.InitBlueprint(id); + } /*public static void SelectBlueprint(Blueprint blueprint) { @@ -16,5 +23,42 @@ namespace GamecraftModdingAPI blueprintResourceId = blueprint.Id }); }*/ + + /// + /// Creates a new, empty blueprint. It will be deleted on disposal unless the game holds a reference to it. + /// + /// A blueprint that doesn't have any blocks + public static Blueprint Create() + { + return new Blueprint(BlockGroup._engine.CreateBlueprint()); + } + + /// + /// Set the blocks that the blueprint contains. + /// + /// The array of blocks to use + /// The anchor position of the blueprint + /// The rotation of the blueprint + public void SetStoredBlocks(Block[] blocks, float3 position = default, float3 rotation = default) + { + BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, blocks, position, + quaternion.Euler(rotation)); + } + + /// + /// Places the blocks the blueprint contains at the specified position and rotation. + /// + /// The position of the blueprint + /// The rotation of the blueprint + /// An array of the placed blocks + public Block[] PlaceBlocks(float3 position, float3 rotation) + { + return BlockGroup._engine.PlaceBlueprintBlocks(Id, Player.LocalPlayer.Id, position, rotation); + } + + public void Dispose() + { + BlockGroup._engine.DisposeBlueprint(Id); + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Utility/FullGameFields.cs b/GamecraftModdingAPI/Utility/FullGameFields.cs index 8fd8895..432103d 100644 --- a/GamecraftModdingAPI/Utility/FullGameFields.cs +++ b/GamecraftModdingAPI/Utility/FullGameFields.cs @@ -12,6 +12,7 @@ using RobocraftX.GUI; using RobocraftX.Multiplayer; using RobocraftX.Rendering; using Svelto.Context; +using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Schedulers.Unity; using UnityEngine; @@ -159,6 +160,14 @@ namespace GamecraftModdingAPI.Utility } } + public static FasterList _deserialisedBlockMap + { + get + { + return (FasterList) fgcr?.Field("_deserialisedBlockMap").GetValue(); + } + } + private static Traverse fgcr; public static void Init(FullGameCompositionRoot instance) From 3dd61b5e4fa50d6d3b799d4c4f5e5658c9cf2de4 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 10 Nov 2020 23:08:27 +0100 Subject: [PATCH 09/98] Replace ToManagedArray() and fix getting blocks from group --- GamecraftModdingAPI/App/GameGameEngine.cs | 21 ++++++++++--- GamecraftModdingAPI/BlockGroup.cs | 24 +++++++++++--- GamecraftModdingAPI/Blocks/BlockEngine.cs | 17 +++++++--- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 31 ++++++++++++------- 4 files changed, 68 insertions(+), 25 deletions(-) diff --git a/GamecraftModdingAPI/App/GameGameEngine.cs b/GamecraftModdingAPI/App/GameGameEngine.cs index dea3821..85fb672 100644 --- a/GamecraftModdingAPI/App/GameGameEngine.cs +++ b/GamecraftModdingAPI/App/GameGameEngine.cs @@ -102,16 +102,27 @@ namespace GamecraftModdingAPI.App if (filter == BlockIDs.Invalid) { foreach (var (blocks, _) in allBlocks) - foreach (var block in blocks.ToBuffer().buffer.ToManagedArray()) - blockEGIDs.Add(block.ID); + { + var buffer = blocks.ToBuffer().buffer; + for (int i = 0; i < buffer.capacity; i++) + blockEGIDs.Add(buffer[i].ID); + } + return blockEGIDs.ToArray(); } else { foreach (var (blocks, _) in allBlocks) - foreach (var block in blocks.ToBuffer().buffer.ToManagedArray()) - if (block.DBID == (ulong) filter) - blockEGIDs.Add(block.ID); + { + var array = blocks.ToBuffer().buffer; + for (var index = 0; index < array.capacity; index++) + { + var block = array[index]; + if (block.DBID == (ulong) filter) + blockEGIDs.Add(block.ID); + } + } + return blockEGIDs.ToArray(); } } diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index 2cd0f42..8d9e761 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -1,4 +1,7 @@ using Gamecraft.Blocks.BlockGroups; +using Unity.Mathematics; +using UnityEngine; + using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Utility; @@ -11,23 +14,36 @@ namespace GamecraftModdingAPI { internal static BlueprintEngine _engine = new BlueprintEngine(); public int Id { get; } - private Block _sourceBlock; + private readonly Block sourceBlock; internal BlockGroup(int id, Block block) { if (id == BlockGroupUtility.GROUP_UNASSIGNED) throw new BlockException("Cannot create a block group for blocks without a group!"); Id = id; - _sourceBlock = block; + sourceBlock = block; } + + /// + /// The position of the block group. Calculated when GetBlocks() is used. + /// + public float3 Position { get; private set; } + + /// + /// The rotation of the block group. Calculated when GetBlocks() is used. + /// + public float3 Rotation { get; private set; } /// - /// Collects each block that is a part of this group. + /// Collects each block that is a part of this group. Also sets the position and rotation. /// /// An array of blocks public Block[] GetBlocks() { - return _engine.GetBlocksFromGroup(_sourceBlock.Id); + var ret = _engine.GetBlocksFromGroup(sourceBlock.Id, out var pos, out var rot); + Position = pos; + Rotation = ((Quaternion) rot).eulerAngles; + return ret; } /// diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 5566525..9ce6d62 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -12,9 +12,9 @@ using RobocraftX.Scene.Simulation; using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Hybrid; +using Unity.Mathematics; using GamecraftModdingAPI.Engines; -using Unity.Mathematics; namespace GamecraftModdingAPI.Blocks { @@ -224,8 +224,10 @@ namespace GamecraftModdingAPI.Blocks var bodies = new HashSet(); foreach (var (coll, _) in groups) { - foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) + var array = coll.ToBuffer().buffer; + for (var index = 0; index < array.capacity; index++) { + var conn = array[index]; if (conn.clusterId == cid) bodies.Add(conn.machineRigidBodyId); } @@ -251,8 +253,11 @@ namespace GamecraftModdingAPI.Blocks var groups = entitiesDB.QueryEntities(); foreach (var (coll, _) in groups) { - foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) - { //Static blocks don't have a cluster ID but the cluster destruction manager should have one + var array = coll.ToBuffer().buffer; + for (var index = 0; index < array.capacity; index++) + { + var conn = array[index]; + //Static blocks don't have a cluster ID but the cluster destruction manager should have one if (conn.machineRigidBodyId == sbid && conn.clusterId != uint.MaxValue) return new Cluster(conn.clusterId); } @@ -267,8 +272,10 @@ namespace GamecraftModdingAPI.Blocks var set = new HashSet(); foreach (var (coll, _) in groups) { - foreach (var conn in coll.ToBuffer().buffer.ToManagedArray()) + var array = coll.ToBuffer().buffer; + for (var index = 0; index < array.capacity; index++) { + var conn = array[index]; if (conn.machineRigidBodyId == sbid) set.Add(new Block(conn.ID)); } diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index f2f0bef..4104ae6 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -17,6 +17,7 @@ using Svelto.ECS.Serialization; using Unity.Collections; using Unity.Mathematics; using UnityEngine; +using Allocator = Svelto.Common.Allocator; namespace GamecraftModdingAPI.Blocks { @@ -24,8 +25,9 @@ namespace GamecraftModdingAPI.Blocks { private readonly MethodInfo getBlocksFromGroup = AccessTools.Method("RobocraftX.CR.MachineEditing.PlaceBlockUtility:GetBlocksSharingBlockgroup"); - private readonly NativeDynamicArray selectedBlocksInGroup = new NativeDynamicArray(); - private readonly NativeHashSet removedConnections = new NativeHashSet(); + + private NativeDynamicArray selectedBlocksInGroup; + private NativeHashSet removedConnections = new NativeHashSet(); private static readonly Type PlaceBlueprintUtilityType = AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceBlueprintUtility"); @@ -44,22 +46,29 @@ namespace GamecraftModdingAPI.Blocks public void Ready() { + selectedBlocksInGroup = NativeDynamicArray.Alloc(Allocator.Persistent); } public EntitiesDB entitiesDB { get; set; } public void Dispose() { + selectedBlocksInGroup.Dispose(); } - public Block[] GetBlocksFromGroup(EGID blockID) + public Block[] GetBlocksFromGroup(EGID blockID, out float3 pos, out quaternion rot) { - var list = new FasterList(); - object blockPos = null, blockRot = null; - getBlocksFromGroup.Invoke(null, new[] {blockID, selectedBlocksInGroup, entitiesDB, blockPos, blockRot}); - for (uint i = 0; i < selectedBlocksInGroup.Count(); i++) - list.Add(new Block(selectedBlocksInGroup.Get(i))); + var blockPos = default(float3); + var blockRot = default(quaternion); + var parameters = new object[] {blockID, selectedBlocksInGroup, entitiesDB, blockPos, blockRot}; + getBlocksFromGroup.Invoke(null, parameters); + pos = (float3) parameters[3]; + rot = (quaternion) parameters[4]; + int count = selectedBlocksInGroup.Count(); + var ret = new Block[count]; + for (uint i = 0; i < count; i++) + ret[i] = new Block(selectedBlocksInGroup.Get(i)); selectedBlocksInGroup.FastClear(); - return list.ToArray(); + return ret; } public void RemoveBlockGroup(int id) @@ -195,7 +204,7 @@ namespace GamecraftModdingAPI.Blocks public static MethodBase TargetMethod() { - return AccessTools.Constructor(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.RemoveBlockEngine")); + return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.RemoveBlockEngine"))[0]; } } @@ -213,7 +222,7 @@ namespace GamecraftModdingAPI.Blocks public static MethodBase TargetMethod() { - return AccessTools.Constructor(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.SelectBlockEngine")); + return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.SelectBlockEngine"))[0]; } } } From d744aaab79ae1c9a02a84784d4358ef51720d1ee Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 12 Nov 2020 02:39:58 +0100 Subject: [PATCH 10/98] Add ability to create & move block groups & other stuff Added a way to store block groups as blueprints Blocks can be added/removed from block groups, although it doesn't work well atm Added some patches to the test class in an attempt to debug an unrelated issue Added a command to test placing a block group Added a SelectedBlueprint property to the Player class --- GamecraftModdingAPI/Block.cs | 28 +++- GamecraftModdingAPI/BlockGroup.cs | 153 ++++++++++++++++-- .../Blocks/BlockEventsEngine.cs | 11 +- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 49 ++++-- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 8 +- GamecraftModdingAPI/Blueprint.cs | 16 +- GamecraftModdingAPI/Player.cs | 13 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 101 ++++++++++++ 8 files changed, 332 insertions(+), 47 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 862db3f..33a1623 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -240,6 +240,8 @@ namespace GamecraftModdingAPI set { MovementEngine.MoveBlock(Id, InitData, value); + if (blockGroup != null) + blockGroup.PosAndRotCalculated = false; } } @@ -252,6 +254,8 @@ namespace GamecraftModdingAPI set { RotationEngine.RotateBlock(Id, InitData, value); + if (blockGroup != null) + blockGroup.PosAndRotCalculated = false; } } @@ -354,15 +358,31 @@ namespace GamecraftModdingAPI } } + private BlockGroup blockGroup; /// /// Returns the block group this block is a part of. Block groups can be placed using blueprints. - /// Returns null if not part of a group. + /// Returns null if not part of a group.
+ /// Setting the group after the block has been initialized will not update everything properly. + /// You should only set this property on blocks newly placed by your code. ///
public BlockGroup BlockGroup { - get => BlockEngine.GetBlockInfo(this, - (BlockGroupEntityComponent bgec) => - bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this)); + get + { + if (blockGroup != null) return blockGroup; + return blockGroup = BlockEngine.GetBlockInfo(this, + (BlockGroupEntityComponent bgec) => + bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this)); + } + set + { + blockGroup?.RemoveInternal(this); + BlockEngine.SetBlockInfo(this, + (ref BlockGroupEntityComponent bgec, BlockGroup val) => bgec.currentBlockGroup = val?.Id ?? -1, + value); + value?.AddInternal(this); + blockGroup = value; + } } /// diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index 8d9e761..d660236 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -1,4 +1,8 @@ -using Gamecraft.Blocks.BlockGroups; +using System; +using System.Collections; +using System.Collections.Generic; + +using Gamecraft.Blocks.BlockGroups; using Unity.Mathematics; using UnityEngine; @@ -10,11 +14,14 @@ namespace GamecraftModdingAPI /// /// A group of blocks that can be selected together. The placed version of blueprints. /// - public class BlockGroup + public class BlockGroup : ICollection { internal static BlueprintEngine _engine = new BlueprintEngine(); public int Id { get; } private readonly Block sourceBlock; + private readonly List blocks; + private float3 position, rotation; + internal bool PosAndRotCalculated; internal BlockGroup(int id, Block block) { @@ -22,41 +29,155 @@ namespace GamecraftModdingAPI throw new BlockException("Cannot create a block group for blocks without a group!"); Id = id; sourceBlock = block; + blocks = new List(GetBlocks()); } /// - /// The position of the block group. Calculated when GetBlocks() is used. + /// The position of the block group (center). Recalculated if blocks have been added/removed since the last query. /// - public float3 Position { get; private set; } - + public float3 Position + { + get + { + if (!PosAndRotCalculated) + Refresh(); + return position; + } + set + { + var diff = value - position; + foreach (var block in blocks) + block.Position += diff; + if (!PosAndRotCalculated) //The condition can only be true if a block has been added/removed manually + Refresh(); //So the blocks array is up to date + else + position += diff; + } + } + /// - /// The rotation of the block group. Calculated when GetBlocks() is used. + /// The rotation of the block group. Recalculated if blocks have been added/removed since the last query. /// - public float3 Rotation { get; private set; } + public float3 Rotation + { + get + { + if (!PosAndRotCalculated) + Refresh(); + return rotation; + } + set + { + var diff = value - rotation; + var qdiff = Quaternion.Euler(diff); + foreach (var block in blocks) + { + block.Rotation += diff; + block.Position = qdiff * block.Position; + } + if (!PosAndRotCalculated) + Refresh(); + else + rotation += diff; + } + } + + /*/// + /// Removes all of the blocks in this group from the world. + /// + public void RemoveBlocks() + { + _engine.RemoveBlockGroup(Id); - TODO: Causes a hard crash + }*/ + + /// + /// Creates a new block group consisting of a single block. + /// You can add more blocks using the Add() method or by setting the BlockGroup property of the blocks.
+ /// Note that only newly placed blocks should be added to groups. + ///
+ /// The block to add + /// A new block group containing the given block + public static BlockGroup Create(Block block) + { + return new BlockGroup(_engine.CreateBlockGroup(default, default), block); + } /// /// Collects each block that is a part of this group. Also sets the position and rotation. /// /// An array of blocks - public Block[] GetBlocks() + private Block[] GetBlocks() { + if (!sourceBlock.Exists) return new[] {sourceBlock}; //The block must exist to get the others var ret = _engine.GetBlocksFromGroup(sourceBlock.Id, out var pos, out var rot); - Position = pos; - Rotation = ((Quaternion) rot).eulerAngles; + position = pos; + rotation = ((Quaternion) rot).eulerAngles; + PosAndRotCalculated = true; return ret; } - /// - /// Removes all of the blocks in this group from the world. - /// - public void Remove() + private void Refresh() { - _engine.RemoveBlockGroup(Id); + blocks.Clear(); + blocks.AddRange(GetBlocks()); } - public static void Init() + internal static void Init() { GameEngineManager.AddGameEngine(_engine); } + + public IEnumerator GetEnumerator() => blocks.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => blocks.GetEnumerator(); + + /// + /// Adds a block to the group. You should only add newly placed blocks + /// so that the game initializes the group membership properly. + /// + /// + /// + public void Add(Block item) + { + if (item == null) throw new NullReferenceException("Cannot add null to a block group"); + item.BlockGroup = this; //Calls AddInternal + } + + internal void AddInternal(Block item) => blocks.Add(item); + + /// + /// Removes all blocks from this group. + /// You should not remove blocks that have been initialized, only those that you placed recently. + /// + public void Clear() + { + while (blocks.Count > 0) + Remove(blocks[blocks.Count - 1]); + } + + public bool Contains(Block item) => blocks.Contains(item); + public void CopyTo(Block[] array, int arrayIndex) => blocks.CopyTo(array, arrayIndex); + + /// + /// Removes a block from this group. + /// You should not remove blocks that have been initialized, only those that you placed recently. + /// + /// + /// + /// + public bool Remove(Block item) + { + if (item == null) throw new NullReferenceException("Cannot remove null from a block group"); + bool ret = item.BlockGroup == this; + if (ret) + item.BlockGroup = null; //Calls RemoveInternal + return ret; + } + + internal void RemoveInternal(Block item) => blocks.Remove(item); + + public int Count => blocks.Count; + public bool IsReadOnly { get; } = false; + + public Block this[int index] => blocks[index]; //Setting is not supported, since the order doesn't matter } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs b/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs index 1e5ce21..d1c2639 100644 --- a/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs @@ -5,10 +5,11 @@ using Svelto.ECS; using GamecraftModdingAPI.Engines; using GamecraftModdingAPI.Utility; +using RobocraftX.Blocks; namespace GamecraftModdingAPI.Blocks { - public class BlockEventsEngine : IReactionaryEngine + public class BlockEventsEngine : IReactionaryEngine { public event EventHandler Placed; public event EventHandler Removed; @@ -27,20 +28,20 @@ namespace GamecraftModdingAPI.Blocks public bool isRemovable { get; } = false; private bool shouldAddRemove; - public void Add(ref DBEntityStruct entityComponent, EGID egid) + public void Add(ref BlockTagEntityStruct entityComponent, EGID egid) { if (!(shouldAddRemove = !shouldAddRemove)) return; ExceptionUtil.InvokeEvent(Placed, this, - new BlockPlacedRemovedEventArgs {ID = egid, Type = (BlockIDs) entityComponent.DBID}); + new BlockPlacedRemovedEventArgs {ID = egid}); } - public void Remove(ref DBEntityStruct entityComponent, EGID egid) + public void Remove(ref BlockTagEntityStruct entityComponent, EGID egid) { if (!(shouldAddRemove = !shouldAddRemove)) return; ExceptionUtil.InvokeEvent(Removed, this, - new BlockPlacedRemovedEventArgs {ID = egid, Type = (BlockIDs) entityComponent.DBID}); + new BlockPlacedRemovedEventArgs {ID = egid}); } } diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index 4104ae6..e46ad50 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reflection; using Gamecraft.Blocks.BlockGroups; using Gamecraft.GUI.Blueprints; @@ -21,7 +22,7 @@ using Allocator = Svelto.Common.Allocator; namespace GamecraftModdingAPI.Blocks { - public class BlueprintEngine : IApiEngine + public class BlueprintEngine : IFactoryEngine { private readonly MethodInfo getBlocksFromGroup = AccessTools.Method("RobocraftX.CR.MachineEditing.PlaceBlockUtility:GetBlocksSharingBlockgroup"); @@ -77,12 +78,29 @@ namespace GamecraftModdingAPI.Blocks connectionFactory, default).Complete(); } + public int CreateBlockGroup(float3 position, quaternion rotation) + { + int nextFilterId = BlockGroupUtility.NextFilterId; + Factory.BuildEntity((uint) nextFilterId, + BlockGroupExclusiveGroups.BlockGroupEntityGroup).Init(new BlockGroupTransformEntityComponent + { + blockGroupGridRotation = rotation, + blockGroupGridPosition = position + }); + return nextFilterId; + } + public void SelectBlueprint(uint resourceID) { - BlueprintUtil.SelectBlueprint(null, new BlueprintInventoryItemEntityStruct + if (resourceID == uint.MaxValue) + BlueprintUtil.UnselectBlueprint(entitiesDB); + else { - blueprintResourceId = resourceID, - }); + BlueprintUtil.SelectBlueprint(entitiesDB, new BlueprintInventoryItemEntityStruct + { + blueprintResourceId = resourceID, + }); + } } public uint CreateBlueprint() @@ -91,28 +109,27 @@ namespace GamecraftModdingAPI.Blocks return index; } - public void ReplaceBlueprint(uint playerID, uint blueprintID, Block[] selected, float3 pos, quaternion rot) + public void ReplaceBlueprint(uint playerID, uint blueprintID, ICollection selected, float3 pos, quaternion rot) { - var blockIDs = new EGID[selected.Length]; - for (var i = 0; i < selected.Length; i++) + var blockIDs = new EGID[selected.Count]; + using (var enumerator = selected.GetEnumerator()) { - var block = selected[i]; - blockIDs[i] = block.Id; + for (var i = 0; enumerator.MoveNext(); i++) + { + var block = enumerator.Current; + blockIDs[i] = block.Id; + } } var serializationData = clipboardManager.GetSerializationData(blueprintID); SelectionSerializationUtility.ClearClipboard(playerID, entitiesDB, entityFunctions, serializationData.blueprintData); - if (selected.Length == 0) + if (selected.Count == 0) return; //ref BlockGroupTransformEntityComponent groupTransform = ref EntityNativeDBExtensions.QueryEntity(entitiesDb, (uint) local1.currentBlockGroup, BlockGroupExclusiveGroups.BlockGroupEntityGroup); //ref ColliderAabb collider = ref EntityNativeDBExtensions.QueryEntity(entitiesDB, (uint) groupID, BlockGroupExclusiveGroups.BlockGroupEntityGroup); //float3 bottomOffset = PlaceBlockUtility.GetBottomOffset(collider); //var rootPosition = math.mul(groupTransform.blockGroupGridRotation, bottomOffset) + groupTransform.blockGroupGridPosition; //var rootRotation = groupTransform.blockGroupGridRotation; - if (math.all(pos == default)) - pos = selected[0].Position; - if (math.all(rot.value == default)) - rot = Quaternion.Euler(selected[0].Rotation); clipboardManager.SetGhostSerialized(blueprintID, false); SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, @@ -189,7 +206,7 @@ namespace GamecraftModdingAPI.Blocks } public string Name { get; } = "GamecraftModdingAPIBlueprintGameEngine"; - public bool isRemovable { get; } + public bool isRemovable { get; } = false; [HarmonyPatch] private static class RemoveEnginePatch @@ -225,5 +242,7 @@ namespace GamecraftModdingAPI.Blocks return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.SelectBlockEngine"))[0]; } } + + public IEntityFactory Factory { get; set; } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index cf9a80f..5357e7f 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -53,15 +53,15 @@ namespace GamecraftModdingAPI.Blocks private EntityComponentInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot, uint playerId) { if (_blockEntityFactory == null) - throw new Exception("The factory is null."); + throw new BlockException("The factory is null."); if (uscale < 1) - throw new Exception("Scale needs to be at least 1"); + throw new BlockException("Scale needs to be at least 1"); if (scale.x < 4e-5) scale.x = uscale; if (scale.y < 4e-5) scale.y = uscale; if (scale.z < 4e-5) scale.z = uscale; uint dbid = block; - if (!PrefabsID.DBIDMAP.ContainsKey(dbid)) - throw new Exception("Block with ID " + dbid + " not found!"); + if (!PrefabsID.HasPrefabRegistered(dbid, 0)) + throw new BlockException("Block with ID " + dbid + " not found!"); //RobocraftX.CR.MachineEditing.PlaceBlockEngine ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale}; Quaternion rotQ = Quaternion.Euler(rot); diff --git a/GamecraftModdingAPI/Blueprint.cs b/GamecraftModdingAPI/Blueprint.cs index 26876f6..458c56c 100644 --- a/GamecraftModdingAPI/Blueprint.cs +++ b/GamecraftModdingAPI/Blueprint.cs @@ -1,5 +1,6 @@ using System; using Unity.Mathematics; +using UnityEngine; namespace GamecraftModdingAPI { @@ -35,16 +36,27 @@ namespace GamecraftModdingAPI /// /// Set the blocks that the blueprint contains. + /// Use the BlockGroup overload for automatically calculated position and rotation. /// /// The array of blocks to use /// The anchor position of the blueprint - /// The rotation of the blueprint - public void SetStoredBlocks(Block[] blocks, float3 position = default, float3 rotation = default) + /// The base rotation of the blueprint + public void StoreBlocks(Block[] blocks, float3 position, float3 rotation) { BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, blocks, position, quaternion.Euler(rotation)); } + /// + /// Store the blocks from the given group in the blueprint with correct position and rotation for the blueprint. + /// + /// The block group to store + public void StoreBlocks(BlockGroup group) + { + BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, group, group.Position, + Quaternion.Euler(group.Rotation)); + } + /// /// Places the blocks the blueprint contains at the specified position and rotation. /// diff --git a/GamecraftModdingAPI/Player.cs b/GamecraftModdingAPI/Player.cs index a4b7064..14892a3 100644 --- a/GamecraftModdingAPI/Player.cs +++ b/GamecraftModdingAPI/Player.cs @@ -1,5 +1,5 @@ using System; - +using Gamecraft.GUI.Blueprints; using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; @@ -343,6 +343,17 @@ namespace GamecraftModdingAPI } } + /// + /// The player's selected blueprint in their hand. Set to null to clear. Dispose after usage. + /// + public Blueprint SelectedBlueprint + { + get => playerEngine.GetPlayerStruct(Id, out BlueprintInventoryItemEntityStruct biies) + ? new Blueprint(biies.blueprintResourceId) + : null; + set => BlockGroup._engine.SelectBlueprint(value?.Id ?? uint.MaxValue); + } + // object methods /// diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index f0334aa..fb806ea 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -1,24 +1,29 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; +using System.Reflection.Emit; using System.Text; using HarmonyLib; using IllusionInjector; // test +using GPUInstancer; using Svelto.ECS; using RobocraftX.Blocks; using RobocraftX.Common; using RobocraftX.SimulationModeState; using RobocraftX.FrontEnd; using Unity.Mathematics; +using UnityEngine; using GamecraftModdingAPI.Commands; using GamecraftModdingAPI.Events; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Players; +using EventType = GamecraftModdingAPI.Events.EventType; namespace GamecraftModdingAPI.Tests { @@ -269,6 +274,20 @@ namespace GamecraftModdingAPI.Tests Logging.CommandLog("Health set to: " + val); }).Build(); + CommandBuilder.Builder("placeBlockGroup", "Places some blocks in a group") + .Action((float x, float y, float z) => + { + var pos = new float3(x, y, z); + var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.AluminiumCube, pos, + color: BlockColors.Aqua)); + Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Blue) + .BlockGroup = group; + Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Green) + .BlockGroup = group; + Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Lime) + .BlockGroup = group; + }).Build(); + GameClient.SetDebugInfo("InstalledMods", InstalledMods); Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Type + " with ID " + args.ID); @@ -391,6 +410,88 @@ namespace GamecraftModdingAPI.Tests return ((Action) MinimumSpecsCheck.CheckRequirementsMet).Method; } } + + [HarmonyPatch] + public class BugHuntPatch + { + public static MethodInfo method = + SymbolExtensions.GetMethodInfo(str => Console.WriteLine(str)); + + public static IEnumerable Transpiler(IEnumerable instructions) + { + int i = 0; + foreach (var instruction in instructions) + { + i++; + yield return instruction; //Return the instruction first + //stloc, dup, callvirt + if (instruction.opcode.Name.ToLower().StartsWith("stloc") + || instruction.opcode == OpCodes.Dup + || instruction.opcode == OpCodes.Callvirt) + { + yield return new CodeInstruction(OpCodes.Ldstr, + "Just ran the " + i + ". instruction ending with " + instruction.opcode.Name); + yield return new CodeInstruction(OpCodes.Call, method); + } + } + } + + public static MethodInfo TargetMethod() + { + return AccessTools.Method("RobocraftX.CR.MachineEditing.BoxSelect.CopySelectionEngine:GenerateThumbnail"); + } + } + + [HarmonyPatch] + public class BugHuntPatch2 + { + public static void Prefix(int width, float fieldOfView, Vector3 cameraDirection, Vector3 lightDirection) + { + Console.WriteLine("TakeThumbnail invoked with parameters: " + width + ", " + fieldOfView + ", " + + cameraDirection + ", " + lightDirection); + + GPUInstancerManager manager = GPUInstancerAPI.GetActiveManagers().Find(m => m is GPUInstancerPrefabManager); + Bounds instancesBounds = manager.ComputeInstancesBounds(2); + Console.WriteLine("Bounds: " + instancesBounds); + Console.WriteLine("Size: " + instancesBounds.size); + Console.WriteLine("Size.x < 0: " + (instancesBounds.size.x < 0)); + } + + public static void Postfix(Texture2D __result) + { + Console.WriteLine("TakeThumbnail returned: " + (__result == null ? null : __result.name)); + } + + private delegate Texture2D TakeThumbnailDel(int width, float fieldOfView, Vector3 cameraDirection, + Vector3 lightDirection); + + public static MethodInfo TargetMethod() + { + return ((TakeThumbnailDel) ThumbnailUtility.TakeThumbnail).Method; + } + } + + [HarmonyPatch] + public class BugHuntPatch3 + { + public static void Prefix(int width, int filterLayerMask, GPUInstancerManager manager, + Vector3 cameraPosition, Quaternion cameraRotation, float cameraFov, Vector3 lightDirection, + int cullingLayer) + { + Console.WriteLine("Inner TakeThumbnail invoked with parameters: " + width + ", " + filterLayerMask + + ", " + (manager != null ? manager.name : null) + ", " + cameraPosition + ", " + + cameraRotation + ", " + cameraFov + ", " + lightDirection + ", " + cullingLayer); + } + + private delegate Texture2D TakeThumbnailDel(int width, int filterLayerMask, GPUInstancerManager manager, + Vector3 cameraPosition, Quaternion cameraRotation, float cameraFov, Vector3 lightDirection, + int cullingLayer); + + public static MethodInfo TargetMethod() + { + return ((TakeThumbnailDel) ThumbnailUtility.TakeThumbnail).Method; + } + } } #endif } From 64b42830a3aec0fa7f419ba1d6e4c8805e3ea563 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 13 Nov 2020 21:35:53 +0100 Subject: [PATCH 11/98] Blueprint fixes, bump version, add block copy support Fixed getting the selected blueprint Fixed block groups not being assigned to first block --- GamecraftModdingAPI/Block.cs | 26 + GamecraftModdingAPI/BlockGroup.cs | 4 +- .../Blocks/BlockCloneEngine.cs | 78 + GamecraftModdingAPI/Blocks/BlockEngine.cs | 2 +- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 13 +- .../GamecraftModdingAPI.csproj | 1384 +++++++++-------- GamecraftModdingAPI/Player.cs | 4 +- doxygen.conf | 2 +- 8 files changed, 857 insertions(+), 656 deletions(-) create mode 100644 GamecraftModdingAPI/Blocks/BlockCloneEngine.cs diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 33a1623..59914fd 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -29,6 +29,7 @@ namespace GamecraftModdingAPI protected static readonly SignalEngine SignalEngine = new SignalEngine(); protected static readonly BlockEventsEngine BlockEventsEngine = new BlockEventsEngine(); protected static readonly ScalingEngine ScalingEngine = new ScalingEngine(); + protected static readonly BlockCloneEngine BlockCloneEngine = new BlockCloneEngine(); protected internal static readonly BlockEngine BlockEngine = new BlockEngine(); @@ -229,6 +230,7 @@ namespace GamecraftModdingAPI public EGID Id { get; } internal BlockEngine.BlockInitData InitData; + private EGID copiedFrom; /// /// The block's current position or zero if the block no longer exists. @@ -415,11 +417,34 @@ namespace GamecraftModdingAPI : null); } + /// + /// Creates a copy of the block in the game with the same basic properties and tweakable stats. + /// + /// + public T Copy() where T : Block + { + var block = PlaceNew(Type, Position, Rotation, Color.Color, Color.Darkness, UniformScale, Scale); + block.copiedFrom = Id; + if (Type == BlockIDs.ConsoleBlock + && (this is ConsoleBlock srcCB || (srcCB = Specialise()) != null) + && (block is ConsoleBlock dstCB || (dstCB = block.Specialise()) != null)) + { + //Console block properties are set by a separate engine in the game + dstCB.Arg1 = srcCB.Arg1; + dstCB.Arg2 = srcCB.Arg2; + dstCB.Arg3 = srcCB.Arg3; + dstCB.Command = srcCB.Command; + } + return block; + } + private void OnPlacedInit(object sender, BlockPlacedRemovedEventArgs e) { //Member method instead of lambda to avoid constantly creating delegates if (e.ID != Id) return; Placed -= OnPlacedInit; //And we can reference it InitData = default; //Remove initializer as it's no longer valid - if the block gets removed it shouldn't be used again + if (copiedFrom != EGID.Empty) + BlockCloneEngine.CopyBlockStats(copiedFrom, Id); } public override string ToString() @@ -462,6 +487,7 @@ namespace GamecraftModdingAPI GameEngineManager.AddGameEngine(BlockEventsEngine); GameEngineManager.AddGameEngine(ScalingEngine); GameEngineManager.AddGameEngine(SignalEngine); + GameEngineManager.AddGameEngine(BlockCloneEngine); Wire.signalEngine = SignalEngine; // requires same functionality, no need to duplicate the engine } diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index d660236..a82e776 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -99,7 +99,9 @@ namespace GamecraftModdingAPI /// A new block group containing the given block public static BlockGroup Create(Block block) { - return new BlockGroup(_engine.CreateBlockGroup(default, default), block); + var bg = new BlockGroup(_engine.CreateBlockGroup(default, default), block); + block.BlockGroup = bg; + return bg; } /// diff --git a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs new file mode 100644 index 0000000..d4d16f1 --- /dev/null +++ b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs @@ -0,0 +1,78 @@ +using System; +using System.Reflection; +using GamecraftModdingAPI.Engines; +using HarmonyLib; +using RobocraftX.Blocks; +using RobocraftX.Character; +using RobocraftX.Common; +using RobocraftX.Common.Players; +using Svelto.DataStructures; +using Svelto.ECS; + +namespace GamecraftModdingAPI.Blocks +{ + public class BlockCloneEngine : IApiEngine + { + private static Type copyEngineType = + AccessTools.TypeByName("Gamecraft.GUI.Tweaks.Engines.CopyTweaksOnPickEngine"); + + private MethodBase copyFromBlock = AccessTools.Method(copyEngineType, "CopyTweaksFromBlock"); + private MethodBase copyToBlock = AccessTools.Method(copyEngineType, "ApplyTweaksToPlacedBlock"); + + public void Ready() + { + } + + public EntitiesDB entitiesDB { get; set; } + + public void Dispose() + { + } + + public void CopyBlockStats(EGID sourceID, EGID targetID) + { + var allCharacters = (LocalFasterReadOnlyList) CharacterExclusiveGroups.AllCharacters; + foreach (var ((pickedBlockColl, count), _) in entitiesDB.QueryEntities(allCharacters)) + { + for (int i = 0; i < count; ++i) + { + ref PickedBlockExtraDataStruct pickedBlock = ref pickedBlockColl[i]; + var oldStruct = pickedBlock; + pickedBlock.pickedBlockEntityID = sourceID; + pickedBlock.placedBlockEntityID = targetID; + pickedBlock.placedBlockTweaksCopied = false; + pickedBlock.placedBlockTweaksMustCopy = true; + if (entitiesDB.Exists(pickedBlock.pickedBlockEntityID) + && entitiesDB.Exists(pickedBlock.placedBlockEntityID)) + { + copyFromBlock.Invoke(Patch.instance, new object[] {pickedBlock.ID, pickedBlock}); + copyToBlock.Invoke(Patch.instance, new object[] {pickedBlock.ID, pickedBlock}); + pickedBlock.placedBlockTweaksMustCopy = false; + pickedBlock.placedBlockTweaksCopied = false; + } + + pickedBlock = oldStruct; //Make sure to not interfere with the game + } + } + } + + [HarmonyPatch] + private static class Patch + { + public static object instance; + + public static void Postfix(object __instance) + { + instance = __instance; + } + + public static MethodBase TargetMethod() + { + return AccessTools.GetDeclaredConstructors(copyEngineType)[0]; + } + } + + public string Name { get; } = "GamecraftModdingAPIBlockCloneGameEngine"; + public bool isRemovable { get; } = false; + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 9ce6d62..351d686 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -8,7 +8,7 @@ using Gamecraft.Wires; using RobocraftX.Blocks; using RobocraftX.Common; using RobocraftX.Physics; -using RobocraftX.Scene.Simulation; + using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Hybrid; diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index e46ad50..1936a17 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -95,12 +95,7 @@ namespace GamecraftModdingAPI.Blocks if (resourceID == uint.MaxValue) BlueprintUtil.UnselectBlueprint(entitiesDB); else - { - BlueprintUtil.SelectBlueprint(entitiesDB, new BlueprintInventoryItemEntityStruct - { - blueprintResourceId = resourceID, - }); - } + BlueprintUtil.SelectBlueprint(entitiesDB, resourceID, false, -1); } public uint CreateBlueprint() @@ -122,7 +117,7 @@ namespace GamecraftModdingAPI.Blocks } var serializationData = clipboardManager.GetSerializationData(blueprintID); - SelectionSerializationUtility.ClearClipboard(playerID, entitiesDB, entityFunctions, serializationData.blueprintData); + SelectionSerializationUtility.ClearClipboard(playerID, entitiesDB, entityFunctions, serializationData.blueprintData, -1); if (selected.Count == 0) return; //ref BlockGroupTransformEntityComponent groupTransform = ref EntityNativeDBExtensions.QueryEntity(entitiesDb, (uint) local1.currentBlockGroup, BlockGroupExclusiveGroups.BlockGroupEntityGroup); @@ -134,7 +129,7 @@ namespace GamecraftModdingAPI.Blocks clipboardManager.SetGhostSerialized(blueprintID, false); SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, serializationData.blueprintData, entitySerialization, entityFactory, blockIDs, - (uint) blockIDs.Length, pos, rot); + (uint) blockIDs.Length, pos, rot, -1); } public Block[] PlaceBlueprintBlocks(uint blueprintID, uint playerID, float3 pos, float3 rot) @@ -173,7 +168,7 @@ namespace GamecraftModdingAPI.Blocks new object[] { playerID, grid, poss, rots, selectionPosition, selectionRotation, blueprintData, - entitiesDB, entitySerialization, nextFilterId1 + entitySerialization, nextFilterId1 }); /* uint playerId, in GridRotationStruct ghostParentGrid, diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 88d16f8..88002d0 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -2,7 +2,7 @@ net472 true - 1.7.0 + 1.8.0 Exmods GNU General Public Licence 3+ https://git.exmods.org/modtainers/GamecraftModdingAPI @@ -17,7 +17,7 @@ DEBUG;TEST;TRACE - + @@ -26,6 +26,310 @@ + + ..\ref\Gamecraft_Data\Managed\Accessibility.dll + ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll + + + ..\ref\Gamecraft_Data\Managed\Analytics.dll + ..\..\ref\Gamecraft_Data\Managed\Analytics.dll + + + ..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll + ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll + + + ..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll + ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll + + + ..\ref\Gamecraft_Data\Managed\Authentication.dll + ..\..\ref\Gamecraft_Data\Managed\Authentication.dll + + + ..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\CommandLine.dll + ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll + + + ..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll + + + ..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll + + + ..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll + ..\..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll + + + ..\ref\Gamecraft_Data\Managed\DataLoader.dll + ..\..\ref\Gamecraft_Data\Managed\DataLoader.dll + + + ..\ref\Gamecraft_Data\Managed\DDNA.dll + ..\..\ref\Gamecraft_Data\Managed\DDNA.dll + + + ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + + + ..\ref\Gamecraft_Data\Managed\FMOD.dll + ..\..\ref\Gamecraft_Data\Managed\FMOD.dll + + + ..\ref\Gamecraft_Data\Managed\FullGame.dll + ..\..\ref\Gamecraft_Data\Managed\FullGame.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockGroups.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockGroups.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + + + ..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + ..\..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.ColourPalette.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ColourPalette.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Blueprints.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Blueprints.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintSets.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintSets.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ModeBar.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ModeBar.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUIs.Hotbar.BlueprintsHotbar.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUIs.Hotbar.BlueprintsHotbar.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll + + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll + + + ..\ref\Gamecraft_Data\Managed\GameState.dll + ..\..\ref\Gamecraft_Data\Managed\GameState.dll + + + ..\ref\Gamecraft_Data\Managed\GhostShark.Outline.dll + ..\..\ref\Gamecraft_Data\Managed\GhostShark.Outline.dll + + + ..\ref\Gamecraft_Data\Managed\GPUInstancer.dll + ..\..\ref\Gamecraft_Data\Managed\GPUInstancer.dll + + + ..\ref\Gamecraft_Data\Managed\Havok.Physics.dll + ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.dll + + + ..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll + ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll ..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll @@ -34,22 +338,26 @@ ..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll ..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll - - ..\ref\Gamecraft_Data\Managed\Accessibility.dll - ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll - - - ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\ref\Gamecraft_Data\Managed\JWT.dll ..\..\ref\Gamecraft_Data\Managed\JWT.dll + + ..\ref\Gamecraft_Data\Managed\LZ4.dll + ..\..\ref\Gamecraft_Data\Managed\LZ4.dll + ..\ref\Gamecraft_Data\Managed\mscorlib.dll ..\..\ref\Gamecraft_Data\Managed\mscorlib.dll + + ..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll + ..\..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll + + + ..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll + ..\..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll + ..\ref\Gamecraft_Data\Managed\netstandard.dll ..\..\ref\Gamecraft_Data\Managed\netstandard.dll @@ -62,6 +370,10 @@ ..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll ..\..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll + + ..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll + ..\..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll + ..\ref\Gamecraft_Data\Managed\Rewired_Core.dll ..\..\ref\Gamecraft_Data\Managed\Rewired_Core.dll @@ -70,10 +382,418 @@ ..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll ..\..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll + + ..\ref\Gamecraft_Data\Managed\RobocraftECS.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftECS.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Hotbar.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Hotbar.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.TabsBar.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.TabsBar.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll + + + ..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll + + + ..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll + + + ..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + + + ..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll + + + ..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll + ..\..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll + + + ..\ref\Gamecraft_Data\Managed\StringFormatter.dll + ..\..\ref\Gamecraft_Data\Managed\StringFormatter.dll + + + ..\ref\Gamecraft_Data\Managed\Svelto.Common.dll + ..\..\ref\Gamecraft_Data\Managed\Svelto.Common.dll + + + ..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll + ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll + + + ..\ref\Gamecraft_Data\Managed\Svelto.Services.dll + ..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll + + + ..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll + ..\..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll + + + ..\ref\Gamecraft_Data\Managed\UltimateDecals.dll + ..\..\ref\Gamecraft_Data\Managed\UltimateDecals.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Burst.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.dll + ..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll + + ..\ref\Gamecraft_Data\Managed\Unity.Collections.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Entities.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.002.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.002.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Physics.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Properties.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Scenes.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Scenes.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + ..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll @@ -242,10 +962,18 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll + + ..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll + ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll + ..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll + + ..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsNativeModule.dll + ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsNativeModule.dll + ..\ref\Gamecraft_Data\Managed\UnityEngine.UIModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIModule.dll @@ -302,6 +1030,10 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.VideoModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VideoModule.dll + + ..\ref\Gamecraft_Data\Managed\UnityEngine.VirtualTexturingModule.dll + ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VirtualTexturingModule.dll + ..\ref\Gamecraft_Data\Managed\UnityEngine.VRModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VRModule.dll @@ -314,638 +1046,6 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll - - ..\ref\Gamecraft_Data\Managed\Analytics.dll - ..\..\ref\Gamecraft_Data\Managed\Analytics.dll - - - ..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll - ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll - - - ..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll - ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll - - - ..\ref\Gamecraft_Data\Managed\Authentication.dll - ..\..\ref\Gamecraft_Data\Managed\Authentication.dll - - - ..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\CommandLine.dll - ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll - - - ..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll - ..\..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll - - - ..\ref\Gamecraft_Data\Managed\DataLoader.dll - ..\..\ref\Gamecraft_Data\Managed\DataLoader.dll - - - ..\ref\Gamecraft_Data\Managed\DDNA.dll - ..\..\ref\Gamecraft_Data\Managed\DDNA.dll - - - ..\ref\Gamecraft_Data\Managed\FMOD.dll - ..\..\ref\Gamecraft_Data\Managed\FMOD.dll - - - ..\ref\Gamecraft_Data\Managed\FullGame.dll - ..\..\ref\Gamecraft_Data\Managed\FullGame.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll - - - ..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll - ..\..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll - - - ..\ref\Gamecraft_Data\Managed\GameState.dll - ..\..\ref\Gamecraft_Data\Managed\GameState.dll - - - ..\ref\Gamecraft_Data\Managed\GPUInstancer.dll - ..\..\ref\Gamecraft_Data\Managed\GPUInstancer.dll - - - ..\ref\Gamecraft_Data\Managed\Havok.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.dll - - - ..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\IL3DN_FOG.dll - ..\..\ref\Gamecraft_Data\Managed\IL3DN_FOG.dll - - - ..\ref\Gamecraft_Data\Managed\LZ4.dll - ..\..\ref\Gamecraft_Data\Managed\LZ4.dll - - - ..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll - ..\..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll - - - ..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll - ..\..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll - - - ..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll - ..\..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftECS.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftECS.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll - - - ..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll - ..\..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll - - - ..\ref\Gamecraft_Data\Managed\StringFormatter.dll - ..\..\ref\Gamecraft_Data\Managed\StringFormatter.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.Common_3.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Common_3.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.Services.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll - - - ..\ref\Gamecraft_Data\Managed\UltimateDecals.dll - ..\..\ref\Gamecraft_Data\Managed\UltimateDecals.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Burst.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Collections.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Scenes.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Scenes.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - ..\ref\Gamecraft_Data\Managed\uREPL.dll ..\..\ref\Gamecraft_Data\Managed\uREPL.dll diff --git a/GamecraftModdingAPI/Player.cs b/GamecraftModdingAPI/Player.cs index 14892a3..4778e02 100644 --- a/GamecraftModdingAPI/Player.cs +++ b/GamecraftModdingAPI/Player.cs @@ -348,8 +348,8 @@ namespace GamecraftModdingAPI /// public Blueprint SelectedBlueprint { - get => playerEngine.GetPlayerStruct(Id, out BlueprintInventoryItemEntityStruct biies) - ? new Blueprint(biies.blueprintResourceId) + get => playerEngine.GetPlayerStruct(Id, out LocalBlueprintInputStruct lbis) + ? new Blueprint(lbis.selectedBlueprintId) : null; set => BlockGroup._engine.SelectBlueprint(value?.Id ?? uint.MaxValue); } diff --git a/doxygen.conf b/doxygen.conf index bf447b4..4b1eaed 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "GamecraftModdingAPI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "v1.5.0" +PROJECT_NUMBER = "v1.8.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 680721256c101fc2ddeab01323ab89850e41fb72 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 13 Nov 2020 23:59:37 +0100 Subject: [PATCH 12/98] Add support for copying wires, some fixes and additions Removing blocks from groups when they are removed from the game Attempted to update graphics when changing blocks Disallowing changing the block group after creation, now that we can copy blocks --- GamecraftModdingAPI/Block.cs | 20 +++++++-- GamecraftModdingAPI/BlockGroup.cs | 28 ++++++++++-- .../Blocks/BlockCloneEngine.cs | 44 ++++++++++++++++--- GamecraftModdingAPI/Blocks/BlockEngine.cs | 11 +++++ GamecraftModdingAPI/Blocks/PlacementEngine.cs | 7 +++ 5 files changed, 97 insertions(+), 13 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 59914fd..0fecf40 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -244,6 +244,7 @@ namespace GamecraftModdingAPI MovementEngine.MoveBlock(Id, InitData, value); if (blockGroup != null) blockGroup.PosAndRotCalculated = false; + BlockEngine.UpdateDisplayedBlock(Id); } } @@ -258,6 +259,7 @@ namespace GamecraftModdingAPI RotationEngine.RotateBlock(Id, InitData, value); if (blockGroup != null) blockGroup.PosAndRotCalculated = false; + BlockEngine.UpdateDisplayedBlock(Id); } } @@ -273,6 +275,7 @@ namespace GamecraftModdingAPI BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, float3 val) => st.scale = val, value); if (!Exists) return; //UpdateCollision needs the block to exist ScalingEngine.UpdateCollision(Id); + BlockEngine.UpdateDisplayedBlock(Id); } } @@ -364,8 +367,10 @@ namespace GamecraftModdingAPI /// /// Returns the block group this block is a part of. Block groups can be placed using blueprints. /// Returns null if not part of a group.
- /// Setting the group after the block has been initialized will not update everything properly. - /// You should only set this property on blocks newly placed by your code. + /// Setting the group after the block has been initialized will not update everything properly, + /// so you can only set this property on blocks newly placed by your code.
+ /// To set it for existing blocks, you can use the Copy() method and set the property on the resulting block + /// (and remove this block). ///
public BlockGroup BlockGroup { @@ -378,6 +383,15 @@ namespace GamecraftModdingAPI } set { + if (Exists) + { + /*var copy = Copy(); + copy.BlockGroup = value; //It won't run this on the new instance as it won't 'exist' yet + Remove();*/ + Logging.LogWarning("Attempted to set group of existing block. This is not supported." + + " Copy the block and set the group of the resulting block."); + return; + } blockGroup?.RemoveInternal(this); BlockEngine.SetBlockInfo(this, (ref BlockGroupEntityComponent bgec, BlockGroup val) => bgec.currentBlockGroup = val?.Id ?? -1, @@ -418,7 +432,7 @@ namespace GamecraftModdingAPI } /// - /// Creates a copy of the block in the game with the same basic properties and tweakable stats. + /// Creates a copy of the block in the game with the same properties, stats and wires. /// /// public T Copy() where T : Block diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index a82e776..4a0d994 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -12,9 +12,9 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI { /// - /// A group of blocks that can be selected together. The placed version of blueprints. + /// A group of blocks that can be selected together. The placed version of blueprints. Dispose after usage. /// - public class BlockGroup : ICollection + public class BlockGroup : ICollection, IDisposable { internal static BlueprintEngine _engine = new BlueprintEngine(); public int Id { get; } @@ -30,8 +30,30 @@ namespace GamecraftModdingAPI Id = id; sourceBlock = block; blocks = new List(GetBlocks()); + Block.Removed += OnBlockRemoved; } - + + private void OnBlockRemoved(object sender, BlockPlacedRemovedEventArgs e) + { + //blocks.RemoveAll(block => block.Id == e.ID); - Allocation heavy + int index = -1; + for (int i = 0; i < blocks.Count; i++) + { + if (blocks[i].Id == e.ID) + { + index = i; + break; + } + } + + if (index != -1) blocks.RemoveAt(index); + } + + public void Dispose() + { + Block.Removed -= OnBlockRemoved; + } + /// /// The position of the block group (center). Recalculated if blocks have been added/removed since the last query. /// diff --git a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs index d4d16f1..0acf44d 100644 --- a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Reflection; +using Gamecraft.Wires; using GamecraftModdingAPI.Engines; using HarmonyLib; using RobocraftX.Blocks; @@ -15,9 +17,15 @@ namespace GamecraftModdingAPI.Blocks { private static Type copyEngineType = AccessTools.TypeByName("Gamecraft.GUI.Tweaks.Engines.CopyTweaksOnPickEngine"); + private static Type copyWireEngineType = + AccessTools.TypeByName("Gamecraft.Wires.WireConnectionCopyOnPickEngine"); + private static Type createWireEngineType = + AccessTools.TypeByName("RobocraftX.GUI.Wires.WireConnectionCreateOnPlaceEngine"); private MethodBase copyFromBlock = AccessTools.Method(copyEngineType, "CopyTweaksFromBlock"); private MethodBase copyToBlock = AccessTools.Method(copyEngineType, "ApplyTweaksToPlacedBlock"); + private MethodBase copyWireFromBlock = AccessTools.Method(copyWireEngineType, "CopyWireInputsAndOutputs"); + private MethodBase copyWireToBlock = AccessTools.Method(createWireEngineType, "PlaceWiresOnPlaceNewCube"); public void Ready() { @@ -45,13 +53,23 @@ namespace GamecraftModdingAPI.Blocks if (entitiesDB.Exists(pickedBlock.pickedBlockEntityID) && entitiesDB.Exists(pickedBlock.placedBlockEntityID)) { - copyFromBlock.Invoke(Patch.instance, new object[] {pickedBlock.ID, pickedBlock}); - copyToBlock.Invoke(Patch.instance, new object[] {pickedBlock.ID, pickedBlock}); + copyFromBlock.Invoke(Patch.copyEngine, new object[] {pickedBlock.ID, pickedBlock}); + + uint playerID = Player.LocalPlayer.Id; + var parameters = new object[] {playerID, pickedBlock}; + copyWireFromBlock.Invoke(Patch.copyWireEngine, parameters); + pickedBlock = (PickedBlockExtraDataStruct) parameters[1]; //ref arg + + copyToBlock.Invoke(Patch.copyEngine, new object[] {pickedBlock.ID, pickedBlock}); + + ExclusiveGroupStruct group = WiresExclusiveGroups.WIRES_COPY_GROUP + playerID; + copyWireToBlock.Invoke(Patch.createWireEngine, new object[] {group, pickedBlock.ID}); + pickedBlock.placedBlockTweaksMustCopy = false; pickedBlock.placedBlockTweaksCopied = false; } - pickedBlock = oldStruct; //Make sure to not interfere with the game + pickedBlock = oldStruct; //Make sure to not interfere with the game - Although that might not be the case with the wire copying } } } @@ -59,16 +77,28 @@ namespace GamecraftModdingAPI.Blocks [HarmonyPatch] private static class Patch { - public static object instance; + public static object copyEngine; + public static object copyWireEngine; + public static object createWireEngine; public static void Postfix(object __instance) { - instance = __instance; + if (__instance.GetType() == copyEngineType) + copyEngine = __instance; + else if (__instance.GetType() == copyWireEngineType) + copyWireEngine = __instance; + else if (__instance.GetType() == createWireEngineType) + createWireEngine = __instance; } - public static MethodBase TargetMethod() + public static IEnumerable TargetMethods() { - return AccessTools.GetDeclaredConstructors(copyEngineType)[0]; + return new[] + { + AccessTools.GetDeclaredConstructors(copyEngineType)[0], + AccessTools.GetDeclaredConstructors(copyWireEngineType)[0], + AccessTools.GetDeclaredConstructors(createWireEngineType)[0] + }; } } diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 351d686..2da04a3 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -8,6 +8,8 @@ using Gamecraft.Wires; using RobocraftX.Blocks; using RobocraftX.Common; using RobocraftX.Physics; +using RobocraftX.Rendering; +using Svelto.ECS.EntityStructs; using Svelto.DataStructures; using Svelto.ECS; @@ -149,6 +151,15 @@ namespace GamecraftModdingAPI.Blocks } } + public void UpdateDisplayedBlock(EGID id) + { + if (!BlockExists(id)) return; + var pos = entitiesDB.QueryEntity(id); + var rot = entitiesDB.QueryEntity(id); + var scale = entitiesDB.QueryEntity(id); + entitiesDB.QueryEntity(id).matrix = float4x4.TRS(pos.position, rot.rotation, scale.scale); + } + public bool BlockExists(EGID blockID) { return entitiesDB.Exists(blockID); diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index 5357e7f..fab9c62 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -101,6 +101,13 @@ namespace GamecraftModdingAPI.Blocks loadedFromDisk = false, placedBy = playerId }); + + /*structInitializer.Init(new CollisionFilterOverride + { + belongsTo = 32U, + collidesWith = 239532U + });*/ + PrimaryRotationUtility.InitialisePrimaryDirection(rotation.rotation, ref structInitializer); EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup); ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity(playerEGID); From f30dcd251fb291b21a44531d10e959f215e5bc12 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 14 Nov 2020 02:52:16 +0100 Subject: [PATCH 13/98] Displaying blueprint before placing, enums, ToString()s Added support for getting the player's current building mode (build, color, config, blueprint) Added support for getting the current game's mode (building, playing, prefab etc.) --- GamecraftModdingAPI/App/CurrentGameMode.cs | 23 +++++++++ GamecraftModdingAPI/App/Game.cs | 12 +++++ GamecraftModdingAPI/BlockGroup.cs | 5 ++ GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 47 +++++++++++++++++++ GamecraftModdingAPI/Blueprint.cs | 5 ++ GamecraftModdingAPI/Player.cs | 9 +++- .../Players/PlayerBuildingMode.cs | 10 ++++ 7 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 GamecraftModdingAPI/App/CurrentGameMode.cs create mode 100644 GamecraftModdingAPI/Players/PlayerBuildingMode.cs diff --git a/GamecraftModdingAPI/App/CurrentGameMode.cs b/GamecraftModdingAPI/App/CurrentGameMode.cs new file mode 100644 index 0000000..84a6d78 --- /dev/null +++ b/GamecraftModdingAPI/App/CurrentGameMode.cs @@ -0,0 +1,23 @@ +namespace GamecraftModdingAPI.App +{ + public enum CurrentGameMode + { + None, + /// + /// Building a game + /// + Build, + /// + /// Playing a game + /// + Play, + /// + /// Viewing a prefab + /// + View, + /// + /// Viewing a tutorial + /// + Tutorial + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/App/Game.cs b/GamecraftModdingAPI/App/Game.cs index d6a4eff..3d73478 100644 --- a/GamecraftModdingAPI/App/Game.cs +++ b/GamecraftModdingAPI/App/Game.cs @@ -335,6 +335,18 @@ namespace GamecraftModdingAPI.App gameEngine.ToggleTimeMode(); } + /// + /// The mode of the game. + /// + public CurrentGameMode Mode + { + get + { + if (menuMode || !VerifyMode()) return CurrentGameMode.None; + return (CurrentGameMode) GameMode.CurrentMode; + } + } + /// /// Load the game save. /// This happens asynchronously, so when this method returns the game not loaded yet. diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index 4a0d994..eee660a 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -203,5 +203,10 @@ namespace GamecraftModdingAPI public bool IsReadOnly { get; } = false; public Block this[int index] => blocks[index]; //Setting is not supported, since the order doesn't matter + + public override string ToString() + { + return $"{nameof(Id)}: {Id}, {nameof(Position)}: {Position}, {nameof(Rotation)}: {Rotation}, {nameof(Count)}: {Count}"; + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index 1936a17..619fda1 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -36,6 +36,10 @@ namespace GamecraftModdingAPI.Blocks AccessTools.DeclaredField(PlaceBlueprintUtilityType, "_localBlockMap"); private static readonly MethodInfo BuildBlock = AccessTools.Method(PlaceBlueprintUtilityType, "BuildBlock"); private static readonly MethodInfo BuildWires = AccessTools.Method(PlaceBlueprintUtilityType, "BuildWires"); + private static readonly Type SerializeGhostBlueprintType = + AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BoxSelect.SerializeGhostChildrenOnAddEngine"); + private static readonly MethodInfo SerializeGhostBlueprint = + AccessTools.Method(SerializeGhostBlueprintType, "SerializeClipboardGhostEntities"); private static NativeEntityRemove nativeRemove; private static MachineGraphConnectionEntityFactory connectionFactory; @@ -44,6 +48,8 @@ namespace GamecraftModdingAPI.Blocks private static IEntitySerialization entitySerialization; private static IEntityFactory entityFactory; private static FasterList globalBlockMap; + private static object SerializeGhostBlueprintInstance; + private static GhostChildEntityFactory BuildGhostBlueprintFactory; public void Ready() { @@ -130,6 +136,19 @@ namespace GamecraftModdingAPI.Blocks SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, serializationData.blueprintData, entitySerialization, entityFactory, blockIDs, (uint) blockIDs.Length, pos, rot, -1); + BuildGhostBlueprint(selected, pos, rot, playerID); + SerializeGhostBlueprint.Invoke(SerializeGhostBlueprintInstance, new object[] {playerID, blueprintID}); + + } + + private void BuildGhostBlueprint(ICollection blocks, float3 pos, quaternion rot, uint playerID) + { + GhostChildUtility.ClearGhostChildren(playerID, entitiesDB, entityFunctions); + foreach (var block in blocks) + { + GhostChildUtility.BuildGhostChild(in playerID, block.Id, in pos, in rot, entitiesDB, + BuildGhostBlueprintFactory, false); + } } public Block[] PlaceBlueprintBlocks(uint blueprintID, uint playerID, float3 pos, float3 rot) @@ -238,6 +257,34 @@ namespace GamecraftModdingAPI.Blocks } } + [HarmonyPatch] + private static class SerializeGhostBlueprintPatch + { + public static void Postfix(object __instance) + { + SerializeGhostBlueprintInstance = __instance; + } + + public static MethodBase TargetMethod() + { + return AccessTools.GetDeclaredConstructors(SerializeGhostBlueprintType)[0]; + } + } + + [HarmonyPatch] + private static class BuildGhostBlueprintPatch + { + public static void Postfix(GhostChildEntityFactory ghostChildEntityFactory) + { + BuildGhostBlueprintFactory = ghostChildEntityFactory; + } + + public static MethodBase TargetMethod() + { + return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine"))[0]; + } + } + public IEntityFactory Factory { get; set; } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blueprint.cs b/GamecraftModdingAPI/Blueprint.cs index 458c56c..765de3d 100644 --- a/GamecraftModdingAPI/Blueprint.cs +++ b/GamecraftModdingAPI/Blueprint.cs @@ -72,5 +72,10 @@ namespace GamecraftModdingAPI { BlockGroup._engine.DisposeBlueprint(Id); } + + public override string ToString() + { + return $"{nameof(Id)}: {Id}"; + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Player.cs b/GamecraftModdingAPI/Player.cs index 4778e02..0bed6a2 100644 --- a/GamecraftModdingAPI/Player.cs +++ b/GamecraftModdingAPI/Player.cs @@ -1,5 +1,4 @@ using System; -using Gamecraft.GUI.Blueprints; using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; @@ -354,7 +353,13 @@ namespace GamecraftModdingAPI set => BlockGroup._engine.SelectBlueprint(value?.Id ?? uint.MaxValue); } - // object methods + /// + /// The player's mode in time stopped mode, determining what they place. + /// + public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine + .GetCharacterStruct(Id, out _).timeStoppedContext; + + // object methods /// /// Teleport the player to the specified coordinates. diff --git a/GamecraftModdingAPI/Players/PlayerBuildingMode.cs b/GamecraftModdingAPI/Players/PlayerBuildingMode.cs new file mode 100644 index 0000000..c7a5e37 --- /dev/null +++ b/GamecraftModdingAPI/Players/PlayerBuildingMode.cs @@ -0,0 +1,10 @@ +namespace GamecraftModdingAPI.Players +{ + public enum PlayerBuildingMode + { + BlockMode, + ColourMode, + ConfigMode, + BlueprintMode + } +} \ No newline at end of file From 1f911b1d32dd498c69852f86d8eba4d4e941a11a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 14 Nov 2020 18:29:48 +0100 Subject: [PATCH 14/98] Fix move/rotate during init, add blueprint properties --- GamecraftModdingAPI/BlockGroup.cs | 8 ++-- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 14 ++++++- GamecraftModdingAPI/Blocks/MovementEngine.cs | 6 +-- GamecraftModdingAPI/Blocks/RotationEngine.cs | 6 +-- GamecraftModdingAPI/Blueprint.cs | 41 ++++++++++++++----- 5 files changed, 54 insertions(+), 21 deletions(-) diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index eee660a..6c600b2 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -115,7 +115,7 @@ namespace GamecraftModdingAPI /// /// Creates a new block group consisting of a single block. /// You can add more blocks using the Add() method or by setting the BlockGroup property of the blocks.
- /// Note that only newly placed blocks should be added to groups. + /// Note that only newly placed blocks can be added to groups. ///
/// The block to add /// A new block group containing the given block @@ -155,7 +155,7 @@ namespace GamecraftModdingAPI IEnumerator IEnumerable.GetEnumerator() => blocks.GetEnumerator(); /// - /// Adds a block to the group. You should only add newly placed blocks + /// Adds a block to the group. You can only add newly placed blocks /// so that the game initializes the group membership properly. /// /// @@ -170,7 +170,7 @@ namespace GamecraftModdingAPI /// /// Removes all blocks from this group. - /// You should not remove blocks that have been initialized, only those that you placed recently. + /// You cannot remove blocks that have been initialized, only those that you placed recently. /// public void Clear() { @@ -183,7 +183,7 @@ namespace GamecraftModdingAPI /// /// Removes a block from this group. - /// You should not remove blocks that have been initialized, only those that you placed recently. + /// You cannot remove blocks that have been initialized, only those that you placed recently. /// /// /// diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index 619fda1..ff22a4c 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -209,6 +209,18 @@ namespace GamecraftModdingAPI.Blocks return blocks; } + public void GetBlueprintInfo(uint blueprintID, out float3 pos, out quaternion rot, out uint selectionSize) + { + var serializationData = clipboardManager.GetSerializationData(blueprintID); + var blueprintData = serializationData.blueprintData; + blueprintData.dataPos = 0U; + BoxSelectSerializationUtilities.ReadClipboardHeader(blueprintData, out selectionSize, out var posst, + out var rotst, out _); + blueprintData.dataPos = 0U; //Just to be sure, it gets reset when it's read anyway + pos = posst.position; + rot = rotst.rotation; + } + public void InitBlueprint(uint blueprintID) { clipboardManager.IncrementRefCount(blueprintID); @@ -280,7 +292,7 @@ namespace GamecraftModdingAPI.Blocks } public static MethodBase TargetMethod() - { + {RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine"))[0]; } } diff --git a/GamecraftModdingAPI/Blocks/MovementEngine.cs b/GamecraftModdingAPI/Blocks/MovementEngine.cs index a4ac0fa..fb3aa55 100644 --- a/GamecraftModdingAPI/Blocks/MovementEngine.cs +++ b/GamecraftModdingAPI/Blocks/MovementEngine.cs @@ -41,9 +41,9 @@ namespace GamecraftModdingAPI.Blocks { if (data.Group == null) return float3.zero; var init = new EntityComponentInitializer(blockID, data.Group); - init.Init(new PositionEntityStruct {position = vector}); - init.Init(new GridRotationStruct {position = vector}); - init.Init(new LocalTransformEntityStruct {position = vector}); + init.GetOrCreate().position = vector; + init.GetOrCreate().position = vector; + init.GetOrCreate().position = vector; return vector; } ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(blockID); diff --git a/GamecraftModdingAPI/Blocks/RotationEngine.cs b/GamecraftModdingAPI/Blocks/RotationEngine.cs index ca97874..fbf8c98 100644 --- a/GamecraftModdingAPI/Blocks/RotationEngine.cs +++ b/GamecraftModdingAPI/Blocks/RotationEngine.cs @@ -41,9 +41,9 @@ namespace GamecraftModdingAPI.Blocks { if (data.Group == null) return float3.zero; var init = new EntityComponentInitializer(blockID, data.Group); - init.Init(new RotationEntityStruct {rotation = new Quaternion {eulerAngles = vector}}); - init.Init(new GridRotationStruct {rotation = new Quaternion {eulerAngles = vector}}); - init.Init(new LocalTransformEntityStruct {rotation = new Quaternion {eulerAngles = vector}}); + init.GetOrCreate().rotation = Quaternion.Euler(vector); + init.GetOrCreate().rotation = Quaternion.Euler(vector); + init.GetOrCreate().rotation = Quaternion.Euler(vector); return vector; } ref RotationEntityStruct rotStruct = ref this.entitiesDB.QueryEntity(blockID); diff --git a/GamecraftModdingAPI/Blueprint.cs b/GamecraftModdingAPI/Blueprint.cs index 765de3d..4d9dff0 100644 --- a/GamecraftModdingAPI/Blueprint.cs +++ b/GamecraftModdingAPI/Blueprint.cs @@ -15,15 +15,23 @@ namespace GamecraftModdingAPI { Id = id; BlockGroup._engine.InitBlueprint(id); + Refresh(); } - - /*public static void SelectBlueprint(Blueprint blueprint) - { - BlueprintUtil.SelectBlueprint(null, new BlueprintInventoryItemEntityStruct - { - blueprintResourceId = blueprint.Id - }); - }*/ + + /// + /// The center of the blueprint. Can only be set using the StoreBlocks() method. + /// + public float3 Position { get; private set; } + + /// + /// The rotation of the blueprint. Can only be set using the StoreBlocks() method. + /// + public float3 Rotation { get; private set; } + + /// + /// The amount of blocks in the blueprint. Gan only be set using the StoreBlocks() method. + /// + public uint BlockCount { get; private set; } /// /// Creates a new, empty blueprint. It will be deleted on disposal unless the game holds a reference to it. @@ -39,12 +47,13 @@ namespace GamecraftModdingAPI /// Use the BlockGroup overload for automatically calculated position and rotation. /// /// The array of blocks to use - /// The anchor position of the blueprint + /// The anchor (center) position of the blueprint /// The base rotation of the blueprint public void StoreBlocks(Block[] blocks, float3 position, float3 rotation) { BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, blocks, position, quaternion.Euler(rotation)); + Refresh(); } /// @@ -55,6 +64,7 @@ namespace GamecraftModdingAPI { BlockGroup._engine.ReplaceBlueprint(Player.LocalPlayer.Id, Id, group, group.Position, Quaternion.Euler(group.Rotation)); + Refresh(); } /// @@ -68,6 +78,17 @@ namespace GamecraftModdingAPI return BlockGroup._engine.PlaceBlueprintBlocks(Id, Player.LocalPlayer.Id, position, rotation); } + /// + /// Updates the properties based on the blueprint data. Only necessary if the blueprint is changed from the game. + /// + public void Refresh() + { + BlockGroup._engine.GetBlueprintInfo(Id, out var pos, out var rot, out uint count); + Position = pos; + Rotation = ((Quaternion) rot).eulerAngles; + BlockCount = count; + } + public void Dispose() { BlockGroup._engine.DisposeBlueprint(Id); @@ -75,7 +96,7 @@ namespace GamecraftModdingAPI public override string ToString() { - return $"{nameof(Id)}: {Id}"; + return $"{nameof(Id)}: {Id}, {nameof(Position)}: {Position}, {nameof(Rotation)}: {Rotation}, {nameof(BlockCount)}: {BlockCount}"; } } } \ No newline at end of file From fad3b5cbf4abb7aa7a714751de57b1cb242fc8bc Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 14 Nov 2020 22:43:45 +0100 Subject: [PATCH 15/98] Fix picking block groups... --- GamecraftModdingAPI/Block.cs | 5 +- GamecraftModdingAPI/BlockGroup.cs | 12 ++- GamecraftModdingAPI/Blocks/BlueprintEngine.cs | 55 ++++++++----- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 2 +- .../GamecraftModdingAPI.csproj | 2 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 82 ------------------- doxygen.conf | 2 +- 7 files changed, 48 insertions(+), 112 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 0fecf40..d0ff657 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -365,7 +365,7 @@ namespace GamecraftModdingAPI private BlockGroup blockGroup; /// - /// Returns the block group this block is a part of. Block groups can be placed using blueprints. + /// Returns the block group this block is a part of. Block groups can also be placed using blueprints. /// Returns null if not part of a group.
/// Setting the group after the block has been initialized will not update everything properly, /// so you can only set this property on blocks newly placed by your code.
@@ -385,9 +385,6 @@ namespace GamecraftModdingAPI { if (Exists) { - /*var copy = Copy(); - copy.BlockGroup = value; //It won't run this on the new instance as it won't 'exist' yet - Remove();*/ Logging.LogWarning("Attempted to set group of existing block. This is not supported." + " Copy the block and set the group of the resulting block."); return; diff --git a/GamecraftModdingAPI/BlockGroup.cs b/GamecraftModdingAPI/BlockGroup.cs index 6c600b2..c1add9a 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/GamecraftModdingAPI/BlockGroup.cs @@ -55,7 +55,7 @@ namespace GamecraftModdingAPI } /// - /// The position of the block group (center). Recalculated if blocks have been added/removed since the last query. + /// The position of the block group (center). Can only be used after initialization is complete. /// public float3 Position { @@ -78,7 +78,7 @@ namespace GamecraftModdingAPI } /// - /// The rotation of the block group. Recalculated if blocks have been added/removed since the last query. + /// The rotation of the block group. Can only be used after initialization is complete. /// public float3 Rotation { @@ -121,7 +121,7 @@ namespace GamecraftModdingAPI /// A new block group containing the given block public static BlockGroup Create(Block block) { - var bg = new BlockGroup(_engine.CreateBlockGroup(default, default), block); + var bg = new BlockGroup(_engine.CreateBlockGroup(block.Position, Quaternion.Euler(block.Rotation)), block); block.BlockGroup = bg; return bg; } @@ -166,7 +166,11 @@ namespace GamecraftModdingAPI item.BlockGroup = this; //Calls AddInternal } - internal void AddInternal(Block item) => blocks.Add(item); + internal void AddInternal(Block item) + { + blocks.Add(item); + _engine.AddBlockToGroup(item.Id, Id); + } /// /// Removes all blocks from this group. diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs index ff22a4c..ddfb051 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlueprintEngine.cs @@ -29,7 +29,8 @@ namespace GamecraftModdingAPI.Blocks private NativeDynamicArray selectedBlocksInGroup; private NativeHashSet removedConnections = new NativeHashSet(); - + private int addingToBlockGroup = -1; + private static readonly Type PlaceBlueprintUtilityType = AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceBlueprintUtility"); private static readonly FieldInfo LocalBlockMap = @@ -50,13 +51,14 @@ namespace GamecraftModdingAPI.Blocks private static FasterList globalBlockMap; private static object SerializeGhostBlueprintInstance; private static GhostChildEntityFactory BuildGhostBlueprintFactory; - + public void Ready() { selectedBlocksInGroup = NativeDynamicArray.Alloc(Allocator.Persistent); } public EntitiesDB entitiesDB { get; set; } + public void Dispose() { selectedBlocksInGroup.Dispose(); @@ -96,6 +98,20 @@ namespace GamecraftModdingAPI.Blocks return nextFilterId; } + public void AddBlockToGroup(EGID blockID, int groupID) + { + if (globalBlockMap == null) + globalBlockMap = FullGameFields._deserialisedBlockMap; + if (groupID != addingToBlockGroup) + { + Logging.MetaDebugLog("Changing current block group from " + addingToBlockGroup + " to " + groupID); + addingToBlockGroup = groupID; + globalBlockMap.Clear(); + } + + globalBlockMap.Add(blockID); + } + public void SelectBlueprint(uint resourceID) { if (resourceID == uint.MaxValue) @@ -109,7 +125,7 @@ namespace GamecraftModdingAPI.Blocks uint index = clipboardManager.AllocateSerializationData(); return index; } - + public void ReplaceBlueprint(uint playerID, uint blueprintID, ICollection selected, float3 pos, quaternion rot) { var blockIDs = new EGID[selected.Count]; @@ -131,14 +147,14 @@ namespace GamecraftModdingAPI.Blocks //float3 bottomOffset = PlaceBlockUtility.GetBottomOffset(collider); //var rootPosition = math.mul(groupTransform.blockGroupGridRotation, bottomOffset) + groupTransform.blockGroupGridPosition; //var rootRotation = groupTransform.blockGroupGridRotation; - + clipboardManager.SetGhostSerialized(blueprintID, false); SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, serializationData.blueprintData, entitySerialization, entityFactory, blockIDs, (uint) blockIDs.Length, pos, rot, -1); BuildGhostBlueprint(selected, pos, rot, playerID); SerializeGhostBlueprint.Invoke(SerializeGhostBlueprintInstance, new object[] {playerID, blueprintID}); - + } private void BuildGhostBlueprint(ICollection blocks, float3 pos, quaternion rot, uint playerID) @@ -173,11 +189,12 @@ namespace GamecraftModdingAPI.Blocks } } int nextFilterId1 = BlockGroupUtility.NextFilterId; - entityFactory.BuildEntity(new EGID((uint) nextFilterId1, BlockGroupExclusiveGroups.BlockGroupEntityGroup)).Init(new BlockGroupTransformEntityComponent - { - blockGroupGridPosition = selectionPosition.position, - blockGroupGridRotation = selectionRotation.rotation - }); + entityFactory.BuildEntity(new EGID((uint) nextFilterId1, + BlockGroupExclusiveGroups.BlockGroupEntityGroup)).Init(new BlockGroupTransformEntityComponent + { + blockGroupGridPosition = selectionPosition.position, + blockGroupGridRotation = selectionRotation.rotation + }); var frot = Quaternion.Euler(rot); var grid = new GridRotationStruct {position = pos, rotation = frot}; var poss = new PositionEntityStruct {position = pos}; @@ -284,17 +301,17 @@ namespace GamecraftModdingAPI.Blocks } [HarmonyPatch] - private static class BuildGhostBlueprintPatch + private static class BuildGhostBlueprintPatch + { + public static void Postfix(GhostChildEntityFactory ghostChildEntityFactory) { - public static void Postfix(GhostChildEntityFactory ghostChildEntityFactory) - { - BuildGhostBlueprintFactory = ghostChildEntityFactory; - } + BuildGhostBlueprintFactory = ghostChildEntityFactory; + } - public static MethodBase TargetMethod() - {RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine - return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine"))[0]; - } + public static MethodBase TargetMethod() + { + return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine"))[0]; + } } public IEntityFactory Factory { get; set; } diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index fab9c62..b0d1365 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -107,7 +107,7 @@ namespace GamecraftModdingAPI.Blocks belongsTo = 32U, collidesWith = 239532U });*/ - + PrimaryRotationUtility.InitialisePrimaryDirection(rotation.rotation, ref structInitializer); EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup); ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity(playerEGID); diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 88002d0..3dabe64 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -2,7 +2,7 @@ net472 true - 1.8.0 + 1.7.0 Exmods GNU General Public Licence 3+ https://git.exmods.org/modtainers/GamecraftModdingAPI diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index fb806ea..81a814c 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -410,88 +410,6 @@ namespace GamecraftModdingAPI.Tests return ((Action) MinimumSpecsCheck.CheckRequirementsMet).Method; } } - - [HarmonyPatch] - public class BugHuntPatch - { - public static MethodInfo method = - SymbolExtensions.GetMethodInfo(str => Console.WriteLine(str)); - - public static IEnumerable Transpiler(IEnumerable instructions) - { - int i = 0; - foreach (var instruction in instructions) - { - i++; - yield return instruction; //Return the instruction first - //stloc, dup, callvirt - if (instruction.opcode.Name.ToLower().StartsWith("stloc") - || instruction.opcode == OpCodes.Dup - || instruction.opcode == OpCodes.Callvirt) - { - yield return new CodeInstruction(OpCodes.Ldstr, - "Just ran the " + i + ". instruction ending with " + instruction.opcode.Name); - yield return new CodeInstruction(OpCodes.Call, method); - } - } - } - - public static MethodInfo TargetMethod() - { - return AccessTools.Method("RobocraftX.CR.MachineEditing.BoxSelect.CopySelectionEngine:GenerateThumbnail"); - } - } - - [HarmonyPatch] - public class BugHuntPatch2 - { - public static void Prefix(int width, float fieldOfView, Vector3 cameraDirection, Vector3 lightDirection) - { - Console.WriteLine("TakeThumbnail invoked with parameters: " + width + ", " + fieldOfView + ", " + - cameraDirection + ", " + lightDirection); - - GPUInstancerManager manager = GPUInstancerAPI.GetActiveManagers().Find(m => m is GPUInstancerPrefabManager); - Bounds instancesBounds = manager.ComputeInstancesBounds(2); - Console.WriteLine("Bounds: " + instancesBounds); - Console.WriteLine("Size: " + instancesBounds.size); - Console.WriteLine("Size.x < 0: " + (instancesBounds.size.x < 0)); - } - - public static void Postfix(Texture2D __result) - { - Console.WriteLine("TakeThumbnail returned: " + (__result == null ? null : __result.name)); - } - - private delegate Texture2D TakeThumbnailDel(int width, float fieldOfView, Vector3 cameraDirection, - Vector3 lightDirection); - - public static MethodInfo TargetMethod() - { - return ((TakeThumbnailDel) ThumbnailUtility.TakeThumbnail).Method; - } - } - - [HarmonyPatch] - public class BugHuntPatch3 - { - public static void Prefix(int width, int filterLayerMask, GPUInstancerManager manager, - Vector3 cameraPosition, Quaternion cameraRotation, float cameraFov, Vector3 lightDirection, - int cullingLayer) - { - Console.WriteLine("Inner TakeThumbnail invoked with parameters: " + width + ", " + filterLayerMask + - ", " + (manager != null ? manager.name : null) + ", " + cameraPosition + ", " + - cameraRotation + ", " + cameraFov + ", " + lightDirection + ", " + cullingLayer); - } - - private delegate Texture2D TakeThumbnailDel(int width, int filterLayerMask, GPUInstancerManager manager, - Vector3 cameraPosition, Quaternion cameraRotation, float cameraFov, Vector3 lightDirection, - int cullingLayer); - - public static MethodInfo TargetMethod() - { - return ((TakeThumbnailDel) ThumbnailUtility.TakeThumbnail).Method; - } - } } #endif } diff --git a/doxygen.conf b/doxygen.conf index 4b1eaed..9958d11 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "GamecraftModdingAPI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "v1.8.0" +PROJECT_NUMBER = "v1.7.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From 404c47c7c01e7c13eb49117cda9ba83e59ca1897 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Wed, 18 Nov 2020 16:46:23 -0500 Subject: [PATCH 16/98] Bump version to 1.8.0 --- .../GamecraftModdingAPI.csproj | 129 +++++++++--------- doxygen.conf | 2 +- 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 3dabe64..b630e64 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -2,7 +2,7 @@ net472 true - 1.7.0 + 1.8.0 Exmods GNU General Public Licence 3+ https://git.exmods.org/modtainers/GamecraftModdingAPI @@ -24,11 +24,16 @@ + - - ..\ref\Gamecraft_Data\Managed\Accessibility.dll - ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll + + ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll + ..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll + + + ..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll + ..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll ..\ref\Gamecraft_Data\Managed\Analytics.dll @@ -74,10 +79,6 @@ ..\ref\Gamecraft_Data\Managed\DDNA.dll ..\..\ref\Gamecraft_Data\Managed\DDNA.dll - - ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\ref\Gamecraft_Data\Managed\FMOD.dll ..\..\ref\Gamecraft_Data\Managed\FMOD.dll @@ -330,26 +331,10 @@ ..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - - ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll - ..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll - - - ..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll - ..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll - - - ..\ref\Gamecraft_Data\Managed\JWT.dll - ..\..\ref\Gamecraft_Data\Managed\JWT.dll - ..\ref\Gamecraft_Data\Managed\LZ4.dll ..\..\ref\Gamecraft_Data\Managed\LZ4.dll - - ..\ref\Gamecraft_Data\Managed\mscorlib.dll - ..\..\ref\Gamecraft_Data\Managed\mscorlib.dll - ..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll ..\..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll @@ -358,30 +343,10 @@ ..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll ..\..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll - - ..\ref\Gamecraft_Data\Managed\netstandard.dll - ..\..\ref\Gamecraft_Data\Managed\netstandard.dll - - - ..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll - ..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll - - - ..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll - ..\..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll - ..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll ..\..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll - - ..\ref\Gamecraft_Data\Managed\Rewired_Core.dll - ..\..\ref\Gamecraft_Data\Managed\Rewired_Core.dll - - - ..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll - ..\..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll - ..\ref\Gamecraft_Data\Managed\RobocraftECS.dll ..\..\ref\Gamecraft_Data\Managed\RobocraftECS.dll @@ -654,18 +619,10 @@ ..\ref\Gamecraft_Data\Managed\Unity.Burst.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.dll - - ..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll - ..\ref\Gamecraft_Data\Managed\Unity.Collections.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.dll - - ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - ..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll ..\..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll @@ -794,6 +751,62 @@ ..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll ..\..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + + ..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll + ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll + + + ..\ref\Gamecraft_Data\Managed\uREPL.dll + ..\..\ref\Gamecraft_Data\Managed\uREPL.dll + + + ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll + ..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll + + + ..\ref\Gamecraft_Data\Managed\Accessibility.dll + ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll + + + ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + + + ..\ref\Gamecraft_Data\Managed\JWT.dll + ..\..\ref\Gamecraft_Data\Managed\JWT.dll + + + ..\ref\Gamecraft_Data\Managed\mscorlib.dll + ..\..\ref\Gamecraft_Data\Managed\mscorlib.dll + + + ..\ref\Gamecraft_Data\Managed\netstandard.dll + ..\..\ref\Gamecraft_Data\Managed\netstandard.dll + + + ..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll + ..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll + + + ..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll + ..\..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll + + + ..\ref\Gamecraft_Data\Managed\Rewired_Core.dll + ..\..\ref\Gamecraft_Data\Managed\Rewired_Core.dll + + + ..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll + ..\..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll + + + ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + ..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll @@ -962,10 +975,6 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll @@ -1046,14 +1055,6 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll - - ..\ref\Gamecraft_Data\Managed\uREPL.dll - ..\..\ref\Gamecraft_Data\Managed\uREPL.dll - - - ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - ..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - \ No newline at end of file diff --git a/doxygen.conf b/doxygen.conf index 9958d11..4b1eaed 100644 --- a/doxygen.conf +++ b/doxygen.conf @@ -38,7 +38,7 @@ PROJECT_NAME = "GamecraftModdingAPI" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "v1.7.0" +PROJECT_NUMBER = "v1.8.0" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a From ab1ae51ecec21b18d789188b17d78bddb4e321b4 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 11 Dec 2020 17:11:24 +0100 Subject: [PATCH 17/98] Update to Gamecraft 2020.11.30.16.02 --- GamecraftModdingAPI/Block.cs | 4 +- GamecraftModdingAPI/Blocks/BlockEngine.cs | 48 +++++++++++-------- GamecraftModdingAPI/Blocks/BlockIDs.cs | 4 ++ .../GamecraftModdingAPI.csproj | 42 ++-------------- GamecraftModdingAPI/Utility/FullGameFields.cs | 2 +- 5 files changed, 37 insertions(+), 63 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index d0ff657..524847d 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -114,8 +114,8 @@ namespace GamecraftModdingAPI private static Dictionary> initializers = new Dictionary>(); - private static Dictionary typeToGroup = - new Dictionary + private static Dictionary typeToGroup = + new Dictionary { {typeof(ConsoleBlock), new[] {CommonExclusiveGroups.CONSOLE_BLOCK_GROUP}}, {typeof(LogicGate), new [] {CommonExclusiveGroups.LOGIC_BLOCK_GROUP}}, diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 2da04a3..a365d54 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -178,37 +178,43 @@ namespace GamecraftModdingAPI.Blocks public SimBody[] GetSimBodiesFromID(byte id) { var ret = new FasterList(4); - if (!entitiesDB.HasAny(CommonExclusiveGroups.OBJID_BLOCK_GROUP)) - return new SimBody[0]; - var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP).ToBuffer(); - var connections = entitiesDB.QueryMappedEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP); - for (int i = 0; i < oids.count; i++) + var oide = entitiesDB.QueryEntities(); + EGIDMapper? connections = null; + foreach (var ((oids, count), _) in oide) { - ref ObjectIdEntityStruct oid = ref oids.buffer[i]; - if (oid.objectId != id) continue; - var rid = connections.Entity(oid.ID.entityID).machineRigidBodyId; - foreach (var rb in ret) - { - if (rb.Id.entityID == rid) - goto DUPLICATE; //Multiple Object Identifiers on one rigid body + for (int i = 0; i < count; i++) + { + ref ObjectIdEntityStruct oid = ref oids[i]; + if (oid.objectId != id) continue; + if (!connections.HasValue) //Would need reflection to get the group from the build group otherwise + connections = entitiesDB.QueryMappedEntities(oid.ID.groupID); + var rid = connections.Value.Entity(oid.ID.entityID).machineRigidBodyId; + foreach (var rb in ret) + { + if (rb.Id.entityID == rid) + goto DUPLICATE; //Multiple Object Identifiers on one rigid body + } + + ret.Add(new SimBody(rid)); + DUPLICATE: ; } - ret.Add(new SimBody(rid)); - DUPLICATE: ; } + return ret.ToArray(); } public ObjectIdentifier[] GetObjectIDsFromID(byte id, bool sim) { var ret = new FasterList(4); - if (!entitiesDB.HasAny(CommonExclusiveGroups.OBJID_BLOCK_GROUP)) - return new ObjectIdentifier[0]; - var oids = entitiesDB.QueryEntities(CommonExclusiveGroups.OBJID_BLOCK_GROUP).ToBuffer(); - for (int i = 0; i < oids.count; i++) + var oide = entitiesDB.QueryEntities(); + foreach (var ((oids, count), _) in oide) { - ref ObjectIdEntityStruct oid = ref oids.buffer[i]; - if (sim ? oid.simObjectId == id : oid.objectId == id) - ret.Add(new ObjectIdentifier(oid.ID)); + for (int i = 0; i < count; i++) + { + ref ObjectIdEntityStruct oid = ref oids[i]; + if (sim ? oid.simObjectId == id : oid.objectId == id) + ret.Add(new ObjectIdentifier(oid.ID)); + } } return ret.ToArray(); diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index 1d55b29..9591ae2 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -329,6 +329,10 @@ namespace GamecraftModdingAPI.Blocks UnlitGlowSlope, Fog, Sky, + GridCube, + GridSlicedCube, + GridSlope, + GridCorner, MagmaRockCube = 777, MagmaRockCubeSliced, MagmaRockSlope, diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 3dabe64..c76ebd9 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -618,34 +618,6 @@ ..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Curves.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.DefaultGraphPipeline.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Graph.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Animation.Hybrid.dll - ..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll @@ -666,10 +638,6 @@ ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - - ..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.DataFlowGraph.dll - ..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll @@ -682,9 +650,9 @@ ..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - - ..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.002.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.002.dll + + ..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.012.dll + ..\..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.012.dll ..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll @@ -718,10 +686,6 @@ ..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll - - ..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Postprocessing.Runtime.dll - ..\ref\Gamecraft_Data\Managed\Unity.Properties.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.dll diff --git a/GamecraftModdingAPI/Utility/FullGameFields.cs b/GamecraftModdingAPI/Utility/FullGameFields.cs index 432103d..ccf80de 100644 --- a/GamecraftModdingAPI/Utility/FullGameFields.cs +++ b/GamecraftModdingAPI/Utility/FullGameFields.cs @@ -14,7 +14,7 @@ using RobocraftX.Rendering; using Svelto.Context; using Svelto.DataStructures; using Svelto.ECS; -using Svelto.ECS.Schedulers.Unity; +using Svelto.ECS.Schedulers; using UnityEngine; using Unity.Entities; using Unity.Physics.Systems; From 432d6bcf969cedd3db1ea1b3670af0cae20c24cf Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Dec 2020 02:28:42 +0100 Subject: [PATCH 18/98] Use the same (physics) componentts and attempt to use custom material --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 44 ++++++++++++++--------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index b960101..7c5d6db 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -3,27 +3,22 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Reflection.Emit; -using System.Text.Formatting; using DataLoader; -using GamecraftModdingAPI.Utility; using GPUInstancer; using HarmonyLib; -using RobocraftX.Blocks.Ghost; +using RobocraftX.Blocks; using RobocraftX.Common; -using RobocraftX.Schedulers; +using RobocraftX.Rendering; using Svelto.DataStructures; -using Svelto.ECS.Extensions.Unity; using Svelto.Tasks; -using Svelto.Tasks.ExtraLean; using Unity.Entities; using Unity.Entities.Conversion; using Unity.Physics; using UnityEngine; using UnityEngine.AddressableAssets; using BoxCollider = UnityEngine.BoxCollider; -using Collider = UnityEngine.Collider; using Material = UnityEngine.Material; +using Object = UnityEngine.Object; namespace GamecraftModdingAPI.Blocks { @@ -122,7 +117,7 @@ namespace GamecraftModdingAPI.Blocks } } - [HarmonyPatch] + /*[HarmonyPatch] public static class RendererPatch { private static Material[] materials; @@ -134,9 +129,16 @@ namespace GamecraftModdingAPI.Blocks //Console.WriteLine("Length: " + gameObject.GetComponentsInChildren().Length); if (materials != null) gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; - ECSGPUIResourceManager.Instance.RegisterRuntimePrefabs( + /*ECSGPUIResourceManager.Instance.RegisterGhostsPrefabsAtRuntime( new[] {new PrefabData {prefabId = prefabID, prefabName = "Assets/Prefabs/Cube.prefab"}}, - new List {gameObject}).Complete(); + new List {gameObject});#1# + GameObject go = Object.Instantiate(gameObject); + go.SetActive(false); + AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:RegisterNewPrefabAtRuntime") + .Invoke(ECSGPUIResourceManager.Instance, + new object[] {(uint) ((int) prefabID * 2 + 1), gameObject, true}); + //ECSGPUIResourceManager.Instance.RegisterNewPrefabAtRuntime((uint) ((int)prefabID * 2 + 1), gameObject, true); //.isOcclusionCulling = false; + UnityEngine.Object.Destroy(gameObject); GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(ECSGPUIResourceManager.Instance.prefabManager, gameObject.GetComponent().prefabPrototype, new[] {gameObject}); Console.WriteLine("Registered prefab to instancer"); @@ -144,7 +146,7 @@ namespace GamecraftModdingAPI.Blocks /*var register = AccessTools.Method("RobocraftX.Common.ECSPhysicResourceManager:RegisterPrefab", new[] {typeof(uint), typeof(GameObject), typeof(World), typeof(BlobAssetStore)}); register.Invoke(ECSPhysicResourceManager.Instance, - new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2});*/ + new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2});#1# /*Console.WriteLine( "Entity: " + ECSPhysicResourceManager.Instance.GetUECSPhysicEntityPrefab(prefabID)); Console.WriteLine("Prefab ID: " + PrefabsID.DBIDMAP[500]); @@ -155,22 +157,23 @@ namespace GamecraftModdingAPI.Blocks Console.WriteLine("Collider type: " + componentData.ColliderPtr->Type); CollisionFilter filter = componentData.Value.Value.Filter; Console.WriteLine("Filter not empty: " + !filter.IsEmpty); - }*/ + }#1# //MGPatch.data.Item1.EntityManager.GetComponentData<>() gameObject.AddComponent(); gameObject.AddComponent(); Console.WriteLine("Registered prefab to physics"); + ECSGPUIResourceManager.Instance.RegisterGhostsPrefabsAtRuntime(); } else if (gameObject.name == "CTR_CommandBlock") materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; } public static MethodBase TargetMethod() - { + {RobocraftX.Common.ECSGPUIResourceManager.RegisterPrefab return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", new[] {typeof(uint), typeof(GameObject)}); } - } + }*/ [HarmonyPatch] public static class RMPatch @@ -180,6 +183,9 @@ namespace GamecraftModdingAPI.Blocks FasterList gos, List prefabData) { + Console.WriteLine("First game object data:\n" + gos[0].GetComponents() + .Select(c => c + " - " + c.name + " " + c.GetType()) + .Aggregate((a, b) => a + "\n" + b)); for (var index = 0; index < prefabData.Count; index++) { var data = prefabData[index]; @@ -200,12 +206,18 @@ namespace GamecraftModdingAPI.Blocks Console.WriteLine("Entity " + current + " has collider: " + entityManager.HasComponent(current)); } + + Console.WriteLine("Adding GPUI prefab"); + ((GPUInstancerPrefabManager) GPUInstancerManager.activeManagerList.Single(gim => + gim is GPUInstancerPrefabManager)) + .AddRuntimeRegisteredPrefab(gos[index].GetComponent()); + Console.WriteLine("Added GPUI prefab"); } } public static MethodBase TargetMethod() { - return AccessTools.Method("RobocraftX.Common.ECSResourceManagerUtility:RelinkEntities", + return AccessTools.Method("RobocraftX.Blocks.ECSResourceManagerUtility:RelinkEntities", new[] { typeof(World), From 5dfb01ef0b10e3e3823031f7ab5dfb22e1968e6b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Dec 2020 16:59:52 +0100 Subject: [PATCH 19/98] Use the console block's material again - IT WORKS It shows up in the inventory but crashes when selected --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 7c5d6db..2cf6b72 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -100,7 +100,9 @@ namespace GamecraftModdingAPI.Blocks } }*/ - public static void Prefix(ref Dictionary blocks) + private static Material[] materials; + + public static void Prefix(List prefabData, IList prefabs) { /*foreach (var block in blocks.Values.Cast()) { @@ -109,11 +111,25 @@ namespace GamecraftModdingAPI.Blocks /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It;*/ + for (int i = 0; i < prefabData.Count; i++) + { + var gameObject = prefabs[i]; + switch (gameObject.name) + { + case "Cube": + gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; + break; + case "CTR_CommandBlock": + materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; + break; + } + } } public static MethodBase TargetMethod() { //General block registration - return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + //return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); + return AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:InitPreRegisteredPrefabs"); } } From 78f0ea01620cbb590588380a7e3c4bb8bf359eaf Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Dec 2020 23:08:56 +0100 Subject: [PATCH 20/98] Use the intended method to create a CubeListData The block can be selected but not placed --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 31 ++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 2cf6b72..7a79345 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -111,9 +111,8 @@ namespace GamecraftModdingAPI.Blocks /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It;*/ - for (int i = 0; i < prefabData.Count; i++) + foreach (var gameObject in prefabs) { - var gameObject = prefabs[i]; switch (gameObject.name) { case "Cube": @@ -251,21 +250,19 @@ namespace GamecraftModdingAPI.Blocks public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB) { data = (physicsWorld, blobStore); - var blocks = dataDB.GetValues(); - blocks.Add("modded_ConsoleBlock", new CubeListData - { - cubeType = CubeType.Block, - cubeCategory = CubeCategory.ConsoleBlock, - inventoryCategory = InventoryCategory.Logic, - ID = 500, - Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) - SpriteName = "CTR_CommandBlock", - CubeNameKey = "strConsoleBlock", - SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, - GridScale = new[] {1, 1, 1}, - Mass = 1, - JointBreakAngle = 1 - }); + //RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock + var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null); + cld.cubeType = CubeType.Block; + cld.cubeCategory = CubeCategory.General; + cld.inventoryCategory = InventoryCategory.Shapes; + cld.ID = 500; + cld.Path = "Assets/Prefabs/Cube.prefab"; //Index out of range exception: Asset failed to load (wrong path) + cld.SpriteName = "CTR_CommandBlock"; + cld.CubeNameKey = "strConsoleBlock"; + cld.SelectableFaces = new[] {0, 1, 2, 3, 4, 5}; + cld.GridScale = new[] {1, 1, 1}; + cld.Mass = 1; + cld.JointBreakAngle = 1; } public static MethodBase TargetMethod() From 4e16f251ee6fdd74049a77a9d0f47827c0f4aa24 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 13 Dec 2020 20:21:46 +0100 Subject: [PATCH 21/98] Don't use the intended method to create a CubeListData It adds it with its ID as key but the ID hasn't been set at that point It works until the second simulation start now --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 37 +++++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 7a79345..af8f374 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using DataLoader; +using GamecraftModdingAPI.Utility; using GPUInstancer; using HarmonyLib; using RobocraftX.Blocks; @@ -246,23 +247,33 @@ namespace GamecraftModdingAPI.Blocks [HarmonyPatch] public static class MGPatch { - internal static (World, BlobAssetStore) data; + internal static (World, BlobAssetStore) data; public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB) { data = (physicsWorld, blobStore); //RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock - var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null); - cld.cubeType = CubeType.Block; - cld.cubeCategory = CubeCategory.General; - cld.inventoryCategory = InventoryCategory.Shapes; - cld.ID = 500; - cld.Path = "Assets/Prefabs/Cube.prefab"; //Index out of range exception: Asset failed to load (wrong path) - cld.SpriteName = "CTR_CommandBlock"; - cld.CubeNameKey = "strConsoleBlock"; - cld.SelectableFaces = new[] {0, 1, 2, 3, 4, 5}; - cld.GridScale = new[] {1, 1, 1}; - cld.Mass = 1; - cld.JointBreakAngle = 1; + //var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null); + var abd = dataDB.GetValue((int) BlockIDs.AluminiumCube); + var cld = new CubeListData + { + cubeType = CubeType.Block, + cubeCategory = CubeCategory.General, + inventoryCategory = InventoryCategory.Shapes, + ID = 500, + Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) + SpriteName = "CTR_CommandBlock", + CubeNameKey = "strConsoleBlock", + SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, + GridScale = new[] {1, 1, 1}, + Mass = 1, + JointBreakAngle = 1, + Material = abd.Material + }; + Console.WriteLine("Aluminium block data:\n" + abd); + Console.WriteLine("Material: " + abd.Material); + dataDB.GetValues().Add("500", cld); //The registration needs to happen after the ID has been set + dataDB.GetFasterValues().Add(500, cld); + //RobocraftX.ExplosionFragments.Engines.PlayFragmentExplodeEngine.PlayRigidBodyEffect } public static MethodBase TargetMethod() From a7f6a1623144cdfd6c78b6a9a5252a9a6268b7cb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 17 Dec 2020 02:34:36 +0100 Subject: [PATCH 22/98] Update to Gamecraft 2020.12.16.14.19 and custom block stuff - Fixed the crash on second time start - Tweaked more stuff about the block Breaking changes coming from FMOD 2.0: - Audio[int index] changed to Audio[PARAMETER_ID index] - Audio.Parameters removed --- GamecraftModdingAPI/Blocks/BlockEngine.cs | 2 +- GamecraftModdingAPI/Blocks/CustomBlock.cs | 12 +++++++-- GamecraftModdingAPI/Blocks/DampedSpring.cs | 8 +++--- GamecraftModdingAPI/Blocks/Piston.cs | 4 +-- GamecraftModdingAPI/Blocks/Servo.cs | 4 +-- GamecraftModdingAPI/Blocks/TextBlock.cs | 6 +---- .../GamecraftModdingAPI.csproj | 22 +++++++++++----- GamecraftModdingAPI/Utility/Audio.cs | 26 ++++--------------- 8 files changed, 40 insertions(+), 44 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index a365d54..53a7254 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -227,7 +227,7 @@ namespace GamecraftModdingAPI.Blocks for (int i = 0; i < joints.count; i++) { ref var joint = ref joints.buffer[i]; - if (joint.jointState == JointState.Broken) continue; + if (joint.isBroken) continue; if (joint.connectedEntityA == id) list.Add(new SimBody(joint.connectedEntityB)); else if (joint.connectedEntityB == id) list.Add(new SimBody(joint.connectedEntityA)); } diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index af8f374..2f33035 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -20,6 +20,7 @@ using UnityEngine.AddressableAssets; using BoxCollider = UnityEngine.BoxCollider; using Material = UnityEngine.Material; using Object = UnityEngine.Object; +using ScalingPermission = DataLoader.ScalingPermission; namespace GamecraftModdingAPI.Blocks { @@ -266,8 +267,15 @@ namespace GamecraftModdingAPI.Blocks SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, GridScale = new[] {1, 1, 1}, Mass = 1, - JointBreakAngle = 1, - Material = abd.Material + Material = abd.Material, + scalingPermission = ScalingPermission.NonUniform, + SortIndex = 12, + DefaultColour = (byte) BlockColors.Lime, + Volume = 1f, + timeRunningCollision = TimeRunningCollision.Enabled, + IsIsolator = false, + EdgeConnectingFaces = new[] {0, 1, 2, 3, 4, 5}, + PointDataVolumeMultiplier = 1f }; Console.WriteLine("Aluminium block data:\n" + abd); Console.WriteLine("Material: " + abd.Material); diff --git a/GamecraftModdingAPI/Blocks/DampedSpring.cs b/GamecraftModdingAPI/Blocks/DampedSpring.cs index 5a5a936..51da25e 100644 --- a/GamecraftModdingAPI/Blocks/DampedSpring.cs +++ b/GamecraftModdingAPI/Blocks/DampedSpring.cs @@ -19,10 +19,10 @@ namespace GamecraftModdingAPI.Blocks /// public float MaxForce { - get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.maxForce); + get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.springFrequency); set => BlockEngine.SetBlockInfo(this, - (ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.maxForce = val, value); + (ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.springFrequency = val, value); } /// @@ -39,10 +39,10 @@ namespace GamecraftModdingAPI.Blocks /// public float Damping { - get => BlockEngine.GetBlockInfo(this, (LinearJointForcesReadOnlyStruct ljf) => ljf.dampingForceMagnitude); + get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.springDamping); set => BlockEngine.SetBlockInfo(this, - (ref LinearJointForcesReadOnlyStruct ljf, float val) => ljf.dampingForceMagnitude = val, value); + (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value); } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/Piston.cs b/GamecraftModdingAPI/Blocks/Piston.cs index 04b3aeb..d05ac20 100644 --- a/GamecraftModdingAPI/Blocks/Piston.cs +++ b/GamecraftModdingAPI/Blocks/Piston.cs @@ -40,11 +40,11 @@ namespace GamecraftModdingAPI.Blocks ///
public float MaximumForce { - get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxForce); + get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.pistonVelocity); set { - BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxForce = val, value); + BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.pistonVelocity = val, value); } } } diff --git a/GamecraftModdingAPI/Blocks/Servo.cs b/GamecraftModdingAPI/Blocks/Servo.cs index 606a48a..a5dceec 100644 --- a/GamecraftModdingAPI/Blocks/Servo.cs +++ b/GamecraftModdingAPI/Blocks/Servo.cs @@ -52,11 +52,11 @@ namespace GamecraftModdingAPI.Blocks ///
public float MaximumForce { - get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxForce); + get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.servoVelocity); set { - BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxForce = val, value); + BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.servoVelocity = val, value); } } diff --git a/GamecraftModdingAPI/Blocks/TextBlock.cs b/GamecraftModdingAPI/Blocks/TextBlock.cs index d7d620a..3d46611 100644 --- a/GamecraftModdingAPI/Blocks/TextBlock.cs +++ b/GamecraftModdingAPI/Blocks/TextBlock.cs @@ -35,10 +35,8 @@ namespace GamecraftModdingAPI.Blocks BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) => { tbds.textCurrent.Set(val); - tbds.textStored.Set(val); + tbds.textStored.Set(val, true); }, value); - BlockEngine.SetBlockInfo(this, - (ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockStringContent.Set(val), value); } } @@ -54,8 +52,6 @@ namespace GamecraftModdingAPI.Blocks if (value == null) value = ""; BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) => tbds.textBlockID.Set(val), value); - BlockEngine.SetBlockInfo(this, - (ref TextBlockNetworkDataStruct st, string val) => st.newTextBlockID.Set(val), value); } } } diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index c76ebd9..6324b9a 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -78,9 +78,9 @@ ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - - ..\ref\Gamecraft_Data\Managed\FMOD.dll - ..\..\ref\Gamecraft_Data\Managed\FMOD.dll + + ..\ref\Gamecraft_Data\Managed\FMODUnity.dll + ..\..\ref\Gamecraft_Data\Managed\FMODUnity.dll ..\ref\Gamecraft_Data\Managed\FullGame.dll @@ -266,6 +266,10 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll + + ..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll @@ -286,6 +290,10 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll + + ..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll @@ -510,6 +518,10 @@ ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + + ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + ..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll @@ -554,10 +566,6 @@ ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Serializers.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll diff --git a/GamecraftModdingAPI/Utility/Audio.cs b/GamecraftModdingAPI/Utility/Audio.cs index 9d227a8..b2566f2 100644 --- a/GamecraftModdingAPI/Utility/Audio.cs +++ b/GamecraftModdingAPI/Utility/Audio.cs @@ -43,40 +43,24 @@ namespace GamecraftModdingAPI.Utility { get { - sound.getParameterValue(key, out float val, out float finalVal); + sound.getParameterByName(key, out float val, out float finalVal); return val; } - set => sound.setParameterValue(key, value); + set => sound.setParameterByName(key, value); } - public float this[int index] + public float this[PARAMETER_ID index] { get { - sound.getParameterValueByIndex(index, out float val, out float finalVal); + sound.getParameterByID(index, out float val, out float finalVal); return val; } - set => sound.setParameterValueByIndex(index, value); + set => sound.setParameterByID(index, value); } - public string[] Parameters - { - get - { - sound.getParameterCount(out int count); - string[] parameters = new string[count]; - for (int i = 0; i < count; i++) - { - sound.getParameterByIndex(i, out ParameterInstance param); - param.getDescription(out PARAMETER_DESCRIPTION desc); - parameters[i] = desc.name; - } - return parameters; - } - } - public float3 Position { get From 712ece86dbf4c462da1e5ba49f2e99713e19a009 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 17 Dec 2020 20:20:46 +0100 Subject: [PATCH 23/98] Add custom block registration functionality and a test --- GamecraftModdingAPI/Block.cs | 2 +- GamecraftModdingAPI/Blocks/CustomBlock.cs | 328 +++++------------- .../Blocks/CustomBlockAttribute.cs | 85 +++++ .../Tests/GamecraftModdingAPIPluginTest.cs | 33 +- 4 files changed, 204 insertions(+), 244 deletions(-) create mode 100644 GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 524847d..4aa0a30 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -213,7 +213,7 @@ namespace GamecraftModdingAPI throw new BlockTypeException("The block has the wrong group! The type is " + GetType() + " while the group is " + id.groupID); } - else if (type != typeof(Block)) + else if (type != typeof(Block) && !typeof(CustomBlock).IsAssignableFrom(type)) Logging.LogWarning($"Unknown block type! Add {type} to the dictionary."); } diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 2f33035..331552c 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -1,9 +1,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Reflection; using DataLoader; +using GamecraftModdingAPI.App; using GamecraftModdingAPI.Utility; using GPUInstancer; using HarmonyLib; @@ -11,8 +13,8 @@ using RobocraftX.Blocks; using RobocraftX.Common; using RobocraftX.Rendering; using Svelto.DataStructures; +using Svelto.ECS; using Svelto.Tasks; -using Unity.Entities; using Unity.Entities.Conversion; using Unity.Physics; using UnityEngine; @@ -24,264 +26,113 @@ using ScalingPermission = DataLoader.ScalingPermission; namespace GamecraftModdingAPI.Blocks { - public class CustomBlock + public class CustomBlock : Block { private static ushort nextID = 500; - public static void RegisterCustomBlock(string path) + /// + /// Key: Prefab path + /// + private static Dictionary _customBlocks = new Dictionary(); + + private static bool _canRegister = true; + + /// + /// Register a custom block type. Call it as soon as possible (in OnApplicationStart()).
+ /// You need a Unity project with Addressables and Havok installed and need a prefab added as an addressable asset. + /// Build the addressables and the project and copy the catalog.json from StreamingAssets, you'll need to reference this file. + /// Also copy the asset files from the subfolder to the same path in the game. + ///
+ /// The custom block type + public static void RegisterCustomBlock() where T : CustomBlock { - var prefabData = new List(); - //category ID: - //0 - regular - //1 - joint - //2 - controller - uint prefabId = PrefabsID.FetchNewPrefabID(PrefabsID.GenerateDBID(0, nextID++)); - prefabData.Add(new PrefabData() - { - prefabName = path, - prefabId = prefabId - }); - var loadTask = Addressables.LoadAssetAsync(path); - AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab") - .Invoke(ECSGPUIResourceManager.Instance, new object[] {prefabId, loadTask.Result, 1}); + if (!_canRegister) + throw new InvalidOperationException( + "It's too late to register custom blocks. Register it before the game starts loading."); + var type = typeof(T); + var attr = type.GetCustomAttribute(); + if (attr == null) + throw new ArgumentException("The custom block type is missing the CustomBlock annotation"); + string typeName = type.FullName ?? + throw new ArgumentException("The given block type doesn't have a concrete full name."); + if (!File.Exists(attr.Catalog)) + throw new FileNotFoundException("The specified catalog cannot be found for " + typeName); + _customBlocks.Add(attr.AssetPath, type); + Logging.MetaDebugLog("Registered custom block type " + typeName); } + public CustomBlock(EGID id) : base(id) + { + if (id.groupID != Group) + throw new BlockTypeException("The block is not a custom block! It has a group of " + id.groupID); + } + + public CustomBlock(uint id) : this(new EGID(id, Group)) + { + } + + public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); + [HarmonyPatch] public static class Patch { - /*public static IEnumerable Transpiler(IEnumerable instructions) - { - var list = new List(instructions); - try - { - *int index = -1; - CodeInstruction loadTask = null; - for (var i = 0; i < list.Count - 1; i++) - { - if (list[i].opcode == OpCodes.Ldfld - && ((string) list[i].operand).Contains("renderingWorld") - && list[i + 1].opcode == OpCodes.Brfalse_S) - index = i - 1; //It loads 'this' first - if (list[i].opcode == OpCodes.Ldflda - && ((string) list[i].operand).Contains("loadTask")) - loadTask = new CodeInstruction(list[i]); - }* - - var array = new[] - { - //Set Yield.It to be returned (current) - new CodeInstruction(OpCodes.Ldarg_0), // this - new CodeInstruction(OpCodes.Ldsfld, - typeof(Yield).GetField("It", BindingFlags.Public | BindingFlags.Static)), - new CodeInstruction(OpCodes.Stfld, "object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current'"), - - //Set which yield return we're at (state) - new CodeInstruction(OpCodes.Ldarg_0), // this - new CodeInstruction(OpCodes.Ldc_I4_1), - //new CodeInstruction(OpCodes.Call, ((Action)AddInfo).Method) - }; - list.InsertRange(index, array); - * - IL_00ad: ldarg.0 // this - IL_00ae: ldsfld class [Svelto.Tasks]Svelto.Tasks.Yield [Svelto.Tasks]Svelto.Tasks.Yield::It - IL_00b3: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current' - - IL_0072: ldarg.0 // this - IL_0073: ldnull - IL_0074: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>2__current' - IL_0079: ldarg.0 // this - IL_007a: ldc.i4.2 - IL_007b: stfld object RobocraftX.Common.ECSResourceManagerUtility/'d__0'::'<>1__state' - IL_0080: ldc.i4.1 - IL_0081: ret - * - yield break; - } - catch (Exception e) - { - Logging.LogWarning("Failed to inject AddInfo method for the debug display!\n" + e); - } - }*/ - private static Material[] materials; public static void Prefix(List prefabData, IList prefabs) { - /*foreach (var block in blocks.Values.Cast()) + for (var index = 0; index < prefabs.Count; index++) { - Console.WriteLine("Block info: " + block); - }*/ + if (prefabData[index].prefabName == "ConsoleBlock") + materials = prefabs[index].GetComponentsInChildren()[0].sharedMaterials; + } - /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); - while (!res.IsDone) yield return Yield.It;*/ - foreach (var gameObject in prefabs) + for (var index = 0; index < prefabs.Count; index++) { - switch (gameObject.name) - { - case "Cube": - gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; - break; - case "CTR_CommandBlock": - materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; - break; - } + if (_customBlocks.ContainsKey(prefabData[index].prefabName)) //This is a custom block + prefabs[index].GetComponentsInChildren()[0].sharedMaterials = materials; } } public static MethodBase TargetMethod() { //General block registration - //return AccessTools.Method("RobocraftX.Blocks.BlocksCompositionRoot:RegisterPartPrefabs"); return AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:InitPreRegisteredPrefabs"); } } - /*[HarmonyPatch] - public static class RendererPatch - { - private static Material[] materials; - public static void Prefix(uint prefabID, GameObject gameObject) - { - Console.WriteLine("ID: " + prefabID + " - Name: " + gameObject.name); - if (gameObject.name == "Cube") - { - //Console.WriteLine("Length: " + gameObject.GetComponentsInChildren().Length); - if (materials != null) - gameObject.GetComponentsInChildren()[0].sharedMaterials = materials; - /*ECSGPUIResourceManager.Instance.RegisterGhostsPrefabsAtRuntime( - new[] {new PrefabData {prefabId = prefabID, prefabName = "Assets/Prefabs/Cube.prefab"}}, - new List {gameObject});#1# - GameObject go = Object.Instantiate(gameObject); - go.SetActive(false); - AccessTools.Method("RobocraftX.Rendering.ECSGPUIResourceManager:RegisterNewPrefabAtRuntime") - .Invoke(ECSGPUIResourceManager.Instance, - new object[] {(uint) ((int) prefabID * 2 + 1), gameObject, true}); - //ECSGPUIResourceManager.Instance.RegisterNewPrefabAtRuntime((uint) ((int)prefabID * 2 + 1), gameObject, true); //.isOcclusionCulling = false; - UnityEngine.Object.Destroy(gameObject); - GPUInstancerAPI.AddInstancesToPrefabPrototypeAtRuntime(ECSGPUIResourceManager.Instance.prefabManager, - gameObject.GetComponent().prefabPrototype, new[] {gameObject}); - Console.WriteLine("Registered prefab to instancer"); - - /*var register = AccessTools.Method("RobocraftX.Common.ECSPhysicResourceManager:RegisterPrefab", - new[] {typeof(uint), typeof(GameObject), typeof(World), typeof(BlobAssetStore)}); - register.Invoke(ECSPhysicResourceManager.Instance, - new object[] {prefabID, gameObject, MGPatch.data.Item1, MGPatch.data.Item2});#1# - /*Console.WriteLine( - "Entity: " + ECSPhysicResourceManager.Instance.GetUECSPhysicEntityPrefab(prefabID)); - Console.WriteLine("Prefab ID: " + PrefabsID.DBIDMAP[500]); - PhysicsCollider componentData = MGPatch.data.Item1.EntityManager.GetComponentData(ECSPhysicResourceManager.Instance.GetUECSPhysicEntityPrefab(prefabID)); - Console.WriteLine("Collider valid: " + componentData.IsValid); - unsafe - { - Console.WriteLine("Collider type: " + componentData.ColliderPtr->Type); - CollisionFilter filter = componentData.Value.Value.Filter; - Console.WriteLine("Filter not empty: " + !filter.IsEmpty); - }#1# - //MGPatch.data.Item1.EntityManager.GetComponentData<>() - gameObject.AddComponent(); - gameObject.AddComponent(); - Console.WriteLine("Registered prefab to physics"); - ECSGPUIResourceManager.Instance.RegisterGhostsPrefabsAtRuntime(); - } - else if (gameObject.name == "CTR_CommandBlock") - materials = gameObject.GetComponentsInChildren()[0].sharedMaterials; - } - - public static MethodBase TargetMethod() - {RobocraftX.Common.ECSGPUIResourceManager.RegisterPrefab - return AccessTools.Method("RobocraftX.Common.ECSGPUIResourceManager:RegisterPrefab", - new[] {typeof(uint), typeof(GameObject)}); - } - }*/ - [HarmonyPatch] - public static class RMPatch + public static class CubeRegistrationPatch { - public static void Prefix(World physicsWorld, - GameObjectConversionSystem getExistingSystem, - FasterList gos, - List prefabData) + public static void Prefix(IDataDB dataDB) { - Console.WriteLine("First game object data:\n" + gos[0].GetComponents() - .Select(c => c + " - " + c.name + " " + c.GetType()) - .Aggregate((a, b) => a + "\n" + b)); - for (var index = 0; index < prefabData.Count; index++) + //var abd = dataDB.GetValue((int) BlockIDs.AluminiumCube); + foreach (var (key, type) in _customBlocks) { - var data = prefabData[index]; - if (!data.prefabName.EndsWith("Cube.prefab")) continue; - //getExistingSystem.DeclareLinkedEntityGroup(gos[index]); - /*Entity entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(gos[index], - GameObjectConversionSettings.FromWorld(physicsWorld, MGPatch.data.Item2));*/ - Console.WriteLine("Transform: " + gos[index].transform.childCount); - Entity primaryEntity = getExistingSystem.GetPrimaryEntity(gos[index]); - MultiListEnumerator entities = getExistingSystem.GetEntities(gos[index]); - Console.WriteLine("ID: " + data.prefabId + " - Name: " + data.prefabName); - Console.WriteLine("Primary entity: " + primaryEntity); - EntityManager entityManager = physicsWorld.EntityManager; - Console.WriteLine("Has collider: " + entityManager.HasComponent(primaryEntity)); - while (entities.MoveNext()) - { - Entity current = entities.Current; - Console.WriteLine("Entity " + current + " has collider: " + - entityManager.HasComponent(current)); - } - - Console.WriteLine("Adding GPUI prefab"); - ((GPUInstancerPrefabManager) GPUInstancerManager.activeManagerList.Single(gim => - gim is GPUInstancerPrefabManager)) - .AddRuntimeRegisteredPrefab(gos[index].GetComponent()); - Console.WriteLine("Added GPUI prefab"); + var attr = type.GetCustomAttribute(); + var cld = new CubeListData + { //"Assets/Prefabs/Cube.prefab" - "CTR_CommandBlock" - "strConsoleBlock" + cubeType = attr.Type, + cubeCategory = attr.Category, + inventoryCategory = attr.InventoryCategory, + ID = nextID++, + Path = attr.AssetPath, //Index out of range exception: Asset failed to load (wrong path) + SpriteName = attr.SpriteName, + CubeNameKey = attr.NameKey, + CubeDescriptionKey = attr.DescKey, + SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, + GridScale = new[] {5, 5, 5}, + Mass = attr.Mass, + Material = attr.Material, + scalingPermission = attr.ScalingPermission, + SortIndex = attr.SortIndex, + DefaultColour = attr.DefaultColor.Index, + Volume = attr.Volume, + EdgeConnectingFaces = new[] {0, 1, 2, 3, 4, 5}, + PointDataVolumeMultiplier = 1f + }; + dataDB.GetValues().Add(cld.ID.ToString(), cld); //The registration needs to happen after the ID has been set + dataDB.GetFasterValues().Add(cld.ID, cld); //So can't use the builtin method to create a CubeListData } - } - public static MethodBase TargetMethod() - { - return AccessTools.Method("RobocraftX.Blocks.ECSResourceManagerUtility:RelinkEntities", - new[] - { - typeof(World), - typeof(GameObjectConversionSystem), - typeof(FasterList), - typeof(List) - }); - } - } - - [HarmonyPatch] - public static class MGPatch - { - internal static (World, BlobAssetStore) data; - public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB) - { - data = (physicsWorld, blobStore); - //RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock - //var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null); - var abd = dataDB.GetValue((int) BlockIDs.AluminiumCube); - var cld = new CubeListData - { - cubeType = CubeType.Block, - cubeCategory = CubeCategory.General, - inventoryCategory = InventoryCategory.Shapes, - ID = 500, - Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path) - SpriteName = "CTR_CommandBlock", - CubeNameKey = "strConsoleBlock", - SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, - GridScale = new[] {1, 1, 1}, - Mass = 1, - Material = abd.Material, - scalingPermission = ScalingPermission.NonUniform, - SortIndex = 12, - DefaultColour = (byte) BlockColors.Lime, - Volume = 1f, - timeRunningCollision = TimeRunningCollision.Enabled, - IsIsolator = false, - EdgeConnectingFaces = new[] {0, 1, 2, 3, 4, 5}, - PointDataVolumeMultiplier = 1f - }; - Console.WriteLine("Aluminium block data:\n" + abd); - Console.WriteLine("Material: " + abd.Material); - dataDB.GetValues().Add("500", cld); //The registration needs to happen after the ID has been set - dataDB.GetFasterValues().Add(500, cld); - //RobocraftX.ExplosionFragments.Engines.PlayFragmentExplodeEngine.PlayRigidBodyEffect + _canRegister = false; } public static MethodBase TargetMethod() @@ -292,16 +143,15 @@ namespace GamecraftModdingAPI.Blocks public static IEnumerator Prep() { //TODO: Don't let the game load until this finishes - Console.WriteLine("Loading custom catalog..."); - var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); - while (!res.IsDone) yield return Yield.It; - Console.WriteLine("Loaded custom catalog: " + res.Result.LocatorId); - Addressables.AddResourceLocator(res.Result); - /*Console.WriteLine("Loading Cube asset..."); - var loadTask = Addressables.LoadAssetAsync("Assets/Cube.prefab"); - while (!loadTask.IsDone) yield return Yield.It; - Console.WriteLine("Exception: "+loadTask.OperationException); - Console.WriteLine("Result: " + loadTask.Result.name);*/ + foreach (var type in _customBlocks.Values) + { + var attr = type.GetCustomAttribute(); + Logging.Log("Loading custom block catalog " + attr.Catalog); + var res = Addressables.LoadContentCatalogAsync(attr.Catalog); + while (!res.IsDone) yield return Yield.It; + Logging.Log("Loaded custom block catalog: " + res.Result.LocatorId); + Addressables.AddResourceLocator(res.Result); + } } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs b/GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs new file mode 100644 index 0000000..7c7669f --- /dev/null +++ b/GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs @@ -0,0 +1,85 @@ +using System; +using DataLoader; + +namespace GamecraftModdingAPI.Blocks +{ + [AttributeUsage(AttributeTargets.Class)] + public class CustomBlockAttribute : Attribute + { + /// + /// Custom block attribute necessary for configuration. + /// + /// File path to the catalog.json that holds asset references for the custom block + /// The path/address to the block's prefab specified in Unity + /// The translation key for the block's name + /// The path to the inventory sprite for the block, console block by default + /// The translation key for the block's description + public CustomBlockAttribute(string catalog, string assetPath, string nameKey, + string spriteName = "CTR_CommandBlock", string descKey = "") + { + Catalog = catalog; + AssetPath = assetPath; + SpriteName = spriteName; + NameKey = nameKey; + DescKey = descKey; + } + + /// + /// The location of the catalog.json file used to find assets for this block. + /// + public string Catalog { get; } + /// + /// The asset path/address for the block's prefab. + /// + public string AssetPath { get; } + /// + /// The name of the sprite used in the inventory. + /// + public string SpriteName { get; } + /// + /// The translation key for the block's name. + /// + public string NameKey { get; } + /// + /// The translation key for the block's description. + /// + public string DescKey { get; } + + /// + /// The block's type - block, joint, light. + /// + public CubeType Type { get; set; } = CubeType.Block; + /// + /// The block's category, so it's treated as a pre-existing functional block. + /// + public CubeCategory Category { get; set; } = CubeCategory.General; + /// + /// The block's inventory category. + /// + public InventoryCategory InventoryCategory { get; set; } = InventoryCategory.Shapes; + /// + /// The block's mass. + /// + public float Mass { get; set; } = 1f; + /// + /// The key of the material properties this block should use. + /// + public string Material { get; set; } = "Aluminium"; + /// + /// The scaling permission determining what scaling is allowed on this block. + /// + public ScalingPermission ScalingPermission { get; set; } + /// + /// The sort index in the inventory. + /// + public int SortIndex { get; set; } + /// + /// The default color of the block when placed. + /// + public BlockColor DefaultColor { get; set; } + /// + /// The volume of the block. + /// + public float Volume { get; set; } = 1f; + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 268fdb2..02c7d2c 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -291,6 +292,13 @@ namespace GamecraftModdingAPI.Tests .BlockGroup = group; }).Build(); + CommandBuilder.Builder("placeCustomBlock", "Places a custom block, needs a custom catalog and assets.") + .Action((float x, float y, float z) => + { + Logging.CommandLog("Block placed: " + + Block.PlaceNew((BlockIDs) 500, new float3(0, 0, 0))); + }).Build(); + GameClient.SetDebugInfo("InstalledMods", InstalledMods); Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Type + " with ID " + args.ID); @@ -361,11 +369,16 @@ namespace GamecraftModdingAPI.Tests Log.Output("Submitted: " + Window.selected.submittedCode); }) .Build(); - /*JObject o1 = JObject.Parse(File.ReadAllText(@"Gamecraft_Data\StreamingAssets\aa\Windows\catalog.json")); - JObject o2 = JObject.Parse(File.ReadAllText(@"customCatalog.json")); - o1.Merge(o2, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Union}); - File.WriteAllText(@"Gamecraft_Data\StreamingAssets\aa\Windows\catalog.json", o1.ToString());*/ CustomBlock.Prep().RunOn(ExtraLean.UIScheduler); + try + { + CustomBlock.RegisterCustomBlock(); + Logging.MetaDebugLog("Registered test custom block"); + } + catch (FileNotFoundException) + { + Logging.MetaDebugLog("Test custom block catalog not found"); + } #if TEST TestRoot.RunTests(); @@ -429,6 +442,18 @@ namespace GamecraftModdingAPI.Tests return ((Action) MinimumSpecsCheck.CheckRequirementsMet).Method; } } + + [CustomBlock("customCatalog.json", "Assets/Prefabs/Cube.prefab", "strAluminiumCube", SortIndex = 12)] + public class TestBlock : CustomBlock + { + public TestBlock(EGID id) : base(id) + { + } + + public TestBlock(uint id) : base(id) + { + } + } } #endif } From 6a9073919771739c32c3eb1ea96b3cd23326b48b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 19 Dec 2020 21:43:49 +0100 Subject: [PATCH 24/98] Attempt to use custom cube category --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 54 ++++++++++++------- GamecraftModdingAPI/Main.cs | 5 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 1 - 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 331552c..15cfb15 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -2,27 +2,19 @@ using System.Collections; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; -using DataLoader; -using GamecraftModdingAPI.App; -using GamecraftModdingAPI.Utility; -using GPUInstancer; using HarmonyLib; + +using DataLoader; using RobocraftX.Blocks; -using RobocraftX.Common; using RobocraftX.Rendering; -using Svelto.DataStructures; using Svelto.ECS; using Svelto.Tasks; -using Unity.Entities.Conversion; -using Unity.Physics; using UnityEngine; using UnityEngine.AddressableAssets; -using BoxCollider = UnityEngine.BoxCollider; using Material = UnityEngine.Material; -using Object = UnityEngine.Object; -using ScalingPermission = DataLoader.ScalingPermission; + +using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { @@ -62,18 +54,18 @@ namespace GamecraftModdingAPI.Blocks public CustomBlock(EGID id) : base(id) { - if (id.groupID != Group) - throw new BlockTypeException("The block is not a custom block! It has a group of " + id.groupID); + /*if (id.groupID != Group) + throw new BlockTypeException("The block is not a custom block! It has a group of " + id.groupID);*/ } - public CustomBlock(uint id) : this(new EGID(id, Group)) + public CustomBlock(uint id) : base(id) { } - public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); + //public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); [HarmonyPatch] - public static class Patch + public static class MaterialCopyPatch { private static Material[] materials; @@ -110,6 +102,7 @@ namespace GamecraftModdingAPI.Blocks var cld = new CubeListData { //"Assets/Prefabs/Cube.prefab" - "CTR_CommandBlock" - "strConsoleBlock" cubeType = attr.Type, + //cubeCategory = (CubeCategory) 1000, cubeCategory = attr.Category, inventoryCategory = attr.InventoryCategory, ID = nextID++, @@ -141,8 +134,24 @@ namespace GamecraftModdingAPI.Blocks } } - public static IEnumerator Prep() - { //TODO: Don't let the game load until this finishes + /*[HarmonyPatch] - The block has no collision even in simulation if using a custom category + private static class FactorySetupPatch + { + public static void Prefix(BlockEntityFactory __instance) + { + var builders = (Dictionary) + AccessTools.Field(__instance.GetType(), "_blockBuilders").GetValue(__instance); + builders.Add((CubeCategory) 1000, new BlockBuilder(Group)); + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method(typeof(BlockEntityFactory), "ParseDataDB"); + } + }*/ + + internal static IEnumerator Prepare() + { //Should be pretty quick foreach (var type in _customBlocks.Values) { var attr = type.GetCustomAttribute(); @@ -153,5 +162,12 @@ namespace GamecraftModdingAPI.Blocks Addressables.AddResourceLocator(res.Result); } } + + /*internal static void OnBlockFactoryObtained(BlockEntityFactory factory) + { + var builders = (Dictionary) + AccessTools.Field(factory.GetType(), "_blockBuilders").GetValue(factory); + builders.Add((CubeCategory) 1000, new BlockBuilder(Group)); + }*/ } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 584ae90..775670f 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -1,12 +1,14 @@ using System; using System.Reflection; -using GamecraftModdingAPI.Blocks; using HarmonyLib; using RobocraftX; +using RobocraftX.Schedulers; using RobocraftX.Services; using Svelto.Context; +using Svelto.Tasks.ExtraLean; +using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Events; using GamecraftModdingAPI.Tasks; @@ -89,6 +91,7 @@ namespace GamecraftModdingAPI AsyncUtils.Init(); GamecraftModdingAPI.App.Client.Init(); GamecraftModdingAPI.App.Game.Init(); + CustomBlock.Prepare().RunOn(ExtraLean.UIScheduler); Logging.MetaLog($"{currentAssembly.GetName().Name} v{currentAssembly.GetName().Version} initialized"); } diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 02c7d2c..009c368 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -369,7 +369,6 @@ namespace GamecraftModdingAPI.Tests Log.Output("Submitted: " + Window.selected.submittedCode); }) .Build(); - CustomBlock.Prep().RunOn(ExtraLean.UIScheduler); try { CustomBlock.RegisterCustomBlock(); From 879901f4b9efa95313e19f0ce5e2f0f4c830ec58 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 20 Dec 2020 00:05:02 +0100 Subject: [PATCH 25/98] Add new block IDs, a property, 2 tests and fixes --- GamecraftModdingAPI/Block.cs | 2 +- GamecraftModdingAPI/Blocks/BlockIDs.cs | 26 +++++++++++----- GamecraftModdingAPI/Blocks/BlockTests.cs | 36 +++++++++++++++++----- GamecraftModdingAPI/Blocks/DampedSpring.cs | 11 +++++++ GamecraftModdingAPI/Tests/Assert.cs | 19 ++++++++++++ 5 files changed, 77 insertions(+), 17 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 4aa0a30..513ad5e 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -171,7 +171,7 @@ namespace GamecraftModdingAPI egid = new EGID(id, group.Value); if (typeToGroup.TryGetValue(type, out var gr) && gr.All(egs => egs != group.Value)) //If this subclass has a specific group, then use that - so Block should still work - throw new BlockTypeException($"Incompatible block type! Type {type.Name} belongs to group {gr.Select(g => g.ToString()).Aggregate((a, b) => a + ", " + b)} instead of {group.Value}"); + throw new BlockTypeException($"Incompatible block type! Type {type.Name} belongs to group {gr.Select(g => ((uint)g).ToString()).Aggregate((a, b) => a + ", " + b)} instead of {(uint)group.Value}"); } if (initializers.TryGetValue(type, out var func)) diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index 9591ae2..ff08b51 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -71,8 +71,9 @@ namespace GamecraftModdingAPI.Blocks GlassConeSegment, GlassCylinder, GlassSphere, - Lever, //63 - two IDs skipped - PlayerSpawn = 66, //Crashes without special handling + Lever, //63 + WoodenSlatsDoor = 65, + PlayerSpawn, //Crashes without special handling SmallSpawn, MediumSpawn, LargeSpawn, @@ -86,10 +87,17 @@ namespace GamecraftModdingAPI.Blocks DampedSpring, ServoPiston, StepperPiston, - PneumaticPiston, + PneumaticPiston, //80 PneumaticHinge, - PneumaticAxle, //82 - PilotSeat = 90, //Might crash + PneumaticAxle, + WindowedDoor, + Bench, + Chair, + Stool, + DampedHingeSpring, + PlainGlassDoor, + PlainWoodenDoor, + PilotSeat, //Might crash PassengerSeat, PilotControls, GrassCube, @@ -148,8 +156,9 @@ namespace GamecraftModdingAPI.Blocks WoodCylinder, WoodHemisphere, WoodSphere, - BrickCube, //149 - BrickSlicedCube = 151, + BrickCube, + DampedAxleSpring, //150 + BrickSlicedCube, BrickSlope, BrickCorner, ConcreteCube, @@ -355,6 +364,7 @@ namespace GamecraftModdingAPI.Blocks HexNetCylinder = 797, HexNetHemisphere, HexNetSphere, - HexNetTubeCorner //800 + HexNetTubeCorner, //800 + CenterOfMassBlock = 1346 } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlockTests.cs b/GamecraftModdingAPI/Blocks/BlockTests.cs index 5447f6c..dbcd39e 100644 --- a/GamecraftModdingAPI/Blocks/BlockTests.cs +++ b/GamecraftModdingAPI/Blocks/BlockTests.cs @@ -1,6 +1,7 @@ using System; using Gamecraft.Wires; +using Unity.Mathematics; using GamecraftModdingAPI; using GamecraftModdingAPI.Tests; @@ -60,19 +61,31 @@ namespace GamecraftModdingAPI.Blocks Assert.Errorless(() => { b = newBlock.Specialise(); }, "Block.Specialize() raised an exception: ", "Block.Specialize() completed without issue."); if (!Assert.NotNull(b, "Block.Specialize() returned null, possibly because it failed silently.", "Specialized Piston is not null.")) return; if (!Assert.CloseTo(b.MaximumExtension, 1.01f, $"Piston.MaximumExtension {b.MaximumExtension} does not equal default value, possibly because it failed silently.", "Piston.MaximumExtension is close enough to default.")) return; - if (!Assert.CloseTo(b.MaximumForce, 750f, $"Piston.MaximumForce {b.MaximumForce} does not equal default value, possibly because it failed silently.", "Piston.MaximumForce is close enough to default.")) return; + if (!Assert.CloseTo(b.MaximumForce, 1.0f, $"Piston.MaximumForce {b.MaximumForce} does not equal default value, possibly because it failed silently.", "Piston.MaximumForce is close enough to default.")) return; } - [APITestCase(TestType.EditMode)] + [APITestCase(TestType.EditMode)] public static void TestServo() { - Block newBlock = Block.PlaceNew(BlockIDs.ServoAxle, Unity.Mathematics.float3.zero + 1); - Servo b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler - Assert.Errorless(() => { b = newBlock.Specialise(); }, "Block.Specialize() raised an exception: ", "Block.Specialize() completed without issue."); - if (!Assert.NotNull(b, "Block.Specialize() returned null, possibly because it failed silently.", "Specialized Servo is not null.")) return; - if (!Assert.CloseTo(b.MaximumAngle, 180f, $"Servo.MaximumAngle {b.MaximumAngle} does not equal default value, possibly because it failed silently.", "Servo.MaximumAngle is close enough to default.")) return; + Block newBlock = Block.PlaceNew(BlockIDs.ServoAxle, Unity.Mathematics.float3.zero + 1); + Servo b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler + Assert.Errorless(() => { b = newBlock.Specialise(); }, "Block.Specialize() raised an exception: ", "Block.Specialize() completed without issue."); + if (!Assert.NotNull(b, "Block.Specialize() returned null, possibly because it failed silently.", "Specialized Servo is not null.")) return; + if (!Assert.CloseTo(b.MaximumAngle, 180f, $"Servo.MaximumAngle {b.MaximumAngle} does not equal default value, possibly because it failed silently.", "Servo.MaximumAngle is close enough to default.")) return; if (!Assert.CloseTo(b.MinimumAngle, -180f, $"Servo.MinimumAngle {b.MinimumAngle} does not equal default value, possibly because it failed silently.", "Servo.MinimumAngle is close enough to default.")) return; - if (!Assert.CloseTo(b.MaximumForce, 750f, $"Servo.MaximumForce {b.MaximumForce} does not equal default value, possibly because it failed silently.", "Servo.MaximumForce is close enough to default.")) return; + if (!Assert.CloseTo(b.MaximumForce, 60f, $"Servo.MaximumForce {b.MaximumForce} does not equal default value, possibly because it failed silently.", "Servo.MaximumForce is close enough to default.")) return; + } + + [APITestCase(TestType.EditMode)] + public static void TestDampedSpring() + { + Block newBlock = Block.PlaceNew(BlockIDs.DampedSpring, Unity.Mathematics.float3.zero + 1); + DampedSpring b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler + Assert.Errorless(() => { b = newBlock.Specialise(); }, "Block.Specialize() raised an exception: ", "Block.Specialize() completed without issue."); + if (!Assert.NotNull(b, "Block.Specialize() returned null, possibly because it failed silently.", "Specialized DampedSpring is not null.")) return; + if (!Assert.CloseTo(b.Stiffness, 1.0f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; + if (!Assert.CloseTo(b.Damping, 0.1f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; + if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; } [APITestCase(TestType.Game)] @@ -119,6 +132,13 @@ namespace GamecraftModdingAPI.Blocks if (!Assert.Errorless(() => { newWire = b.Connect(0, target, 0);})) return; if (!Assert.NotNull(newWire, "SignalingBlock.Connect(...) returned null, possible because it failed silently.", "SignalingBlock.Connect(...) returned a non-null value.")) return; } + + [APITestCase(TestType.EditMode)] + public static void TestSpecialiseError() + { + Block newBlock = Block.PlaceNew(BlockIDs.Bench, new float3(1, 1, 1)); + if (Assert.Errorful(() => newBlock.Specialise(), "Block.Specialise() was expected to error on a bench block.", "Block.Specialise() errored as expected for a bench block.")) return; + } } #endif } diff --git a/GamecraftModdingAPI/Blocks/DampedSpring.cs b/GamecraftModdingAPI/Blocks/DampedSpring.cs index 51da25e..20d28f2 100644 --- a/GamecraftModdingAPI/Blocks/DampedSpring.cs +++ b/GamecraftModdingAPI/Blocks/DampedSpring.cs @@ -44,5 +44,16 @@ namespace GamecraftModdingAPI.Blocks set => BlockEngine.SetBlockInfo(this, (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value); } + + /// + /// The spring's maximum extension. + /// + public float MaxExtension + { + get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.maxExtent); + + set => BlockEngine.SetBlockInfo(this, + (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.maxExtent = val, value); + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Tests/Assert.cs b/GamecraftModdingAPI/Tests/Assert.cs index 78f0597..edc1392 100644 --- a/GamecraftModdingAPI/Tests/Assert.cs +++ b/GamecraftModdingAPI/Tests/Assert.cs @@ -119,6 +119,25 @@ namespace GamecraftModdingAPI.Tests return true; } + public static bool Errorful(Action tryThis, string err = null, string success = null) where T : Exception + { + if (err == null) err = $"{tryThis} was expected to error but completed without errors."; + if (success == null) success = $"{tryThis} completed with an expected error."; + try + { + tryThis(); + } + catch (T e) + { + TestRoot.TestsPassed = true; + Log(PASS + success + " " + e.GetType().Name + ": " + e.Message); + return true; + } + Log(FAIL + err); + TestRoot.TestsPassed = false; + return false; + } + public static bool CloseTo(float a, float b, string err = null, string success = null, float delta = float.Epsilon) { if (err == null) err = $"{a} is not within {delta} of {b}."; From 1c014e36acb81b389782482788d54cee599f22a2 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 21 Dec 2020 16:31:57 -0500 Subject: [PATCH 26/98] Add IMGUI styling and initial OOP implementation --- GamecraftModdingAPI/Interface/IMGUI/Button.cs | 92 ++++++++++ .../Interface/IMGUI/Constants.cs | 168 ++++++++++++++++++ GamecraftModdingAPI/Interface/IMGUI/Group.cs | 157 ++++++++++++++++ .../Interface/IMGUI/IMGUIManager.cs | 94 ++++++++++ GamecraftModdingAPI/Interface/IMGUI/Image.cs | 58 ++++++ GamecraftModdingAPI/Interface/IMGUI/Label.cs | 59 ++++++ GamecraftModdingAPI/Interface/IMGUI/Text.cs | 109 ++++++++++++ .../Interface/IMGUI/UIElement.cs | 28 +++ GamecraftModdingAPI/Main.cs | 3 + .../Tests/GamecraftModdingAPIPluginTest.cs | 37 +++- 10 files changed, 803 insertions(+), 2 deletions(-) create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Button.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Constants.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Group.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Image.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Label.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/Text.cs create mode 100644 GamecraftModdingAPI/Interface/IMGUI/UIElement.cs diff --git a/GamecraftModdingAPI/Interface/IMGUI/Button.cs b/GamecraftModdingAPI/Interface/IMGUI/Button.cs new file mode 100644 index 0000000..5a119f6 --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Button.cs @@ -0,0 +1,92 @@ +using System; +using Unity.Mathematics; +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// A clickable button. + /// This wraps Unity's IMGUI Button. + /// + public class Button : UIElement + { + private bool automaticLayout = false; + + private string text; + + /// + /// The rectangular area that the button can use. + /// + public Rect Box { get; set; } = Rect.zero; + + /// + /// An event that fires when the button is clicked. + /// + public event EventHandler OnClick; + + public void OnGUI() + { + if (automaticLayout) + { + if (GUILayout.Button(text, Constants.Default.button)) + { + OnClick?.Invoke(this, true); + } + } + else + { + if (GUI.Button(Box, text, Constants.Default.button)) + { + OnClick?.Invoke(this, true); + } + } + } + + /// + /// The button's unique name. + /// + public string Name { get; private set; } + + /// + /// Whether to display the button. + /// + public bool Enabled { get; set; } = true; + + /// + /// Initialize a new button with automatic layout. + /// + /// The text to display on the button. + /// The button's name. + public Button(string text, string name = null) + { + automaticLayout = true; + this.text = text; + if (name == null) + { + this.Name = typeof(Button).FullName + "::" + text; + } + else + { + this.Name = name; + } + IMGUIManager.AddElement(this); + } + + /// + /// Initialize a new button. + /// + /// The text to display on the button. + /// Rectangular area for the button to use. + /// The button's name. + public Button(string text, Rect box, string name = null) : this(text, name) + { + automaticLayout = false; + this.Box = box; + } + + ~Button() + { + IMGUIManager.RemoveElement(this); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/Constants.cs b/GamecraftModdingAPI/Interface/IMGUI/Constants.cs new file mode 100644 index 0000000..3e2fa8f --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Constants.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; +using GamecraftModdingAPI.Utility; +using HarmonyLib; +using Svelto.Tasks; +using Svelto.Tasks.Lean; +using UnityEngine; +using UnityEngine.AddressableAssets; +using UnityEngine.ResourceManagement.AsyncOperations; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// Convenient IMGUI values. + /// + public static class Constants + { + private static byte _defaultCompletion = 0; + private static GUISkin _default = null; + + /// + /// Best-effort imitation of Gamecraft's UI style. + /// + public static GUISkin Default + { + get + { + if (_defaultCompletion != 0) _default = BuildDefaultGUISkin(); + return _default; + } + } + + private static Font _riffic = null; + + private static Texture2D _blueBackground = null; + private static Texture2D _grayBackground = null; + private static Texture2D _whiteBackground = null; + private static Texture2D _textInputBackground = null; + private static Texture2D _areaBackground = null; + + internal static void Init() + { + LoadGUIAssets(); + } + + private static GUISkin BuildDefaultGUISkin() + { + _defaultCompletion = 0; + if (_riffic == null) return GUI.skin; + // build GUISkin + GUISkin gui = ScriptableObject.CreateInstance(); + gui.font = _riffic; + gui.settings.selectionColor = Color.white; + gui.settings.tripleClickSelectsLine = true; + // set properties off all UI elements + foreach (PropertyInfo p in typeof(GUISkin).GetProperties()) + { + // for a "scriptable" GUI system, it's ironic there's no better way to do this + if (p.GetValue(gui) is GUIStyle style) + { + style.richText = true; + style.alignment = TextAnchor.MiddleCenter; + style.fontSize = 30; + style.wordWrap = true; + style.border = new RectOffset(4, 4, 4, 4); + style.margin = new RectOffset(4, 4, 4, 4); + style.padding = new RectOffset(4, 4, 4, 4); + // normal state + style.normal.background = _blueBackground; + style.normal.textColor = Color.white; + // hover state + style.hover.background = _grayBackground; + style.hover.textColor = Color.white; + // focused + style.focused.background = _grayBackground; + style.focused.textColor = Color.white; + // clicking state + style.active.background = _whiteBackground; + style.active.textColor = Color.white; + + p.SetValue(gui, style); // probably unnecessary + } + } + // set element-specific styles + // label + gui.label.normal.background = null; + gui.label.hover.background = null; + gui.label.focused.background = null; + gui.label.active.background = null; + // text input + gui.textField.normal.background = _textInputBackground; + gui.textField.hover.background = _textInputBackground; + gui.textField.focused.background = _textInputBackground; + gui.textField.active.background = _textInputBackground; + // text area + gui.textArea.normal.background = _textInputBackground; + gui.textArea.hover.background = _textInputBackground; + gui.textArea.focused.background = _textInputBackground; + gui.textArea.active.background = _textInputBackground; + // window + gui.window.normal.background = _areaBackground; + gui.window.hover.background = _areaBackground; + gui.window.focused.background = _areaBackground; + gui.window.active.background = _areaBackground; + // box (also used by layout groups & areas) + gui.box.normal.background = _areaBackground; + gui.box.hover.background = _areaBackground; + gui.box.focused.background = _areaBackground; + gui.box.active.background = _areaBackground; + return gui; + } + + private static void LoadGUIAssets() + { + AsyncOperationHandle rifficHandle = Addressables.LoadAssetAsync("Assets/Art/Fonts/riffic-bold.ttf"); + rifficHandle.Completed += handle => + { + _riffic = handle.Result; + _defaultCompletion++; + }; + _blueBackground = new Texture2D(1, 1); + _blueBackground.SetPixel(0, 0, new Color(0.004f, 0.522f, 0.847f) /* Gamecraft Blue */); + _blueBackground.Apply(); + _grayBackground = new Texture2D(1, 1); + _grayBackground.SetPixel(0, 0, new Color(0.745f, 0.745f, 0.745f) /* Gray */); + _grayBackground.Apply(); + _whiteBackground = new Texture2D(1, 1); + _whiteBackground.SetPixel(0, 0, new Color(0.898f, 0.898f, 0.898f) /* Very light gray */); + _whiteBackground.Apply(); + _textInputBackground = new Texture2D(1, 1); + _textInputBackground.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.25f) /* Translucent gray */); + _textInputBackground.Apply(); + _areaBackground = new Texture2D(1, 1); + _areaBackground.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.25f) /* Translucent gray */); + _areaBackground.Apply(); + /* // this is actually gray (used for the loading screen) + AsyncOperationHandle backgroundHandle = + Addressables.LoadAssetAsync("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg"); + backgroundHandle.Completed += handle => + { + _blueBackground = handle.Result; + _defaultCompletion++; + };*/ + _defaultCompletion++; + } + } + + [HarmonyPatch(typeof(FMODUnity.RuntimeManager), "PlayOneShot", new []{ typeof(Guid), typeof(Vector3)})] + public class FMODRuntimeManagerPlayOneShotPatch + { + public static void Prefix(Guid guid) + { + Logging.MetaLog($"Playing sound with guid '{guid.ToString()}'"); + } + } + + [HarmonyPatch(typeof(FMODUnity.RuntimeManager), "PlayOneShot", new []{ typeof(string), typeof(Vector3)})] + public class FMODRuntimeManagerPlayOneShotPatch2 + { + public static void Prefix(string path) + { + Logging.MetaLog($"Playing sound with str '{path}'"); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/Group.cs b/GamecraftModdingAPI/Interface/IMGUI/Group.cs new file mode 100644 index 0000000..7033dee --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Group.cs @@ -0,0 +1,157 @@ +using System; +using GamecraftModdingAPI.Utility; +using Svelto.DataStructures; +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// A group of elements. + /// This wraps Unity's GUILayout Area and GUI Group system. + /// + public class Group : UIElement + { + private bool automaticLayout; + + private FasterList elements = new FasterList(); + + /// + /// The rectangular area in the window that the UI group can use + /// + public Rect Box { get; set; } + + public void OnGUI() + { + /*if (Constants.Default == null) return; + if (Constants.Default.box == null) return;*/ + GUIStyle guiStyle = Constants.Default.box; + UIElement[] elems = elements.ToArrayFast(out uint count); + if (automaticLayout) + { + GUILayout.BeginArea(Box, guiStyle); + for (uint i = 0; i < count; i++) + { + /*try + { + if (elems[i].Enabled) + elems[i].OnGUI(); + } + catch (ArgumentException) + { + // ignore these, since this is (hopefully) just Unity being dumb + } + catch (Exception e) + { + Logging.MetaDebugLog($"Element '{elems[i].Name}' threw exception:\n{e.ToString()}"); + }*/ + if (elems[i].Enabled) + elems[i].OnGUI(); + } + GUILayout.EndArea(); + } + else + { + GUI.BeginGroup(Box, guiStyle); + for (uint i = 0; i < count; i++) + { + if (elems[i].Enabled) + elems[i].OnGUI(); + } + GUI.EndGroup(); + } + } + + /// + /// The group's unique name. + /// + public string Name { get; } + + /// + /// Whether to display the group and everything in it. + /// + public bool Enabled { set; get; } = true; + + /// + /// The amount of elements in the group. + /// + public int Length + { + get => elements.count; + } + + /// + /// Initializes a new instance of the class. + /// + /// The rectangular area to use in the window. + /// Name of the group. + /// Whether to use automatic UI layout. + public Group(Rect box, string name = null, bool automaticLayout = false) + { + Box = box; + if (name == null) + { + this.Name = typeof(Group).FullName + "::" + box.ToString().Replace(" ", ""); + } + else + { + this.Name = name; + } + this.automaticLayout = automaticLayout; + IMGUIManager.AddElement(this); + } + + /// + /// Add an element to the group. + /// + /// The element to add. + /// Index of the new element. + public int AddElement(UIElement element) + { + IMGUIManager.RemoveElement(element); // groups manage internal elements themselves + elements.Add(element); + return elements.count - 1; + } + + /// + /// Remove an element from the group. + /// + /// The element to remove. + /// Whether removal was successful. + public bool RemoveElement(UIElement element) + { + int index = IndexOf(element); + return RemoveAt(index); + } + + /// + /// Remove the element in a specific location. + /// + /// Index of the element. + /// Whether removal was successful. + public bool RemoveAt(int index) + { + if (index < 0 || index >= elements.count) return false; + IMGUIManager.AddElement(elements[index]); // re-add to global manager + elements.RemoveAt(index); + return true; + } + + /// + /// Get the index of an element. + /// + /// The element to search for. + /// The element's index, or -1 if not found. + public int IndexOf(UIElement element) + { + UIElement[] elems = elements.ToArrayFast(out uint count); + for (int i = 0; i < count; i++) + { + if (elems[i].Name == element.Name) + { + return i; + } + } + return -1; + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs new file mode 100644 index 0000000..f6048e7 --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using GamecraftModdingAPI.App; +using GamecraftModdingAPI.Utility; +using Rewired.Internal; +using Svelto.DataStructures; +using Svelto.Tasks; +using Svelto.Tasks.ExtraLean; +using Svelto.Tasks.ExtraLean.Unity; +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + public static class IMGUIManager + { + internal static OnGuiRunner ImguiScheduler = new OnGuiRunner("GamecraftModdingAPI_IMGUIScheduler"); + + private static FasterDictionary _activeElements = new FasterDictionary(); + + public static void AddElement(UIElement e) + { + if (!ExistsElement(e)) + { + _activeElements[e.Name] = e; + } + } + + public static bool ExistsElement(string name) + { + return _activeElements.ContainsKey(name); + } + + public static bool ExistsElement(UIElement element) + { + return ExistsElement(element.Name); + } + + public static bool RemoveElement(string name) + { + if (ExistsElement(name)) + { + return _activeElements.Remove(name); + } + + return false; + } + + public static bool RemoveElement(UIElement element) + { + return RemoveElement(element.Name); + } + + private static void OnGUI() + { + UIElement[] elements = _activeElements.GetValuesArray(out uint count); + for(uint i = 0; i < count; i++) + { + if (elements[i].Enabled) + elements[i].OnGUI(); + /*try + { + if (elements[i].Enabled) + elements[i].OnGUI(); + } + catch (ArgumentException) + { + // ignore these, since this is (hopefully) just Unity being dumb + } + catch (Exception e) + { + Logging.MetaDebugLog($"Element '{elements[i].Name}' threw exception:\n{e.ToString()}"); + }*/ + + } + } + + private static IEnumerator OnGUIAsync() + { + yield return (new Svelto.Tasks.Enumerators.WaitForSecondsEnumerator(5)).Continue(); // wait for some startup + while (true) + { + yield return Yield.It; + GUI.skin = Constants.Default; + OnGUI(); + } + } + + internal static void Init() + { + OnGUIAsync().RunOn(ImguiScheduler); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/Image.cs b/GamecraftModdingAPI/Interface/IMGUI/Image.cs new file mode 100644 index 0000000..8c026ed --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Image.cs @@ -0,0 +1,58 @@ +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + public class Image : UIElement + { + private bool automaticLayout = false; + + public Texture Texture { get; set; } + + public Rect Box { get; set; } = Rect.zero; + + public void OnGUI() + { + //if (Texture == null) return; + if (automaticLayout) + { + GUILayout.Label(Texture, Constants.Default.label); + } + else + { + GUI.Label(Box, Texture, Constants.Default.label); + } + } + + public string Name { get; } + public bool Enabled { set; get; } = true; + + public Image(Texture texture = null, string name = null) + { + automaticLayout = true; + Texture = texture; + if (name == null) + { + if (texture == null) + { + this.Name = typeof(Image).FullName + "::" + texture; + } + else + { + this.Name = typeof(Image).FullName + "::" + texture.name + "(" + texture.width + "x" + texture.height + ")"; + } + + } + else + { + this.Name = name; + } + IMGUIManager.AddElement(this); + } + + public Image(Rect box, Texture texture = null, string name = null) : this(texture, name) + { + this.Box = box; + automaticLayout = false; + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/Label.cs b/GamecraftModdingAPI/Interface/IMGUI/Label.cs new file mode 100644 index 0000000..2fb54f7 --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Label.cs @@ -0,0 +1,59 @@ +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// A simple text label. + /// This wraps Unity IMGUI's Label. + /// + public class Label : UIElement + { + private bool automaticLayout = false; + + /// + /// String to display on the label. + /// + public string Text { get; set; } + + /// + /// The rectangular area that the label can use. + /// + public Rect Box { get; set; } = Rect.zero; + + public void OnGUI() + { + if (automaticLayout) + { + GUILayout.Label(Text, Constants.Default.label); + } + else + { + GUI.Label(Box, Text, Constants.Default.label); + } + } + + public string Name { get; } + public bool Enabled { set; get; } = true; + + public Label(string initialText = null, string name = null) + { + automaticLayout = true; + Text = initialText; + if (name == null) + { + this.Name = typeof(Label).FullName + "::" + initialText; + } + else + { + this.Name = name; + } + IMGUIManager.AddElement(this); + } + + public Label(Rect box, string initialText = null, string name = null) : this(initialText, name) + { + this.Box = box; + automaticLayout = false; + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/Text.cs b/GamecraftModdingAPI/Interface/IMGUI/Text.cs new file mode 100644 index 0000000..1b94804 --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/Text.cs @@ -0,0 +1,109 @@ +using System; +using UnityEngine; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// A text input field. + /// This wraps Unity's IMGUI TextField and TextArea. + /// + public class Text : UIElement + { + private bool automaticLayout; + + /// + /// Whether the text input field is multiline (true -> TextArea) or not (false -> TextField). + /// + public bool Multiline { get; set; } + + private string text; + + /// + /// The rectangular area that the text field can use. + /// + public Rect Box { get; set; } = Rect.zero; + + /// + /// An event that fires whenever the text input is edited. + /// + public event EventHandler OnEdit; + + public void OnGUI() + { + string editedText = null; + if (automaticLayout) + { + if (Multiline) + { + editedText = GUILayout.TextArea(text, Constants.Default.textArea); + } + else + { + editedText = GUILayout.TextField(text, Constants.Default.textField); + } + } + else + { + if (Multiline) + { + editedText = GUI.TextArea(Box, text, Constants.Default.textArea); + } + else + { + editedText = GUI.TextField(Box, text, Constants.Default.textField); + } + } + + if (editedText != null && editedText != text) + { + OnEdit?.Invoke(this, editedText); + text = editedText; + } + } + + /// + /// The text field's unique name. + /// + public string Name { get; } + + /// + /// Whether to display the text field. + /// + public bool Enabled { set; get; } = true; + + /// + /// Initialize the text input field with automatic layout. + /// + /// Initial text in the input field. + /// The text field's name. + /// Allow multiple lines? + public Text(string initialText = null, string name = null, bool multiline = false) + { + this.Multiline = multiline; + automaticLayout = true; + text = initialText ?? ""; + if (name == null) + { + this.Name = typeof(Text).FullName + "::" + text; + } + else + { + this.Name = name; + } + IMGUIManager.AddElement(this); + } + + /// + /// Initialize the text input field. + /// + /// Rectangular area for the text field. + /// Initial text in the input field. + /// The text field's name. + /// Allow multiple lines? + public Text(Rect box, string initialText = null, string name = null, bool multiline = false) : this(initialText, name, multiline) + { + this.Box = box; + automaticLayout = false; + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Interface/IMGUI/UIElement.cs b/GamecraftModdingAPI/Interface/IMGUI/UIElement.cs new file mode 100644 index 0000000..abaed6e --- /dev/null +++ b/GamecraftModdingAPI/Interface/IMGUI/UIElement.cs @@ -0,0 +1,28 @@ +using System; + +namespace GamecraftModdingAPI.Interface.IMGUI +{ + /// + /// GUI Element like a text field, button or picture. + /// This interface is used to wrap many elements from Unity's IMGUI system. + /// + public interface UIElement + { + /// + /// GUI operations to perform in the OnGUI scope. + /// This is basically equivalent to a MonoBehaviour's OnGUI method. + /// + void OnGUI(); + + /// + /// The element's name. + /// This should be unique for every instance of the class. + /// + string Name { get; } + + /// + /// Whether to display the UI element or not. + /// + bool Enabled { get; } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 584ae90..d957a46 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -89,6 +89,9 @@ namespace GamecraftModdingAPI AsyncUtils.Init(); GamecraftModdingAPI.App.Client.Init(); GamecraftModdingAPI.App.Game.Init(); + // init UI + Interface.IMGUI.Constants.Init(); + Interface.IMGUI.IMGUIManager.Init(); Logging.MetaLog($"{currentAssembly.GetName().Name} v{currentAssembly.GetName().Version} initialized"); } diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 81a814c..e3abdca 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; - +using GamecraftModdingAPI.App; using HarmonyLib; using IllusionInjector; // test @@ -22,8 +22,16 @@ using GamecraftModdingAPI.Commands; using GamecraftModdingAPI.Events; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Blocks; +using GamecraftModdingAPI.Interface.IMGUI; using GamecraftModdingAPI.Players; +using UnityEngine.AddressableAssets; +using UnityEngine.AddressableAssets.ResourceLocators; +using UnityEngine.ResourceManagement.AsyncOperations; +using UnityEngine.ResourceManagement.ResourceLocations; +using UnityEngine.ResourceManagement.ResourceProviders; +using Debug = FMOD.Debug; using EventType = GamecraftModdingAPI.Events.EventType; +using Label = GamecraftModdingAPI.Interface.IMGUI.Label; namespace GamecraftModdingAPI.Tests { @@ -347,13 +355,38 @@ namespace GamecraftModdingAPI.Tests { Logging.Log("Compatible GamecraftScripting detected"); } + // Interface test + /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true); + Interface.IMGUI.Button button = new Button("TEST"); + button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; + Interface.IMGUI.Button button2 = new Button("TEST2"); + button2.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; + Text uiText = new Text("This is text!", multiline: true); + uiText.OnEdit += (t, txt) => { Logging.MetaDebugLog($"Text in {((Text)t).Name} is now '{txt}'"); }; + Label uiLabel = new Label("Label!"); + Image uiImg = new Image(name:"Behold this texture!"); + uiImg.Enabled = false; + uiGroup.AddElement(button); + uiGroup.AddElement(button2); + uiGroup.AddElement(uiText); + uiGroup.AddElement(uiLabel); + uiGroup.AddElement(uiImg); + Addressables.LoadAssetAsync("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg") + .Completed += + handle => + { + uiImg.Texture = handle.Result; + uiImg.Enabled = true; + Logging.MetaDebugLog($"Got blue bg asset {handle.Result}"); + }; + */ #if TEST TestRoot.RunTests(); #endif } - private string modsString; + private string modsString; private string InstalledMods() { if (modsString != null) return modsString; From fdc47832f4b75a6d58187bab1dd9c61d90150c87 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 26 Dec 2020 01:59:06 +0100 Subject: [PATCH 27/98] Store custom block IDs in save files --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 33 ++++++++--- .../Blocks/CustomBlockEntityDescriptor.cs | 57 +++++++++++++++++++ GamecraftModdingAPI/Main.cs | 2 +- .../Utility/ApiExclusiveGroups.cs | 14 ++++- 4 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 15cfb15..c72475e 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -6,10 +6,12 @@ using System.Reflection; using HarmonyLib; using DataLoader; -using RobocraftX.Blocks; using RobocraftX.Rendering; +using RobocraftX.Schedulers; using Svelto.ECS; +using Svelto.ECS.Experimental; using Svelto.Tasks; +using Svelto.Tasks.ExtraLean; using UnityEngine; using UnityEngine.AddressableAssets; using Material = UnityEngine.Material; @@ -18,13 +20,17 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { + /// + /// Experimental support for adding custom blocks to the game. + /// public class CustomBlock : Block { private static ushort nextID = 500; /// /// Key: Prefab path /// - private static Dictionary _customBlocks = new Dictionary(); + private static readonly Dictionary CustomBlocks = new Dictionary(); + private static readonly CustomBlockEngine Engine = new CustomBlockEngine(); private static bool _canRegister = true; @@ -48,7 +54,7 @@ namespace GamecraftModdingAPI.Blocks throw new ArgumentException("The given block type doesn't have a concrete full name."); if (!File.Exists(attr.Catalog)) throw new FileNotFoundException("The specified catalog cannot be found for " + typeName); - _customBlocks.Add(attr.AssetPath, type); + CustomBlocks.Add(attr.AssetPath, type); Logging.MetaDebugLog("Registered custom block type " + typeName); } @@ -79,7 +85,7 @@ namespace GamecraftModdingAPI.Blocks for (var index = 0; index < prefabs.Count; index++) { - if (_customBlocks.ContainsKey(prefabData[index].prefabName)) //This is a custom block + if (CustomBlocks.ContainsKey(prefabData[index].prefabName)) //This is a custom block prefabs[index].GetComponentsInChildren()[0].sharedMaterials = materials; } } @@ -96,7 +102,7 @@ namespace GamecraftModdingAPI.Blocks public static void Prefix(IDataDB dataDB) { //var abd = dataDB.GetValue((int) BlockIDs.AluminiumCube); - foreach (var (key, type) in _customBlocks) + foreach (var (key, type) in CustomBlocks) { var attr = type.GetCustomAttribute(); var cld = new CubeListData @@ -123,6 +129,7 @@ namespace GamecraftModdingAPI.Blocks }; dataDB.GetValues().Add(cld.ID.ToString(), cld); //The registration needs to happen after the ID has been set dataDB.GetFasterValues().Add(cld.ID, cld); //So can't use the builtin method to create a CubeListData + Engine.RegisterBlock((ushort) cld.ID, key); } _canRegister = false; @@ -150,9 +157,9 @@ namespace GamecraftModdingAPI.Blocks } }*/ - internal static IEnumerator Prepare() + private static IEnumerator Prepare() { //Should be pretty quick - foreach (var type in _customBlocks.Values) + foreach (var type in CustomBlocks.Values) { var attr = type.GetCustomAttribute(); Logging.Log("Loading custom block catalog " + attr.Catalog); @@ -163,11 +170,23 @@ namespace GamecraftModdingAPI.Blocks } } + internal new static void Init() + { + Prepare().RunOn(ExtraLean.UIScheduler); + GameEngineManager.AddGameEngine(Engine); + } + /*internal static void OnBlockFactoryObtained(BlockEntityFactory factory) { var builders = (Dictionary) AccessTools.Field(factory.GetType(), "_blockBuilders").GetValue(factory); builders.Add((CubeCategory) 1000, new BlockBuilder(Group)); }*/ + + internal struct DataStruct : IEntityComponent + { + public ECSString Name; + public ushort ID; + } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs b/GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs new file mode 100644 index 0000000..7e8ea6e --- /dev/null +++ b/GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs @@ -0,0 +1,57 @@ +using System; +using GamecraftModdingAPI.Engines; +using GamecraftModdingAPI.Persistence; +using GamecraftModdingAPI.Utility; +using RobocraftX.Common; +using Svelto.ECS; +using Svelto.ECS.Experimental; +using Svelto.ECS.Serialization; + +namespace GamecraftModdingAPI.Blocks +{ + public class CustomBlockEngine : IFactoryEngine + { + public class CustomBlockEntityDescriptor : SerializableEntityDescriptor< + CustomBlockEntityDescriptor._CustomBlockDescriptor> + { + [HashName("GamecraftModdingAPICustomBlockV0")] + public class _CustomBlockDescriptor : IEntityDescriptor + { + public IComponentBuilder[] componentsToBuild { get; } = + { + new SerializableComponentBuilder( + ((int) SerializationType.Network, new DefaultSerializer()), + ((int) SerializationType.Storage, new DefaultSerializer())) + }; + } + } + + public void Ready() + { + SerializerManager.AddSerializer(new SimpleEntitySerializer(db => + { + var (coll, c) = db.QueryEntities(ApiExclusiveGroups.customBlockGroup); + var egids = new EGID[c]; + for (int i = 0; i < c; i++) + egids[i] = new EGID(coll[i].ID, ApiExclusiveGroups.customBlockGroup); + + return egids; + })); + } + + public EntitiesDB entitiesDB { get; set; } + public void Dispose() + { + } + + public void RegisterBlock(ushort id, string name) + { + Factory.BuildEntity(id, ApiExclusiveGroups.customBlockGroup) + .Init(new CustomBlock.DataStruct {Name = new ECSString(name), ID = id}); + } + + public string Name { get; } = "GamecraftModdingAPICustomBlockEngine"; + public bool isRemovable { get; } = false; + public IEntityFactory Factory { get; set; } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 66e923e..36a0db4 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -91,7 +91,7 @@ namespace GamecraftModdingAPI AsyncUtils.Init(); GamecraftModdingAPI.App.Client.Init(); GamecraftModdingAPI.App.Game.Init(); - CustomBlock.Prepare().RunOn(ExtraLean.UIScheduler); + CustomBlock.Init(); // init UI Interface.IMGUI.Constants.Init(); Interface.IMGUI.IMGUIManager.Init(); diff --git a/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs b/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs index 19211e6..8dc052d 100644 --- a/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs +++ b/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs @@ -38,6 +38,18 @@ namespace GamecraftModdingAPI.Utility } return _versionGroup; } - } + } + + private static ExclusiveGroup _customBlockGroup; + + public static ExclusiveGroup customBlockGroup + { + get + { + if (_customBlockGroup == null) + _customBlockGroup = new ExclusiveGroup("GamecraftModdingAPI CustomBlockGroup"); + return _customBlockGroup; + } + } } } From d954060a5ab268921fc1386fee0eaa8b2742a177 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 27 Dec 2020 21:13:49 +0100 Subject: [PATCH 28/98] Add ability to change properties of existing blocks And not storing custom block data for now --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 21 +++++++++-- ...tityDescriptor.cs => CustomBlockEngine.cs} | 35 +++++++++++-------- .../Tests/GamecraftModdingAPIPluginTest.cs | 4 +++ 3 files changed, 43 insertions(+), 17 deletions(-) rename GamecraftModdingAPI/Blocks/{CustomBlockEntityDescriptor.cs => CustomBlockEngine.cs} (57%) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index c72475e..bafccc2 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -30,7 +30,9 @@ namespace GamecraftModdingAPI.Blocks /// Key: Prefab path ///
private static readonly Dictionary CustomBlocks = new Dictionary(); - private static readonly CustomBlockEngine Engine = new CustomBlockEngine(); + //private static readonly CustomBlockEngine Engine = new CustomBlockEngine(); + private static readonly List<(ushort id, Action action)> BlockChangeActions = + new List<(ushort, Action)>(); private static bool _canRegister = true; @@ -58,6 +60,16 @@ namespace GamecraftModdingAPI.Blocks Logging.MetaDebugLog("Registered custom block type " + typeName); } + /// + /// A low-level method for changing any property of an existing block. Use with caution. + /// + /// The block ID + /// An action that modifies a property of the block + public static void ChangeExistingBlock(ushort id, Action modifier) + { + BlockChangeActions.Add((id, modifier)); + } + public CustomBlock(EGID id) : base(id) { /*if (id.groupID != Group) @@ -129,9 +141,12 @@ namespace GamecraftModdingAPI.Blocks }; dataDB.GetValues().Add(cld.ID.ToString(), cld); //The registration needs to happen after the ID has been set dataDB.GetFasterValues().Add(cld.ID, cld); //So can't use the builtin method to create a CubeListData - Engine.RegisterBlock((ushort) cld.ID, key); + //Engine.RegisterBlock((ushort) cld.ID, key); - TODO } + foreach (var (id, action) in BlockChangeActions) + action(dataDB.GetValue(id)); + _canRegister = false; } @@ -173,7 +188,7 @@ namespace GamecraftModdingAPI.Blocks internal new static void Init() { Prepare().RunOn(ExtraLean.UIScheduler); - GameEngineManager.AddGameEngine(Engine); + //GameEngineManager.AddGameEngine(Engine); - TODO: Fix serialization and implement block ID update } /*internal static void OnBlockFactoryObtained(BlockEntityFactory factory) diff --git a/GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs b/GamecraftModdingAPI/Blocks/CustomBlockEngine.cs similarity index 57% rename from GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs rename to GamecraftModdingAPI/Blocks/CustomBlockEngine.cs index 7e8ea6e..bb1192b 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlockEntityDescriptor.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlockEngine.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using GamecraftModdingAPI.Engines; using GamecraftModdingAPI.Persistence; using GamecraftModdingAPI.Utility; @@ -9,10 +10,9 @@ using Svelto.ECS.Serialization; namespace GamecraftModdingAPI.Blocks { - public class CustomBlockEngine : IFactoryEngine + /*public class CustomBlockEngine : IFactoryEngine { - public class CustomBlockEntityDescriptor : SerializableEntityDescriptor< - CustomBlockEntityDescriptor._CustomBlockDescriptor> + public class CustomBlockEntityDescriptor : SerializableEntityDescriptor { [HashName("GamecraftModdingAPICustomBlockV0")] public class _CustomBlockDescriptor : IEntityDescriptor @@ -28,30 +28,37 @@ namespace GamecraftModdingAPI.Blocks public void Ready() { - SerializerManager.AddSerializer(new SimpleEntitySerializer(db => - { - var (coll, c) = db.QueryEntities(ApiExclusiveGroups.customBlockGroup); - var egids = new EGID[c]; - for (int i = 0; i < c; i++) - egids[i] = new EGID(coll[i].ID, ApiExclusiveGroups.customBlockGroup); + SerializerManager.AddSerializer( + new SimpleEntitySerializer(db => + { + var (coll, c) = db.QueryEntities(ApiExclusiveGroups.customBlockGroup); + var egids = new EGID[c]; + for (int i = 0; i < c; i++) + egids[i] = new EGID(coll[i].ID, ApiExclusiveGroups.customBlockGroup); - return egids; - })); + return egids; + })); + foreach (var (id, name) in _registeredBlocks) + { + Factory.BuildEntity(id, ApiExclusiveGroups.customBlockGroup) + .Init(new CustomBlock.DataStruct {Name = new ECSString(name), ID = id}); + } } public EntitiesDB entitiesDB { get; set; } + private List<(ushort id, string name)> _registeredBlocks = new List<(ushort, string)>(); + public void Dispose() { } public void RegisterBlock(ushort id, string name) { - Factory.BuildEntity(id, ApiExclusiveGroups.customBlockGroup) - .Init(new CustomBlock.DataStruct {Name = new ECSString(name), ID = id}); + _registeredBlocks.Add((id, name)); } public string Name { get; } = "GamecraftModdingAPICustomBlockEngine"; public bool isRemovable { get; } = false; public IEntityFactory Factory { get; set; } - } + }*/ } \ No newline at end of file diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index dd96226..acb8bc4 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -36,6 +36,7 @@ using UnityEngine.ResourceManagement.ResourceProviders; using Debug = FMOD.Debug; using EventType = GamecraftModdingAPI.Events.EventType; using Label = GamecraftModdingAPI.Interface.IMGUI.Label; +using ScalingPermission = DataLoader.ScalingPermission; namespace GamecraftModdingAPI.Tests { @@ -412,6 +413,9 @@ namespace GamecraftModdingAPI.Tests { Logging.MetaDebugLog("Test custom block catalog not found"); } + + CustomBlock.ChangeExistingBlock((ushort) BlockIDs.TyreS, + cld => cld.scalingPermission = ScalingPermission.NonUniform); #if TEST TestRoot.RunTests(); #endif From 0ef875b6b28372cd117d6f7cac88ec55d90a0ee2 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 27 Dec 2020 18:57:23 -0500 Subject: [PATCH 29/98] Document undocumented IMGUI element classes --- .../Interface/IMGUI/IMGUIManager.cs | 32 +++++++++++++++++++ GamecraftModdingAPI/Interface/IMGUI/Image.cs | 28 ++++++++++++++++ GamecraftModdingAPI/Interface/IMGUI/Label.cs | 18 +++++++++++ 3 files changed, 78 insertions(+) diff --git a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs index f6048e7..e75f8f2 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs +++ b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs @@ -12,12 +12,22 @@ using UnityEngine; namespace GamecraftModdingAPI.Interface.IMGUI { + /// + /// Keeps track of UIElement instances. + /// This also handles displaying and processing them during the MonoBehaviour.OnGUI phase of screen updates. + /// Most of this functionality is handled implicitly by the included UIElement implementations, + /// but this is left as a public API so it can be expanded. + /// public static class IMGUIManager { internal static OnGuiRunner ImguiScheduler = new OnGuiRunner("GamecraftModdingAPI_IMGUIScheduler"); private static FasterDictionary _activeElements = new FasterDictionary(); + /// + /// Add an UIElement instance to be managed by IMGUIManager. + /// + /// The UIElement instance. public static void AddElement(UIElement e) { if (!ExistsElement(e)) @@ -26,16 +36,32 @@ namespace GamecraftModdingAPI.Interface.IMGUI } } + /// + /// Determine whether the UIElement instance is already tracked by IMGUIManager. + /// + /// The UIElement's unique name. + /// Whether the UIElement instance is already tracked by IMGUIManager (true) or not (false). public static bool ExistsElement(string name) { return _activeElements.ContainsKey(name); } + /// + /// Determine whether the UIElement instance is already tracked by IMGUIManager. + /// + /// The UIElement instance. + /// Whether the UIElement instance is already tracked by IMGUIManager (true) or not (false). public static bool ExistsElement(UIElement element) { return ExistsElement(element.Name); } + /// + /// Remove an UIElement instance from IMGUIManager. + /// The UIElement will become invisible and stop generating events. + /// + /// The UIElement's unique name. + /// Whether the UIElement instance existed in IMGUIManager (true) or not (false). public static bool RemoveElement(string name) { if (ExistsElement(name)) @@ -46,6 +72,12 @@ namespace GamecraftModdingAPI.Interface.IMGUI return false; } + /// + /// Remove an UIElement instance from IMGUIManager. + /// The UIElement will become invisible and stop generating events. + /// + /// The UIElement instance. + /// Whether the UIElement instance existed in IMGUIManager (true) or not (false). public static bool RemoveElement(UIElement element) { return RemoveElement(element.Name); diff --git a/GamecraftModdingAPI/Interface/IMGUI/Image.cs b/GamecraftModdingAPI/Interface/IMGUI/Image.cs index 8c026ed..b4fac9f 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Image.cs +++ b/GamecraftModdingAPI/Interface/IMGUI/Image.cs @@ -2,12 +2,22 @@ using UnityEngine; namespace GamecraftModdingAPI.Interface.IMGUI { + /// + /// An image. + /// This wraps Unity's IMGUI Label. + /// public class Image : UIElement { private bool automaticLayout = false; + /// + /// The image texture to display + /// public Texture Texture { get; set; } + /// + /// The rectangular area in the window that the image can use + /// public Rect Box { get; set; } = Rect.zero; public void OnGUI() @@ -23,9 +33,21 @@ namespace GamecraftModdingAPI.Interface.IMGUI } } + /// + /// The image element's unique name. + /// public string Name { get; } + + /// + /// Whether to display the image and everything in it. + /// public bool Enabled { set; get; } = true; + /// + /// Initializes a new instance of the class with automatic layout. + /// + /// Image to display. + /// The element's name. public Image(Texture texture = null, string name = null) { automaticLayout = true; @@ -49,6 +71,12 @@ namespace GamecraftModdingAPI.Interface.IMGUI IMGUIManager.AddElement(this); } + /// + /// Initializes a new instance of the class. + /// + /// Rectangular area for the image. + /// Image to display. + /// The element's name. public Image(Rect box, Texture texture = null, string name = null) : this(texture, name) { this.Box = box; diff --git a/GamecraftModdingAPI/Interface/IMGUI/Label.cs b/GamecraftModdingAPI/Interface/IMGUI/Label.cs index 2fb54f7..2483e3d 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Label.cs +++ b/GamecraftModdingAPI/Interface/IMGUI/Label.cs @@ -32,9 +32,21 @@ namespace GamecraftModdingAPI.Interface.IMGUI } } + /// + /// The label's unique name. + /// public string Name { get; } + + /// + /// Whether to display the label. + /// public bool Enabled { set; get; } = true; + /// + /// Initializes a new instance of the class with automatic layout. + /// + /// Initial string to display on the label. + /// The element's name. public Label(string initialText = null, string name = null) { automaticLayout = true; @@ -50,6 +62,12 @@ namespace GamecraftModdingAPI.Interface.IMGUI IMGUIManager.AddElement(this); } + /// + /// Initializes a new instance of the . + /// + /// Rectangular area for the label. + /// Initial string to display on the label. + /// The element's name. public Label(Rect box, string initialText = null, string name = null) : this(initialText, name) { this.Box = box; From 37e3c6f71877705656fb45c6d9ff40479681c4ed Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 28 Dec 2020 13:47:08 -0500 Subject: [PATCH 30/98] Remove debug FMOD patches --- .../Interface/IMGUI/Constants.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/GamecraftModdingAPI/Interface/IMGUI/Constants.cs b/GamecraftModdingAPI/Interface/IMGUI/Constants.cs index 3e2fa8f..42a7f18 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Constants.cs +++ b/GamecraftModdingAPI/Interface/IMGUI/Constants.cs @@ -147,22 +147,4 @@ namespace GamecraftModdingAPI.Interface.IMGUI _defaultCompletion++; } } - - [HarmonyPatch(typeof(FMODUnity.RuntimeManager), "PlayOneShot", new []{ typeof(Guid), typeof(Vector3)})] - public class FMODRuntimeManagerPlayOneShotPatch - { - public static void Prefix(Guid guid) - { - Logging.MetaLog($"Playing sound with guid '{guid.ToString()}'"); - } - } - - [HarmonyPatch(typeof(FMODUnity.RuntimeManager), "PlayOneShot", new []{ typeof(string), typeof(Vector3)})] - public class FMODRuntimeManagerPlayOneShotPatch2 - { - public static void Prefix(string path) - { - Logging.MetaLog($"Playing sound with str '{path}'"); - } - } } \ No newline at end of file From a6b69d94c92d8139732ca3c9040903373d42340f Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 10 Apr 2021 02:02:47 +0200 Subject: [PATCH 31/98] Start compatibility with Techblox Added some TODOs as well --- Automation/gen_csproj.py | 2 +- GamecraftModdingAPI/App/GameGameEngine.cs | 6 +- GamecraftModdingAPI/App/GameMenuEngine.cs | 12 +- GamecraftModdingAPI/Block.cs | 11 - .../Blocks/BlockCloneEngine.cs | 2 - GamecraftModdingAPI/Blocks/BlockEngine.cs | 6 +- GamecraftModdingAPI/Blocks/BlockEngineInit.cs | 2 +- GamecraftModdingAPI/Blocks/ConsoleBlock.cs | 75 - GamecraftModdingAPI/Blocks/CustomBlock.cs | 4 +- GamecraftModdingAPI/Blocks/MovementEngine.cs | 4 +- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 42 +- GamecraftModdingAPI/Blocks/RotationEngine.cs | 4 +- GamecraftModdingAPI/Blocks/SignalEngine.cs | 4 +- .../GamecraftModdingAPI.csproj | 1730 +++++++++-------- .../Interface/IMGUI/IMGUIManager.cs | 9 +- .../Persistence/SimpleEntitySerializer.cs | 4 +- GamecraftModdingAPI/Players/PlayerEngine.cs | 4 +- 17 files changed, 942 insertions(+), 979 deletions(-) delete mode 100644 GamecraftModdingAPI/Blocks/ConsoleBlock.cs diff --git a/Automation/gen_csproj.py b/Automation/gen_csproj.py index d0f18c4..af00dd1 100755 --- a/Automation/gen_csproj.py +++ b/Automation/gen_csproj.py @@ -32,7 +32,7 @@ if __name__ == "__main__": args = parser.parse_args() print("Building Assembly references") - asmXml = buildReferencesXml("../ref/Gamecraft_Data/Managed") + asmXml = buildReferencesXml("../ref/TechbloxPreview_Data/Managed") # print(asmXml) with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "r") as xmlFile: diff --git a/GamecraftModdingAPI/App/GameGameEngine.cs b/GamecraftModdingAPI/App/GameGameEngine.cs index 85fb672..da270cc 100644 --- a/GamecraftModdingAPI/App/GameGameEngine.cs +++ b/GamecraftModdingAPI/App/GameGameEngine.cs @@ -13,6 +13,7 @@ using Svelto.Tasks.Lean; using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Engines; using GamecraftModdingAPI.Utility; +using RobocraftX.Blocks; namespace GamecraftModdingAPI.App { @@ -97,7 +98,7 @@ namespace GamecraftModdingAPI.App public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid) { - var allBlocks = entitiesDB.QueryEntities(); + var allBlocks = entitiesDB.QueryEntities(); List blockEGIDs = new List(); if (filter == BlockIDs.Invalid) { @@ -118,7 +119,8 @@ namespace GamecraftModdingAPI.App for (var index = 0; index < array.capacity; index++) { var block = array[index]; - if (block.DBID == (ulong) filter) + uint dbid = entitiesDB.QueryEntity(block.ID).DBID; + if (dbid == (ulong) filter) blockEGIDs.Add(block.ID); } } diff --git a/GamecraftModdingAPI/App/GameMenuEngine.cs b/GamecraftModdingAPI/App/GameMenuEngine.cs index efcb73e..67b159b 100644 --- a/GamecraftModdingAPI/App/GameMenuEngine.cs +++ b/GamecraftModdingAPI/App/GameMenuEngine.cs @@ -44,7 +44,7 @@ namespace GamecraftModdingAPI.App public bool CreateMyGame(EGID id, string path = "", uint thumbnailId = 0, string gameName = "", string creatorName = "", string description = "", long createdDate = 0L) { - EntityComponentInitializer eci = Factory.BuildEntity(id); + EntityInitializer eci = Factory.BuildEntity(id); eci.Init(new MyGameDataEntityStruct { SavedGamePath = new ECSString(path), @@ -93,7 +93,7 @@ namespace GamecraftModdingAPI.App { if (!ExistsGameInfo(id)) return false; GetGameInfo(id).GameName.Set(name); - GetGameViewInfo(id).MyGamesSlotComponent.GameName = StringUtil.SanitiseString(name); + //GetGameViewInfo(id).MyGamesSlotComponent.GameName = StringUtil.SanitiseString(name); - TODO: Input field struct return true; } @@ -101,7 +101,7 @@ namespace GamecraftModdingAPI.App { if (!ExistsGameInfo(id)) return false; GetGameInfo(id).GameDescription.Set(name); - GetGameViewInfo(id).MyGamesSlotComponent.GameDescription = StringUtil.SanitiseString(name); + //GetGameViewInfo(id).MyGamesSlotComponent.GameDescription = StringUtil.SanitiseString(name); - TODO return true; } @@ -115,7 +115,7 @@ namespace GamecraftModdingAPI.App return ref GetComponent(id); } - public ref MyGamesSlotEntityViewStruct GetGameViewInfo(EGID id) + /*public ref MyGamesSlotEntityViewStruct GetGameViewInfo(EGID id) { EntityCollection entities = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.GameSlotGuiEntities); @@ -128,8 +128,8 @@ namespace GamecraftModdingAPI.App } } MyGamesSlotEntityViewStruct[] defRef = new MyGamesSlotEntityViewStruct[1]; - return ref defRef[0]; - } + return ref defRef[0]; - TODO: The struct is internal now + }*/ public ref T GetComponent(EGID id) where T: unmanaged, IEntityComponent { diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 513ad5e..607213d 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -117,7 +117,6 @@ namespace GamecraftModdingAPI private static Dictionary typeToGroup = new Dictionary { - {typeof(ConsoleBlock), new[] {CommonExclusiveGroups.CONSOLE_BLOCK_GROUP}}, {typeof(LogicGate), new [] {CommonExclusiveGroups.LOGIC_BLOCK_GROUP}}, {typeof(Motor), new[] {CommonExclusiveGroups.MOTOR_BLOCK_GROUP}}, {typeof(MusicBlock), new[] {CommonExclusiveGroups.MUSIC_BLOCK_GROUP}}, @@ -436,16 +435,6 @@ namespace GamecraftModdingAPI { var block = PlaceNew(Type, Position, Rotation, Color.Color, Color.Darkness, UniformScale, Scale); block.copiedFrom = Id; - if (Type == BlockIDs.ConsoleBlock - && (this is ConsoleBlock srcCB || (srcCB = Specialise()) != null) - && (block is ConsoleBlock dstCB || (dstCB = block.Specialise()) != null)) - { - //Console block properties are set by a separate engine in the game - dstCB.Arg1 = srcCB.Arg1; - dstCB.Arg2 = srcCB.Arg2; - dstCB.Arg3 = srcCB.Arg3; - dstCB.Command = srcCB.Command; - } return block; } diff --git a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs index 0acf44d..1c9c91c 100644 --- a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs @@ -48,7 +48,6 @@ namespace GamecraftModdingAPI.Blocks var oldStruct = pickedBlock; pickedBlock.pickedBlockEntityID = sourceID; pickedBlock.placedBlockEntityID = targetID; - pickedBlock.placedBlockTweaksCopied = false; pickedBlock.placedBlockTweaksMustCopy = true; if (entitiesDB.Exists(pickedBlock.pickedBlockEntityID) && entitiesDB.Exists(pickedBlock.placedBlockEntityID)) @@ -66,7 +65,6 @@ namespace GamecraftModdingAPI.Blocks copyWireToBlock.Invoke(Patch.createWireEngine, new object[] {group, pickedBlock.ID}); pickedBlock.placedBlockTweaksMustCopy = false; - pickedBlock.placedBlockTweaksCopied = false; } pickedBlock = oldStruct; //Make sure to not interfere with the game - Although that might not be the case with the wire copying diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 53a7254..46afb09 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -114,7 +114,7 @@ namespace GamecraftModdingAPI.Blocks private U GetBlockInitInfo(Block block, Func getter, U def) where T : struct, IEntityComponent { if (block.InitData.Group == null) return def; - var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); + var initializer = new EntityInitializer(block.Id, block.InitData.Group); if (initializer.Has()) return getter(initializer.Get()); return def; @@ -143,7 +143,7 @@ namespace GamecraftModdingAPI.Blocks { if (block.InitData.Group != null) { - var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); + var initializer = new EntityInitializer(block.Id, block.InitData.Group); T component = initializer.Has() ? initializer.Get() : default; ref T structRef = ref component; setter(ref structRef, value); @@ -171,7 +171,7 @@ namespace GamecraftModdingAPI.Blocks return true; if (block.InitData.Group == null) return false; - var init = new EntityComponentInitializer(block.Id, block.InitData.Group); + var init = new EntityInitializer(block.Id, block.InitData.Group); return init.Has(); } diff --git a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs index 1bf6c15..aaed6ef 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs @@ -18,7 +18,7 @@ namespace GamecraftModdingAPI.Blocks } internal delegate FasterDictionary GetInitGroup( - EntityComponentInitializer initializer); + EntityInitializer initializer); /// /// Accesses the group field of the initializer diff --git a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs b/GamecraftModdingAPI/Blocks/ConsoleBlock.cs deleted file mode 100644 index e696fca..0000000 --- a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; - -using RobocraftX.Blocks; -using RobocraftX.Common; -using Svelto.ECS; -using Unity.Mathematics; - -using GamecraftModdingAPI; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Blocks -{ - public class ConsoleBlock : SignalingBlock - { - public ConsoleBlock(EGID id): base(id) - { - } - - public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.CONSOLE_BLOCK_GROUP)) - { - } - - // custom console block properties - - /// - /// Setting a nonexistent command will crash the game when switching to simulation - /// - public string Command - { - get - { - return BlockEngine.GetBlockInfo(this, (ConsoleBlockEntityStruct st) => st.commandName); - } - - set - { - BlockEngine.SetBlockInfo(this, (ref ConsoleBlockEntityStruct st, string val) => st.commandName.Set(val), - value); - } - } - - public string Arg1 - { - get => BlockEngine.GetBlockInfo(this, (ConsoleBlockEntityStruct st) => st.arg1); - - set - { - BlockEngine.SetBlockInfo(this, (ref ConsoleBlockEntityStruct st, string val) => st.arg1.Set(val), - value); - } - } - - public string Arg2 - { - get => BlockEngine.GetBlockInfo(this, (ConsoleBlockEntityStruct st) => st.arg2); - - set - { - BlockEngine.SetBlockInfo(this, (ref ConsoleBlockEntityStruct st, string val) => st.arg2.Set(val), - value); - } - } - - public string Arg3 - { - get => BlockEngine.GetBlockInfo(this, (ConsoleBlockEntityStruct st) => st.arg3); - - set - { - BlockEngine.SetBlockInfo(this, (ref ConsoleBlockEntityStruct st, string val) => st.arg3.Set(val), - value); - } - } - } -} diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index bafccc2..62d8ce6 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -6,6 +6,7 @@ using System.Reflection; using HarmonyLib; using DataLoader; +using RobocraftX.Common; using RobocraftX.Rendering; using RobocraftX.Schedulers; using Svelto.ECS; @@ -130,8 +131,7 @@ namespace GamecraftModdingAPI.Blocks CubeDescriptionKey = attr.DescKey, SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, GridScale = new[] {5, 5, 5}, - Mass = attr.Mass, - Material = attr.Material, + DefaultMaterialID = 0, //TODO: Material API scalingPermission = attr.ScalingPermission, SortIndex = attr.SortIndex, DefaultColour = attr.DefaultColor.Index, diff --git a/GamecraftModdingAPI/Blocks/MovementEngine.cs b/GamecraftModdingAPI/Blocks/MovementEngine.cs index fb3aa55..6a9b05e 100644 --- a/GamecraftModdingAPI/Blocks/MovementEngine.cs +++ b/GamecraftModdingAPI/Blocks/MovementEngine.cs @@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityComponentInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group); init.GetOrCreate().position = vector; init.GetOrCreate().position = vector; init.GetOrCreate().position = vector; @@ -70,7 +70,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityComponentInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group); return init.Has() ? init.Get().position : float3.zero; } ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(blockID); diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index b0d1365..506456b 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -38,10 +38,10 @@ namespace GamecraftModdingAPI.Blocks } public EntitiesDB entitiesDB { get; set; } - private static BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine + private static BlockEntityFactory _blockEntityFactory; //Injected from PlaceSingleBlockEngine public EGID PlaceBlock(BlockIDs block, BlockColors color, byte darkness, float3 position, int uscale, - float3 scale, Player player, float3 rotation, out EntityComponentInitializer initializer) + float3 scale, Player player, float3 rotation, out EntityInitializer initializer) { //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one if (darkness > 9) throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)"); @@ -50,7 +50,7 @@ namespace GamecraftModdingAPI.Blocks return initializer.EGID; } - private EntityComponentInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot, uint playerId) + private EntityInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot, uint playerId) { if (_blockEntityFactory == null) throw new BlockException("The factory is null."); @@ -59,32 +59,34 @@ namespace GamecraftModdingAPI.Blocks if (scale.x < 4e-5) scale.x = uscale; if (scale.y < 4e-5) scale.y = uscale; if (scale.z < 4e-5) scale.z = uscale; - uint dbid = block; - if (!PrefabsID.HasPrefabRegistered(dbid, 0)) - throw new BlockException("Block with ID " + dbid + " not found!"); - //RobocraftX.CR.MachineEditing.PlaceBlockEngine + uint resourceId = (uint) PrefabsID.GenerateResourceID(0, block); + if (!PrefabsID.PrefabIDByResourceIDMap.ContainsKey(resourceId)) + throw new BlockException("Block with ID " + block + " not found!"); + //RobocraftX.CR.MachineEditing.PlaceSingleBlockEngine ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale}; Quaternion rotQ = Quaternion.Euler(rot); RotationEntityStruct rotation = new RotationEntityStruct {rotation = rotQ}; GridRotationStruct gridRotation = new GridRotationStruct {position = position, rotation = rotQ}; - DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid}; + DBEntityStruct dbEntity = new DBEntityStruct {DBID = block}; BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct { blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale }; - EquippedColourStruct colour = new EquippedColourStruct {indexInPalette = color}; - EntityComponentInitializer - structInitializer = - _blockEntityFactory.Build(CommonExclusiveGroups.nextBlockEntityID, dbid); //The ghost block index is only used for triggers - if (colour.indexInPalette != byte.MaxValue) + EntityInitializer structInitializer = _blockEntityFactory.Build(CommonExclusiveGroups.nextBlockEntityID, block); //The ghost block index is only used for triggers + if (color != byte.MaxValue) structInitializer.Init(new ColourParameterEntityStruct { - indexInPalette = colour.indexInPalette, + indexInPalette = color, hasNetworkChange = true }); - uint prefabId = PrefabsID.GetPrefabId(dbid, 0); + structInitializer.Init(new CubeMaterialStruct + { + materialId = 0, //TODO + cosmeticallyPaintedOnly = true //TODO + }); + uint prefabId = PrefabsID.GetOrCreatePrefabID(block, 0, 0, false); //TODO structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId)); structInitializer.Init(dbEntity); @@ -99,16 +101,16 @@ namespace GamecraftModdingAPI.Blocks structInitializer.Init(new BlockPlacementInfoStruct() { loadedFromDisk = false, - placedBy = playerId + placedBy = playerId, + triggerAutoWiring = false //TODO }); - + /*structInitializer.Init(new CollisionFilterOverride { belongsTo = 32U, collidesWith = 239532U });*/ - PrimaryRotationUtility.InitialisePrimaryDirection(rotation.rotation, ref structInitializer); EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup); ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity(playerEGID); pickedBlock.placedBlockEntityID = structInitializer.EGID; @@ -118,7 +120,7 @@ namespace GamecraftModdingAPI.Blocks public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine"; - public bool isRemovable => false; + public bool isRemovable => false; [HarmonyPatch] public class FactoryObtainerPatch @@ -131,7 +133,7 @@ namespace GamecraftModdingAPI.Blocks static MethodBase TargetMethod(Harmony instance) { - return AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceBlockEngine").GetConstructors()[0]; + return AccessTools.TypeByName("RobocraftX.CR.MachineEditing.PlaceSingleBlockEngine").GetConstructors()[0]; } } } diff --git a/GamecraftModdingAPI/Blocks/RotationEngine.cs b/GamecraftModdingAPI/Blocks/RotationEngine.cs index fbf8c98..3322b92 100644 --- a/GamecraftModdingAPI/Blocks/RotationEngine.cs +++ b/GamecraftModdingAPI/Blocks/RotationEngine.cs @@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityComponentInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group); init.GetOrCreate().rotation = Quaternion.Euler(vector); init.GetOrCreate().rotation = Quaternion.Euler(vector); init.GetOrCreate().rotation = Quaternion.Euler(vector); @@ -77,7 +77,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityComponentInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group); return init.Has() ? (float3) ((Quaternion) init.Get().rotation).eulerAngles : float3.zero; diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs index 0980d79..22865df 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs @@ -42,7 +42,7 @@ namespace GamecraftModdingAPI.Blocks public WireEntityStruct CreateNewWire(EGID startBlock, byte startPort, EGID endBlock, byte endPort) { EGID wireEGID = new EGID(WiresExclusiveGroups.NewWireEntityId, NamedExclusiveGroup.Group); - EntityComponentInitializer wireInitializer = Factory.BuildEntity(wireEGID); + EntityInitializer wireInitializer = Factory.BuildEntity(wireEGID); wireInitializer.Init(new WireEntityStruct { sourceBlockEGID = startBlock, @@ -399,7 +399,7 @@ namespace GamecraftModdingAPI.Blocks exists = false; return ref defRef[0]; } - EntityComponentInitializer initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); + EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group); if (initializer.Has()) { exists = true; diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 8b6404c..bd4135c 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -28,1012 +28,1060 @@ - ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll - ..\..\ref\Gamecraft_Data\Managed\IllusionInjector.dll + ..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll + ..\..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll - ..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll - ..\..\ref\Gamecraft_Data\Managed\IllusionPlugin.dll + ..\ref\TechbloxPreview_Data\Managed\IllusionPlugin.dll + ..\..\ref\TechbloxPreview_Data\Managed\IllusionPlugin.dll - ..\ref\Gamecraft_Data\Managed\Analytics.dll - ..\..\ref\Gamecraft_Data\Managed\Analytics.dll + ..\ref\TechbloxPreview_Data\Managed\Analytics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Analytics.dll - ..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll - ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp-firstpass.dll + ..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp-firstpass.dll + ..\..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp-firstpass.dll - ..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll - ..\..\ref\Gamecraft_Data\Managed\Assembly-CSharp.dll + ..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp.dll + ..\..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp.dll - - ..\ref\Gamecraft_Data\Managed\Authentication.dll - ..\..\ref\Gamecraft_Data\Managed\Authentication.dll + + ..\ref\TechbloxPreview_Data\Managed\BevelEffect.dll + ..\..\ref\TechbloxPreview_Data\Managed\BevelEffect.dll - ..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll - ..\ref\Gamecraft_Data\Managed\CommandLine.dll - ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll + ..\ref\TechbloxPreview_Data\Managed\CommandLine.dll + ..\..\ref\TechbloxPreview_Data\Managed\CommandLine.dll - ..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll - ..\..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll + ..\ref\TechbloxPreview_Data\Managed\CommandLineCompositionRoot.dll + ..\..\ref\TechbloxPreview_Data\Managed\CommandLineCompositionRoot.dll - ..\ref\Gamecraft_Data\Managed\DataLoader.dll - ..\..\ref\Gamecraft_Data\Managed\DataLoader.dll + ..\ref\TechbloxPreview_Data\Managed\DataLoader.dll + ..\..\ref\TechbloxPreview_Data\Managed\DataLoader.dll - ..\ref\Gamecraft_Data\Managed\DDNA.dll - ..\..\ref\Gamecraft_Data\Managed\DDNA.dll + ..\ref\TechbloxPreview_Data\Managed\DDNA.dll + ..\..\ref\TechbloxPreview_Data\Managed\DDNA.dll - ..\ref\Gamecraft_Data\Managed\FMODUnity.dll - ..\..\ref\Gamecraft_Data\Managed\FMODUnity.dll + ..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll + ..\..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll - - ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll + + ..\ref\TechbloxPreview_Data\Managed\FMODUnityResonance.dll + ..\..\ref\TechbloxPreview_Data\Managed\FMODUnityResonance.dll - ..\ref\Gamecraft_Data\Managed\FullGame.dll - ..\..\ref\Gamecraft_Data\Managed\FullGame.dll + ..\ref\TechbloxPreview_Data\Managed\FullGame.dll + ..\..\ref\TechbloxPreview_Data\Managed\FullGame.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.AudioBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.AudioBlocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockGroups.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockGroups.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll - ..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll - ..\..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + ..\ref\TechbloxPreview_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TimerBlock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerability.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerability.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.ColourPalette.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ColourPalette.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.ColourPalette.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.ColourPalette.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Damage.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GraphicsSettings.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Blueprints.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Blueprints.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Blueprints.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Blueprints.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintSets.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.BlueprintSets.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintSets.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintSets.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.BlueprintsHotbar.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.BlueprintsHotbar.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ModeBar.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ModeBar.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.OptionsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TimeModeClock.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TimeModeClock.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Tweaks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Tweaks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Tweaks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.GUIs.Hotbar.BlueprintsHotbar.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUIs.Hotbar.BlueprintsHotbar.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.JointBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.JointBlocks.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Music.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Music.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.NetStrings.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.NetStrings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.NetStrings.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll - ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Serialization.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll - - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll - - - ..\ref\Gamecraft_Data\Managed\GameState.dll - ..\..\ref\Gamecraft_Data\Managed\GameState.dll - - - ..\ref\Gamecraft_Data\Managed\GhostShark.Outline.dll - ..\..\ref\Gamecraft_Data\Managed\GhostShark.Outline.dll - - - ..\ref\Gamecraft_Data\Managed\GPUInstancer.dll - ..\..\ref\Gamecraft_Data\Managed\GPUInstancer.dll - - - ..\ref\Gamecraft_Data\Managed\Havok.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll - ..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Havok.Physics.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\LZ4.dll - ..\..\ref\Gamecraft_Data\Managed\LZ4.dll - - - ..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll - ..\..\ref\Gamecraft_Data\Managed\MultiplayerNetworking.dll - - - ..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll - ..\..\ref\Gamecraft_Data\Managed\MultiplayerTest.dll - - - ..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll - ..\..\ref\Gamecraft_Data\Managed\RCX.ScreenshotTaker.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftECS.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftECS.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.AccountPreferences.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.dll + ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Ghost.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Blocks.Triggers.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.BoxSelect.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Building.Jobs.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Character.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ClusterToWireConversion.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Common.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.ControlsScreen.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Crosshair.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.FrontEnd.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.BlockLabel.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.DebugDisplay.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Hotbar.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Hotbar.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.Inventory.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.RemoveBlock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.ScaleGhost.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.TabsBar.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUI.TabsBar.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.GUIs.WorkshopPrefabs.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Input.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MachineEditor.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainGame.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MainSimulation.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MockCharacter.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.GUI.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Multiplayer.Serializers.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.MultiplayerInput.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll - ..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll - ..\..\ref\Gamecraft_Data\Managed\Robocraftx.ObjectIdBlocks.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Party.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PartyGui.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Physics.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.PilotSeat.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Player.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Rendering.Mock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveAndLoad.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SaveGameDialog.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.Services.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.SignalHandling.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX.StateSync.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX_SpawnPoints.dll - - - ..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll - ..\..\ref\Gamecraft_Data\Managed\RobocraftX_TextBlock.dll - - - ..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll - ..\..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll - - - ..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll - ..\..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll + ..\ref\TechbloxPreview_Data\Managed\Robocraftx.ObjectIdBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Robocraftx.ObjectIdBlocks.dll - ..\ref\Gamecraft_Data\Managed\StringFormatter.dll - ..\..\ref\Gamecraft_Data\Managed\StringFormatter.dll + ..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll + ..\..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll - - ..\ref\Gamecraft_Data\Managed\Svelto.Common.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Common.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.ECS.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.Services.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Services.dll - - - ..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll - ..\..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll - - - ..\ref\Gamecraft_Data\Managed\UltimateDecals.dll - ..\..\ref\Gamecraft_Data\Managed\UltimateDecals.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.FlyCam.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.FlyCam.dll - ..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Build.SlimPlayerRuntime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Burst.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Collections.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Deformations.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Entities.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.012.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.InternalAPIEngineBridge.012.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Jobs.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.MemoryProfiler.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Physics.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Physics.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Platforms.Common.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.Reflection.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Properties.UI.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipeline.Universal.ShaderLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.RenderPipelines.Universal.Shaders.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll - ..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.ResourceManager.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Scenes.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Scenes.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.ScriptableBuildPipeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Serialization.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.TextMeshPro.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Timeline.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Transforms.Hybrid.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.VisualEffectGraph.Runtime.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UI.dll - - - ..\ref\Gamecraft_Data\Managed\uREPL.dll - ..\..\ref\Gamecraft_Data\Managed\uREPL.dll - - - ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - ..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - - - ..\ref\Gamecraft_Data\Managed\Accessibility.dll - ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll - - - ..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - ..\..\ref\Gamecraft_Data\Managed\Facepunch.Steamworks.Win64.dll - - - ..\ref\Gamecraft_Data\Managed\JWT.dll - ..\..\ref\Gamecraft_Data\Managed\JWT.dll - - - ..\ref\Gamecraft_Data\Managed\mscorlib.dll - ..\..\ref\Gamecraft_Data\Managed\mscorlib.dll - - - ..\ref\Gamecraft_Data\Managed\netstandard.dll - ..\..\ref\Gamecraft_Data\Managed\netstandard.dll - - - ..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll - ..\..\ref\Gamecraft_Data\Managed\Newtonsoft.Json.dll - - - ..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll - ..\..\ref\Gamecraft_Data\Managed\Novell.Directory.Ldap.dll - - - ..\ref\Gamecraft_Data\Managed\Rewired_Core.dll - ..\..\ref\Gamecraft_Data\Managed\Rewired_Core.dll - - - ..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll - ..\..\ref\Gamecraft_Data\Managed\Rewired_Windows.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.dll - - - ..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.AIModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AIModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.AndroidJNIModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AndroidJNIModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.AnimationModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AnimationModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ARModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ARModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.AssetBundleModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AssetBundleModule.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.AudioModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AudioModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ClothModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ClothModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ClusterInputModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ClusterInputModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ClusterRendererModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ClusterRendererModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.CoreModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.CrashReportingModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.CrashReportingModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.DirectorModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.DirectorModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.DSPGraphModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.DSPGraphModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.GameCenterModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.GameCenterModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.GridModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.GridModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.HotReloadModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.HotReloadModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ImageConversionModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ImageConversionModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.IMGUIModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.IMGUIModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.InputLegacyModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.InputLegacyModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.InputModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.InputModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.JSONSerializeModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.JSONSerializeModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.LocalizationModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.LocalizationModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ParticleSystemModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ParticleSystemModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.PerformanceReportingModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.PerformanceReportingModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.Physics2DModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.Physics2DModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.PhysicsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.PhysicsModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ProfilerModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ProfilerModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.ScreenCaptureModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.ScreenCaptureModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.SharedInternalsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.SharedInternalsModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.SpriteMaskModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.SpriteMaskModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.SpriteShapeModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.SpriteShapeModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.StreamingModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.StreamingModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.SubstanceModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.SubstanceModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.SubsystemsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.SubsystemsModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TerrainModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TerrainModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TerrainPhysicsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TerrainPhysicsModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TextCoreModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TextCoreModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TextRenderingModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TextRenderingModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TilemapModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TilemapModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.TLSModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsNativeModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIElementsNativeModule.dll - - - ..\ref\Gamecraft_Data\Managed\UnityEngine.UIModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UIModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UmbraModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UmbraModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PopupMessage.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PopupMessage.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Projectiles.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Projectiles.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Serialization.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Serialization.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.Mockup.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.Mockup.dll + + + ..\ref\TechbloxPreview_Data\Managed\GameState.dll + ..\..\ref\TechbloxPreview_Data\Managed\GameState.dll + + + ..\ref\TechbloxPreview_Data\Managed\GhostShark.Outline.dll + ..\..\ref\TechbloxPreview_Data\Managed\GhostShark.Outline.dll + + + ..\ref\TechbloxPreview_Data\Managed\GPUInstancer.CrowdAnimations.dll + ..\..\ref\TechbloxPreview_Data\Managed\GPUInstancer.CrowdAnimations.dll + + + ..\ref\TechbloxPreview_Data\Managed\GPUInstancer.dll + ..\..\ref\TechbloxPreview_Data\Managed\GPUInstancer.dll + + + ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\JWT.dll + ..\..\ref\TechbloxPreview_Data\Managed\JWT.dll + + + ..\ref\TechbloxPreview_Data\Managed\LZ4.dll + ..\..\ref\TechbloxPreview_Data\Managed\LZ4.dll + + + ..\ref\TechbloxPreview_Data\Managed\mscorlib.dll + ..\..\ref\TechbloxPreview_Data\Managed\mscorlib.dll + + + ..\ref\TechbloxPreview_Data\Managed\MultiplayerNetworking.dll + ..\..\ref\TechbloxPreview_Data\Managed\MultiplayerNetworking.dll + + + ..\ref\TechbloxPreview_Data\Managed\MultiplayerTest.dll + ..\..\ref\TechbloxPreview_Data\Managed\MultiplayerTest.dll + + + ..\ref\TechbloxPreview_Data\Managed\netstandard.dll + ..\..\ref\TechbloxPreview_Data\Managed\netstandard.dll + + + ..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll + ..\..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll + + + ..\ref\TechbloxPreview_Data\Managed\RCX.ScreenshotTaker.dll + ..\..\ref\TechbloxPreview_Data\Managed\RCX.ScreenshotTaker.dll + + + ..\ref\TechbloxPreview_Data\Managed\Rewired_Core.dll + ..\..\ref\TechbloxPreview_Data\Managed\Rewired_Core.dll + + + ..\ref\TechbloxPreview_Data\Managed\Rewired_Windows.dll + ..\..\ref\TechbloxPreview_Data\Managed\Rewired_Windows.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftECS.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftECS.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.AccountPreferences.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.AccountPreferences.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.BoxSelect.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.BoxSelect.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.Jobs.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.Jobs.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.ControlsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.ControlsScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Crosshair.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Crosshair.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.FrontEnd.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.FrontEnd.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.BlockLabel.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.BlockLabel.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Hotbar.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Hotbar.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.RemoveBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.RemoveBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.TabsBar.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.TabsBar.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MockCharacter.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MockCharacter.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.PilotSeat.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.PilotSeat.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveAndLoad.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveAndLoad.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveGameDialog.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveGameDialog.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Services.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Services.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SignalHandling.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SignalHandling.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SpawnPoints.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SpawnPoints.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX_TextBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX_TextBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + + + ..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll + ..\..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.InputCapture.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.InputCapture.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.MouseCursor.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.MouseCursor.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.WheelRigBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.WheelRigBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.Addressables.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.Addressables.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.DOTween.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.DOTween.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.Linq.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.Linq.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Mdb.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Mdb.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Pdb.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Pdb.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Rocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Rocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Unsafe.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Unsafe.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Collections.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Collections.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Deformations.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Deformations.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Entities.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.InternalAPIEngineBridge.012.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.InternalAPIEngineBridge.012.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Jobs.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Jobs.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.MemoryProfiler.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.MemoryProfiler.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Physics.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Physics.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Platforms.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Platforms.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.Reflection.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.Reflection.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.ScriptableBuildPipeline.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.ScriptableBuildPipeline.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Serialization.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Serialization.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.TextMeshPro.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.TextMeshPro.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Timeline.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Timeline.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AccessibilityModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AccessibilityModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AndroidJNIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AndroidJNIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AnimationModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AnimationModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ARModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ARModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterInputModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterInputModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterRendererModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterRendererModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.CrashReportingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CrashReportingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.DirectorModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.DirectorModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.DSPGraphModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.DSPGraphModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GameCenterModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GameCenterModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GridModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GridModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.HotReloadModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.HotReloadModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.JSONSerializeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.JSONSerializeModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.LocalizationModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.LocalizationModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ParticleSystemModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ParticleSystemModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.PerformanceReportingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.PerformanceReportingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.Physics2DModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.Physics2DModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.PhysicsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.PhysicsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ProfilerModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ProfilerModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ScreenCaptureModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ScreenCaptureModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SharedInternalsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SharedInternalsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubstanceModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubstanceModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubsystemsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubsystemsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextCoreModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextCoreModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextRenderingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextRenderingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TilemapModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TilemapModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TLSModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TLSModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UI.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UI.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsNativeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsNativeModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UNETModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UNETModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityAnalyticsModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityAnalyticsModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityAnalyticsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityAnalyticsModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityConnectModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityConnectModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityConnectModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityConnectModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityCurlModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityCurlModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityTestProtocolModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityTestProtocolModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityTestProtocolModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityTestProtocolModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.VehiclesModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VehiclesModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VehiclesModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VehiclesModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.VFXModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VFXModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VFXModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VFXModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.VideoModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VideoModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VideoModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VideoModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.VirtualTexturingModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VirtualTexturingModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VirtualTexturingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VirtualTexturingModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.VRModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.VRModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VRModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VRModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.WindModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.WindModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.WindModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.WindModule.dll - ..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll - ..\..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\uREPL.dll + ..\..\ref\TechbloxPreview_Data\Managed\uREPL.dll + + + ..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll + ..\..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll diff --git a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs index e75f8f2..a4bb6d2 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs +++ b/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs @@ -22,7 +22,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI { internal static OnGuiRunner ImguiScheduler = new OnGuiRunner("GamecraftModdingAPI_IMGUIScheduler"); - private static FasterDictionary _activeElements = new FasterDictionary(); + private static Dictionary _activeElements = new Dictionary(); /// /// Add an UIElement instance to be managed by IMGUIManager. @@ -85,11 +85,10 @@ namespace GamecraftModdingAPI.Interface.IMGUI private static void OnGUI() { - UIElement[] elements = _activeElements.GetValuesArray(out uint count); - for(uint i = 0; i < count; i++) + foreach (var element in _activeElements.Values) { - if (elements[i].Enabled) - elements[i].OnGUI(); + if (element.Enabled) + element.OnGUI(); /*try { if (elements[i].Enabled) diff --git a/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs b/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs index 3e136ae..59fd9fd 100644 --- a/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs +++ b/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs @@ -23,9 +23,9 @@ namespace GamecraftModdingAPI.Persistence public EntitiesDB entitiesDB { set; protected get; } - public EntityComponentInitializer BuildDeserializedEntity(EGID egid, ISerializationData serializationData, ISerializableEntityDescriptor entityDescriptor, int serializationType, IEntitySerialization entitySerialization, IEntityFactory factory, bool enginesRootIsDeserializationOnly) + public EntityInitializer BuildDeserializedEntity(EGID egid, ISerializationData serializationData, ISerializableEntityDescriptor entityDescriptor, int serializationType, IEntitySerialization entitySerialization, IEntityFactory factory, bool enginesRootIsDeserializationOnly) { - EntityComponentInitializer esi = factory.BuildEntity(egid); + EntityInitializer esi = factory.BuildEntity(egid); entitySerialization.DeserializeEntityComponents(serializationData, entityDescriptor, ref esi, serializationType); return esi; } diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index e253eac..189b3a8 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -10,10 +10,10 @@ using RobocraftX.Common.Input; using RobocraftX.CR.MachineEditing.BoxSelect; using RobocraftX.Physics; using RobocraftX.Blocks.Ghost; -using RobocraftX.Character.Camera; -using RobocraftX.Character.Factories; using Gamecraft.GUI.HUDFeedbackBlocks; using Svelto.ECS; +using Techblox.Camera; +using Techblox.FlyCam; using Unity.Mathematics; using Unity.Physics; using UnityEngine; From 2d41026a05a2604edfb3e2198d327497afdbfc1e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 11 Apr 2021 02:36:00 +0200 Subject: [PATCH 32/98] Turned the rest of the errors into TODOs --- GamecraftModdingAPI/Input/FakeInput.cs | 6 +++--- GamecraftModdingAPI/Inventory/HotbarEngine.cs | 4 ++-- GamecraftModdingAPI/Players/PlayerEngine.cs | 2 +- GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs | 4 ++-- GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs | 5 +++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/GamecraftModdingAPI/Input/FakeInput.cs b/GamecraftModdingAPI/Input/FakeInput.cs index 8cab6f5..a8129a9 100644 --- a/GamecraftModdingAPI/Input/FakeInput.cs +++ b/GamecraftModdingAPI/Input/FakeInput.cs @@ -109,8 +109,8 @@ namespace GamecraftModdingAPI.Input } ref LocalInputEntityStruct currentInput = ref inputEngine.GetInputRef(playerID); //Utility.Logging.CommandLog($"Current sim frame {currentInput.frame}"); - // set inputs - if (toggleMode) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleTimeRunningMode; + // set inputs - TODO + /*if (toggleMode) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleTimeRunningMode; if (forward) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Forward; if (backward) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Backward; if (up) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Up; @@ -134,7 +134,7 @@ namespace GamecraftModdingAPI.Input if (rotateBlockCounterclockwise) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.RotateBlockAnticlockwise; if (cutSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.CutSelection; if (copySelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.CopySelection; - if (deleteSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.DeleteSelection; + if (deleteSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.DeleteSelection;*/ } public static void Init() diff --git a/GamecraftModdingAPI/Inventory/HotbarEngine.cs b/GamecraftModdingAPI/Inventory/HotbarEngine.cs index 34cdf12..ab9b7d2 100644 --- a/GamecraftModdingAPI/Inventory/HotbarEngine.cs +++ b/GamecraftModdingAPI/Inventory/HotbarEngine.cs @@ -41,8 +41,8 @@ namespace GamecraftModdingAPI.Inventory for (int i = 0; i < inputs.count; i++) { if (inputs.buffer[i].ID.entityID == playerID) { - inputs.buffer[i].cubeSelectedByPick = cubeSelectedByPick; - inputs.buffer[i].selectedCube = block; + /*inputs.buffer[i].cubeSelectedByPick = cubeSelectedByPick; - TODO + inputs.buffer[i].selectedCube = block;*/ return true; } } diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index 189b3a8..dfdb580 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -232,7 +232,7 @@ namespace GamecraftModdingAPI.Players EGID egid = new EGID(playerId, PlayerGroupFromEnum(type)); if (entitiesDB.Exists(egid)) { - return entitiesDB.QueryEntity(egid).lastPingTimeSinceLevelLoad; + //return entitiesDB.QueryEntity(egid).lastPingTimeSinceLevelLoad; - TODO } return null; } diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index acb8bc4..919e639 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -242,7 +242,7 @@ namespace GamecraftModdingAPI.Tests } }).Build(); - CommandBuilder.Builder() + /*CommandBuilder.Builder() .Name("PlaceConsole") .Description("Place a bunch of console block with a given text - entering simulation with them crashes the game as the cmd doesn't exist") .Action((float x, float y, float z) => @@ -262,7 +262,7 @@ namespace GamecraftModdingAPI.Tests sw.Stop(); Logging.CommandLog($"Blocks placed in {sw.ElapsedMilliseconds} ms"); }) - .Build(); + .Build();*/ CommandBuilder.Builder() .Name("WireTest") diff --git a/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs b/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs index 56aab89..7b6ef1e 100644 --- a/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs +++ b/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs @@ -16,10 +16,11 @@ namespace GamecraftModdingAPI.Utility private IEnumerator WaitForSubmissionInternal(IEntityFunctions efu, IEntityFactory efa, EntitiesDB entitiesDB, TaskCompletionSource task) { - var waitEnumerator = new WaitForSubmissionEnumerator(efu, efa, entitiesDB); + /*var waitEnumerator = new WaitForSubmissionEnumerator(efu, efa, entitiesDB); while (waitEnumerator.MoveNext()) yield return null; - task.SetResult(null); + task.SetResult(null);*/ + yield break; //TODO } private IEnumerator WaitForNextFrameInternal(TaskCompletionSource task) From 98e00de6420769bf23891839ac482e44ec5927ed Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 12 Apr 2021 17:37:51 +0200 Subject: [PATCH 33/98] Fix all startup errors --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 2 +- .../Inventory/HotbarSlotSelectionHandlerEnginePatch.cs | 4 ++-- GamecraftModdingAPI/Main.cs | 2 +- GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs | 2 +- GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 62d8ce6..535ce7a 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -83,7 +83,7 @@ namespace GamecraftModdingAPI.Blocks //public static ExclusiveGroup Group { get; } = new ExclusiveGroup("Custom block"); - [HarmonyPatch] + //[HarmonyPatch] - TODO public static class MaterialCopyPatch { private static Material[] materials; diff --git a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs index a0ad5c1..153d82c 100644 --- a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs +++ b/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs @@ -15,9 +15,9 @@ namespace GamecraftModdingAPI.Inventory public static BlockIDs EquippedPartID { get => (BlockIDs)selectedBlockInt; } - private static MethodInfo PatchedMethod { get; } = AccessTools.Method("Gamecraft.GUI.Hotbar.Blocks.SyncHotbarSlotSelectedToEquippedPartEngine:ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int), typeof(ExclusiveGroupStruct) }); + private static MethodInfo PatchedMethod { get; } = AccessTools.Method("Gamecraft.GUI.Hotbar.Blocks.SyncHotbarSlotSelectedToEquippedPartEngine:ActivateSlotForCube", parameters: new Type[] { typeof(uint), typeof(int) }); - public static void Prefix(uint playerID, int selectedDBPartID, ExclusiveGroupStruct groupID) + public static void Prefix(uint playerID, int selectedDBPartID) { selectedBlockInt = selectedDBPartID; } diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index 36a0db4..bfb382e 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -123,7 +123,7 @@ namespace GamecraftModdingAPI private static void OnPatchError() { - ErrorBuilder.DisplayMustQuitError("Failed to patch Gamecraft!\n" + + ErrorBuilder.DisplayMustQuitError("Failed to patch Techblox!\n" + "Make sure you're using the latest version of GamecraftModdingAPI or disable mods if the API isn't released yet."); } } diff --git a/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs b/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs index a603fa2..0145c09 100644 --- a/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs +++ b/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs @@ -13,7 +13,7 @@ using HarmonyLib; namespace GamecraftModdingAPI.Persistence { - [HarmonyPatch] + //[HarmonyPatch] - TODO class SaveGameEnginePatch { private static readonly byte[] frameStart = Encoding.UTF8.GetBytes("\0\0\0GamecraftModdingAPI\0\0\0"); diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 919e639..bf7c0d6 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -47,7 +47,7 @@ namespace GamecraftModdingAPI.Tests /// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself /// public class GamecraftModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin - { + { private static Harmony harmony { get; set; } @@ -73,7 +73,7 @@ namespace GamecraftModdingAPI.Tests //SteamInitPatch.ForcePassSteamCheck = true; // in case running in a VM //MinimumSpecsCheckPatch.ForcePassMinimumSpecCheck = true; - // disable some Gamecraft analytics + // disable some Techblox analytics //AnalyticsDisablerPatch.DisableAnalytics = true; // disable background music Logging.MetaDebugLog("Audio Mixers: " + string.Join(",", AudioTools.GetMixers())); @@ -144,7 +144,7 @@ namespace GamecraftModdingAPI.Tests { CommandBuilder.Builder() .Name("Exit") - .Description("Close Gamecraft immediately, without any prompts") + .Description("Close Techblox immediately, without any prompts") .Action(() => { UnityEngine.Application.Quit(); }) .Build(); From 124ef410c737fe1f343e269ffc5666abe73817a7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 13 Apr 2021 02:05:16 +0200 Subject: [PATCH 34/98] Attempt to bring console back and update block ID list --- GamecraftModdingAPI/Blocks/BlockIDs.cs | 487 +++++------------- GamecraftModdingAPI/Blocks/BlockTests.cs | 4 +- GamecraftModdingAPI/Blocks/CustomBlock.cs | 9 +- GamecraftModdingAPI/Input/FakeInput.cs | 8 +- GamecraftModdingAPI/Main.cs | 2 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 40 +- 6 files changed, 176 insertions(+), 374 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index ff08b51..07e4192 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -9,362 +9,145 @@ namespace GamecraftModdingAPI.Blocks /// Called "nothing" in Gamecraft. (DBID.NOTHING) /// Invalid = ushort.MaxValue, - AluminiumCube = 0, - AxleS, - HingeS = 3, - MotorS, - HingeM, - MotorM, - TyreM, - AxleM, - IronCube, - RubberCube, - OiledCube, - AluminiumConeSegment, //12 - AluminiumCorner, - AluminiumRoundedCorner, - AluminiumSlicedCube, - AluminiumRoundedSlicedCube, - AluminiumCylinder, - AluminiumPyramidSegment, - AluminiumSlope, - AluminiumRoundedSlope, - AluminiumSphere, - RubberConeSegment, //22 - RubberCorner, - RubberRoundedCorner, - RubberSlicedCube, - RubberRoundedSlicedCube, - RubberCylinder, - RubberPyramidSegment, - RubberSlope, - RubberRoundedSlope, - RubberSphere, - OiledConeSegment, //32 - OiledCorner, - OiledRoundedCorner, - OiledSlicedCube, - OiledRoundedSlicedCube, - OiledCylinder, - OiledPyramidSegment, - OiledSlope, - OiledRoundedSlope, - OiledSphere, - IronConeSegment, //42 - IronCorner, - IronRoundedCorner, - IronSlicedCube, - IronRoundedSlicedCube, - IronCylinder, - IronPyramidSegment, - IronSlope, - IronRoundedSlope, - IronSphere, - GlassCube, //52 - GlassSlicedCube, - GlassSlope, - GlassCorner, - GlassPyramidSegment, - GlassRoundedSlicedCube, - GlassRoundedSlope, - GlassRoundedCorner, - GlassConeSegment, - GlassCylinder, - GlassSphere, - Lever, //63 - WoodenSlatsDoor = 65, - PlayerSpawn, //Crashes without special handling - SmallSpawn, - MediumSpawn, - LargeSpawn, + Cube = 0, + Wedge, + QuarterPyramid, + Tetrahedron, + RoundedWedge, + RoundedQuarterPyramid, + RoundedTetrahedron, + NegativeQuarterPyramid, + NegativeTetrahedron, + RoundedNegativeQuarterPyramid, + RoundedNegativeTetrahedron, //10 + PlateCube, + PlateWedge, + PlateQuarterPyramid, + PlateTetrahedron, + Sphere, + Frame, + FrameS1, + FrameS2, + FrameS3, + FrameS4, //20 + FrameS5, + FrameWedge, + FrameWedgeS1, + FrameWedgeS2, + FrameWedgeS3, + FrameWedgeS4, + SideS0S1, + SideS0S2, + SideS0S3, + SideS0S4, //30 + SideS0S5, + SideS1S1, + SideS1S2, + SideS1S3, + SideS1S4, + SideS1S5, + SideS2S1, + SideS2S2, + SideS2S3, + SideS2S4, + SideS2S5, + WindscreenS1, //42 + WindscreenS2, + WindscreenS3, + WindscreenS4, + WindscreenS5, + CarWheelArch, + CarArchSmallFlare, + CarArchFlare, + CarArchExtrudedFlare, //50 + Cube1X1, + Cube1X2, + Cube1X3, + Cube1X4, + Cube1X6, + Cube2X2, + Cube2X3, + Cube2X4, + Cube2X6, + Wedge1X1, //60 + Wedge1X2, + Wedge1X3, + Wedge2X1, + Wedge2X2, + Wedge2X3, + RoundedWedge1X1, + RoundedWedge1X2, + RoundedWedge1X3, + RoundedWedge2X1, + RoundedWedge2X2, //70 + RoundedWedge2X3, + Plate1X1, + Plate1X2, + Plate1X3, + Plate1X4, + Plate2X2, + Plate2X3, + Plate2X4, + Plate3X3, + Plate3X4, //80 + Cube1X1S1, + Cube1X2S1, + Cube1X3S1, + Wedge1X1S1, + Wedge1X2S1, + Wedge1X3S1, + Wedge2X1S1, + Wedge2X2S1, + Wedge2X3S1, + Wedge3X1S1, //90 + Wedge3X2S1, + Wedge3X3S1, + NegativeTetrahedron1X1S1, + NegativeTetrahedron1X2S1, + NegativeTetrahedron1X3S1, + NegativeTetrahedron2X1S1, + NegativeTetrahedron2X2S1, + NegativeTetrahedron2X3S1, + NegativeTetrahedron3X1S1, + Axle, //100 + Hinge, BallJoint, UniversalJoint, - ServoAxle, - ServoHinge, - StepperAxle, - StepperHinge, TelescopicJoint, + HingeSpring, + AxleSpring, DampedSpring, - ServoPiston, - StepperPiston, - PneumaticPiston, //80 - PneumaticHinge, - PneumaticAxle, - WindowedDoor, - Bench, - Chair, - Stool, - DampedHingeSpring, - PlainGlassDoor, - PlainWoodenDoor, - PilotSeat, //Might crash + WheelRigNoSteering, + WheelRigWithSteering, + NegativeTetrahedron3X2S1, //110 + NegativeTetrahedron3X3S1, + Tetrahedron1X1S1, + Tetrahedron1X2S1, + Tetrahedron1X3S1, + Tetrahedron2X1S1, + Tetrahedron2X2S1, + Tetrahedron2X3S1, + Tetrahedron3X1S1, + Tetrahedron3X2S1, + Tetrahedron3X3S1, //120 + QuarterPyramid1X1S1, + QuarterPyramid1X2S1, + QuarterPyramid1X3S1, + QuarterPyramid2X1S1, + QuarterPyramid2X2S1, + QuarterPyramid2X3S1, + QuarterPyramid3X1S1, + QuarterPyramid3X2S1, + QuarterPyramid3X3S1, + PlateTriangle, //130 + PlateCircle, + PlateQtrCircle, + PlateRWedge, + PlateRTetrahedron, + DriverSeat = 150, PassengerSeat, - PilotControls, - GrassCube, - DirtCube, - GrassConeSegment, - GrassCorner, - GrassRoundedCorner, - GrassSlicedCube, - GrassRoundedSlicedCube, - GrassPyramidSegment, - GrassSlope, - GrassRoundedSlope, - DirtConeSegment, - DirtCorner, - DirtRoundedCorner, - DirtSlicedCube, - DirtRoundedSlicedCube, - DirtPyramidSegment, - DirtSlope, - DirtRoundedSlope, - RubberHemisphere, - AluminiumHemisphere, - GrassInnerCornerBulged, - DirtInnerCornerBulged, - IronHemisphere, - OiledHemisphere, - GlassHemisphere, - TyreS, - ThreeWaySwitch, - Dial, //120 - CharacterOnEnterTrigger, //Probably crashes - CharacterOnLeaveTrigger, - CharacterOnStayTrigger, - ObjectOnEnterTrigger, - ObjectOnLeaveTrigger, - ObjectOnStayTrigger, - Button, - Switch, - TextBlock, //Brings up a screen - ConsoleBlock, //Brings up a screen - Door, - GlassDoor, - PoweredDoor, - PoweredGlassDoor, - AluminiumTubeCorner, - IronTubeCorner, - WoodCube, - WoodSlicedCube, - WoodSlope, - WoodCorner, - WoodPyramidSegment, - WoodConeSegment, - WoodRoundedSlicedCube, - WoodRoundedSlope, - WoodRoundedCorner, - WoodCylinder, - WoodHemisphere, - WoodSphere, - BrickCube, - DampedAxleSpring, //150 - BrickSlicedCube, - BrickSlope, - BrickCorner, - ConcreteCube, - ConcreteSlicedCube, - ConcreteSlope, - ConcreteCorner, - RoadCarTyre, - OffRoadCarTyre, - RacingCarTyre, - BicycleTyre, - FrontBikeTyre, - RearBikeTyre, - ChopperBikeTyre, - TractorTyre, - MonsterTruckTyre, - MotocrossBikeTyre, - CartTyre, //168 - ObjectIdentifier, - ANDLogicBlock, - NANDLogicBlock, - NORLogicBlock, - NOTLogicBlock, - ORLogicBlock, - XNORLogicBlock, - XORLogicBlock, - AbsoluteMathsBlock, - AdderMathsBlock, - DividerMathsBlock, - SignMathsBlock, //180 - MaxMathsBlock, - MinMathsBlock, - MultiplierMathsBlock, - SubtractorMathsBlock, - SimpleConnector, - MeanMathsBlock, - Bit, - Counter, - Timer, - ObjectFilter, - PlayerFilter, - TeamFilter, - Number2Text, //193 - DestructionManager = 260, - ChunkHealthModifier, - ClusterHealthModifier, //262 - BeachTree1 = 200, - BeachTree2, - BeachTree3, - Rock1, - Rock2, - Rock3, - Rock4, - BirchTree1, - BirchTree2, - BirchTree3, - PineTree1, - PineTree2, - PineTree3, - Flower1, - Flower2, - Flower3, - Shrub1, - Shrub2, - Shrub3, - CliffCube, - CliffSlicedCorner, - CliffCornerA, - CliffCornerB, - CliffSlopeA, - CliffSlopeB, - GrassEdge, - GrassEdgeInnerCorner, - GrassEdgeCorner, - GrassEdgeSlope, - CentreHUD, - ObjectiveHUD, - GameStatsHUD, //231 - GameOverBlock, - SFXBlockGameplay = 240, - SFXBlock8Bit, - SFXBlockInstrument, - SFXBlockSciFi, - SFXBlockLoops, - SFXBlockVocal, - MovementConstrainer, //246 - RotationConstrainer, - AdvancedMovementDampener, - AdvancedRotationDampener, - Mover = 250, - Rotator, - MovementDampener, - RotationDampener, - AdvancedMover, - AdvancedRotator, - MusicBlock, //256 - PlasmaCannonBlock, - QuantumRiflePickup = 300, - QuantumRifleAmmoPickup, - AluminiumSlicedFraction, - AluminiumSlicedSlope, - AluminiumHalfPyramidLeft = 305, - AluminiumHalfPyramidRight, - AluminiumPyramidSliced, - AluminiumTubeCross, - AluminiumTubeT, - AluminiumPlateSquare, - AluminiumPlateCircle, - AluminiumPlateTriangle, //312 - OiledSlicedFraction = 314, - OiledSlicedSlope, - OiledHalfPyramidLeft, - OiledHalfPyramidRight, - OiledPyramidSliced, - GlassSlicedFraction, - GlassSlicedSlope, - GlassHalfPyramidLeft, - GlassHalfPyramidRight, - GlassPyramidSliced, - RubberSlicedFraction, - RubberSlicedSlope, - RubberHalfPyramidLeft, - RubberHalfPyramidRight, - RubberPyramidSliced, - WoodSlicedFraction, - WoodSlicedSlope, //330 - WoodHalfPyramidLeft, - WoodHalfPyramidRight, - WoodPyramidSliced, - HexNetSlicedFraction, - HexNetSlicedSlope, - HexNetHalfPyramidLeft, - HexNetHalfPyramidRight, - HexNetPyramidSliced, - OiledTubeCross, - OiledTubeT, //340 - GlassTubeCross, - GlassTubeT, - RubberTubeCross, - RubberTubeT, - WoodTubeCross, - WoodTubeT, - HexNetTubeCross, - HexNetTubeT, - BouncyCube, - BouncySlicedCube, //350 - BouncySlope, - BouncyCorner, - OiledTubeCorner, - GlassTubeCorner, - RubberTubeCorner, - WoodTubeCorner, - Basketball, - BowlingBall, - SoccerBall, - GolfBall, //360 - HockeyPuck, - PoolBall, - BouncyBall, - TennisBall, - UnlitCube, - IronSlicedFraction, - IronSlicedSlope, - IronHalfPyramidLeft, - IronHalfPyramidRight, - IronPyramidSliced, //370 - IronTubeCross, - IronTubeT, - SFXBlockMob = 374, - PointLight, - SpotLight, - SunLight, - AmbientLight, - UnlitGlowCube = 381, - PointLightInvisible, - SpotLightInvisible, - UnlitSlope, - UnlitGlowSlope, - Fog, - Sky, - GridCube, - GridSlicedCube, - GridSlope, - GridCorner, - MagmaRockCube = 777, - MagmaRockCubeSliced, - MagmaRockSlope, - MagmaRockCorner, - MagmaRockPyramidSegment, - MagmaRockConeSegment, - MagmaRockSlicedRounded, - MagmaRockSlopeRounded, - MagmaRockCornerRounded, - HexNetCube, - HexNetCubeSliced, - HexNetSlope, - HexNetCorner, - HexNetPyramidSegment, - HexNetConeSegment, - HexNetSlicedRounded, - HexNetSlopeRounded, - HexNetCornerRounded, //794 - MagmaRockBulgedInner, - HexNetCylinder = 797, - HexNetHemisphere, - HexNetSphere, - HexNetTubeCorner, //800 - CenterOfMassBlock = 1346 + Engine, + CarWheelWideProfile = 200, + CarWheel, } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/BlockTests.cs b/GamecraftModdingAPI/Blocks/BlockTests.cs index dbcd39e..7aac012 100644 --- a/GamecraftModdingAPI/Blocks/BlockTests.cs +++ b/GamecraftModdingAPI/Blocks/BlockTests.cs @@ -19,14 +19,14 @@ namespace GamecraftModdingAPI.Blocks [APITestCase(TestType.EditMode)] public static void TestPlaceNew() { - Block newBlock = Block.PlaceNew(BlockIDs.AluminiumCube, Unity.Mathematics.float3.zero); + Block newBlock = Block.PlaceNew(BlockIDs.Cube, Unity.Mathematics.float3.zero); Assert.NotNull(newBlock.Id, "Newly placed block is missing Id. This should be populated when the block is placed.", "Newly placed block Id is not null, block successfully placed."); } [APITestCase(TestType.EditMode)] public static void TestInitProperty() { - Block newBlock = Block.PlaceNew(BlockIDs.AluminiumCube, Unity.Mathematics.float3.zero + 2); + Block newBlock = Block.PlaceNew(BlockIDs.Cube, Unity.Mathematics.float3.zero + 2); if (!Assert.CloseTo(newBlock.Position, (Unity.Mathematics.float3.zero + 2), $"Newly placed block at {newBlock.Position} is expected at {Unity.Mathematics.float3.zero + 2}.", "Newly placed block position matches.")) return; //Assert.Equal(newBlock.Exists, true, "Newly placed block does not exist, possibly because Sync() skipped/missed/failed.", "Newly placed block exists, Sync() successful."); } diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 535ce7a..c979234 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -18,6 +18,7 @@ using UnityEngine.AddressableAssets; using Material = UnityEngine.Material; using GamecraftModdingAPI.Utility; +using ServiceLayer; namespace GamecraftModdingAPI.Blocks { @@ -114,7 +115,7 @@ namespace GamecraftModdingAPI.Blocks { public static void Prefix(IDataDB dataDB) { - //var abd = dataDB.GetValue((int) BlockIDs.AluminiumCube); + //var abd = dataDB.GetValue((int) BlockIDs.Cube); foreach (var (key, type) in CustomBlocks) { var attr = type.GetCustomAttribute(); @@ -146,6 +147,12 @@ namespace GamecraftModdingAPI.Blocks foreach (var (id, action) in BlockChangeActions) action(dataDB.GetValue(id)); + + /*foreach (var (key, value) in dataDB.GetValues()) + { + var data = (CubeListData) value; + Console.WriteLine($"ID: {key} - Name: {data.CubeNameKey}: {LocalizationService.Localize(data.CubeNameKey)}"); + }*/ _canRegister = false; } diff --git a/GamecraftModdingAPI/Input/FakeInput.cs b/GamecraftModdingAPI/Input/FakeInput.cs index a8129a9..1d5564d 100644 --- a/GamecraftModdingAPI/Input/FakeInput.cs +++ b/GamecraftModdingAPI/Input/FakeInput.cs @@ -53,7 +53,7 @@ namespace GamecraftModdingAPI.Input /// Select the hotbar page by number? /// Quicksave? /// Paste? - public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool commandLine = false, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, bool colour = false, int hotbarPage = -1, bool quickSave = false, bool paste = false) + public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, int hotbarPage = -1, bool quickSave = false, bool paste = false) { if (playerID == uint.MaxValue) { @@ -76,7 +76,6 @@ namespace GamecraftModdingAPI.Input case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Hotbar_9; break; default: break; } - //if (commandLine) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleCommandLine; - TODO if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape; if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return; if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay; @@ -97,6 +96,7 @@ namespace GamecraftModdingAPI.Input case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage10; break; default: break; } + //RewiredConsts.Action if (quickSave) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.QuickSave; if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.PasteSelection; } @@ -118,8 +118,8 @@ namespace GamecraftModdingAPI.Input if (left) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Left; if (right) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Right; if (sprint) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Sprint; - if (toggleFly) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SwitchFlyMode; - if (alt) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.AltAction; + //if (toggleFly) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SwitchFlyMode; + //if (alt) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.AltAction; if (primary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.PrimaryAction; if (secondary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.SecondaryAction; if (tertiary) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.TertiaryAction; diff --git a/GamecraftModdingAPI/Main.cs b/GamecraftModdingAPI/Main.cs index bfb382e..57349de 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/GamecraftModdingAPI/Main.cs @@ -91,7 +91,7 @@ namespace GamecraftModdingAPI AsyncUtils.Init(); GamecraftModdingAPI.App.Client.Init(); GamecraftModdingAPI.App.Game.Init(); - CustomBlock.Init(); + //CustomBlock.Init(); // init UI Interface.IMGUI.Constants.Init(); Interface.IMGUI.IMGUIManager.Init(); diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index bf7c0d6..410c0a5 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -26,8 +26,11 @@ using GamecraftModdingAPI.Commands; using GamecraftModdingAPI.Events; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Blocks; +using GamecraftModdingAPI.Input; using GamecraftModdingAPI.Interface.IMGUI; using GamecraftModdingAPI.Players; +using RobocraftX.Common.Input; +using Svelto.DataStructures; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.ResourceManagement.AsyncOperations; @@ -171,7 +174,7 @@ namespace GamecraftModdingAPI.Tests .Description("Place a block of aluminium at the given coordinates") .Action((float x, float y, float z) => { - var block = Block.PlaceNew(BlockIDs.AluminiumCube, new float3(x, y, z)); + var block = Block.PlaceNew(BlockIDs.Cube, new float3(x, y, z)); Logging.CommandLog("Block placed with type: " + block.Type); }) .Build(); @@ -185,7 +188,7 @@ namespace GamecraftModdingAPI.Tests var sw = Stopwatch.StartNew(); for (int i = 0; i < 100; i++) for (int j = 0; j < 100; j++) - Block.PlaceNew(BlockIDs.AluminiumCube, new float3(x + i, y, z + j)); + Block.PlaceNew(BlockIDs.Cube, new float3(x + i, y, z + j)); //Block.Sync(); sw.Stop(); Logging.CommandLog("Finished in " + sw.ElapsedMilliseconds + "ms"); @@ -264,7 +267,7 @@ namespace GamecraftModdingAPI.Tests }) .Build();*/ - CommandBuilder.Builder() + /*CommandBuilder.Builder() .Name("WireTest") .Description("Place two blocks and then wire them together") .Action(() => @@ -275,7 +278,7 @@ namespace GamecraftModdingAPI.Tests Wire conn = notBlock.Connect(0, andBlock, 1); Logging.CommandLog(conn.ToString()); }) - .Build(); + .Build();*/ CommandBuilder.Builder("TestChunkHealth", "Sets the chunk looked at to the given health.") .Action((float val, float max) => @@ -291,13 +294,13 @@ namespace GamecraftModdingAPI.Tests .Action((float x, float y, float z) => { var pos = new float3(x, y, z); - var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.AluminiumCube, pos, + var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.Cube, pos, color: BlockColors.Aqua)); - Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Blue) + Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Blue) .BlockGroup = group; - Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Green) + Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Green) .BlockGroup = group; - Block.PlaceNew(BlockIDs.AluminiumCube, pos += new float3(1, 0, 0), color: BlockColors.Lime) + Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Lime) .BlockGroup = group; }).Build(); @@ -328,7 +331,7 @@ namespace GamecraftModdingAPI.Tests } }, "MoveLastBlock", "Move the most-recently-placed block, and any connected blocks by the given offset")); CommandManager.AddCommand(new SimpleCustomCommandEngine( - (x, y, z) => { Blocks.Placement.PlaceBlock(Blocks.BlockIDs.AluminiumCube, new Unity.Mathematics.float3(x, y, z)); }, + (x, y, z) => { Blocks.Placement.PlaceBlock(Blocks.BlockIDs.Cube, new Unity.Mathematics.float3(x, y, z)); }, "PlaceAluminium", "Place a block of aluminium at the given coordinates")); System.Random random = new System.Random(); // for command below CommandManager.AddCommand(new SimpleCustomCommandEngine( @@ -368,7 +371,7 @@ namespace GamecraftModdingAPI.Tests Logging.Log("Compatible GamecraftScripting detected"); } // Interface test - Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true); + /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true); Interface.IMGUI.Button button = new Button("TEST"); button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; Interface.IMGUI.Button button2 = new Button("TEST2"); @@ -382,16 +385,16 @@ namespace GamecraftModdingAPI.Tests uiGroup.AddElement(button2); uiGroup.AddElement(uiText); uiGroup.AddElement(uiLabel); - uiGroup.AddElement(uiImg); + uiGroup.AddElement(uiImg);*/ - Addressables.LoadAssetAsync("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg") + /*Addressables.LoadAssetAsync("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg") .Completed += handle => { uiImg.Texture = handle.Result; uiImg.Enabled = true; Logging.MetaDebugLog($"Got blue bg asset {handle.Result}"); - }; + };*/ CommandBuilder.Builder("enableCompletions") @@ -414,8 +417,11 @@ namespace GamecraftModdingAPI.Tests Logging.MetaDebugLog("Test custom block catalog not found"); } - CustomBlock.ChangeExistingBlock((ushort) BlockIDs.TyreS, + CustomBlock.ChangeExistingBlock((ushort) BlockIDs.CarWheel, cld => cld.scalingPermission = ScalingPermission.NonUniform); + + /*((FasterList)AccessTools.Property(typeof(GuiInputMap), "GuiInputsButtonDown").GetValue(null)) + .Add(new GuiInputMap.GuiInputMapElement(RewiredConsts.Action.ToggleCommandLine, GuiIn))*/ #if TEST TestRoot.RunTests(); #endif @@ -465,6 +471,12 @@ namespace GamecraftModdingAPI.Tests } } + public override void OnUpdate() + { + if(UnityEngine.Input.GetKeyDown(KeyCode.Backslash)) + FakeInput.CustomInput(new LocalInputEntityStruct{commandLineToggleInput = true}); + } + [HarmonyPatch] public class MinimumSpecsPatch { From 9a4ff858f3e9aad9197f7b470456541787951d84 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 16 Apr 2021 01:40:30 +0200 Subject: [PATCH 35/98] Improve color API and add material API --- GamecraftModdingAPI/Block.cs | 29 +++++++------ GamecraftModdingAPI/Blocks/BlockColor.cs | 42 +++++++++---------- GamecraftModdingAPI/Blocks/BlockMaterial.cs | 12 ++++++ GamecraftModdingAPI/Blocks/PlacementEngine.cs | 18 ++++---- .../Tests/GamecraftModdingAPIPluginTest.cs | 4 +- .../Utility/DebugInterfaceEngine.cs | 4 +- 6 files changed, 62 insertions(+), 47 deletions(-) create mode 100644 GamecraftModdingAPI/Blocks/BlockMaterial.cs diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 607213d..daeeba3 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -40,18 +40,18 @@ namespace GamecraftModdingAPI /// /// The block's type /// The block's color - /// The block color's darkness (0-9) - 0 is default color + /// The block's material /// The block's position - default block size is 0.2 /// The block's rotation in degrees /// The block's uniform scale - default scale is 1 (with 0.2 width) /// The block's non-uniform scale - 0 means is used /// The player who placed the block /// The placed block or null if failed - public static Block PlaceNew(BlockIDs block, float3 position, - float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0, + public static Block PlaceNew(BlockIDs block, float3 position, float3 rotation = default, + BlockColors color = BlockColors.Default, BlockMaterial material = BlockMaterial.Default, int uscale = 1, float3 scale = default, Player player = null) { - return PlaceNew(block, position, rotation, color, darkness, uscale, scale, player); + return PlaceNew(block, position, rotation, color, material, uscale, scale, player); } /// @@ -61,7 +61,7 @@ namespace GamecraftModdingAPI /// /// The block's type /// The block's color - /// The block color's darkness (0-9) - 0 is default color + /// The block's materialr /// The block's position - default block size is 0.2 /// The block's rotation in degrees /// The block's uniform scale - default scale is 1 (with 0.2 width) @@ -69,12 +69,12 @@ namespace GamecraftModdingAPI /// The player who placed the block /// The placed block or null if failed public static T PlaceNew(BlockIDs block, float3 position, - float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0, + float3 rotation = default, BlockColor? color = null, BlockMaterial material = BlockMaterial.Default, int uscale = 1, float3 scale = default, Player player = null) where T : Block { if (PlacementEngine.IsInGame && GameState.IsBuildMode()) { - var egid = PlacementEngine.PlaceBlock(block, color, darkness, + var egid = PlacementEngine.PlaceBlock(block, color ?? BlockColors.Default, material, position, uscale, scale, player, rotation, out var initializer); var bl = New(egid.entityID, egid.groupID); bl.InitData.Group = BlockEngine.InitGroup(initializer); @@ -319,9 +319,7 @@ namespace GamecraftModdingAPI { BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, BlockColor val) => { - color.indexInPalette = (byte) (val.Color + val.Darkness * 10); - //color.overridePaletteColour = false; - //color.needsUpdate = true; + color.indexInPalette = val.Index; color.hasNetworkChange = true; color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); }, value); @@ -339,13 +337,18 @@ namespace GamecraftModdingAPI BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) => { color.paletteColour = val; - //color.overridePaletteColour = true; - //color.needsUpdate = true; color.hasNetworkChange = true; }, value); } } + public BlockMaterial Material + { + get => BlockEngine.GetBlockInfo(this, (CubeMaterialStruct cmst) => (BlockMaterial) cmst.materialId); + set => BlockEngine.SetBlockInfo(this, + (ref CubeMaterialStruct cmst, BlockMaterial val) => cmst.materialId = (byte) val, value); + } + /// /// The text displayed on the block if applicable, or null. /// Setting it is temporary to the session, it won't be saved. @@ -433,7 +436,7 @@ namespace GamecraftModdingAPI /// public T Copy() where T : Block { - var block = PlaceNew(Type, Position, Rotation, Color.Color, Color.Darkness, UniformScale, Scale); + var block = PlaceNew(Type, Position, Rotation, Color, Material, UniformScale, Scale); block.copiedFrom = Id; return block; } diff --git a/GamecraftModdingAPI/Blocks/BlockColor.cs b/GamecraftModdingAPI/Blocks/BlockColor.cs index bf22090..bb5fa4a 100644 --- a/GamecraftModdingAPI/Blocks/BlockColor.cs +++ b/GamecraftModdingAPI/Blocks/BlockColor.cs @@ -5,35 +5,35 @@ namespace GamecraftModdingAPI.Blocks { public struct BlockColor { - public BlockColors Color; - public byte Darkness; + public BlockColors Color => Index == byte.MaxValue + ? BlockColors.Default + : (BlockColors) (Index % 10); - public byte Index => Color == BlockColors.Default - ? byte.MaxValue - : (byte) (Darkness * 10 + Color); + public byte Darkness => (byte) (Index == byte.MaxValue + ? 0 + : Index / 10); + + public byte Index { get; } public BlockColor(byte index) { - if (index == byte.MaxValue) - { - Color = BlockColors.Default; - Darkness = 0; - } - else - { - if (index > 99) - throw new ArgumentOutOfRangeException(nameof(index), "Invalid color index. Must be 0-90 or 255."); - Color = (BlockColors) (index % 10); - Darkness = (byte) (index / 10); - } + if (index > 99 && index != byte.MaxValue) + throw new ArgumentOutOfRangeException(nameof(index), "Invalid color index. Must be 0-90 or 255."); + Index = index; } - public BlockColor(BlockColors color, byte darkness) + public BlockColor(BlockColors color, byte darkness = 0) { if (darkness > 9) throw new ArgumentOutOfRangeException(nameof(darkness), "Darkness must be 0-9 where 0 is default."); - Color = color; - Darkness = darkness; + if (color > BlockColors.Red) //Last valid color + throw new ArgumentOutOfRangeException(nameof(color), "Invalid color!"); + Index = (byte) (darkness * 10 + (byte) color); + } + + public static implicit operator BlockColor(BlockColors color) + { + return new BlockColor(color); } public float4 RGBA => Block.BlockEngine.ConvertBlockColor(Index); @@ -47,7 +47,7 @@ namespace GamecraftModdingAPI.Blocks /// /// Preset block colours /// - public enum BlockColors + public enum BlockColors : byte { Default = byte.MaxValue, White = 0, diff --git a/GamecraftModdingAPI/Blocks/BlockMaterial.cs b/GamecraftModdingAPI/Blocks/BlockMaterial.cs new file mode 100644 index 0000000..74d45bb --- /dev/null +++ b/GamecraftModdingAPI/Blocks/BlockMaterial.cs @@ -0,0 +1,12 @@ +namespace GamecraftModdingAPI.Blocks +{ + public enum BlockMaterial : byte + { + Default = byte.MaxValue, + SteelBodywork = 0, + RigidSteel, + CarbonFiber, + Plastic, + Wood + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index 506456b..908eadf 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -40,17 +40,17 @@ namespace GamecraftModdingAPI.Blocks public EntitiesDB entitiesDB { get; set; } private static BlockEntityFactory _blockEntityFactory; //Injected from PlaceSingleBlockEngine - public EGID PlaceBlock(BlockIDs block, BlockColors color, byte darkness, float3 position, int uscale, + public EGID PlaceBlock(BlockIDs block, BlockColor color, BlockMaterial materialId, float3 position, int uscale, float3 scale, Player player, float3 rotation, out EntityInitializer initializer) { //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one - if (darkness > 9) + if (color.Darkness > 9) throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)"); - initializer = BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation, + initializer = BuildBlock((ushort) block, color.Index, (byte) materialId, position, uscale, scale, rotation, (player ?? new Player(PlayerType.Local)).Id); return initializer.EGID; } - private EntityInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, float3 rot, uint playerId) + private EntityInitializer BuildBlock(ushort block, byte color, byte materialId, float3 position, int uscale, float3 scale, float3 rot, uint playerId) { if (_blockEntityFactory == null) throw new BlockException("The factory is null."); @@ -81,11 +81,11 @@ namespace GamecraftModdingAPI.Blocks indexInPalette = color, hasNetworkChange = true }); - structInitializer.Init(new CubeMaterialStruct - { - materialId = 0, //TODO - cosmeticallyPaintedOnly = true //TODO - }); + if (materialId != byte.MaxValue) + structInitializer.Init(new CubeMaterialStruct + { + materialId = materialId + }); uint prefabId = PrefabsID.GetOrCreatePrefabID(block, 0, 0, false); //TODO structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId)); diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 410c0a5..92b1d7a 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -224,8 +224,8 @@ namespace GamecraftModdingAPI.Tests float.Parse(s[1]), float.Parse(s[2]), float.Parse(s[3])); return; } - new Player(PlayerType.Local).GetBlockLookedAt().Color = - new BlockColor { Color = color }; + + new Player(PlayerType.Local).GetBlockLookedAt().Color = color; Logging.CommandLog("Colored block to " + color); }).Build(); diff --git a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs b/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs index 0e4d023..9c14075 100644 --- a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs +++ b/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs @@ -31,8 +31,8 @@ namespace GamecraftModdingAPI.Utility public void SetInfo(string id, Func contentGetter) => _extraInfo[id] = contentGetter; public bool RemoveInfo(string id) => _extraInfo.Remove(id); - public string Name { get; } = "GamecraftModdingAPIDebugInterfaceGameEngine"; - public bool isRemovable { get; } = true; + public string Name => "GamecraftModdingAPIDebugInterfaceGameEngine"; + public bool isRemovable => true; [HarmonyPatch] private class Patch From 1f688195afb0a56fd88f470c28aca1db20e2e973 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 19 Apr 2021 03:13:00 +0200 Subject: [PATCH 36/98] Add support for flipped blocks and auto-wiring, other fixes --- GamecraftModdingAPI/Block.cs | 32 ++++++++++++++++--- GamecraftModdingAPI/Blocks/BlockEngine.cs | 12 +------ .../Blocks/BlockIdentifiers.cs | 5 +-- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 13 ++++---- GamecraftModdingAPI/Inventory/HotbarEngine.cs | 19 +++++------ 5 files changed, 47 insertions(+), 34 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index daeeba3..234ee6e 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -13,6 +13,7 @@ using Gamecraft.Blocks.GUI; using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Utility; +using RobocraftX.Rendering.GPUI; namespace GamecraftModdingAPI { @@ -45,13 +46,15 @@ namespace GamecraftModdingAPI /// The block's rotation in degrees /// The block's uniform scale - default scale is 1 (with 0.2 width) /// The block's non-uniform scale - 0 means is used + /// Whether the block should be flipped + /// Whether the block should be auto-wired (if functional) /// The player who placed the block /// The placed block or null if failed public static Block PlaceNew(BlockIDs block, float3 position, float3 rotation = default, BlockColors color = BlockColors.Default, BlockMaterial material = BlockMaterial.Default, - int uscale = 1, float3 scale = default, Player player = null) + int uscale = 1, float3 scale = default, bool isFlipped = false, bool autoWire = false, Player player = null) { - return PlaceNew(block, position, rotation, color, material, uscale, scale, player); + return PlaceNew(block, position, rotation, color, material, uscale, scale, isFlipped, autoWire, player); } /// @@ -66,16 +69,19 @@ namespace GamecraftModdingAPI /// The block's rotation in degrees /// The block's uniform scale - default scale is 1 (with 0.2 width) /// The block's non-uniform scale - 0 means is used + /// Whether the block should be flipped + /// Whether the block should be auto-wired (if functional) /// The player who placed the block /// The placed block or null if failed public static T PlaceNew(BlockIDs block, float3 position, float3 rotation = default, BlockColor? color = null, BlockMaterial material = BlockMaterial.Default, - int uscale = 1, float3 scale = default, Player player = null) where T : Block + int uscale = 1, float3 scale = default, bool isFlipped = false, bool autoWire = false, Player player = null) + where T : Block { if (PlacementEngine.IsInGame && GameState.IsBuildMode()) { var egid = PlacementEngine.PlaceBlock(block, color ?? BlockColors.Default, material, - position, uscale, scale, player, rotation, out var initializer); + position, uscale, scale, player, rotation, isFlipped, autoWire, out var initializer); var bl = New(egid.entityID, egid.groupID); bl.InitData.Group = BlockEngine.InitGroup(initializer); Placed += bl.OnPlacedInit; @@ -293,6 +299,24 @@ namespace GamecraftModdingAPI } } + /** + * Whether the block is fipped. + */ + public bool Flipped + { + get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale.x < 0); + set + { + BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) => + st.scale.x = math.abs(st.scale.x) * (val ? -1 : 1), value); + BlockEngine.SetBlockInfo(this, (ref GFXPrefabEntityStructGPUI st, bool val) => + { + uint prefabId = PrefabsID.GetOrCreatePrefabID((ushort) Type, (byte) Material, 0, value); + st.prefabID = prefabId; + }, value); + } + } + /// /// The block's type (ID). Returns BlockIDs.Invalid if the block doesn't exist anymore. /// diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 46afb09..5eff5b2 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -80,17 +80,7 @@ namespace GamecraftModdingAPI.Blocks public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityViewComponent { if (entitiesDB.Exists(blockID)) - { - // TODO: optimize by using EntitiesDB internal calls instead of iterating over everything - BT> entities = entitiesDB.QueryEntities(blockID.groupID).ToBuffer(); - for (int i = 0; i < entities.count; i++) - { - if (entities.buffer[i].ID == blockID) - { - return ref entities.buffer[i]; - } - } - } + return ref entitiesDB.QueryEntity(blockID); T[] structHolder = new T[1]; //Create something that can be referenced return ref structHolder[0]; //Gets a default value automatically } diff --git a/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs b/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs index 0c3222b..bc426d5 100644 --- a/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs +++ b/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs @@ -2,6 +2,7 @@ using RobocraftX.Common; using HarmonyLib; +using Svelto.DataStructures; namespace GamecraftModdingAPI.Blocks { @@ -12,8 +13,8 @@ namespace GamecraftModdingAPI.Blocks { /// /// Blocks placed by the player - /// - TODO - //public static ExclusiveGroup OWNED_BLOCKS { get { return CommonExclusiveGroups.REAL_BLOCKS_GROUPS_DON_T_USE_IN_NEW_CODE; } } + /// + public static FasterReadOnlyList OWNED_BLOCKS { get { return CommonExclusiveGroups.REAL_BLOCKS_GROUPS_DON_T_USE_IN_NEW_CODE; } } /// /// Extra parts used in functional blocks diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index 908eadf..cbc49e2 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -2,6 +2,7 @@ using System; using System.Reflection; using DataLoader; +using Gamecraft.Wires; using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Blocks.Scaling; @@ -41,16 +42,16 @@ namespace GamecraftModdingAPI.Blocks private static BlockEntityFactory _blockEntityFactory; //Injected from PlaceSingleBlockEngine public EGID PlaceBlock(BlockIDs block, BlockColor color, BlockMaterial materialId, float3 position, int uscale, - float3 scale, Player player, float3 rotation, out EntityInitializer initializer) + float3 scale, Player player, float3 rotation, bool isFlipped, bool autoWire, out EntityInitializer initializer) { //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one if (color.Darkness > 9) throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)"); initializer = BuildBlock((ushort) block, color.Index, (byte) materialId, position, uscale, scale, rotation, - (player ?? new Player(PlayerType.Local)).Id); + isFlipped, autoWire, (player ?? new Player(PlayerType.Local)).Id); return initializer.EGID; } - private EntityInitializer BuildBlock(ushort block, byte color, byte materialId, float3 position, int uscale, float3 scale, float3 rot, uint playerId) + private EntityInitializer BuildBlock(ushort block, byte color, byte materialId, float3 position, int uscale, float3 scale, float3 rot, bool isFlipped, bool autoWire, uint playerId) { if (_blockEntityFactory == null) throw new BlockException("The factory is null."); @@ -63,7 +64,7 @@ namespace GamecraftModdingAPI.Blocks if (!PrefabsID.PrefabIDByResourceIDMap.ContainsKey(resourceId)) throw new BlockException("Block with ID " + block + " not found!"); //RobocraftX.CR.MachineEditing.PlaceSingleBlockEngine - ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale}; + ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale * (isFlipped ? -1 : 1)}; Quaternion rotQ = Quaternion.Euler(rot); RotationEntityStruct rotation = new RotationEntityStruct {rotation = rotQ}; GridRotationStruct gridRotation = new GridRotationStruct @@ -86,7 +87,7 @@ namespace GamecraftModdingAPI.Blocks { materialId = materialId }); - uint prefabId = PrefabsID.GetOrCreatePrefabID(block, 0, 0, false); //TODO + uint prefabId = PrefabsID.GetOrCreatePrefabID(block, materialId, 0, isFlipped); structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId)); structInitializer.Init(dbEntity); @@ -102,7 +103,7 @@ namespace GamecraftModdingAPI.Blocks { loadedFromDisk = false, placedBy = playerId, - triggerAutoWiring = false //TODO + triggerAutoWiring = autoWire && structInitializer.Has() }); /*structInitializer.Init(new CollisionFilterOverride diff --git a/GamecraftModdingAPI/Inventory/HotbarEngine.cs b/GamecraftModdingAPI/Inventory/HotbarEngine.cs index ab9b7d2..b20928b 100644 --- a/GamecraftModdingAPI/Inventory/HotbarEngine.cs +++ b/GamecraftModdingAPI/Inventory/HotbarEngine.cs @@ -11,6 +11,8 @@ using Svelto.ECS; using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Utility; using GamecraftModdingAPI.Engines; +using RobocraftX.Blocks; +using Techblox.FlyCam; namespace GamecraftModdingAPI.Inventory { @@ -36,18 +38,13 @@ namespace GamecraftModdingAPI.Inventory public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false) { - var inputs = entitiesDB.QueryEntities(InputExclusiveGroups.LocalPlayers).ToBuffer(); - if (inputs.count == 0) return false; - for (int i = 0; i < inputs.count; i++) - { - if (inputs.buffer[i].ID.entityID == playerID) { - /*inputs.buffer[i].cubeSelectedByPick = cubeSelectedByPick; - TODO - inputs.buffer[i].selectedCube = block;*/ - return true; - } - } + if (!entitiesDB.TryQueryEntitiesAndIndex(playerID, Techblox.FlyCam.FlyCam.Group, + out var index, out var inputs)) + return false; + inputs[index].CubeSelectedByPick = cubeSelectedByPick; + inputs[index].SelectedDBPartID = block; // TODO: expose the rest of the input functionality - return false; + return true; } public uint GetLocalPlayerID() From 677c8b0907601032cdbaecf2c8e6a371a3d84a8c Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 19 Apr 2021 19:32:14 +0200 Subject: [PATCH 37/98] Add constructor for placing block, remove most PlaceNew args --- GamecraftModdingAPI/Block.cs | 52 +++++++++++---- GamecraftModdingAPI/Blocks/PlacementEngine.cs | 64 ++++--------------- .../Tests/GamecraftModdingAPIPluginTest.cs | 15 ++--- 3 files changed, 59 insertions(+), 72 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 234ee6e..99574ff 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -50,11 +50,9 @@ namespace GamecraftModdingAPI /// Whether the block should be auto-wired (if functional) /// The player who placed the block /// The placed block or null if failed - public static Block PlaceNew(BlockIDs block, float3 position, float3 rotation = default, - BlockColors color = BlockColors.Default, BlockMaterial material = BlockMaterial.Default, - int uscale = 1, float3 scale = default, bool isFlipped = false, bool autoWire = false, Player player = null) + public static Block PlaceNew(BlockIDs block, float3 position, bool autoWire = false, Player player = null) { - return PlaceNew(block, position, rotation, color, material, uscale, scale, isFlipped, autoWire, player); + return PlaceNew(block, position, autoWire, player); } /// @@ -73,15 +71,13 @@ namespace GamecraftModdingAPI /// Whether the block should be auto-wired (if functional) /// The player who placed the block /// The placed block or null if failed - public static T PlaceNew(BlockIDs block, float3 position, - float3 rotation = default, BlockColor? color = null, BlockMaterial material = BlockMaterial.Default, - int uscale = 1, float3 scale = default, bool isFlipped = false, bool autoWire = false, Player player = null) + public static T PlaceNew(BlockIDs block, float3 position, bool autoWire = false, Player player = null) where T : Block { if (PlacementEngine.IsInGame && GameState.IsBuildMode()) { - var egid = PlacementEngine.PlaceBlock(block, color ?? BlockColors.Default, material, - position, uscale, scale, player, rotation, isFlipped, autoWire, out var initializer); + var initializer = PlacementEngine.PlaceBlock(block, position, player, autoWire); + var egid = initializer.EGID; var bl = New(egid.entityID, egid.groupID); bl.InitData.Group = BlockEngine.InitGroup(initializer); Placed += bl.OnPlacedInit; @@ -232,6 +228,23 @@ namespace GamecraftModdingAPI Id = BlockEngine.FindBlockEGID(id) ?? throw new BlockTypeException("Could not find the appropriate group for the block. The block probably doesn't exist or hasn't been submitted."); } + /// + /// Places a new block in the world. + /// + /// The block's type + /// The block's position (a block is 0.2 wide in terms of position) + /// Whether the block should be auto-wired (if functional) + /// The player who placed the block + public Block(BlockIDs type, float3 position, bool autoWire = false, Player player = null) + { + if (!PlacementEngine.IsInGame || !GameState.IsBuildMode()) + throw new BlockException("Blocks can only be placed in build mode."); + var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire); + Id = initializer.EGID; + InitData.Group = BlockEngine.InitGroup(initializer); + Placed += OnPlacedInit; + } + public EGID Id { get; } internal BlockEngine.BlockInitData InitData; @@ -277,6 +290,10 @@ namespace GamecraftModdingAPI get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale); set { + int uscale = UniformScale; + if (value.x < 4e-5) value.x = uscale; + if (value.y < 4e-5) value.y = uscale; + if (value.z < 4e-5) value.z = uscale; BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, float3 val) => st.scale = val, value); if (!Exists) return; //UpdateCollision needs the block to exist ScalingEngine.UpdateCollision(Id); @@ -293,6 +310,7 @@ namespace GamecraftModdingAPI get => BlockEngine.GetBlockInfo(this, (UniformBlockScaleEntityStruct st) => st.scaleFactor); set { + if (value < 1) value = 1; BlockEngine.SetBlockInfo(this, (ref UniformBlockScaleEntityStruct st, int val) => st.scaleFactor = val, value); Scale = new float3(value, value, value); @@ -300,7 +318,7 @@ namespace GamecraftModdingAPI } /** - * Whether the block is fipped. + * Whether the block is flipped. */ public bool Flipped { @@ -342,7 +360,7 @@ namespace GamecraftModdingAPI set { BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, BlockColor val) => - { + { //TODO: Check if setting to 255 works color.indexInPalette = val.Index; color.hasNetworkChange = true; color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); @@ -366,9 +384,12 @@ namespace GamecraftModdingAPI } } + /** + * The block's material. + */ public BlockMaterial Material { - get => BlockEngine.GetBlockInfo(this, (CubeMaterialStruct cmst) => (BlockMaterial) cmst.materialId); + get => BlockEngine.GetBlockInfo(this, (CubeMaterialStruct cmst) => (BlockMaterial) cmst.materialId, BlockMaterial.Default); set => BlockEngine.SetBlockInfo(this, (ref CubeMaterialStruct cmst, BlockMaterial val) => cmst.materialId = (byte) val, value); } @@ -460,7 +481,12 @@ namespace GamecraftModdingAPI /// public T Copy() where T : Block { - var block = PlaceNew(Type, Position, Rotation, Color, Material, UniformScale, Scale); + var block = PlaceNew(Type, Position); + block.Rotation = Rotation; + block.Color = Color; + block.Material = Material; + block.UniformScale = UniformScale; + block.Scale = Scale; block.copiedFrom = Id; return block; } diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index cbc49e2..1d01ae8 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -41,64 +41,27 @@ namespace GamecraftModdingAPI.Blocks public EntitiesDB entitiesDB { get; set; } private static BlockEntityFactory _blockEntityFactory; //Injected from PlaceSingleBlockEngine - public EGID PlaceBlock(BlockIDs block, BlockColor color, BlockMaterial materialId, float3 position, int uscale, - float3 scale, Player player, float3 rotation, bool isFlipped, bool autoWire, out EntityInitializer initializer) + public EntityInitializer PlaceBlock(BlockIDs block, float3 position, Player player, bool autoWire) { //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one - if (color.Darkness > 9) - throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)"); - initializer = BuildBlock((ushort) block, color.Index, (byte) materialId, position, uscale, scale, rotation, - isFlipped, autoWire, (player ?? new Player(PlayerType.Local)).Id); - return initializer.EGID; + return BuildBlock((ushort) block, position, autoWire, (player ?? Player.LocalPlayer).Id); } - private EntityInitializer BuildBlock(ushort block, byte color, byte materialId, float3 position, int uscale, float3 scale, float3 rot, bool isFlipped, bool autoWire, uint playerId) + private EntityInitializer BuildBlock(ushort block, float3 position, bool autoWire, uint playerId) { if (_blockEntityFactory == null) throw new BlockException("The factory is null."); - if (uscale < 1) - throw new BlockException("Scale needs to be at least 1"); - if (scale.x < 4e-5) scale.x = uscale; - if (scale.y < 4e-5) scale.y = uscale; - if (scale.z < 4e-5) scale.z = uscale; uint resourceId = (uint) PrefabsID.GenerateResourceID(0, block); if (!PrefabsID.PrefabIDByResourceIDMap.ContainsKey(resourceId)) throw new BlockException("Block with ID " + block + " not found!"); //RobocraftX.CR.MachineEditing.PlaceSingleBlockEngine - ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale * (isFlipped ? -1 : 1)}; - Quaternion rotQ = Quaternion.Euler(rot); - RotationEntityStruct rotation = new RotationEntityStruct {rotation = rotQ}; - GridRotationStruct gridRotation = new GridRotationStruct - {position = position, rotation = rotQ}; DBEntityStruct dbEntity = new DBEntityStruct {DBID = block}; - BlockPlacementScaleEntityStruct placementScale = new BlockPlacementScaleEntityStruct - { - blockPlacementHeight = uscale, blockPlacementWidth = uscale, desiredScaleFactor = uscale - }; EntityInitializer structInitializer = _blockEntityFactory.Build(CommonExclusiveGroups.nextBlockEntityID, block); //The ghost block index is only used for triggers - if (color != byte.MaxValue) - structInitializer.Init(new ColourParameterEntityStruct - { - indexInPalette = color, - hasNetworkChange = true - }); - if (materialId != byte.MaxValue) - structInitializer.Init(new CubeMaterialStruct - { - materialId = materialId - }); - uint prefabId = PrefabsID.GetOrCreatePrefabID(block, materialId, 0, isFlipped); + uint prefabId = PrefabsID.GetOrCreatePrefabID(block, (byte) BlockMaterial.SteelBodywork, 0, false); structInitializer.Init(new GFXPrefabEntityStructGPUI(prefabId)); structInitializer.Init(new PhysicsPrefabEntityStruct(prefabId)); structInitializer.Init(dbEntity); structInitializer.Init(new PositionEntityStruct {position = position}); - structInitializer.Init(rotation); - structInitializer.Init(scaling); - structInitializer.Init(gridRotation); - structInitializer.Init(new UniformBlockScaleEntityStruct - { - scaleFactor = placementScale.desiredScaleFactor - }); structInitializer.Init(new BlockPlacementInfoStruct() { loadedFromDisk = false, @@ -106,20 +69,19 @@ namespace GamecraftModdingAPI.Blocks triggerAutoWiring = autoWire && structInitializer.Has() }); - /*structInitializer.Init(new CollisionFilterOverride + foreach (var group in CharacterExclusiveGroups.AllCharacters) { - belongsTo = 32U, - collidesWith = 239532U - });*/ - - EGID playerEGID = new EGID(playerId, CharacterExclusiveGroups.OnFootGroup); - ref PickedBlockExtraDataStruct pickedBlock = ref entitiesDB.QueryEntity(playerEGID); - pickedBlock.placedBlockEntityID = structInitializer.EGID; - pickedBlock.placedBlockWasAPickedBlock = false; + EGID playerEGID = new EGID(playerId, group); + if (!entitiesDB.TryQueryEntitiesAndIndex(playerEGID, out uint index, + out var array)) continue; + ref PickedBlockExtraDataStruct pickedBlock = ref array[index]; + pickedBlock.placedBlockEntityID = structInitializer.EGID; + pickedBlock.placedBlockWasAPickedBlock = false; + } return structInitializer; } - public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine"; + public string Name => "GamecraftModdingAPIPlacementGameEngine"; public bool isRemovable => false; diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 92b1d7a..973cd4a 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -294,14 +294,13 @@ namespace GamecraftModdingAPI.Tests .Action((float x, float y, float z) => { var pos = new float3(x, y, z); - var group = BlockGroup.Create(Block.PlaceNew(BlockIDs.Cube, pos, - color: BlockColors.Aqua)); - Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Blue) - .BlockGroup = group; - Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Green) - .BlockGroup = group; - Block.PlaceNew(BlockIDs.Cube, pos += new float3(1, 0, 0), color: BlockColors.Lime) - .BlockGroup = group; + var group = BlockGroup.Create(new Block(BlockIDs.Cube, pos) {Color = BlockColors.Aqua}); + new Block(BlockIDs.Cube, pos += new float3(1, 0, 0)) + {Color = BlockColors.Blue, BlockGroup = group}; + new Block(BlockIDs.Cube, pos += new float3(1, 0, 0)) + {Color = BlockColors.Green, BlockGroup = group}; + new Block(BlockIDs.Cube, pos + new float3(1, 0, 0)) + {Color = BlockColors.Lime, BlockGroup = group}; }).Build(); CommandBuilder.Builder("placeCustomBlock", "Places a custom block, needs a custom catalog and assets.") From cc4850a0730821d031528fbf675867c532793d2b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 20 Apr 2021 01:23:39 +0200 Subject: [PATCH 38/98] Fix fake input --- GamecraftModdingAPI/Input/FakeInput.cs | 58 ++++++++++++------- GamecraftModdingAPI/Input/FakeInputEngine.cs | 45 +++++++++++--- .../Tests/GamecraftModdingAPIPluginTest.cs | 7 ++- 3 files changed, 78 insertions(+), 32 deletions(-) diff --git a/GamecraftModdingAPI/Input/FakeInput.cs b/GamecraftModdingAPI/Input/FakeInput.cs index 1d5564d..031a841 100644 --- a/GamecraftModdingAPI/Input/FakeInput.cs +++ b/GamecraftModdingAPI/Input/FakeInput.cs @@ -12,27 +12,41 @@ namespace GamecraftModdingAPI.Input { private static readonly FakeInputEngine inputEngine = new FakeInputEngine(); - /// - /// Customize the player input. - /// - /// The custom input. - /// The player. Omit this to use the local player. - public static void CustomInput(LocalInputEntityStruct input, uint playerID = uint.MaxValue) + /// + /// Customize the local input. + /// + /// The custom input. + public static void CustomInput(LocalInputEntityStruct input) { - if (playerID == uint.MaxValue) - { - playerID = inputEngine.GetLocalPlayerID(); - } - inputEngine.SendCustomInput(input, playerID); + inputEngine.SendCustomInput(input); } - public static LocalInputEntityStruct GetInput(uint playerID = uint.MaxValue) + /// + /// Customize the player input. + /// + /// The custom input. + /// The player. Omit this to use the local player. + public static void CustomPlayerInput(LocalPlayerInputEntityStruct input, uint playerID = uint.MaxValue) { if (playerID == uint.MaxValue) - { - playerID = inputEngine.GetLocalPlayerID(); - } - return inputEngine.GetInput(playerID); + { + playerID = inputEngine.GetLocalPlayerID(); + } + inputEngine.SendCustomPlayerInput(input, playerID); + } + + public static LocalInputEntityStruct GetInput() + { + return inputEngine.GetInput(); + } + + public static LocalPlayerInputEntityStruct GetPlayerInput(uint playerID = uint.MaxValue) + { + if (playerID == uint.MaxValue) + { + playerID = inputEngine.GetLocalPlayerID(); + } + return inputEngine.GetPlayerInput(playerID); } /// @@ -59,7 +73,7 @@ namespace GamecraftModdingAPI.Input { playerID = inputEngine.GetLocalPlayerID(); } - ref LocalInputEntityStruct currentInput = ref inputEngine.GetInputRef(playerID); + ref LocalInputEntityStruct currentInput = ref inputEngine.GetInputRef(); //Utility.Logging.CommandLog($"Current sim frame {currentInput.frame}"); // set inputs switch(hotbar) @@ -107,10 +121,10 @@ namespace GamecraftModdingAPI.Input { playerID = inputEngine.GetLocalPlayerID(); } - ref LocalInputEntityStruct currentInput = ref inputEngine.GetInputRef(playerID); - //Utility.Logging.CommandLog($"Current sim frame {currentInput.frame}"); - // set inputs - TODO - /*if (toggleMode) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleTimeRunningMode; + ref LocalPlayerInputEntityStruct currentInput = ref inputEngine.GetPlayerInputRef(playerID); + //Utility.Logging.CommandLog($"Current sim frame {currentInput.frame}"); + // set inputs + if (toggleMode) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.ToggleTimeRunningMode; if (forward) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Forward; if (backward) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Backward; if (up) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.Up; @@ -134,7 +148,7 @@ namespace GamecraftModdingAPI.Input if (rotateBlockCounterclockwise) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.RotateBlockAnticlockwise; if (cutSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.CutSelection; if (copySelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.CopySelection; - if (deleteSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.DeleteSelection;*/ + if (deleteSelection) currentInput.actionMask |= RobocraftX.Common.Input.ActionInput.DeleteSelection; } public static void Init() diff --git a/GamecraftModdingAPI/Input/FakeInputEngine.cs b/GamecraftModdingAPI/Input/FakeInputEngine.cs index 11d5f3a..9b85c97 100644 --- a/GamecraftModdingAPI/Input/FakeInputEngine.cs +++ b/GamecraftModdingAPI/Input/FakeInputEngine.cs @@ -1,5 +1,6 @@ using System; +using RobocraftX.Common; using RobocraftX.Common.Input; using RobocraftX.Players; using Svelto.ECS; @@ -29,9 +30,9 @@ namespace GamecraftModdingAPI.Input IsReady = true; } - public bool SendCustomInput(LocalInputEntityStruct input, uint playerID, bool remote = false) + public bool SendCustomInput(LocalInputEntityStruct input) { - EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers); + EGID egid = CommonExclusiveGroups.GameStateEGID; if (entitiesDB.Exists(egid)) { ref LocalInputEntityStruct ies = ref entitiesDB.QueryEntity(egid); @@ -41,22 +42,50 @@ namespace GamecraftModdingAPI.Input else return false; } - public LocalInputEntityStruct GetInput(uint playerID, bool remote = false) + public bool SendCustomPlayerInput(LocalPlayerInputEntityStruct input, uint playerID, bool remote = false) { EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers); - if (entitiesDB.Exists(egid)) + if (entitiesDB.Exists(egid)) { - return entitiesDB.QueryEntity(egid); + ref LocalPlayerInputEntityStruct ies = ref entitiesDB.QueryEntity(egid); + ies = input; + return true; } - else return default(LocalInputEntityStruct); + else return false; } - public ref LocalInputEntityStruct GetInputRef(uint playerID, bool remote = false) + public LocalInputEntityStruct GetInput() { - EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers); + EGID egid = CommonExclusiveGroups.GameStateEGID; + if (entitiesDB.Exists(egid)) + { + return entitiesDB.QueryEntity(egid); + } + else return default(LocalInputEntityStruct); + } + + public LocalPlayerInputEntityStruct GetPlayerInput(uint playerID, bool remote = false) + { + EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers); + if (entitiesDB.Exists(egid)) + { + return entitiesDB.QueryEntity(egid); + } + else return default; + } + + public ref LocalInputEntityStruct GetInputRef() + { + EGID egid = CommonExclusiveGroups.GameStateEGID; return ref entitiesDB.QueryEntity(egid); } + public ref LocalPlayerInputEntityStruct GetPlayerInputRef(uint playerID, bool remote = false) + { + EGID egid = new EGID(playerID, remote ? InputExclusiveGroups.RemotePlayers : InputExclusiveGroups.LocalPlayers); + return ref entitiesDB.QueryEntity(egid); + } + public uint GetLocalPlayerID() { return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB); diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 973cd4a..126fd7d 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -472,8 +472,11 @@ namespace GamecraftModdingAPI.Tests public override void OnUpdate() { - if(UnityEngine.Input.GetKeyDown(KeyCode.Backslash)) - FakeInput.CustomInput(new LocalInputEntityStruct{commandLineToggleInput = true}); + if (UnityEngine.Input.GetKeyDown(KeyCode.End)) + { + Console.WriteLine("Pressed button to toggle console"); + FakeInput.CustomInput(new LocalInputEntityStruct {commandLineToggleInput = true}); + } } [HarmonyPatch] From 6a2459b3e79600c2e40594cab080b665bef9d6a2 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 24 Apr 2021 03:41:37 +0200 Subject: [PATCH 39/98] Attempts to bring console commands back (test) --- .../Tests/GamecraftModdingAPIPluginTest.cs | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 126fd7d..218e310 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -29,8 +29,15 @@ using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Input; using GamecraftModdingAPI.Interface.IMGUI; using GamecraftModdingAPI.Players; +using GamecraftModdingAPI.Tasks; using RobocraftX.Common.Input; +using RobocraftX.CR.MainGame; +using RobocraftX.GUI.CommandLine; +using RobocraftX.Multiplayer; +using RobocraftX.StateSync; +using Svelto.Context; using Svelto.DataStructures; +using Svelto.Services; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.ResourceManagement.AsyncOperations; @@ -493,6 +500,114 @@ namespace GamecraftModdingAPI.Tests } } + [HarmonyPatch] + public static class MainGamePatch + { + public static void Postfix(Transform mainGameTransform) + { + //CommandLineCompositionRoot.Init(mainGameTransform).RunOn(Scheduler.extraLeanRunner); - uREPL C# compilation not supported anymore + } + + public static MethodInfo TargetMethod() + { + return AccessTools.Method(typeof(MainGameCompositionRoot), "Init"); + } + } + + [HarmonyPatch] + public static class MainGamePatch2 + { + public static void Postfix(UnityContext contextHolder, + Action reloadGame, MultiplayerInitParameters multiplayerParameters, + StateSyncRegistrationHelper stateSyncReg) + { + /*CommandLineCompositionRoot.Compose(contextHolder, stateSyncReg.enginesRoot, reloadGame, multiplayerParameters, + stateSyncReg); - uREPL C# compilation not supported anymore */ + var enginesRoot = stateSyncReg.enginesRoot; + var entityFunctions = enginesRoot.GenerateEntityFunctions(); + var entityFactory = enginesRoot.GenerateEntityFactory(); + var entitySerializer = enginesRoot.GenerateEntitySerializer(); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetGravityCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsPrecisionCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsFrequencyCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteClearAllPartsCommandEngine"), + entityFunctions)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteHelpCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteSetLinearRestingThresholdCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteSetAngularRestingThresholdCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteEnableVisualProfilerCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetNetworkJitterFramesEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetSendConnectedEntitiesCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetMaxSimFramesEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetDebugDisplayExtraInfoCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetNetSyncBandwidthLimitCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ThrowExceptionCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetPriorityCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterCommandEngine"), + entityFactory)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTextBlockTextCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCharacterRunSpeedCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCameraZoomDistanceCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditLightingSettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditSkySettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditFogSettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterImplementationEngine"), + entityFunctions)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteConnectToServerCommandEngine"), + entityFunctions, entitySerializer, reloadGame, multiplayerParameters)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetInputBroadcastCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetJointInertiaTensorCommandEngine"))); + enginesRoot.AddEngine( + (IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineInputEngine"))); + stateSyncReg.AddDeterministicEngine( + (IDeterministicEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteCommandEngine"))); + enginesRoot.AddEngine( + (IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTeamCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DamageCharacterCommandEngine"), entityFactory)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DisableCharacterDamageCommandEngine"))); + } + + public static MethodInfo TargetMethod() + { + return AccessTools.Method(typeof(MainGameCompositionRoot), "DeterministicCompose") + .MakeGenericMethod(typeof(UnityContext)); + } + } + [CustomBlock("customCatalog.json", "Assets/Prefabs/Cube.prefab", "strAluminiumCube", SortIndex = 12)] public class TestBlock : CustomBlock { From eb7a09ed2226a231ded572b57386e795e20ad8eb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 25 Apr 2021 02:06:47 +0200 Subject: [PATCH 40/98] Fixes, move command patch out of the test class Removed some command line engines that shouldn't be registered Fixed registering custom commands - registering it with the existing ones --- GamecraftModdingAPI/Commands/CommandPatch.cs | 103 ++++++++++++++--- .../Tests/GamecraftModdingAPIPluginTest.cs | 108 ------------------ 2 files changed, 85 insertions(+), 126 deletions(-) diff --git a/GamecraftModdingAPI/Commands/CommandPatch.cs b/GamecraftModdingAPI/Commands/CommandPatch.cs index ab90e6e..bf9f186 100644 --- a/GamecraftModdingAPI/Commands/CommandPatch.cs +++ b/GamecraftModdingAPI/Commands/CommandPatch.cs @@ -1,38 +1,105 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System; using System.Reflection; using HarmonyLib; using Svelto.Context; using Svelto.ECS; -using RobocraftX; - -using GamecraftModdingAPI.Utility; +using RobocraftX.CR.MainGame; +using RobocraftX.Multiplayer; +using RobocraftX.StateSync; namespace GamecraftModdingAPI.Commands { /// - /// Patch of RobocraftX.GUI.CommandLine.CommandLineCompositionRoot.Compose() + /// Patch of RobocraftX.CR.MainGame.MainGameCompositionRoot.DeterministicCompose() + /// Initializes existing and custom commands /// - // TODO: fix [HarmonyPatch] - //[HarmonyPatch(typeof(RobocraftX.GUI.CommandLine.CommandLineCompositionRoot))] - //[HarmonyPatch("Compose")] - //[HarmonyPatch("Compose", new Type[] { typeof(UnityContext), typeof(EnginesRoot), typeof(World), typeof(Action), typeof(MultiplayerInitParameters), typeof(StateSyncRegistrationHelper)})] static class CommandPatch { - public static void Postfix(EnginesRoot enginesRoot) + public static void Postfix(Action reloadGame, MultiplayerInitParameters multiplayerParameters, + StateSyncRegistrationHelper stateSyncReg) { - // When a game is loaded, register the command engines + /*CommandLineCompositionRoot.Compose(contextHolder, stateSyncReg.enginesRoot, reloadGame, multiplayerParameters, + stateSyncReg); - uREPL C# compilation not supported anymore */ + var enginesRoot = stateSyncReg.enginesRoot; + var entityFunctions = enginesRoot.GenerateEntityFunctions(); + var entityFactory = enginesRoot.GenerateEntityFactory(); + var entitySerializer = enginesRoot.GenerateEntitySerializer(); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetGravityCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsPrecisionCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsFrequencyCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteClearAllPartsCommandEngine"), + entityFunctions)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteHelpCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteSetLinearRestingThresholdCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName( + "RobocraftX.GUI.CommandLine.ExecuteSetAngularRestingThresholdCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteEnableVisualProfilerCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetNetworkJitterFramesEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetSendConnectedEntitiesCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetMaxSimFramesEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetDebugDisplayExtraInfoCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetNetSyncBandwidthLimitCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ThrowExceptionCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetPriorityCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterCommandEngine"), + entityFactory)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTextBlockTextCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCharacterRunSpeedCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCameraZoomDistanceCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditLightingSettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditSkySettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditFogSettingsCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterImplementationEngine"), + entityFunctions)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteConnectToServerCommandEngine"), + entityFunctions, entitySerializer, reloadGame, multiplayerParameters)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetInputBroadcastCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetJointInertiaTensorCommandEngine"))); + enginesRoot.AddEngine( + (IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTeamCommandEngine"))); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DamageCharacterCommandEngine"), entityFactory)); + enginesRoot.AddEngine((IEngine) Activator.CreateInstance( + AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DisableCharacterDamageCommandEngine"))); + CommandManager.RegisterEngines(enginesRoot); } - public static MethodBase TargetMethod(Harmony instance) + public static MethodInfo TargetMethod() { - return typeof(RobocraftX.GUI.CommandLine.CommandLineCompositionRoot).GetMethod("Compose").MakeGenericMethod(typeof(object)); - //return func.Method; + return AccessTools.Method(typeof(MainGameCompositionRoot), "DeterministicCompose") + .MakeGenericMethod(typeof(UnityContext)); } } -} +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 218e310..75079a8 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -500,114 +500,6 @@ namespace GamecraftModdingAPI.Tests } } - [HarmonyPatch] - public static class MainGamePatch - { - public static void Postfix(Transform mainGameTransform) - { - //CommandLineCompositionRoot.Init(mainGameTransform).RunOn(Scheduler.extraLeanRunner); - uREPL C# compilation not supported anymore - } - - public static MethodInfo TargetMethod() - { - return AccessTools.Method(typeof(MainGameCompositionRoot), "Init"); - } - } - - [HarmonyPatch] - public static class MainGamePatch2 - { - public static void Postfix(UnityContext contextHolder, - Action reloadGame, MultiplayerInitParameters multiplayerParameters, - StateSyncRegistrationHelper stateSyncReg) - { - /*CommandLineCompositionRoot.Compose(contextHolder, stateSyncReg.enginesRoot, reloadGame, multiplayerParameters, - stateSyncReg); - uREPL C# compilation not supported anymore */ - var enginesRoot = stateSyncReg.enginesRoot; - var entityFunctions = enginesRoot.GenerateEntityFunctions(); - var entityFactory = enginesRoot.GenerateEntityFactory(); - var entitySerializer = enginesRoot.GenerateEntitySerializer(); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetGravityCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsPrecisionCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsFrequencyCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteClearAllPartsCommandEngine"), - entityFunctions)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteHelpCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteSetLinearRestingThresholdCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteSetAngularRestingThresholdCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteEnableVisualProfilerCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetNetworkJitterFramesEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetSendConnectedEntitiesCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetMaxSimFramesEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetDebugDisplayExtraInfoCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetNetSyncBandwidthLimitCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ThrowExceptionCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetPriorityCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterCommandEngine"), - entityFactory)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTextBlockTextCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCharacterRunSpeedCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCameraZoomDistanceCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditLightingSettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditSkySettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditFogSettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterImplementationEngine"), - entityFunctions)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteConnectToServerCommandEngine"), - entityFunctions, entitySerializer, reloadGame, multiplayerParameters)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetInputBroadcastCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetJointInertiaTensorCommandEngine"))); - enginesRoot.AddEngine( - (IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineInputEngine"))); - stateSyncReg.AddDeterministicEngine( - (IDeterministicEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteCommandEngine"))); - enginesRoot.AddEngine( - (IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTeamCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DamageCharacterCommandEngine"), entityFactory)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DisableCharacterDamageCommandEngine"))); - } - - public static MethodInfo TargetMethod() - { - return AccessTools.Method(typeof(MainGameCompositionRoot), "DeterministicCompose") - .MakeGenericMethod(typeof(UnityContext)); - } - } - [CustomBlock("customCatalog.json", "Assets/Prefabs/Cube.prefab", "strAluminiumCube", SortIndex = 12)] public class TestBlock : CustomBlock { From 55b38f1678c9df281b8a913f3f424b5d54fd94a7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Apr 2021 03:12:22 +0200 Subject: [PATCH 41/98] Start working on FlyCam and create an overcomplicated struct Just some native code that's totally unnecessary --- GamecraftModdingAPI/FlyCam.cs | 26 ++++++ GamecraftModdingAPI/OptionalRef.cs | 99 +++++++++++++++++++++ GamecraftModdingAPI/Players/FlyCamEngine.cs | 28 ++++++ 3 files changed, 153 insertions(+) create mode 100644 GamecraftModdingAPI/FlyCam.cs create mode 100644 GamecraftModdingAPI/OptionalRef.cs create mode 100644 GamecraftModdingAPI/Players/FlyCamEngine.cs diff --git a/GamecraftModdingAPI/FlyCam.cs b/GamecraftModdingAPI/FlyCam.cs new file mode 100644 index 0000000..15a6aa5 --- /dev/null +++ b/GamecraftModdingAPI/FlyCam.cs @@ -0,0 +1,26 @@ +using GamecraftModdingAPI.Players; +using Svelto.ECS.EntityStructs; +using Unity.Mathematics; + +namespace GamecraftModdingAPI +{ + public class FlyCam + { + private static FlyCamEngine Engine; + + public uint Id { get; } + + public FlyCam(uint id) => Id = id; + + public unsafe float3 Position + { + get => Engine.GetComponent(Id).Map(pos => &pos->position); + set => Engine.GetComponent(Id).Map(pos => &pos->position).Set(value); + } + + public static void Init() + { + Engine = new FlyCamEngine(); + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/OptionalRef.cs b/GamecraftModdingAPI/OptionalRef.cs new file mode 100644 index 0000000..a1b09cd --- /dev/null +++ b/GamecraftModdingAPI/OptionalRef.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using GamecraftModdingAPI.Blocks; +using Svelto.DataStructures; +using Svelto.ECS; + +namespace GamecraftModdingAPI +{ + public struct OptionalRef where T : unmanaged + { + private bool exists; + private NB array; + private uint index; + + private unsafe T* pointer; + + public OptionalRef(NB array, uint index) + { + exists = true; + this.array = array; + this.index = index; + unsafe + { + pointer = null; + } + } + + public OptionalRef(ref T value) + { + unsafe + { + fixed(T* p = &value) pointer = p; + } + + exists = true; + array = default; + index = default; + } + + public ref T Get() + { + unsafe + { + if (pointer != null && exists) + return ref *pointer; + } + + if (exists) + return ref array[index]; + throw new InvalidOperationException("Calling Get() on an empty OptionalRef"); + } + + public T Value + { + get + { + unsafe + { + if (pointer != null && exists) + return *pointer; + } + + if (exists) + return array[index]; + return default; + } + } + + public unsafe void Set(T value) //Can't use properties because it complains that you can't set struct members + { + if (pointer != null && exists) + *pointer = value; + } + + public bool Exists => exists; + + public static implicit operator T(OptionalRef opt) => opt.Value; + + public static implicit operator bool(OptionalRef opt) => opt.exists; + + public delegate ref TR Mapper(ref T component) where TR : unmanaged; + public unsafe delegate TR* PMapper(T* component) where TR : unmanaged; + + /*public OptionalRef Map(Mapper mapper) where TR : unmanaged => + exists ? new OptionalRef(ref mapper(ref Get())) : new OptionalRef();*/ + + /*public OptionalRef Map(Expression> expression) where TR : unmanaged + { + if (expression.Body.NodeType == ExpressionType.MemberAccess) + Console.WriteLine(((MemberExpression) expression.Body).Member); + }*/ + + public unsafe OptionalRef Map(PMapper mapper) where TR : unmanaged => + exists ? new OptionalRef(ref *mapper(pointer)) : new OptionalRef(); + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/Players/FlyCamEngine.cs b/GamecraftModdingAPI/Players/FlyCamEngine.cs new file mode 100644 index 0000000..b8f8cf4 --- /dev/null +++ b/GamecraftModdingAPI/Players/FlyCamEngine.cs @@ -0,0 +1,28 @@ +using GamecraftModdingAPI.Engines; +using Svelto.ECS; +using Techblox.FlyCam; + +namespace GamecraftModdingAPI.Players +{ + public class FlyCamEngine : IApiEngine + { + public void Ready() + { + } + + public EntitiesDB entitiesDB { get; set; } + public void Dispose() + { + } + + public string Name => "TechbloxModdingAPIFlyCamEngine"; + public bool isRemovable => false; + + public OptionalRef GetComponent(uint id) where T : unmanaged, IEntityComponent + { + if (entitiesDB.TryQueryEntitiesAndIndex(id, Techblox.FlyCam.FlyCam.Group, out uint index, out var array)) + return new OptionalRef(array, index); + return new OptionalRef(); + } + } +} \ No newline at end of file From 6e03847ab0764dab84b413177147dd7d5c684767 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 27 Apr 2021 01:52:54 +0200 Subject: [PATCH 42/98] FlyCam additions, improve struct Added property to get the camera from the player Removed pointer magic --- GamecraftModdingAPI/FlyCam.cs | 103 ++++++++++++++++++++- GamecraftModdingAPI/OptionalRef.cs | 99 -------------------- GamecraftModdingAPI/Player.cs | 5 + GamecraftModdingAPI/Utility/OptionalRef.cs | 60 ++++++++++++ 4 files changed, 163 insertions(+), 104 deletions(-) delete mode 100644 GamecraftModdingAPI/OptionalRef.cs create mode 100644 GamecraftModdingAPI/Utility/OptionalRef.cs diff --git a/GamecraftModdingAPI/FlyCam.cs b/GamecraftModdingAPI/FlyCam.cs index 15a6aa5..be9955f 100644 --- a/GamecraftModdingAPI/FlyCam.cs +++ b/GamecraftModdingAPI/FlyCam.cs @@ -1,26 +1,119 @@ using GamecraftModdingAPI.Players; +using GamecraftModdingAPI.Utility; + +using RobocraftX.Physics; using Svelto.ECS.EntityStructs; +using Techblox.FlyCam; using Unity.Mathematics; +using UnityEngine; namespace GamecraftModdingAPI { public class FlyCam { - private static FlyCamEngine Engine; + private static FlyCamEngine Engine = new FlyCamEngine(); public uint Id { get; } public FlyCam(uint id) => Id = id; - public unsafe float3 Position + /// + /// The local player's camera. + /// + public static FlyCam LocalCamera => new FlyCam(Player.LocalPlayer.Id); + + /// + /// The current position of the camera. + /// + public float3 Position { - get => Engine.GetComponent(Id).Map(pos => &pos->position); - set => Engine.GetComponent(Id).Map(pos => &pos->position).Set(value); + get => Engine.GetComponent(Id).Get().position; + set + { + Engine.GetComponent(Id).Get().position = value; + Engine.GetComponent(Id).Get().position = value; + } + } + + /// + /// The current rotation of the camera. + /// + public float3 Rotation + { + get => ((Quaternion) Engine.GetComponent(Id).Get().rotation).eulerAngles; + set + { + Engine.GetComponent(Id).Get().rotation = Quaternion.Euler(value); + Engine.GetComponent(Id).Get().rotation = Quaternion.Euler(value); + } + } + + /// + /// The current direction the camera is moving. + /// + public float3 MovementDirection + { + get => Engine.GetComponent(Id).Get().movementDirection; + set => Engine.GetComponent(Id).Get().movementDirection = value; + } + + /// + /// Whether the camera (player) is sprinting. + /// + public bool Sprinting + { + get => Engine.GetComponent(Id).Get().sprinting; + set => Engine.GetComponent(Id).Get().sprinting = value; + } + + /// + /// The speed setting of the camera. + /// + public float Speed + { + get => Engine.GetComponent(Id).Get().speed; + set => Engine.GetComponent(Id).Get().speed = value; + } + + /// + /// The multiplier setting to use when sprinting. + /// + public float SpeedSprintMultiplier + { + get => Engine.GetComponent(Id).Get().speedSprintMultiplier; + set => Engine.GetComponent(Id).Get().speedSprintMultiplier = value; + } + + /// + /// The acceleration setting of the camera. + /// + public float Acceleration + { + get => Engine.GetComponent(Id).Get().acceleration; + set => Engine.GetComponent(Id).Get().acceleration = value; + } + + /// + /// The current velocity of the camera. + /// + public float3 Velocity + { + get => Engine.GetComponent(Id).Get().velocity; + set => Engine.GetComponent(Id).Get().velocity = value; + } + + /// + /// The current angular velocity of the camera. + /// + public float3 AngularVelocity + { + get => Engine.GetComponent(Id).Get().angularVelocity; + set => Engine.GetComponent(Id).Get().angularVelocity = value; } public static void Init() { - Engine = new FlyCamEngine(); + GameEngineManager.AddGameEngine(Engine); } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/OptionalRef.cs b/GamecraftModdingAPI/OptionalRef.cs deleted file mode 100644 index a1b09cd..0000000 --- a/GamecraftModdingAPI/OptionalRef.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using GamecraftModdingAPI.Blocks; -using Svelto.DataStructures; -using Svelto.ECS; - -namespace GamecraftModdingAPI -{ - public struct OptionalRef where T : unmanaged - { - private bool exists; - private NB array; - private uint index; - - private unsafe T* pointer; - - public OptionalRef(NB array, uint index) - { - exists = true; - this.array = array; - this.index = index; - unsafe - { - pointer = null; - } - } - - public OptionalRef(ref T value) - { - unsafe - { - fixed(T* p = &value) pointer = p; - } - - exists = true; - array = default; - index = default; - } - - public ref T Get() - { - unsafe - { - if (pointer != null && exists) - return ref *pointer; - } - - if (exists) - return ref array[index]; - throw new InvalidOperationException("Calling Get() on an empty OptionalRef"); - } - - public T Value - { - get - { - unsafe - { - if (pointer != null && exists) - return *pointer; - } - - if (exists) - return array[index]; - return default; - } - } - - public unsafe void Set(T value) //Can't use properties because it complains that you can't set struct members - { - if (pointer != null && exists) - *pointer = value; - } - - public bool Exists => exists; - - public static implicit operator T(OptionalRef opt) => opt.Value; - - public static implicit operator bool(OptionalRef opt) => opt.exists; - - public delegate ref TR Mapper(ref T component) where TR : unmanaged; - public unsafe delegate TR* PMapper(T* component) where TR : unmanaged; - - /*public OptionalRef Map(Mapper mapper) where TR : unmanaged => - exists ? new OptionalRef(ref mapper(ref Get())) : new OptionalRef();*/ - - /*public OptionalRef Map(Expression> expression) where TR : unmanaged - { - if (expression.Body.NodeType == ExpressionType.MemberAccess) - Console.WriteLine(((MemberExpression) expression.Body).Member); - }*/ - - public unsafe OptionalRef Map(PMapper mapper) where TR : unmanaged => - exists ? new OptionalRef(ref *mapper(pointer)) : new OptionalRef(); - } -} \ No newline at end of file diff --git a/GamecraftModdingAPI/Player.cs b/GamecraftModdingAPI/Player.cs index 0bed6a2..8b204d0 100644 --- a/GamecraftModdingAPI/Player.cs +++ b/GamecraftModdingAPI/Player.cs @@ -414,6 +414,11 @@ namespace GamecraftModdingAPI return playerEngine.GetSelectedBlocks(Id); } + /// + /// The camera of this player used when building. + /// + public FlyCam BuildCamera => new FlyCam(Id); + public bool Equals(Player other) { if (ReferenceEquals(null, other)) return false; diff --git a/GamecraftModdingAPI/Utility/OptionalRef.cs b/GamecraftModdingAPI/Utility/OptionalRef.cs new file mode 100644 index 0000000..4ac293d --- /dev/null +++ b/GamecraftModdingAPI/Utility/OptionalRef.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using GamecraftModdingAPI.Blocks; +using Svelto.DataStructures; +using Svelto.ECS; + +namespace GamecraftModdingAPI +{ + public struct OptionalRef where T : unmanaged + { + private bool exists; + private NB array; + private uint index; + + public OptionalRef(NB array, uint index) + { + exists = true; + this.array = array; + this.index = index; + } + + public OptionalRef(ref T value) + { + exists = true; + array = default; + index = default; + } + + public ref T Get(T def = default) + { + if (exists) + return ref array[index]; + return ref CompRefCache._default; + } + + public bool Exists => exists; + + public static implicit operator T(OptionalRef opt) => opt.Get(); + + public static implicit operator bool(OptionalRef opt) => opt.exists; + + /*public delegate ref TR Mapper(ref T component) where TR : unmanaged; + public unsafe delegate TR* PMapper(T* component) where TR : unmanaged; + + public unsafe OptionalRef Map(PMapper mapper) where TR : unmanaged => + exists ? new OptionalRef(ref *mapper(pointer)) : new OptionalRef();*/ + + /// + /// Creates an instance of a struct T that can be referenced. + /// + /// The struct type to cache + private struct CompRefCache where T : unmanaged + { + public static T _default; + } + } +} \ No newline at end of file From df6a2e84e156a3dd12c483ecdc5a22a26bd7e46e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 30 Apr 2021 22:36:54 +0200 Subject: [PATCH 43/98] Update to Techblox 2021.04.29.18.37 --- GamecraftModdingAPI/Block.cs | 1 + GamecraftModdingAPI/Blocks/BlockEngine.cs | 6 +++--- GamecraftModdingAPI/Blocks/BlockEngineInit.cs | 1 + GamecraftModdingAPI/Blocks/CustomBlock.cs | 2 +- GamecraftModdingAPI/Blocks/MovementEngine.cs | 4 ++-- GamecraftModdingAPI/Blocks/RotationEngine.cs | 4 ++-- GamecraftModdingAPI/Blocks/SignalEngine.cs | 2 +- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 99574ff..e4c50cd 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -80,6 +80,7 @@ namespace GamecraftModdingAPI var egid = initializer.EGID; var bl = New(egid.entityID, egid.groupID); bl.InitData.Group = BlockEngine.InitGroup(initializer); + bl.InitData.Reference = initializer.reference; Placed += bl.OnPlacedInit; return bl; } diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 5eff5b2..e0291c0 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -104,7 +104,7 @@ namespace GamecraftModdingAPI.Blocks private U GetBlockInitInfo(Block block, Func getter, U def) where T : struct, IEntityComponent { if (block.InitData.Group == null) return def; - var initializer = new EntityInitializer(block.Id, block.InitData.Group); + var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); if (initializer.Has()) return getter(initializer.Get()); return def; @@ -133,7 +133,7 @@ namespace GamecraftModdingAPI.Blocks { if (block.InitData.Group != null) { - var initializer = new EntityInitializer(block.Id, block.InitData.Group); + var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); T component = initializer.Has() ? initializer.Get() : default; ref T structRef = ref component; setter(ref structRef, value); @@ -161,7 +161,7 @@ namespace GamecraftModdingAPI.Blocks return true; if (block.InitData.Group == null) return false; - var init = new EntityInitializer(block.Id, block.InitData.Group); + var init = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); return init.Has(); } diff --git a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs index aaed6ef..ac7f3c4 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngineInit.cs @@ -15,6 +15,7 @@ namespace GamecraftModdingAPI.Blocks internal struct BlockInitData { public FasterDictionary Group; + public EntityReference Reference; } internal delegate FasterDictionary GetInitGroup( diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index c979234..7c82fe1 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -131,7 +131,7 @@ namespace GamecraftModdingAPI.Blocks CubeNameKey = attr.NameKey, CubeDescriptionKey = attr.DescKey, SelectableFaces = new[] {0, 1, 2, 3, 4, 5}, - GridScale = new[] {5, 5, 5}, + GridScale = new[] {5f, 5, 5}, DefaultMaterialID = 0, //TODO: Material API scalingPermission = attr.ScalingPermission, SortIndex = attr.SortIndex, diff --git a/GamecraftModdingAPI/Blocks/MovementEngine.cs b/GamecraftModdingAPI/Blocks/MovementEngine.cs index 6a9b05e..87a7259 100644 --- a/GamecraftModdingAPI/Blocks/MovementEngine.cs +++ b/GamecraftModdingAPI/Blocks/MovementEngine.cs @@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group, data.Reference); init.GetOrCreate().position = vector; init.GetOrCreate().position = vector; init.GetOrCreate().position = vector; @@ -70,7 +70,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group, data.Reference); return init.Has() ? init.Get().position : float3.zero; } ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(blockID); diff --git a/GamecraftModdingAPI/Blocks/RotationEngine.cs b/GamecraftModdingAPI/Blocks/RotationEngine.cs index 3322b92..2d8d1db 100644 --- a/GamecraftModdingAPI/Blocks/RotationEngine.cs +++ b/GamecraftModdingAPI/Blocks/RotationEngine.cs @@ -40,7 +40,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group, data.Reference); init.GetOrCreate().rotation = Quaternion.Euler(vector); init.GetOrCreate().rotation = Quaternion.Euler(vector); init.GetOrCreate().rotation = Quaternion.Euler(vector); @@ -77,7 +77,7 @@ namespace GamecraftModdingAPI.Blocks if (!entitiesDB.Exists(blockID)) { if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group); + var init = new EntityInitializer(blockID, data.Group, data.Reference); return init.Has() ? (float3) ((Quaternion) init.Get().rotation).eulerAngles : float3.zero; diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs index 22865df..8329a3b 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs @@ -399,7 +399,7 @@ namespace GamecraftModdingAPI.Blocks exists = false; return ref defRef[0]; } - EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group); + EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); if (initializer.Has()) { exists = true; From 807470e289c2b13d2e3169d907261acf40d52e06 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 1 May 2021 00:38:27 +0200 Subject: [PATCH 44/98] Add new block types and improve listing them Now it prints them ordered and mostly suitable to be used in code (it only needs a couple replaces) --- GamecraftModdingAPI/Blocks/BlockIDs.cs | 121 +++++++--------------- GamecraftModdingAPI/Blocks/CustomBlock.cs | 9 +- 2 files changed, 47 insertions(+), 83 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index 07e4192..5c44f11 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -19,8 +19,8 @@ namespace GamecraftModdingAPI.Blocks NegativeQuarterPyramid, NegativeTetrahedron, RoundedNegativeQuarterPyramid, - RoundedNegativeTetrahedron, //10 - PlateCube, + RoundedNegativeTetrahedron, + Plate, PlateWedge, PlateQuarterPyramid, PlateTetrahedron, @@ -29,7 +29,7 @@ namespace GamecraftModdingAPI.Blocks FrameS1, FrameS2, FrameS3, - FrameS4, //20 + FrameS4, FrameS5, FrameWedge, FrameWedgeS1, @@ -39,7 +39,7 @@ namespace GamecraftModdingAPI.Blocks SideS0S1, SideS0S2, SideS0S3, - SideS0S4, //30 + SideS0S4, SideS0S5, SideS1S1, SideS1S2, @@ -51,7 +51,7 @@ namespace GamecraftModdingAPI.Blocks SideS2S3, SideS2S4, SideS2S5, - WindscreenS1, //42 + WindscreenS1, WindscreenS2, WindscreenS3, WindscreenS4, @@ -59,94 +59,53 @@ namespace GamecraftModdingAPI.Blocks CarWheelArch, CarArchSmallFlare, CarArchFlare, - CarArchExtrudedFlare, //50 - Cube1X1, - Cube1X2, - Cube1X3, - Cube1X4, - Cube1X6, - Cube2X2, - Cube2X3, - Cube2X4, - Cube2X6, - Wedge1X1, //60 - Wedge1X2, - Wedge1X3, - Wedge2X1, - Wedge2X2, - Wedge2X3, - RoundedWedge1X1, - RoundedWedge1X2, - RoundedWedge1X3, - RoundedWedge2X1, - RoundedWedge2X2, //70 - RoundedWedge2X3, - Plate1X1, - Plate1X2, - Plate1X3, - Plate1X4, - Plate2X2, - Plate2X3, - Plate2X4, - Plate3X3, - Plate3X4, //80 - Cube1X1S1, - Cube1X2S1, - Cube1X3S1, - Wedge1X1S1, - Wedge1X2S1, - Wedge1X3S1, - Wedge2X1S1, - Wedge2X2S1, - Wedge2X3S1, - Wedge3X1S1, //90 - Wedge3X2S1, - Wedge3X3S1, - NegativeTetrahedron1X1S1, - NegativeTetrahedron1X2S1, - NegativeTetrahedron1X3S1, - NegativeTetrahedron2X1S1, - NegativeTetrahedron2X2S1, - NegativeTetrahedron2X3S1, - NegativeTetrahedron3X1S1, - Axle, //100 + CarArchExtrudedFlare, + Axle = 100, Hinge, BallJoint, UniversalJoint, TelescopicJoint, - HingeSpring, - AxleSpring, + DampedHingeSpring, + DampedAxleSpring, DampedSpring, WheelRigNoSteering, WheelRigWithSteering, - NegativeTetrahedron3X2S1, //110 - NegativeTetrahedron3X3S1, - Tetrahedron1X1S1, - Tetrahedron1X2S1, - Tetrahedron1X3S1, - Tetrahedron2X1S1, - Tetrahedron2X2S1, - Tetrahedron2X3S1, - Tetrahedron3X1S1, - Tetrahedron3X2S1, - Tetrahedron3X3S1, //120 - QuarterPyramid1X1S1, - QuarterPyramid1X2S1, - QuarterPyramid1X3S1, - QuarterPyramid2X1S1, - QuarterPyramid2X2S1, - QuarterPyramid2X3S1, - QuarterPyramid3X1S1, - QuarterPyramid3X2S1, - QuarterPyramid3X3S1, - PlateTriangle, //130 + PlateTriangle = 130, PlateCircle, - PlateQtrCircle, + PlateQuarterCircle, PlateRWedge, PlateRTetrahedron, - DriverSeat = 150, + Cone, + ConeSegment, + DoubleSliced, + HalfDoubleSliced, + EighthPyramid, + Hemisphere, + WideCylinder, + WideCylinderBend, + WideCylinderT, + WideCylinderCross, + WideCylinderCorner, + NarrowCylinder, + NarrowCylinderBend, + NarrowCylinderT, + NarrowCylinderCross, + DriverSeat, PassengerSeat, Engine, + NarrowCylinderCorner, + PlateWideCylinder, + PlateNarrowCylinder, + PlateNegativeTetrahedron, + PlateNegativeQuarterPyramid, + PlateRoundedNegativeTetrahedron, + PlateRoundedNegativeQuarterPyramid, + HeadlampSquare, + HeadlampCircle, + HeadlampWedge, + WideCylinderDiagonal, + NarrowCylinderDiagonal, + HeadlampTetrahedron, CarWheelWideProfile = 200, CarWheel, } diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 7c82fe1..3567afd 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Reflection; using HarmonyLib; @@ -148,10 +149,14 @@ namespace GamecraftModdingAPI.Blocks foreach (var (id, action) in BlockChangeActions) action(dataDB.GetValue(id)); - /*foreach (var (key, value) in dataDB.GetValues()) + /*ushort lastKey = ushort.MaxValue; + foreach (var (key, value) in dataDB.GetValues() + .OrderBy(kv=>ushort.Parse(kv.Key))) { var data = (CubeListData) value; - Console.WriteLine($"ID: {key} - Name: {data.CubeNameKey}: {LocalizationService.Localize(data.CubeNameKey)}"); + ushort currentKey = ushort.Parse(key); + Console.WriteLine($"{LocalizationService.Localize(data.CubeNameKey)}{(currentKey != lastKey + 1 ? $" = {key}" : "")},"); + lastKey = currentKey; }*/ _canRegister = false; From a6f52070eef5d74e9e183268151b3b6a0e4706c5 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 2 May 2021 01:08:25 +0200 Subject: [PATCH 45/98] Rename to TechbloxModdingAPI --- GamecraftModdingAPI.sln | 2 +- .../App/AppCallbacksTest.cs | 4 +- .../App/AppEngine.cs | 7 ++-- .../App/AppExceptions.cs | 2 +- .../App/Client.cs | 11 +++--- .../App/ClientAlertTest.cs | 4 +- .../App/CurrentGameMode.cs | 2 +- .../App/Game.cs | 16 ++++---- .../App/GameBuildSimEventEngine.cs | 7 ++-- .../App/GameGameEngine.cs | 9 ++--- .../App/GameMenuEngine.cs | 7 ++-- .../App/StateSyncRegPatch.cs | 2 +- .../App/UserPrompts.cs | 2 +- .../Block.cs | 9 ++--- .../BlockGroup.cs | 7 ++-- .../Blocks/BlockCloneEngine.cs | 4 +- .../Blocks/BlockColor.cs | 2 +- .../Blocks/BlockEngine.cs | 5 +-- .../Blocks/BlockEngineInit.cs | 2 +- .../Blocks/BlockEventsEngine.cs | 7 ++-- .../Blocks/BlockExceptions.cs | 4 +- .../Blocks/BlockIDs.cs | 2 +- .../Blocks/BlockIdentifiers.cs | 2 +- .../Blocks/BlockMaterial.cs | 2 +- .../Blocks/BlockTests.cs | 20 +++++----- .../Blocks/BlueprintEngine.cs | 6 +-- .../Blocks/CustomBlock.cs | 5 +-- .../Blocks/CustomBlockAttribute.cs | 2 +- .../Blocks/CustomBlockEngine.cs | 8 ++-- .../Blocks/DampedSpring.cs | 2 +- .../Blocks/LogicGate.cs | 2 +- .../Blocks/Motor.cs | 4 +- .../Blocks/MovementEngine.cs | 7 ++-- .../Blocks/MusicBlock.cs | 8 ++-- .../Blocks/ObjectIdentifier.cs | 2 +- .../Blocks/Piston.cs | 4 +- .../Blocks/PlacementEngine.cs | 9 ++--- .../Blocks/RemovalEngine.cs | 7 ++-- .../Blocks/RotationEngine.cs | 7 ++-- .../Blocks/ScalingEngine.cs | 7 ++-- .../Blocks/Servo.cs | 4 +- .../Blocks/SfxBlock.cs | 2 +- .../Blocks/SignalEngine.cs | 5 +-- .../Blocks/SignalingBlock.cs | 6 +-- .../Blocks/SpawnPoint.cs | 6 +-- .../Blocks/TextBlock.cs | 6 +-- .../Blocks/Timer.cs | 6 +-- .../Blocks/Wire.cs | 4 +- .../Blueprint.cs | 2 +- .../Cluster.cs | 2 +- .../Commands/CommandBuilder.cs | 5 +-- .../Commands/CommandEngineFactory.cs | 2 +- .../Commands/CommandExceptions.cs | 2 +- .../Commands/CommandManager.cs | 5 +-- .../Commands/CommandPatch.cs | 2 +- .../Commands/CommandRegistrationHelper.cs | 2 +- .../Commands/ExistingCommands.cs | 2 +- .../Commands/ICustomCommandEngine.cs | 6 +-- .../Commands/SimpleCustomCommandEngine.cs | 9 ++--- .../Commands/SimpleCustomCommandEngine1.cs | 9 ++--- .../Commands/SimpleCustomCommandEngine2.cs | 9 ++--- .../Commands/SimpleCustomCommandEngine3.cs | 9 ++--- .../Engines/IApiEngine.cs | 4 +- .../Engines/IFactoryEngine.cs | 4 +- .../Engines/IReactionaryEngine.cs | 4 +- ...terministicStepComposeEngineGroupsPatch.cs | 4 +- .../Events/EmitterBuilder.cs | 2 +- .../Events/EventEngineFactory.cs | 2 +- .../Events/EventExceptions.cs | 2 +- .../Events/EventManager.cs | 7 ++-- .../Events/EventType.cs | 2 +- .../Events/GameActivatedComposePatch.cs | 5 +-- .../Events/GameReloadedPatch.cs | 4 +- .../Events/GameStateBuildEmitterEngine.cs | 5 +-- .../GameStateSimulationEmitterEngine.cs | 5 +-- .../Events/GameSwitchedToPatch.cs | 4 +- .../Events/HandlerBuilder.cs | 2 +- .../Events/IEventEmitterEngine.cs | 5 +-- .../Events/IEventHandlerEngine.cs | 5 +-- .../Events/MenuActivatedPatch.cs | 5 +-- .../Events/MenuSwitchedToPatch.cs | 5 +-- .../Events/ModEventEntityDescriptor.cs | 2 +- .../Events/ModEventEntityStruct.cs | 2 +- .../Events/SimpleEventEmitterEngine.cs | 4 +- .../Events/SimpleEventHandlerEngine.cs | 5 +-- .../FlyCam.cs | 7 ++-- .../GamecraftModdingAPIException.cs | 2 +- .../Input/FakeInput.cs | 5 +-- .../Input/FakeInputEngine.cs | 6 +-- .../Interface/IMGUI/Button.cs | 2 +- .../Interface/IMGUI/Constants.cs | 4 +- .../Interface/IMGUI/Group.cs | 6 +-- .../Interface/IMGUI/IMGUIManager.cs | 6 +-- .../Interface/IMGUI/Image.cs | 6 +-- .../Interface/IMGUI/Label.cs | 6 +-- .../Interface/IMGUI/Text.cs | 2 +- .../Interface/IMGUI/UIElement.cs | 2 +- .../Inventory/Hotbar.cs | 7 ++-- .../Inventory/HotbarEngine.cs | 8 ++-- .../HotbarSlotSelectionHandlerEnginePatch.cs | 4 +- .../Main.cs | 28 ++++++------- .../DeserializeFromDiskEntitiesEnginePatch.cs | 4 +- .../Persistence/IEntitySerializer.cs | 4 +- .../SaveAndLoadCompositionRootPatch.cs | 2 +- .../Persistence/SaveGameEnginePatch.cs | 7 ++-- .../Persistence/SerializerManager.cs | 5 +-- .../Persistence/SimpleEntitySerializer.cs | 2 +- .../Player.cs | 13 +++---- .../Players/FlyCamEngine.cs | 4 +- .../Players/PlayerBuildingMode.cs | 2 +- .../Players/PlayerEngine.cs | 5 +-- .../Players/PlayerExceptions.cs | 2 +- .../Players/PlayerTests.cs | 6 +-- .../Players/PlayerType.cs | 2 +- .../SimBody.cs | 2 +- .../Tasks/ISchedulable.cs | 2 +- .../Tasks/Once.cs | 2 +- .../Tasks/Repeatable.cs | 2 +- .../Tasks/Scheduler.cs | 2 +- .../TechbloxModdingAPI.csproj | 1 + .../Tests/APITestAttributes.cs | 2 +- .../Tests/Assert.cs | 2 +- .../Tests/GamecraftModdingAPIPluginTest.cs | 39 +++++++++---------- .../Tests/TestRoot.cs | 13 +++---- .../Tests/TestTest.cs | 2 +- .../Utility/ApiExclusiveGroups.cs | 8 ++-- .../Utility/AsyncUtils.cs | 2 +- .../Utility/AsyncUtilsEngine.cs | 5 +-- .../Utility/Audio.cs | 2 +- .../Utility/AudioTools.cs | 2 +- .../Utility/DebugInterfaceEngine.cs | 8 ++-- .../Utility/Dependency.cs | 2 +- .../Utility/ExceptionUtil.cs | 4 +- .../Utility/FullGameFields.cs | 2 +- .../Utility/GameClient.cs | 4 +- .../Utility/GameEngineManager.cs | 5 +-- .../Utility/GameState.cs | 2 +- .../Utility/GameStateEngine.cs | 5 +-- .../Utility/Logging.cs | 2 +- .../Utility/MenuEngineManager.cs | 5 +-- .../Utility/OptionalRef.cs | 4 +- .../Utility/VersionTracking.cs | 7 ++-- 142 files changed, 334 insertions(+), 378 deletions(-) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/AppCallbacksTest.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/AppEngine.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/AppExceptions.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/Client.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/ClientAlertTest.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/CurrentGameMode.cs (91%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/Game.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/GameBuildSimEventEngine.cs (91%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/GameGameEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/GameMenuEngine.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/StateSyncRegPatch.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/App/UserPrompts.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Block.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/BlockGroup.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockCloneEngine.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockColor.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockEngine.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockEngineInit.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockEventsEngine.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockExceptions.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockIDs.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockIdentifiers.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockMaterial.cs (82%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlockTests.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/BlueprintEngine.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/CustomBlock.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/CustomBlockAttribute.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/CustomBlockEngine.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/DampedSpring.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/LogicGate.cs (88%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/Motor.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/MovementEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/MusicBlock.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/ObjectIdentifier.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/Piston.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/PlacementEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/RemovalEngine.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/RotationEngine.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/ScalingEngine.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/Servo.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/SfxBlock.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/SignalEngine.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/SignalingBlock.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/SpawnPoint.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/TextBlock.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/Timer.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blocks/Wire.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Blueprint.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Cluster.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandBuilder.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandEngineFactory.cs (88%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandExceptions.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandManager.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandPatch.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/CommandRegistrationHelper.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/ExistingCommands.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/ICustomCommandEngine.cs (85%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/SimpleCustomCommandEngine.cs (87%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/SimpleCustomCommandEngine1.cs (86%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/SimpleCustomCommandEngine2.cs (86%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Commands/SimpleCustomCommandEngine3.cs (86%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Engines/IApiEngine.cs (83%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Engines/IFactoryEngine.cs (88%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Engines/IReactionaryEngine.cs (86%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/DeterministicStepComposeEngineGroupsPatch.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/EmitterBuilder.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/EventEngineFactory.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/EventExceptions.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/EventManager.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/EventType.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/GameActivatedComposePatch.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/GameReloadedPatch.cs (87%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/GameStateBuildEmitterEngine.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/GameStateSimulationEmitterEngine.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/GameSwitchedToPatch.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/HandlerBuilder.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/IEventEmitterEngine.cs (86%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/IEventHandlerEngine.cs (84%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/MenuActivatedPatch.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/MenuSwitchedToPatch.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/ModEventEntityDescriptor.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/ModEventEntityStruct.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/SimpleEventEmitterEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Events/SimpleEventHandlerEngine.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/FlyCam.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/GamecraftModdingAPIException.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Input/FakeInput.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Input/FakeInputEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Button.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Constants.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Group.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/IMGUIManager.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Image.cs (89%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Label.cs (88%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/Text.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Interface/IMGUI/UIElement.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Inventory/Hotbar.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Inventory/HotbarEngine.cs (88%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Main.cs (87%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/IEntitySerializer.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/SaveAndLoadCompositionRootPatch.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/SaveGameEnginePatch.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/SerializerManager.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Persistence/SimpleEntitySerializer.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Player.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/FlyCamEngine.cs (90%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/PlayerBuildingMode.cs (75%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/PlayerEngine.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/PlayerExceptions.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/PlayerTests.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Players/PlayerType.cs (70%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/SimBody.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tasks/ISchedulable.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tasks/Once.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tasks/Repeatable.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tasks/Scheduler.cs (98%) rename GamecraftModdingAPI/GamecraftModdingAPI.csproj => TechbloxModdingAPI/TechbloxModdingAPI.csproj (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tests/APITestAttributes.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tests/Assert.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tests/GamecraftModdingAPIPluginTest.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tests/TestRoot.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Tests/TestTest.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/ApiExclusiveGroups.cs (74%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/AsyncUtils.cs (95%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/AsyncUtilsEngine.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/Audio.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/AudioTools.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/DebugInterfaceEngine.cs (94%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/Dependency.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/ExceptionUtil.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/FullGameFields.cs (98%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/GameClient.cs (93%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/GameEngineManager.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/GameState.cs (97%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/GameStateEngine.cs (92%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/Logging.cs (99%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/MenuEngineManager.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/OptionalRef.cs (96%) rename {GamecraftModdingAPI => TechbloxModdingAPI}/Utility/VersionTracking.cs (96%) diff --git a/GamecraftModdingAPI.sln b/GamecraftModdingAPI.sln index 6482776..2191746 100644 --- a/GamecraftModdingAPI.sln +++ b/GamecraftModdingAPI.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29411.108 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GamecraftModdingAPI", "GamecraftModdingAPI\GamecraftModdingAPI.csproj", "{7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechbloxModdingAPI", "TechbloxModdingAPI\TechbloxModdingAPI.csproj", "{7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/GamecraftModdingAPI/App/AppCallbacksTest.cs b/TechbloxModdingAPI/App/AppCallbacksTest.cs similarity index 93% rename from GamecraftModdingAPI/App/AppCallbacksTest.cs rename to TechbloxModdingAPI/App/AppCallbacksTest.cs index 041ac50..c1e184b 100644 --- a/GamecraftModdingAPI/App/AppCallbacksTest.cs +++ b/TechbloxModdingAPI/App/AppCallbacksTest.cs @@ -1,8 +1,8 @@ using System; -using GamecraftModdingAPI.Tests; +using TechbloxModdingAPI.Tests; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { #if TEST /// diff --git a/GamecraftModdingAPI/App/AppEngine.cs b/TechbloxModdingAPI/App/AppEngine.cs similarity index 92% rename from GamecraftModdingAPI/App/AppEngine.cs rename to TechbloxModdingAPI/App/AppEngine.cs index 9cc454d..d14f932 100644 --- a/GamecraftModdingAPI/App/AppEngine.cs +++ b/TechbloxModdingAPI/App/AppEngine.cs @@ -3,11 +3,10 @@ using RobocraftX.GUI.MyGamesScreen; using RobocraftX.GUI; using Svelto.ECS; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class AppEngine : IFactoryEngine { diff --git a/GamecraftModdingAPI/App/AppExceptions.cs b/TechbloxModdingAPI/App/AppExceptions.cs similarity index 95% rename from GamecraftModdingAPI/App/AppExceptions.cs rename to TechbloxModdingAPI/App/AppExceptions.cs index 2e67695..b3393cb 100644 --- a/GamecraftModdingAPI/App/AppExceptions.cs +++ b/TechbloxModdingAPI/App/AppExceptions.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.Serialization; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class AppException : GamecraftModdingAPIException { diff --git a/GamecraftModdingAPI/App/Client.cs b/TechbloxModdingAPI/App/Client.cs similarity index 94% rename from GamecraftModdingAPI/App/Client.cs rename to TechbloxModdingAPI/App/Client.cs index ca5dcfa..4887448 100644 --- a/GamecraftModdingAPI/App/Client.cs +++ b/TechbloxModdingAPI/App/Client.cs @@ -4,11 +4,10 @@ using HarmonyLib; using RobocraftX.Services; using UnityEngine; - -using GamecraftModdingAPI.Utility; using RobocraftX.Common; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { /// /// The Gamecraft application that is running this code right now. @@ -111,13 +110,13 @@ namespace GamecraftModdingAPI.App // this would have been so much simpler if this didn't involve a bunch of internal fields & classes Type errorHandler = AccessTools.TypeByName("RobocraftX.Services.ErrorHandler"); Type errorHandle = AccessTools.TypeByName("RobocraftX.Services.ErrorHandle"); - ErrorHandlerInstanceGetter = (Func) AccessTools.Method("GamecraftModdingAPI.App.Client:GenInstanceGetter") + ErrorHandlerInstanceGetter = (Func) AccessTools.Method("TechbloxModdingAPI.App.Client:GenInstanceGetter") .MakeGenericMethod(errorHandler) .Invoke(null, new object[0]); - EnqueueError = (Action) AccessTools.Method("GamecraftModdingAPI.App.Client:GenEnqueueError") + EnqueueError = (Action) AccessTools.Method("TechbloxModdingAPI.App.Client:GenEnqueueError") .MakeGenericMethod(errorHandler, errorHandle) .Invoke(null, new object[0]); - /*HandleErrorClosed = (Action) AccessTools.Method("GamecraftModdingAPI.App.Client:GenHandlePopupClosed") + /*HandleErrorClosed = (Action) AccessTools.Method("TechbloxModdingAPI.App.Client:GenHandlePopupClosed") .MakeGenericMethod(errorHandler) .Invoke(null, new object[0]);*/ // register engines diff --git a/GamecraftModdingAPI/App/ClientAlertTest.cs b/TechbloxModdingAPI/App/ClientAlertTest.cs similarity index 95% rename from GamecraftModdingAPI/App/ClientAlertTest.cs rename to TechbloxModdingAPI/App/ClientAlertTest.cs index 23ced76..20d8201 100644 --- a/GamecraftModdingAPI/App/ClientAlertTest.cs +++ b/TechbloxModdingAPI/App/ClientAlertTest.cs @@ -3,9 +3,9 @@ using HarmonyLib; using RobocraftX.Services; -using GamecraftModdingAPI.Tests; +using TechbloxModdingAPI.Tests; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { #if TEST /// diff --git a/GamecraftModdingAPI/App/CurrentGameMode.cs b/TechbloxModdingAPI/App/CurrentGameMode.cs similarity index 91% rename from GamecraftModdingAPI/App/CurrentGameMode.cs rename to TechbloxModdingAPI/App/CurrentGameMode.cs index 84a6d78..85b3e09 100644 --- a/GamecraftModdingAPI/App/CurrentGameMode.cs +++ b/TechbloxModdingAPI/App/CurrentGameMode.cs @@ -1,4 +1,4 @@ -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public enum CurrentGameMode { diff --git a/GamecraftModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs similarity index 96% rename from GamecraftModdingAPI/App/Game.cs rename to TechbloxModdingAPI/App/Game.cs index 3d73478..a3099eb 100644 --- a/GamecraftModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -7,12 +7,12 @@ using RobocraftX.GUI.MyGamesScreen; using RobocraftX.StateSync; using Svelto.ECS; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Tasks; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Tasks; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { /// /// An in-game save. @@ -33,7 +33,7 @@ namespace GamecraftModdingAPI.App private bool hasId = false; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Menu identifier. public Game(uint id) : this(new EGID(id, MyGamesScreenExclusiveGroups.MyGames)) @@ -41,7 +41,7 @@ namespace GamecraftModdingAPI.App } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Menu identifier. public Game(EGID id) @@ -54,7 +54,7 @@ namespace GamecraftModdingAPI.App } /// - /// Initializes a new instance of the class without id. + /// Initializes a new instance of the class without id. /// This is assumed to be the current game. /// public Game() diff --git a/GamecraftModdingAPI/App/GameBuildSimEventEngine.cs b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs similarity index 91% rename from GamecraftModdingAPI/App/GameBuildSimEventEngine.cs rename to TechbloxModdingAPI/App/GameBuildSimEventEngine.cs index 4c9a536..f4b5766 100644 --- a/GamecraftModdingAPI/App/GameBuildSimEventEngine.cs +++ b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs @@ -4,11 +4,10 @@ using RobocraftX.Common; using RobocraftX.StateSync; using Svelto.ECS; using Unity.Jobs; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class GameBuildSimEventEngine : IApiEngine, IUnorderedInitializeOnTimeRunningModeEntered, IUnorderedInitializeOnTimeStoppedModeEntered { diff --git a/GamecraftModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs similarity index 96% rename from GamecraftModdingAPI/App/GameGameEngine.cs rename to TechbloxModdingAPI/App/GameGameEngine.cs index da270cc..d5a2f60 100644 --- a/GamecraftModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -9,13 +9,12 @@ using RobocraftX.SimulationModeState; using Svelto.ECS; using Svelto.Tasks; using Svelto.Tasks.Lean; - -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; using RobocraftX.Blocks; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class GameGameEngine : IApiEngine { diff --git a/GamecraftModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs similarity index 97% rename from GamecraftModdingAPI/App/GameMenuEngine.cs rename to TechbloxModdingAPI/App/GameMenuEngine.cs index 67b159b..9fce3b7 100644 --- a/GamecraftModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -7,12 +7,11 @@ using RobocraftX.GUI; using RobocraftX.GUI.MyGamesScreen; using Svelto.ECS; using Svelto.ECS.Experimental; - -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; using Svelto.DataStructures; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class GameMenuEngine : IFactoryEngine { diff --git a/GamecraftModdingAPI/App/StateSyncRegPatch.cs b/TechbloxModdingAPI/App/StateSyncRegPatch.cs similarity index 93% rename from GamecraftModdingAPI/App/StateSyncRegPatch.cs rename to TechbloxModdingAPI/App/StateSyncRegPatch.cs index 9c2ce68..87842d2 100644 --- a/GamecraftModdingAPI/App/StateSyncRegPatch.cs +++ b/TechbloxModdingAPI/App/StateSyncRegPatch.cs @@ -6,7 +6,7 @@ using RobocraftX.StateSync; using HarmonyLib; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { [HarmonyPatch] class StateSyncRegPatch diff --git a/GamecraftModdingAPI/App/UserPrompts.cs b/TechbloxModdingAPI/App/UserPrompts.cs similarity index 96% rename from GamecraftModdingAPI/App/UserPrompts.cs rename to TechbloxModdingAPI/App/UserPrompts.cs index 26a9395..7548055 100644 --- a/GamecraftModdingAPI/App/UserPrompts.cs +++ b/TechbloxModdingAPI/App/UserPrompts.cs @@ -3,7 +3,7 @@ using HarmonyLib; using RobocraftX.Services; -namespace GamecraftModdingAPI.App +namespace TechbloxModdingAPI.App { public class DualChoicePrompt : MultiChoiceError { diff --git a/GamecraftModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs similarity index 99% rename from GamecraftModdingAPI/Block.cs rename to TechbloxModdingAPI/Block.cs index e4c50cd..4729a91 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -10,16 +10,15 @@ using RobocraftX.Common; using RobocraftX.Blocks; using Unity.Mathematics; using Gamecraft.Blocks.GUI; - -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Utility; using RobocraftX.Rendering.GPUI; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// A single (perhaps scaled) block. Properties may return default values if the block is removed and then setting them is ignored. - /// For specific block type operations, use the specialised block classes in the GamecraftModdingAPI.Blocks namespace. + /// For specific block type operations, use the specialised block classes in the TechbloxModdingAPI.Blocks namespace. /// public class Block : IEquatable, IEquatable { diff --git a/GamecraftModdingAPI/BlockGroup.cs b/TechbloxModdingAPI/BlockGroup.cs similarity index 98% rename from GamecraftModdingAPI/BlockGroup.cs rename to TechbloxModdingAPI/BlockGroup.cs index c1add9a..5361445 100644 --- a/GamecraftModdingAPI/BlockGroup.cs +++ b/TechbloxModdingAPI/BlockGroup.cs @@ -5,11 +5,10 @@ using System.Collections.Generic; using Gamecraft.Blocks.BlockGroups; using Unity.Mathematics; using UnityEngine; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// A group of blocks that can be selected together. The placed version of blueprints. Dispose after usage. diff --git a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs b/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs similarity index 98% rename from GamecraftModdingAPI/Blocks/BlockCloneEngine.cs rename to TechbloxModdingAPI/Blocks/BlockCloneEngine.cs index 1c9c91c..8703953 100644 --- a/GamecraftModdingAPI/Blocks/BlockCloneEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Reflection; using Gamecraft.Wires; -using GamecraftModdingAPI.Engines; using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Character; @@ -10,8 +9,9 @@ using RobocraftX.Common; using RobocraftX.Common.Players; using Svelto.DataStructures; using Svelto.ECS; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class BlockCloneEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Blocks/BlockColor.cs b/TechbloxModdingAPI/Blocks/BlockColor.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/BlockColor.cs rename to TechbloxModdingAPI/Blocks/BlockColor.cs index bb5fa4a..33363a2 100644 --- a/GamecraftModdingAPI/Blocks/BlockColor.cs +++ b/TechbloxModdingAPI/Blocks/BlockColor.cs @@ -1,7 +1,7 @@ using System; using Unity.Mathematics; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public struct BlockColor { diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/BlockEngine.cs rename to TechbloxModdingAPI/Blocks/BlockEngine.cs index e0291c0..956871b 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -15,10 +15,9 @@ using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Hybrid; using Unity.Mathematics; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Engine for executing general block actions diff --git a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs b/TechbloxModdingAPI/Blocks/BlockEngineInit.cs similarity index 98% rename from GamecraftModdingAPI/Blocks/BlockEngineInit.cs rename to TechbloxModdingAPI/Blocks/BlockEngineInit.cs index ac7f3c4..b9b9eae 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngineInit.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngineInit.cs @@ -5,7 +5,7 @@ using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Internal; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public partial class BlockEngine { diff --git a/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs b/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs similarity index 92% rename from GamecraftModdingAPI/Blocks/BlockEventsEngine.cs rename to TechbloxModdingAPI/Blocks/BlockEventsEngine.cs index d1c2639..f89768b 100644 --- a/GamecraftModdingAPI/Blocks/BlockEventsEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs @@ -2,12 +2,11 @@ using System; using RobocraftX.Common; using Svelto.ECS; - -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; using RobocraftX.Blocks; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class BlockEventsEngine : IReactionaryEngine { diff --git a/GamecraftModdingAPI/Blocks/BlockExceptions.cs b/TechbloxModdingAPI/Blocks/BlockExceptions.cs similarity index 93% rename from GamecraftModdingAPI/Blocks/BlockExceptions.cs rename to TechbloxModdingAPI/Blocks/BlockExceptions.cs index 9949424..409bb02 100644 --- a/GamecraftModdingAPI/Blocks/BlockExceptions.cs +++ b/TechbloxModdingAPI/Blocks/BlockExceptions.cs @@ -1,8 +1,8 @@ using System; -using GamecraftModdingAPI; +using TechbloxModdingAPI; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class BlockException : GamecraftModdingAPIException { diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs similarity index 98% rename from GamecraftModdingAPI/Blocks/BlockIDs.cs rename to TechbloxModdingAPI/Blocks/BlockIDs.cs index 5c44f11..30fa76f 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -1,4 +1,4 @@ -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Possible block types diff --git a/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs b/TechbloxModdingAPI/Blocks/BlockIdentifiers.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/BlockIdentifiers.cs rename to TechbloxModdingAPI/Blocks/BlockIdentifiers.cs index bc426d5..10305dc 100644 --- a/GamecraftModdingAPI/Blocks/BlockIdentifiers.cs +++ b/TechbloxModdingAPI/Blocks/BlockIdentifiers.cs @@ -4,7 +4,7 @@ using RobocraftX.Common; using HarmonyLib; using Svelto.DataStructures; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// ExclusiveGroups and IDs used with blocks diff --git a/GamecraftModdingAPI/Blocks/BlockMaterial.cs b/TechbloxModdingAPI/Blocks/BlockMaterial.cs similarity index 82% rename from GamecraftModdingAPI/Blocks/BlockMaterial.cs rename to TechbloxModdingAPI/Blocks/BlockMaterial.cs index 74d45bb..723bd63 100644 --- a/GamecraftModdingAPI/Blocks/BlockMaterial.cs +++ b/TechbloxModdingAPI/Blocks/BlockMaterial.cs @@ -1,4 +1,4 @@ -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public enum BlockMaterial : byte { diff --git a/GamecraftModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/BlockTests.cs rename to TechbloxModdingAPI/Blocks/BlockTests.cs index 7aac012..7a96c27 100644 --- a/GamecraftModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -3,11 +3,11 @@ using Gamecraft.Wires; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Tests; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Tests; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { #if TEST /// @@ -31,7 +31,7 @@ namespace GamecraftModdingAPI.Blocks //Assert.Equal(newBlock.Exists, true, "Newly placed block does not exist, possibly because Sync() skipped/missed/failed.", "Newly placed block exists, Sync() successful."); } - [APITestCase(TestType.EditMode)] + /*[APITestCase(TestType.EditMode)] public static void TestTextBlock() { TextBlock textBlock = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler @@ -74,7 +74,7 @@ namespace GamecraftModdingAPI.Blocks if (!Assert.CloseTo(b.MaximumAngle, 180f, $"Servo.MaximumAngle {b.MaximumAngle} does not equal default value, possibly because it failed silently.", "Servo.MaximumAngle is close enough to default.")) return; if (!Assert.CloseTo(b.MinimumAngle, -180f, $"Servo.MinimumAngle {b.MinimumAngle} does not equal default value, possibly because it failed silently.", "Servo.MinimumAngle is close enough to default.")) return; if (!Assert.CloseTo(b.MaximumForce, 60f, $"Servo.MaximumForce {b.MaximumForce} does not equal default value, possibly because it failed silently.", "Servo.MaximumForce is close enough to default.")) return; - } + }*/ [APITestCase(TestType.EditMode)] public static void TestDampedSpring() @@ -88,7 +88,7 @@ namespace GamecraftModdingAPI.Blocks if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; } - [APITestCase(TestType.Game)] + /*[APITestCase(TestType.Game)] public static void TestMusicBlock1() { Block newBlock = Block.PlaceNew(BlockIDs.MusicBlock, Unity.Mathematics.float3.zero + 2); @@ -131,14 +131,14 @@ namespace GamecraftModdingAPI.Blocks Wire newWire = null; if (!Assert.Errorless(() => { newWire = b.Connect(0, target, 0);})) return; if (!Assert.NotNull(newWire, "SignalingBlock.Connect(...) returned null, possible because it failed silently.", "SignalingBlock.Connect(...) returned a non-null value.")) return; - } + }*/ - [APITestCase(TestType.EditMode)] + /*[APITestCase(TestType.EditMode)] public static void TestSpecialiseError() { Block newBlock = Block.PlaceNew(BlockIDs.Bench, new float3(1, 1, 1)); if (Assert.Errorful(() => newBlock.Specialise(), "Block.Specialise() was expected to error on a bench block.", "Block.Specialise() errored as expected for a bench block.")) return; - } + }*/ } #endif } diff --git a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs b/TechbloxModdingAPI/Blocks/BlueprintEngine.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/BlueprintEngine.cs rename to TechbloxModdingAPI/Blocks/BlueprintEngine.cs index ddfb051..19e0afc 100644 --- a/GamecraftModdingAPI/Blocks/BlueprintEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlueprintEngine.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Reflection; using Gamecraft.Blocks.BlockGroups; using Gamecraft.GUI.Blueprints; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Common; @@ -15,12 +13,14 @@ using Svelto.ECS; using Svelto.ECS.DataStructures; using Svelto.ECS.EntityStructs; using Svelto.ECS.Serialization; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; using Unity.Collections; using Unity.Mathematics; using UnityEngine; using Allocator = Svelto.Common.Allocator; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class BlueprintEngine : IFactoryEngine { diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/TechbloxModdingAPI/Blocks/CustomBlock.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/CustomBlock.cs rename to TechbloxModdingAPI/Blocks/CustomBlock.cs index 3567afd..4027c31 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/TechbloxModdingAPI/Blocks/CustomBlock.cs @@ -17,11 +17,10 @@ using Svelto.Tasks.ExtraLean; using UnityEngine; using UnityEngine.AddressableAssets; using Material = UnityEngine.Material; - -using GamecraftModdingAPI.Utility; using ServiceLayer; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Experimental support for adding custom blocks to the game. diff --git a/GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs b/TechbloxModdingAPI/Blocks/CustomBlockAttribute.cs similarity index 98% rename from GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs rename to TechbloxModdingAPI/Blocks/CustomBlockAttribute.cs index 7c7669f..b4a11f6 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlockAttribute.cs +++ b/TechbloxModdingAPI/Blocks/CustomBlockAttribute.cs @@ -1,7 +1,7 @@ using System; using DataLoader; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { [AttributeUsage(AttributeTargets.Class)] public class CustomBlockAttribute : Attribute diff --git a/GamecraftModdingAPI/Blocks/CustomBlockEngine.cs b/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs similarity index 94% rename from GamecraftModdingAPI/Blocks/CustomBlockEngine.cs rename to TechbloxModdingAPI/Blocks/CustomBlockEngine.cs index bb1192b..ef3c1e5 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs @@ -1,14 +1,14 @@ using System; using System.Collections.Generic; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Persistence; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Persistence; +using TechbloxModdingAPI.Utility; using RobocraftX.Common; using Svelto.ECS; using Svelto.ECS.Experimental; using Svelto.ECS.Serialization; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /*public class CustomBlockEngine : IFactoryEngine { diff --git a/GamecraftModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/DampedSpring.cs rename to TechbloxModdingAPI/Blocks/DampedSpring.cs index 20d28f2..34c7543 100644 --- a/GamecraftModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -2,7 +2,7 @@ using RobocraftX.Blocks; using RobocraftX.Common; using Svelto.ECS; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class DampedSpring : Block { diff --git a/GamecraftModdingAPI/Blocks/LogicGate.cs b/TechbloxModdingAPI/Blocks/LogicGate.cs similarity index 88% rename from GamecraftModdingAPI/Blocks/LogicGate.cs rename to TechbloxModdingAPI/Blocks/LogicGate.cs index 2ec4cef..50a819c 100644 --- a/GamecraftModdingAPI/Blocks/LogicGate.cs +++ b/TechbloxModdingAPI/Blocks/LogicGate.cs @@ -1,7 +1,7 @@ using RobocraftX.Common; using Svelto.ECS; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class LogicGate : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/Motor.cs b/TechbloxModdingAPI/Blocks/Motor.cs similarity index 95% rename from GamecraftModdingAPI/Blocks/Motor.cs rename to TechbloxModdingAPI/Blocks/Motor.cs index 0a69d27..6b1e500 100644 --- a/GamecraftModdingAPI/Blocks/Motor.cs +++ b/TechbloxModdingAPI/Blocks/Motor.cs @@ -5,9 +5,9 @@ using RobocraftX.Common; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class Motor : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/MovementEngine.cs b/TechbloxModdingAPI/Blocks/MovementEngine.cs similarity index 96% rename from GamecraftModdingAPI/Blocks/MovementEngine.cs rename to TechbloxModdingAPI/Blocks/MovementEngine.cs index 87a7259..b01b714 100644 --- a/GamecraftModdingAPI/Blocks/MovementEngine.cs +++ b/TechbloxModdingAPI/Blocks/MovementEngine.cs @@ -4,11 +4,10 @@ using Svelto.ECS; using Svelto.ECS.EntityStructs; using Unity.Transforms; using Unity.Mathematics; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Engine which executes block movement actions diff --git a/GamecraftModdingAPI/Blocks/MusicBlock.cs b/TechbloxModdingAPI/Blocks/MusicBlock.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/MusicBlock.cs rename to TechbloxModdingAPI/Blocks/MusicBlock.cs index 6b99b6f..30ca5ab 100644 --- a/GamecraftModdingAPI/Blocks/MusicBlock.cs +++ b/TechbloxModdingAPI/Blocks/MusicBlock.cs @@ -8,11 +8,11 @@ using RobocraftX.Blocks; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Tests; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Tests; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class MusicBlock : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/ObjectIdentifier.cs rename to TechbloxModdingAPI/Blocks/ObjectIdentifier.cs index 1233343..67e250e 100644 --- a/GamecraftModdingAPI/Blocks/ObjectIdentifier.cs +++ b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs @@ -2,7 +2,7 @@ using RobocraftX.Common; using Svelto.ECS; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class ObjectIdentifier : Block { diff --git a/GamecraftModdingAPI/Blocks/Piston.cs b/TechbloxModdingAPI/Blocks/Piston.cs similarity index 94% rename from GamecraftModdingAPI/Blocks/Piston.cs rename to TechbloxModdingAPI/Blocks/Piston.cs index d05ac20..b5953ee 100644 --- a/GamecraftModdingAPI/Blocks/Piston.cs +++ b/TechbloxModdingAPI/Blocks/Piston.cs @@ -4,10 +4,10 @@ using RobocraftX.Blocks; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; using RobocraftX.Common; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class Piston : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/PlacementEngine.cs similarity index 96% rename from GamecraftModdingAPI/Blocks/PlacementEngine.cs rename to TechbloxModdingAPI/Blocks/PlacementEngine.cs index 1d01ae8..38e27f1 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/PlacementEngine.cs @@ -13,13 +13,12 @@ using Svelto.ECS; using Svelto.ECS.EntityStructs; using Unity.Mathematics; using UnityEngine; - -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Players; +using TechbloxModdingAPI.Players; using RobocraftX.Rendering.GPUI; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Engine which executes block placement actions diff --git a/GamecraftModdingAPI/Blocks/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/RemovalEngine.cs similarity index 94% rename from GamecraftModdingAPI/Blocks/RemovalEngine.cs rename to TechbloxModdingAPI/Blocks/RemovalEngine.cs index c27c339..08216fc 100644 --- a/GamecraftModdingAPI/Blocks/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/RemovalEngine.cs @@ -4,11 +4,10 @@ using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Common; using Svelto.ECS; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class RemovalEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Blocks/RotationEngine.cs b/TechbloxModdingAPI/Blocks/RotationEngine.cs similarity index 97% rename from GamecraftModdingAPI/Blocks/RotationEngine.cs rename to TechbloxModdingAPI/Blocks/RotationEngine.cs index 2d8d1db..1f35d17 100644 --- a/GamecraftModdingAPI/Blocks/RotationEngine.cs +++ b/TechbloxModdingAPI/Blocks/RotationEngine.cs @@ -4,11 +4,10 @@ using Svelto.ECS; using Svelto.ECS.EntityStructs; using Unity.Mathematics; using UnityEngine; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Engine which executes block movement actions diff --git a/GamecraftModdingAPI/Blocks/ScalingEngine.cs b/TechbloxModdingAPI/Blocks/ScalingEngine.cs similarity index 93% rename from GamecraftModdingAPI/Blocks/ScalingEngine.cs rename to TechbloxModdingAPI/Blocks/ScalingEngine.cs index fcbf900..81131e6 100644 --- a/GamecraftModdingAPI/Blocks/ScalingEngine.cs +++ b/TechbloxModdingAPI/Blocks/ScalingEngine.cs @@ -5,11 +5,10 @@ using RobocraftX.Common; using RobocraftX.UECS; using Svelto.ECS; using Unity.Entities; +using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class ScalingEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Blocks/Servo.cs b/TechbloxModdingAPI/Blocks/Servo.cs similarity index 96% rename from GamecraftModdingAPI/Blocks/Servo.cs rename to TechbloxModdingAPI/Blocks/Servo.cs index a5dceec..12232de 100644 --- a/GamecraftModdingAPI/Blocks/Servo.cs +++ b/TechbloxModdingAPI/Blocks/Servo.cs @@ -5,9 +5,9 @@ using RobocraftX.Common; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class Servo : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/SfxBlock.cs b/TechbloxModdingAPI/Blocks/SfxBlock.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/SfxBlock.cs rename to TechbloxModdingAPI/Blocks/SfxBlock.cs index 88d69d2..c72d37a 100644 --- a/GamecraftModdingAPI/Blocks/SfxBlock.cs +++ b/TechbloxModdingAPI/Blocks/SfxBlock.cs @@ -6,7 +6,7 @@ using RobocraftX.Blocks; using RobocraftX.Common; using Svelto.ECS; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class SfxBlock : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/TechbloxModdingAPI/Blocks/SignalEngine.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/SignalEngine.cs rename to TechbloxModdingAPI/Blocks/SignalEngine.cs index 8329a3b..3b1cf6a 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/TechbloxModdingAPI/Blocks/SignalEngine.cs @@ -2,10 +2,9 @@ using Svelto.ECS; using Svelto.DataStructures; using Gamecraft.Wires; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Engine which executes signal actions diff --git a/GamecraftModdingAPI/Blocks/SignalingBlock.cs b/TechbloxModdingAPI/Blocks/SignalingBlock.cs similarity index 98% rename from GamecraftModdingAPI/Blocks/SignalingBlock.cs rename to TechbloxModdingAPI/Blocks/SignalingBlock.cs index a137b98..b18521a 100644 --- a/GamecraftModdingAPI/Blocks/SignalingBlock.cs +++ b/TechbloxModdingAPI/Blocks/SignalingBlock.cs @@ -4,10 +4,10 @@ using Gamecraft.Wires; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { /// /// Common implementation for blocks that support wiring. diff --git a/GamecraftModdingAPI/Blocks/SpawnPoint.cs b/TechbloxModdingAPI/Blocks/SpawnPoint.cs similarity index 95% rename from GamecraftModdingAPI/Blocks/SpawnPoint.cs rename to TechbloxModdingAPI/Blocks/SpawnPoint.cs index 17bffd9..ac6c014 100644 --- a/GamecraftModdingAPI/Blocks/SpawnPoint.cs +++ b/TechbloxModdingAPI/Blocks/SpawnPoint.cs @@ -6,10 +6,10 @@ using Gamecraft.CharacterVulnerability; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class SpawnPoint : Block { diff --git a/GamecraftModdingAPI/Blocks/TextBlock.cs b/TechbloxModdingAPI/Blocks/TextBlock.cs similarity index 93% rename from GamecraftModdingAPI/Blocks/TextBlock.cs rename to TechbloxModdingAPI/Blocks/TextBlock.cs index 3d46611..0e33b75 100644 --- a/GamecraftModdingAPI/Blocks/TextBlock.cs +++ b/TechbloxModdingAPI/Blocks/TextBlock.cs @@ -5,10 +5,10 @@ using RobocraftX.Common; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class TextBlock : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/Timer.cs b/TechbloxModdingAPI/Blocks/Timer.cs similarity index 95% rename from GamecraftModdingAPI/Blocks/Timer.cs rename to TechbloxModdingAPI/Blocks/Timer.cs index 0bbd302..6337864 100644 --- a/GamecraftModdingAPI/Blocks/Timer.cs +++ b/TechbloxModdingAPI/Blocks/Timer.cs @@ -6,10 +6,10 @@ using Gamecraft.Blocks.TimerBlock; using Svelto.ECS; using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class Timer : SignalingBlock { diff --git a/GamecraftModdingAPI/Blocks/Wire.cs b/TechbloxModdingAPI/Blocks/Wire.cs similarity index 99% rename from GamecraftModdingAPI/Blocks/Wire.cs rename to TechbloxModdingAPI/Blocks/Wire.cs index e58a625..289dee7 100644 --- a/GamecraftModdingAPI/Blocks/Wire.cs +++ b/TechbloxModdingAPI/Blocks/Wire.cs @@ -4,9 +4,9 @@ using Gamecraft.Wires; using Svelto.ECS; using Svelto.ECS.Experimental; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Blocks +namespace TechbloxModdingAPI.Blocks { public class Wire { diff --git a/GamecraftModdingAPI/Blueprint.cs b/TechbloxModdingAPI/Blueprint.cs similarity index 99% rename from GamecraftModdingAPI/Blueprint.cs rename to TechbloxModdingAPI/Blueprint.cs index 4d9dff0..2724e5a 100644 --- a/GamecraftModdingAPI/Blueprint.cs +++ b/TechbloxModdingAPI/Blueprint.cs @@ -2,7 +2,7 @@ using Unity.Mathematics; using UnityEngine; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// Represents a blueprint in the inventory. When placed it becomes a block group. diff --git a/GamecraftModdingAPI/Cluster.cs b/TechbloxModdingAPI/Cluster.cs similarity index 98% rename from GamecraftModdingAPI/Cluster.cs rename to TechbloxModdingAPI/Cluster.cs index 79b5822..11b995c 100644 --- a/GamecraftModdingAPI/Cluster.cs +++ b/TechbloxModdingAPI/Cluster.cs @@ -2,7 +2,7 @@ using RobocraftX.Common; using Svelto.ECS; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// Represnts a cluster of blocks in time running mode, meaning blocks that are connected either directly or via joints. diff --git a/GamecraftModdingAPI/Commands/CommandBuilder.cs b/TechbloxModdingAPI/Commands/CommandBuilder.cs similarity index 99% rename from GamecraftModdingAPI/Commands/CommandBuilder.cs rename to TechbloxModdingAPI/Commands/CommandBuilder.cs index 7bd5ed9..1a34f45 100644 --- a/GamecraftModdingAPI/Commands/CommandBuilder.cs +++ b/TechbloxModdingAPI/Commands/CommandBuilder.cs @@ -1,10 +1,9 @@ using System; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// Custom Command builder. diff --git a/GamecraftModdingAPI/Commands/CommandEngineFactory.cs b/TechbloxModdingAPI/Commands/CommandEngineFactory.cs similarity index 88% rename from GamecraftModdingAPI/Commands/CommandEngineFactory.cs rename to TechbloxModdingAPI/Commands/CommandEngineFactory.cs index ddcdcb8..07e9a67 100644 --- a/GamecraftModdingAPI/Commands/CommandEngineFactory.cs +++ b/TechbloxModdingAPI/Commands/CommandEngineFactory.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// UNIMPLEMENTED! diff --git a/GamecraftModdingAPI/Commands/CommandExceptions.cs b/TechbloxModdingAPI/Commands/CommandExceptions.cs similarity index 97% rename from GamecraftModdingAPI/Commands/CommandExceptions.cs rename to TechbloxModdingAPI/Commands/CommandExceptions.cs index 39502a7..4141a9f 100644 --- a/GamecraftModdingAPI/Commands/CommandExceptions.cs +++ b/TechbloxModdingAPI/Commands/CommandExceptions.cs @@ -1,5 +1,5 @@ using System; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { public class CommandException : GamecraftModdingAPIException { diff --git a/GamecraftModdingAPI/Commands/CommandManager.cs b/TechbloxModdingAPI/Commands/CommandManager.cs similarity index 96% rename from GamecraftModdingAPI/Commands/CommandManager.cs rename to TechbloxModdingAPI/Commands/CommandManager.cs index 876d634..e275ace 100644 --- a/GamecraftModdingAPI/Commands/CommandManager.cs +++ b/TechbloxModdingAPI/Commands/CommandManager.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// Keeps track of custom commands diff --git a/GamecraftModdingAPI/Commands/CommandPatch.cs b/TechbloxModdingAPI/Commands/CommandPatch.cs similarity index 99% rename from GamecraftModdingAPI/Commands/CommandPatch.cs rename to TechbloxModdingAPI/Commands/CommandPatch.cs index bf9f186..d098948 100644 --- a/GamecraftModdingAPI/Commands/CommandPatch.cs +++ b/TechbloxModdingAPI/Commands/CommandPatch.cs @@ -8,7 +8,7 @@ using RobocraftX.CR.MainGame; using RobocraftX.Multiplayer; using RobocraftX.StateSync; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// Patch of RobocraftX.CR.MainGame.MainGameCompositionRoot.DeterministicCompose() diff --git a/GamecraftModdingAPI/Commands/CommandRegistrationHelper.cs b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs similarity index 98% rename from GamecraftModdingAPI/Commands/CommandRegistrationHelper.cs rename to TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs index 5cb9069..633bf75 100644 --- a/GamecraftModdingAPI/Commands/CommandRegistrationHelper.cs +++ b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using uREPL; using RobocraftX.CommandLine.Custom; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// Convenient methods for registering commands to Gamecraft. diff --git a/GamecraftModdingAPI/Commands/ExistingCommands.cs b/TechbloxModdingAPI/Commands/ExistingCommands.cs similarity index 96% rename from GamecraftModdingAPI/Commands/ExistingCommands.cs rename to TechbloxModdingAPI/Commands/ExistingCommands.cs index 60bd900..35dd199 100644 --- a/GamecraftModdingAPI/Commands/ExistingCommands.cs +++ b/TechbloxModdingAPI/Commands/ExistingCommands.cs @@ -2,7 +2,7 @@ using uREPL; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { public static class ExistingCommands { diff --git a/GamecraftModdingAPI/Commands/ICustomCommandEngine.cs b/TechbloxModdingAPI/Commands/ICustomCommandEngine.cs similarity index 85% rename from GamecraftModdingAPI/Commands/ICustomCommandEngine.cs rename to TechbloxModdingAPI/Commands/ICustomCommandEngine.cs index 1704e84..afb0237 100644 --- a/GamecraftModdingAPI/Commands/ICustomCommandEngine.cs +++ b/TechbloxModdingAPI/Commands/ICustomCommandEngine.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; using Svelto.ECS; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; +using TechbloxModdingAPI.Utility; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// Engine interface to handle command operations. diff --git a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine.cs b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine.cs similarity index 87% rename from GamecraftModdingAPI/Commands/SimpleCustomCommandEngine.cs rename to TechbloxModdingAPI/Commands/SimpleCustomCommandEngine.cs index 2ce60a9..87e0960 100644 --- a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine.cs +++ b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// A simple implementation of ICustomCommandEngine sufficient for most commands. @@ -37,13 +36,13 @@ namespace GamecraftModdingAPI.Commands public void Dispose() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Unregister(this.Name); } public void Ready() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Register(this.Name, this.InvokeCatchError, this.Description); } diff --git a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine1.cs b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine1.cs similarity index 86% rename from GamecraftModdingAPI/Commands/SimpleCustomCommandEngine1.cs rename to TechbloxModdingAPI/Commands/SimpleCustomCommandEngine1.cs index bac16ef..ef3bb02 100644 --- a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine1.cs +++ b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine1.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// A simple implementation of ICustomCommandEngine sufficient for most commands. @@ -28,13 +27,13 @@ namespace GamecraftModdingAPI.Commands public void Dispose() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Unregister(this.Name); } public void Ready() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Register(this.Name, this.InvokeCatchError, this.Description); } diff --git a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine2.cs b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine2.cs similarity index 86% rename from GamecraftModdingAPI/Commands/SimpleCustomCommandEngine2.cs rename to TechbloxModdingAPI/Commands/SimpleCustomCommandEngine2.cs index 4b2b38d..8127861 100644 --- a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine2.cs +++ b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine2.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// A simple implementation of ICustomCommandEngine sufficient for most commands. @@ -28,13 +27,13 @@ namespace GamecraftModdingAPI.Commands public void Dispose() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Unregister(this.Name); } public void Ready() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Register(this.Name, this.InvokeCatchError, this.Description); } diff --git a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine3.cs b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine3.cs similarity index 86% rename from GamecraftModdingAPI/Commands/SimpleCustomCommandEngine3.cs rename to TechbloxModdingAPI/Commands/SimpleCustomCommandEngine3.cs index c9c942e..9b2f6b1 100644 --- a/GamecraftModdingAPI/Commands/SimpleCustomCommandEngine3.cs +++ b/TechbloxModdingAPI/Commands/SimpleCustomCommandEngine3.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Commands +namespace TechbloxModdingAPI.Commands { /// /// A simple implementation of ICustomCommandEngine sufficient for most commands. @@ -28,13 +27,13 @@ namespace GamecraftModdingAPI.Commands public void Dispose() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Unregistering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Unregister(this.Name); } public void Ready() { - GamecraftModdingAPI.Utility.Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); + Logging.MetaDebugLog($"Registering SimpleCustomCommandEngine {this.Name}"); CommandRegistrationHelper.Register(this.Name, this.InvokeCatchError, this.Description); } diff --git a/GamecraftModdingAPI/Engines/IApiEngine.cs b/TechbloxModdingAPI/Engines/IApiEngine.cs similarity index 83% rename from GamecraftModdingAPI/Engines/IApiEngine.cs rename to TechbloxModdingAPI/Engines/IApiEngine.cs index 210c13d..6a8519a 100644 --- a/GamecraftModdingAPI/Engines/IApiEngine.cs +++ b/TechbloxModdingAPI/Engines/IApiEngine.cs @@ -6,10 +6,10 @@ using System.Threading.Tasks; using Svelto.ECS; -namespace GamecraftModdingAPI.Engines +namespace TechbloxModdingAPI.Engines { /// - /// Base engine interface used by all GamecraftModdingAPI engines + /// Base engine interface used by all TechbloxModdingAPI engines /// public interface IApiEngine : IEngine, IQueryingEntitiesEngine, IDisposable { diff --git a/GamecraftModdingAPI/Engines/IFactoryEngine.cs b/TechbloxModdingAPI/Engines/IFactoryEngine.cs similarity index 88% rename from GamecraftModdingAPI/Engines/IFactoryEngine.cs rename to TechbloxModdingAPI/Engines/IFactoryEngine.cs index 3e9c23e..d03b4e3 100644 --- a/GamecraftModdingAPI/Engines/IFactoryEngine.cs +++ b/TechbloxModdingAPI/Engines/IFactoryEngine.cs @@ -6,9 +6,9 @@ using System.Threading.Tasks; using Svelto.ECS; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Engines +namespace TechbloxModdingAPI.Engines { /// /// Engine interface to create a ModEventEntityStruct in entitiesDB when Emit() is called. diff --git a/GamecraftModdingAPI/Engines/IReactionaryEngine.cs b/TechbloxModdingAPI/Engines/IReactionaryEngine.cs similarity index 86% rename from GamecraftModdingAPI/Engines/IReactionaryEngine.cs rename to TechbloxModdingAPI/Engines/IReactionaryEngine.cs index 9381605..d627866 100644 --- a/GamecraftModdingAPI/Engines/IReactionaryEngine.cs +++ b/TechbloxModdingAPI/Engines/IReactionaryEngine.cs @@ -7,9 +7,9 @@ using System.Threading.Tasks; using Svelto.ECS; using Svelto.ECS.Internal; -using GamecraftModdingAPI.Events; +using TechbloxModdingAPI.Events; -namespace GamecraftModdingAPI.Engines +namespace TechbloxModdingAPI.Engines { /// /// Engine interface to handle ModEventEntityStruct events emitted by IEventEmitterEngines. diff --git a/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs b/TechbloxModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs similarity index 95% rename from GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs rename to TechbloxModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs index 9f16955..cf00ae0 100644 --- a/GamecraftModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs +++ b/TechbloxModdingAPI/Events/DeterministicStepComposeEngineGroupsPatch.cs @@ -10,9 +10,9 @@ using Svelto.ECS; using RobocraftX.Common; using RobocraftX.StateSync; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.StateSync.DeterministicStepCompositionRoot.ComposeEnginesGroups(...) diff --git a/GamecraftModdingAPI/Events/EmitterBuilder.cs b/TechbloxModdingAPI/Events/EmitterBuilder.cs similarity index 98% rename from GamecraftModdingAPI/Events/EmitterBuilder.cs rename to TechbloxModdingAPI/Events/EmitterBuilder.cs index c6a6879..1e5a2c2 100644 --- a/GamecraftModdingAPI/Events/EmitterBuilder.cs +++ b/TechbloxModdingAPI/Events/EmitterBuilder.cs @@ -2,7 +2,7 @@ using Svelto.ECS; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { [Obsolete] public class EmitterBuilder diff --git a/GamecraftModdingAPI/Events/EventEngineFactory.cs b/TechbloxModdingAPI/Events/EventEngineFactory.cs similarity index 98% rename from GamecraftModdingAPI/Events/EventEngineFactory.cs rename to TechbloxModdingAPI/Events/EventEngineFactory.cs index 7981303..7361053 100644 --- a/GamecraftModdingAPI/Events/EventEngineFactory.cs +++ b/TechbloxModdingAPI/Events/EventEngineFactory.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Svelto.ECS; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Convenient factories for mod event engines diff --git a/GamecraftModdingAPI/Events/EventExceptions.cs b/TechbloxModdingAPI/Events/EventExceptions.cs similarity index 96% rename from GamecraftModdingAPI/Events/EventExceptions.cs rename to TechbloxModdingAPI/Events/EventExceptions.cs index b4458bc..a796752 100644 --- a/GamecraftModdingAPI/Events/EventExceptions.cs +++ b/TechbloxModdingAPI/Events/EventExceptions.cs @@ -1,5 +1,5 @@ using System; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { public class EventException : GamecraftModdingAPIException { diff --git a/GamecraftModdingAPI/Events/EventManager.cs b/TechbloxModdingAPI/Events/EventManager.cs similarity index 96% rename from GamecraftModdingAPI/Events/EventManager.cs rename to TechbloxModdingAPI/Events/EventManager.cs index f021e9f..05b92cf 100644 --- a/GamecraftModdingAPI/Events/EventManager.cs +++ b/TechbloxModdingAPI/Events/EventManager.cs @@ -5,16 +5,15 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Keeps track of event handlers and emitters. /// This is used to add, remove and get API event handlers and emitters. /// - [Obsolete("This will be removed in an upcoming update. Use the new C# event architecture from GamecraftModdingAPI.App")] + [Obsolete("This will be removed in an upcoming update. Use the new C# event architecture from TechbloxModdingAPI.App")] public static class EventManager { private static Dictionary _eventEmitters = new Dictionary(); diff --git a/GamecraftModdingAPI/Events/EventType.cs b/TechbloxModdingAPI/Events/EventType.cs similarity index 92% rename from GamecraftModdingAPI/Events/EventType.cs rename to TechbloxModdingAPI/Events/EventType.cs index 468e214..3f826cc 100644 --- a/GamecraftModdingAPI/Events/EventType.cs +++ b/TechbloxModdingAPI/Events/EventType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Built-in event types. diff --git a/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs similarity index 96% rename from GamecraftModdingAPI/Events/GameActivatedComposePatch.cs rename to TechbloxModdingAPI/Events/GameActivatedComposePatch.cs index c3a5fb5..62b5666 100644 --- a/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs +++ b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs @@ -9,10 +9,9 @@ using HarmonyLib; using RobocraftX.CR.MainGame; using Svelto.ECS; using Unity.Entities; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame() diff --git a/GamecraftModdingAPI/Events/GameReloadedPatch.cs b/TechbloxModdingAPI/Events/GameReloadedPatch.cs similarity index 87% rename from GamecraftModdingAPI/Events/GameReloadedPatch.cs rename to TechbloxModdingAPI/Events/GameReloadedPatch.cs index 7228084..5deb9ee 100644 --- a/GamecraftModdingAPI/Events/GameReloadedPatch.cs +++ b/TechbloxModdingAPI/Events/GameReloadedPatch.cs @@ -7,9 +7,9 @@ using System.Threading.Tasks; using HarmonyLib; using RobocraftX; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.ReloadGame() diff --git a/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs b/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs similarity index 95% rename from GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs rename to TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs index 725f544..29fb418 100644 --- a/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs @@ -4,10 +4,9 @@ using Unity.Jobs; using RobocraftX.SimulationModeState; using RobocraftX.StateSync; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Event emitter engine for switching to to build mode. diff --git a/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs b/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs similarity index 95% rename from GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs rename to TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs index 6e6e2ce..add45d5 100644 --- a/GamecraftModdingAPI/Events/GameStateSimulationEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs @@ -4,10 +4,9 @@ using Unity.Jobs; using RobocraftX.SimulationModeState; using RobocraftX.StateSync; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Event emitter engine for switching to simulation mode. diff --git a/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs b/TechbloxModdingAPI/Events/GameSwitchedToPatch.cs similarity index 90% rename from GamecraftModdingAPI/Events/GameSwitchedToPatch.cs rename to TechbloxModdingAPI/Events/GameSwitchedToPatch.cs index dbd63c0..f45eb0b 100644 --- a/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs +++ b/TechbloxModdingAPI/Events/GameSwitchedToPatch.cs @@ -10,9 +10,9 @@ using RobocraftX; using RobocraftX.CR.MainGame; using Svelto.ECS; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame() diff --git a/GamecraftModdingAPI/Events/HandlerBuilder.cs b/TechbloxModdingAPI/Events/HandlerBuilder.cs similarity index 99% rename from GamecraftModdingAPI/Events/HandlerBuilder.cs rename to TechbloxModdingAPI/Events/HandlerBuilder.cs index 10f3290..f726d0a 100644 --- a/GamecraftModdingAPI/Events/HandlerBuilder.cs +++ b/TechbloxModdingAPI/Events/HandlerBuilder.cs @@ -2,7 +2,7 @@ using Svelto.ECS; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { [Obsolete] public class HandlerBuilder diff --git a/GamecraftModdingAPI/Events/IEventEmitterEngine.cs b/TechbloxModdingAPI/Events/IEventEmitterEngine.cs similarity index 86% rename from GamecraftModdingAPI/Events/IEventEmitterEngine.cs rename to TechbloxModdingAPI/Events/IEventEmitterEngine.cs index 8917cef..1ae89d2 100644 --- a/GamecraftModdingAPI/Events/IEventEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/IEventEmitterEngine.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Engine interface to create a ModEventEntityStruct in entitiesDB when a specific event occurs. diff --git a/GamecraftModdingAPI/Events/IEventHandlerEngine.cs b/TechbloxModdingAPI/Events/IEventHandlerEngine.cs similarity index 84% rename from GamecraftModdingAPI/Events/IEventHandlerEngine.cs rename to TechbloxModdingAPI/Events/IEventHandlerEngine.cs index 228adb8..003b6c5 100644 --- a/GamecraftModdingAPI/Events/IEventHandlerEngine.cs +++ b/TechbloxModdingAPI/Events/IEventHandlerEngine.cs @@ -6,10 +6,9 @@ using System.Threading.Tasks; using Svelto.ECS; using Svelto.ECS.Internal; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Engine interface to handle ModEventEntityStruct events emitted by IEventEmitterEngines. diff --git a/GamecraftModdingAPI/Events/MenuActivatedPatch.cs b/TechbloxModdingAPI/Events/MenuActivatedPatch.cs similarity index 95% rename from GamecraftModdingAPI/Events/MenuActivatedPatch.cs rename to TechbloxModdingAPI/Events/MenuActivatedPatch.cs index 382bac4..64aa57f 100644 --- a/GamecraftModdingAPI/Events/MenuActivatedPatch.cs +++ b/TechbloxModdingAPI/Events/MenuActivatedPatch.cs @@ -7,10 +7,9 @@ using System.Threading.Tasks; using HarmonyLib; using RobocraftX; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.ActivateMenu() diff --git a/GamecraftModdingAPI/Events/MenuSwitchedToPatch.cs b/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs similarity index 90% rename from GamecraftModdingAPI/Events/MenuSwitchedToPatch.cs rename to TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs index 30b84da..c8fec0a 100644 --- a/GamecraftModdingAPI/Events/MenuSwitchedToPatch.cs +++ b/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs @@ -7,10 +7,9 @@ using System.Threading.Tasks; using HarmonyLib; using RobocraftX; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.SwitchToMenu() diff --git a/GamecraftModdingAPI/Events/ModEventEntityDescriptor.cs b/TechbloxModdingAPI/Events/ModEventEntityDescriptor.cs similarity index 90% rename from GamecraftModdingAPI/Events/ModEventEntityDescriptor.cs rename to TechbloxModdingAPI/Events/ModEventEntityDescriptor.cs index 5172d9c..a4b2235 100644 --- a/GamecraftModdingAPI/Events/ModEventEntityDescriptor.cs +++ b/TechbloxModdingAPI/Events/ModEventEntityDescriptor.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Svelto.ECS; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// EntityDescriptor for creating ModEventEntityStructs diff --git a/GamecraftModdingAPI/Events/ModEventEntityStruct.cs b/TechbloxModdingAPI/Events/ModEventEntityStruct.cs similarity index 92% rename from GamecraftModdingAPI/Events/ModEventEntityStruct.cs rename to TechbloxModdingAPI/Events/ModEventEntityStruct.cs index cc945ec..9b92bf3 100644 --- a/GamecraftModdingAPI/Events/ModEventEntityStruct.cs +++ b/TechbloxModdingAPI/Events/ModEventEntityStruct.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Svelto.ECS; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// The event entity struct diff --git a/GamecraftModdingAPI/Events/SimpleEventEmitterEngine.cs b/TechbloxModdingAPI/Events/SimpleEventEmitterEngine.cs similarity index 96% rename from GamecraftModdingAPI/Events/SimpleEventEmitterEngine.cs rename to TechbloxModdingAPI/Events/SimpleEventEmitterEngine.cs index 0ea8170..f80eda1 100644 --- a/GamecraftModdingAPI/Events/SimpleEventEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/SimpleEventEmitterEngine.cs @@ -5,9 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// A simple implementation of IEventEmitterEngine sufficient for most uses diff --git a/GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs b/TechbloxModdingAPI/Events/SimpleEventHandlerEngine.cs similarity index 98% rename from GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs rename to TechbloxModdingAPI/Events/SimpleEventHandlerEngine.cs index ebce21d..7cfd979 100644 --- a/GamecraftModdingAPI/Events/SimpleEventHandlerEngine.cs +++ b/TechbloxModdingAPI/Events/SimpleEventHandlerEngine.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Events +namespace TechbloxModdingAPI.Events { /// /// A simple implementation of IEventHandlerEngine sufficient for most uses diff --git a/GamecraftModdingAPI/FlyCam.cs b/TechbloxModdingAPI/FlyCam.cs similarity index 97% rename from GamecraftModdingAPI/FlyCam.cs rename to TechbloxModdingAPI/FlyCam.cs index be9955f..b72b174 100644 --- a/GamecraftModdingAPI/FlyCam.cs +++ b/TechbloxModdingAPI/FlyCam.cs @@ -1,13 +1,12 @@ -using GamecraftModdingAPI.Players; -using GamecraftModdingAPI.Utility; - using RobocraftX.Physics; using Svelto.ECS.EntityStructs; using Techblox.FlyCam; +using TechbloxModdingAPI.Players; +using TechbloxModdingAPI.Utility; using Unity.Mathematics; using UnityEngine; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { public class FlyCam { diff --git a/GamecraftModdingAPI/GamecraftModdingAPIException.cs b/TechbloxModdingAPI/GamecraftModdingAPIException.cs similarity index 94% rename from GamecraftModdingAPI/GamecraftModdingAPIException.cs rename to TechbloxModdingAPI/GamecraftModdingAPIException.cs index bc944aa..0b4f7d5 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPIException.cs +++ b/TechbloxModdingAPI/GamecraftModdingAPIException.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.Serialization; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { public class GamecraftModdingAPIException : Exception { diff --git a/GamecraftModdingAPI/Input/FakeInput.cs b/TechbloxModdingAPI/Input/FakeInput.cs similarity index 99% rename from GamecraftModdingAPI/Input/FakeInput.cs rename to TechbloxModdingAPI/Input/FakeInput.cs index 031a841..6104a4e 100644 --- a/GamecraftModdingAPI/Input/FakeInput.cs +++ b/TechbloxModdingAPI/Input/FakeInput.cs @@ -3,10 +3,9 @@ using RobocraftX.Common; using RobocraftX.Common.Input; using Svelto.ECS; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Input +namespace TechbloxModdingAPI.Input { public static class FakeInput { diff --git a/GamecraftModdingAPI/Input/FakeInputEngine.cs b/TechbloxModdingAPI/Input/FakeInputEngine.cs similarity index 96% rename from GamecraftModdingAPI/Input/FakeInputEngine.cs rename to TechbloxModdingAPI/Input/FakeInputEngine.cs index 9b85c97..0a41fb2 100644 --- a/GamecraftModdingAPI/Input/FakeInputEngine.cs +++ b/TechbloxModdingAPI/Input/FakeInputEngine.cs @@ -5,10 +5,10 @@ using RobocraftX.Common.Input; using RobocraftX.Players; using Svelto.ECS; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; +using TechbloxModdingAPI.Utility; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Input +namespace TechbloxModdingAPI.Input { public class FakeInputEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Interface/IMGUI/Button.cs b/TechbloxModdingAPI/Interface/IMGUI/Button.cs similarity index 98% rename from GamecraftModdingAPI/Interface/IMGUI/Button.cs rename to TechbloxModdingAPI/Interface/IMGUI/Button.cs index 5a119f6..de8e7cc 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Button.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Button.cs @@ -2,7 +2,7 @@ using System; using Unity.Mathematics; using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// A clickable button. diff --git a/GamecraftModdingAPI/Interface/IMGUI/Constants.cs b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs similarity index 98% rename from GamecraftModdingAPI/Interface/IMGUI/Constants.cs rename to TechbloxModdingAPI/Interface/IMGUI/Constants.cs index 42a7f18..a34d8fe 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Constants.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs @@ -3,7 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Reflection; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; using HarmonyLib; using Svelto.Tasks; using Svelto.Tasks.Lean; @@ -11,7 +11,7 @@ using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// Convenient IMGUI values. diff --git a/GamecraftModdingAPI/Interface/IMGUI/Group.cs b/TechbloxModdingAPI/Interface/IMGUI/Group.cs similarity index 96% rename from GamecraftModdingAPI/Interface/IMGUI/Group.cs rename to TechbloxModdingAPI/Interface/IMGUI/Group.cs index 7033dee..bbbbdf1 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Group.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Group.cs @@ -1,9 +1,9 @@ using System; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; using Svelto.DataStructures; using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// A group of elements. @@ -80,7 +80,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The rectangular area to use in the window. /// Name of the group. diff --git a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs b/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs similarity index 97% rename from GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs rename to TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs index a4bb6d2..d4f3bb7 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/IMGUIManager.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs @@ -1,8 +1,8 @@ using System; using System.Collections; using System.Collections.Generic; -using GamecraftModdingAPI.App; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.App; +using TechbloxModdingAPI.Utility; using Rewired.Internal; using Svelto.DataStructures; using Svelto.Tasks; @@ -10,7 +10,7 @@ using Svelto.Tasks.ExtraLean; using Svelto.Tasks.ExtraLean.Unity; using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// Keeps track of UIElement instances. diff --git a/GamecraftModdingAPI/Interface/IMGUI/Image.cs b/TechbloxModdingAPI/Interface/IMGUI/Image.cs similarity index 89% rename from GamecraftModdingAPI/Interface/IMGUI/Image.cs rename to TechbloxModdingAPI/Interface/IMGUI/Image.cs index b4fac9f..2bea1f4 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Image.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Image.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// An image. @@ -44,7 +44,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI public bool Enabled { set; get; } = true; /// - /// Initializes a new instance of the class with automatic layout. + /// Initializes a new instance of the class with automatic layout. /// /// Image to display. /// The element's name. @@ -72,7 +72,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Rectangular area for the image. /// Image to display. diff --git a/GamecraftModdingAPI/Interface/IMGUI/Label.cs b/TechbloxModdingAPI/Interface/IMGUI/Label.cs similarity index 88% rename from GamecraftModdingAPI/Interface/IMGUI/Label.cs rename to TechbloxModdingAPI/Interface/IMGUI/Label.cs index 2483e3d..960a6ca 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Label.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Label.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// A simple text label. @@ -43,7 +43,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI public bool Enabled { set; get; } = true; /// - /// Initializes a new instance of the class with automatic layout. + /// Initializes a new instance of the class with automatic layout. /// /// Initial string to display on the label. /// The element's name. @@ -63,7 +63,7 @@ namespace GamecraftModdingAPI.Interface.IMGUI } /// - /// Initializes a new instance of the . + /// Initializes a new instance of the . /// /// Rectangular area for the label. /// Initial string to display on the label. diff --git a/GamecraftModdingAPI/Interface/IMGUI/Text.cs b/TechbloxModdingAPI/Interface/IMGUI/Text.cs similarity index 98% rename from GamecraftModdingAPI/Interface/IMGUI/Text.cs rename to TechbloxModdingAPI/Interface/IMGUI/Text.cs index 1b94804..bdf6738 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/Text.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Text.cs @@ -1,7 +1,7 @@ using System; using UnityEngine; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// A text input field. diff --git a/GamecraftModdingAPI/Interface/IMGUI/UIElement.cs b/TechbloxModdingAPI/Interface/IMGUI/UIElement.cs similarity index 94% rename from GamecraftModdingAPI/Interface/IMGUI/UIElement.cs rename to TechbloxModdingAPI/Interface/IMGUI/UIElement.cs index abaed6e..dd66af6 100644 --- a/GamecraftModdingAPI/Interface/IMGUI/UIElement.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/UIElement.cs @@ -1,6 +1,6 @@ using System; -namespace GamecraftModdingAPI.Interface.IMGUI +namespace TechbloxModdingAPI.Interface.IMGUI { /// /// GUI Element like a text field, button or picture. diff --git a/GamecraftModdingAPI/Inventory/Hotbar.cs b/TechbloxModdingAPI/Inventory/Hotbar.cs similarity index 92% rename from GamecraftModdingAPI/Inventory/Hotbar.cs rename to TechbloxModdingAPI/Inventory/Hotbar.cs index 838c554..92bca86 100644 --- a/GamecraftModdingAPI/Inventory/Hotbar.cs +++ b/TechbloxModdingAPI/Inventory/Hotbar.cs @@ -2,12 +2,11 @@ using RobocraftX.Common.Input; using RobocraftX.Multiplayer.Input; - -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Utility; using HarmonyLib; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Inventory +namespace TechbloxModdingAPI.Inventory { public static class Hotbar { diff --git a/GamecraftModdingAPI/Inventory/HotbarEngine.cs b/TechbloxModdingAPI/Inventory/HotbarEngine.cs similarity index 88% rename from GamecraftModdingAPI/Inventory/HotbarEngine.cs rename to TechbloxModdingAPI/Inventory/HotbarEngine.cs index b20928b..764f535 100644 --- a/GamecraftModdingAPI/Inventory/HotbarEngine.cs +++ b/TechbloxModdingAPI/Inventory/HotbarEngine.cs @@ -8,13 +8,13 @@ using RobocraftX.Common.Input; using RobocraftX.Common.Players; using Svelto.ECS; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Engines; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; using RobocraftX.Blocks; using Techblox.FlyCam; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Inventory +namespace TechbloxModdingAPI.Inventory { public class HotbarEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs b/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs similarity index 90% rename from GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs rename to TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs index 153d82c..1a068f0 100644 --- a/GamecraftModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs +++ b/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs @@ -4,9 +4,9 @@ using System.Reflection; using Svelto.ECS; using HarmonyLib; -using GamecraftModdingAPI.Blocks; +using TechbloxModdingAPI.Blocks; -namespace GamecraftModdingAPI.Inventory +namespace TechbloxModdingAPI.Inventory { [HarmonyPatch] public class HotbarSlotSelectionHandlerEnginePatch diff --git a/GamecraftModdingAPI/Main.cs b/TechbloxModdingAPI/Main.cs similarity index 87% rename from GamecraftModdingAPI/Main.cs rename to TechbloxModdingAPI/Main.cs index 57349de..b81e127 100644 --- a/GamecraftModdingAPI/Main.cs +++ b/TechbloxModdingAPI/Main.cs @@ -7,16 +7,16 @@ using RobocraftX.Schedulers; using RobocraftX.Services; using Svelto.Context; using Svelto.Tasks.ExtraLean; +using TechbloxModdingAPI.App; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Events; +using TechbloxModdingAPI.Tasks; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Events; -using GamecraftModdingAPI.Tasks; - -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// - /// The main class of the GamecraftModdingAPI. + /// The main class of the TechbloxModdingAPI. /// Use this to initialize the API before calling it. /// public static class Main @@ -30,7 +30,7 @@ namespace GamecraftModdingAPI private static int referenceCount = 0; /// - /// Initializes the GamecraftModdingAPI. + /// Initializes the TechbloxModdingAPI. /// Call this as soon as possible after Gamecraft starts up. /// Ideally, this should be called from your main Plugin class's OnApplicationStart() method. /// @@ -40,7 +40,7 @@ namespace GamecraftModdingAPI if (referenceCount > 1) { return; } if (IsInitialized) { - Logging.LogWarning("GamecraftModdingAPI.Main.Init() called but API is already initialized!"); + Logging.LogWarning("TechbloxModdingAPI.Main.Init() called but API is already initialized!"); return; } Logging.MetaDebugLog($"Patching Gamecraft"); @@ -89,8 +89,8 @@ namespace GamecraftModdingAPI Wire.Init(); GameClient.Init(); AsyncUtils.Init(); - GamecraftModdingAPI.App.Client.Init(); - GamecraftModdingAPI.App.Game.Init(); + Client.Init(); + Game.Init(); //CustomBlock.Init(); // init UI Interface.IMGUI.Constants.Init(); @@ -99,7 +99,7 @@ namespace GamecraftModdingAPI } /// - /// Shuts down & cleans up the GamecraftModdingAPI. + /// Shuts down & cleans up the TechbloxModdingAPI. /// Call this as late as possible before Gamecraft quits. /// Ideally, this should be called from your main Plugin class's OnApplicationQuit() method. /// @@ -110,7 +110,7 @@ namespace GamecraftModdingAPI { if (!IsInitialized) { - Logging.LogWarning("GamecraftModdingAPI.Main.Shutdown() called but API is not initialized!"); + Logging.LogWarning("TechbloxModdingAPI.Main.Shutdown() called but API is not initialized!"); return; } Scheduler.Dispose(); @@ -124,7 +124,7 @@ namespace GamecraftModdingAPI private static void OnPatchError() { ErrorBuilder.DisplayMustQuitError("Failed to patch Techblox!\n" + - "Make sure you're using the latest version of GamecraftModdingAPI or disable mods if the API isn't released yet."); + "Make sure you're using the latest version of TechbloxModdingAPI or disable mods if the API isn't released yet."); } } } diff --git a/GamecraftModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs similarity index 97% rename from GamecraftModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs rename to TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs index 0ff675f..f436e56 100644 --- a/GamecraftModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs @@ -8,9 +8,9 @@ using Svelto.ECS; using Svelto.ECS.Serialization; using HarmonyLib; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { [HarmonyPatch] class DeserializeFromDiskEntitiesEnginePatch diff --git a/GamecraftModdingAPI/Persistence/IEntitySerializer.cs b/TechbloxModdingAPI/Persistence/IEntitySerializer.cs similarity index 94% rename from GamecraftModdingAPI/Persistence/IEntitySerializer.cs rename to TechbloxModdingAPI/Persistence/IEntitySerializer.cs index 5c4fb85..e7fcd5c 100644 --- a/GamecraftModdingAPI/Persistence/IEntitySerializer.cs +++ b/TechbloxModdingAPI/Persistence/IEntitySerializer.cs @@ -3,9 +3,9 @@ using Svelto.ECS; using Svelto.ECS.Serialization; -using GamecraftModdingAPI.Utility; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { /// /// Entity serializer and deserializer interface for storing and retrieving data in a Gamecraft save file (GameSave.GC). diff --git a/GamecraftModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs b/TechbloxModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs similarity index 90% rename from GamecraftModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs rename to TechbloxModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs index 58f5708..b3ae6de 100644 --- a/GamecraftModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs +++ b/TechbloxModdingAPI/Persistence/SaveAndLoadCompositionRootPatch.cs @@ -5,7 +5,7 @@ using Svelto.ECS; using HarmonyLib; -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { [HarmonyPatch(typeof(SaveAndLoadCompositionRoot), "Compose")] class SaveAndLoadCompositionRootPatch diff --git a/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs similarity index 94% rename from GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs rename to TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs index 0145c09..74edddf 100644 --- a/GamecraftModdingAPI/Persistence/SaveGameEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs @@ -7,11 +7,10 @@ using RobocraftX.SaveAndLoad; using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Serialization; - -using GamecraftModdingAPI.Utility; using HarmonyLib; +using TechbloxModdingAPI.Utility; -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { //[HarmonyPatch] - TODO class SaveGameEnginePatch @@ -30,7 +29,7 @@ namespace GamecraftModdingAPI.Persistence BinaryBufferWriter bbw = new BinaryBufferWriter(serializationData.data.ToArrayFast(out uint buffLen), serializationData.dataPos); uint originalPos = serializationData.dataPos; Logging.MetaDebugLog($"dataPos: {originalPos}"); - // Add frame start so it's easier to find GamecraftModdingAPI-serialized components + // Add frame start so it's easier to find TechbloxModdingAPI-serialized components for (int i = 0; i < frameStart.Length; i++) { bbw.Write(frameStart[i]); diff --git a/GamecraftModdingAPI/Persistence/SerializerManager.cs b/TechbloxModdingAPI/Persistence/SerializerManager.cs similarity index 96% rename from GamecraftModdingAPI/Persistence/SerializerManager.cs rename to TechbloxModdingAPI/Persistence/SerializerManager.cs index 161662b..6177d7c 100644 --- a/GamecraftModdingAPI/Persistence/SerializerManager.cs +++ b/TechbloxModdingAPI/Persistence/SerializerManager.cs @@ -4,10 +4,9 @@ using System.Linq; using Svelto.ECS; using Svelto.ECS.Serialization; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { /// /// Keeps track of serializers. diff --git a/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs b/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs similarity index 98% rename from GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs rename to TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs index 59fd9fd..7f605c3 100644 --- a/GamecraftModdingAPI/Persistence/SimpleEntitySerializer.cs +++ b/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs @@ -5,7 +5,7 @@ using Svelto.ECS.Serialization; using RobocraftX.Common; -namespace GamecraftModdingAPI.Persistence +namespace TechbloxModdingAPI.Persistence { /// /// Simple entity serializer sufficient for simple entity components. diff --git a/GamecraftModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs similarity index 97% rename from GamecraftModdingAPI/Player.cs rename to TechbloxModdingAPI/Player.cs index 8b204d0..2c6b122 100644 --- a/GamecraftModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -3,11 +3,10 @@ using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; using Svelto.ECS; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Players; -using GamecraftModdingAPI.Players; -using GamecraftModdingAPI.Blocks; - -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// An in-game player character. Any Leo you see is a player. @@ -68,7 +67,7 @@ namespace GamecraftModdingAPI } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The player's unique identifier. public Player(uint id) @@ -82,7 +81,7 @@ namespace GamecraftModdingAPI } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The player type. Chooses the first available player matching the criteria. public Player(PlayerType player) @@ -252,7 +251,7 @@ namespace GamecraftModdingAPI } /// - /// Whether this is damageable. + /// Whether this is damageable. /// /// true if damageable; otherwise, false. public bool Damageable diff --git a/GamecraftModdingAPI/Players/FlyCamEngine.cs b/TechbloxModdingAPI/Players/FlyCamEngine.cs similarity index 90% rename from GamecraftModdingAPI/Players/FlyCamEngine.cs rename to TechbloxModdingAPI/Players/FlyCamEngine.cs index b8f8cf4..0b98071 100644 --- a/GamecraftModdingAPI/Players/FlyCamEngine.cs +++ b/TechbloxModdingAPI/Players/FlyCamEngine.cs @@ -1,8 +1,8 @@ -using GamecraftModdingAPI.Engines; using Svelto.ECS; using Techblox.FlyCam; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { public class FlyCamEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Players/PlayerBuildingMode.cs b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs similarity index 75% rename from GamecraftModdingAPI/Players/PlayerBuildingMode.cs rename to TechbloxModdingAPI/Players/PlayerBuildingMode.cs index c7a5e37..383e1af 100644 --- a/GamecraftModdingAPI/Players/PlayerBuildingMode.cs +++ b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs @@ -1,4 +1,4 @@ -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { public enum PlayerBuildingMode { diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs similarity index 99% rename from GamecraftModdingAPI/Players/PlayerEngine.cs rename to TechbloxModdingAPI/Players/PlayerEngine.cs index dfdb580..cc24650 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -17,13 +17,12 @@ using Techblox.FlyCam; using Unity.Mathematics; using Unity.Physics; using UnityEngine; - -using GamecraftModdingAPI.Engines; using HarmonyLib; using RobocraftX.Common; using Svelto.ECS.DataStructures; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { internal class PlayerEngine : IApiEngine, IFactoryEngine { diff --git a/GamecraftModdingAPI/Players/PlayerExceptions.cs b/TechbloxModdingAPI/Players/PlayerExceptions.cs similarity index 92% rename from GamecraftModdingAPI/Players/PlayerExceptions.cs rename to TechbloxModdingAPI/Players/PlayerExceptions.cs index 94312b9..d5bba55 100644 --- a/GamecraftModdingAPI/Players/PlayerExceptions.cs +++ b/TechbloxModdingAPI/Players/PlayerExceptions.cs @@ -1,5 +1,5 @@ using System; -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { public class PlayerException : GamecraftModdingAPIException { diff --git a/GamecraftModdingAPI/Players/PlayerTests.cs b/TechbloxModdingAPI/Players/PlayerTests.cs similarity index 94% rename from GamecraftModdingAPI/Players/PlayerTests.cs rename to TechbloxModdingAPI/Players/PlayerTests.cs index 1af7992..8086d96 100644 --- a/GamecraftModdingAPI/Players/PlayerTests.cs +++ b/TechbloxModdingAPI/Players/PlayerTests.cs @@ -2,10 +2,10 @@ using Unity.Mathematics; -using GamecraftModdingAPI; -using GamecraftModdingAPI.Tests; +using TechbloxModdingAPI; +using TechbloxModdingAPI.Tests; -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { #if TEST /// diff --git a/GamecraftModdingAPI/Players/PlayerType.cs b/TechbloxModdingAPI/Players/PlayerType.cs similarity index 70% rename from GamecraftModdingAPI/Players/PlayerType.cs rename to TechbloxModdingAPI/Players/PlayerType.cs index 0b4966c..3e2214f 100644 --- a/GamecraftModdingAPI/Players/PlayerType.cs +++ b/TechbloxModdingAPI/Players/PlayerType.cs @@ -1,5 +1,5 @@ using System; -namespace GamecraftModdingAPI.Players +namespace TechbloxModdingAPI.Players { public enum PlayerType { diff --git a/GamecraftModdingAPI/SimBody.cs b/TechbloxModdingAPI/SimBody.cs similarity index 99% rename from GamecraftModdingAPI/SimBody.cs rename to TechbloxModdingAPI/SimBody.cs index 42812d9..dd7429e 100644 --- a/GamecraftModdingAPI/SimBody.cs +++ b/TechbloxModdingAPI/SimBody.cs @@ -7,7 +7,7 @@ using Gamecraft.Damage; using RobocraftX.Common; using RobocraftX.Physics; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { /// /// A rigid body (like a chunk of connected blocks) during simulation. diff --git a/GamecraftModdingAPI/Tasks/ISchedulable.cs b/TechbloxModdingAPI/Tasks/ISchedulable.cs similarity index 92% rename from GamecraftModdingAPI/Tasks/ISchedulable.cs rename to TechbloxModdingAPI/Tasks/ISchedulable.cs index 0b04a3e..679e999 100644 --- a/GamecraftModdingAPI/Tasks/ISchedulable.cs +++ b/TechbloxModdingAPI/Tasks/ISchedulable.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Svelto.Tasks; -namespace GamecraftModdingAPI.Tasks +namespace TechbloxModdingAPI.Tasks { /// /// Interface for asynchronous tasks diff --git a/GamecraftModdingAPI/Tasks/Once.cs b/TechbloxModdingAPI/Tasks/Once.cs similarity index 96% rename from GamecraftModdingAPI/Tasks/Once.cs rename to TechbloxModdingAPI/Tasks/Once.cs index 52651e6..807dae7 100644 --- a/GamecraftModdingAPI/Tasks/Once.cs +++ b/TechbloxModdingAPI/Tasks/Once.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Svelto.Tasks; using Svelto.Tasks.Enumerators; -namespace GamecraftModdingAPI.Tasks +namespace TechbloxModdingAPI.Tasks { /// /// An asynchronous task to be performed once. diff --git a/GamecraftModdingAPI/Tasks/Repeatable.cs b/TechbloxModdingAPI/Tasks/Repeatable.cs similarity index 98% rename from GamecraftModdingAPI/Tasks/Repeatable.cs rename to TechbloxModdingAPI/Tasks/Repeatable.cs index 0b9982e..0cafe48 100644 --- a/GamecraftModdingAPI/Tasks/Repeatable.cs +++ b/TechbloxModdingAPI/Tasks/Repeatable.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Svelto.Tasks; using Svelto.Tasks.Enumerators; -namespace GamecraftModdingAPI.Tasks +namespace TechbloxModdingAPI.Tasks { /// /// An asynchronous repeating task. diff --git a/GamecraftModdingAPI/Tasks/Scheduler.cs b/TechbloxModdingAPI/Tasks/Scheduler.cs similarity index 98% rename from GamecraftModdingAPI/Tasks/Scheduler.cs rename to TechbloxModdingAPI/Tasks/Scheduler.cs index 803bd2f..af47d1d 100644 --- a/GamecraftModdingAPI/Tasks/Scheduler.cs +++ b/TechbloxModdingAPI/Tasks/Scheduler.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using Svelto.Tasks.Lean; using Svelto.Tasks.ExtraLean; -namespace GamecraftModdingAPI.Tasks +namespace TechbloxModdingAPI.Tasks { /// /// Asynchronous task scheduling for ISchedulables. diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj similarity index 99% rename from GamecraftModdingAPI/GamecraftModdingAPI.csproj rename to TechbloxModdingAPI/TechbloxModdingAPI.csproj index bd4135c..4624c80 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -8,6 +8,7 @@ https://git.exmods.org/modtainers/GamecraftModdingAPI en-CA true + GamecraftModdingAPI diff --git a/GamecraftModdingAPI/Tests/APITestAttributes.cs b/TechbloxModdingAPI/Tests/APITestAttributes.cs similarity index 97% rename from GamecraftModdingAPI/Tests/APITestAttributes.cs rename to TechbloxModdingAPI/Tests/APITestAttributes.cs index cf9da49..0ebe81d 100644 --- a/GamecraftModdingAPI/Tests/APITestAttributes.cs +++ b/TechbloxModdingAPI/Tests/APITestAttributes.cs @@ -1,5 +1,5 @@ using System; -namespace GamecraftModdingAPI.Tests +namespace TechbloxModdingAPI.Tests { /// /// Test type. diff --git a/GamecraftModdingAPI/Tests/Assert.cs b/TechbloxModdingAPI/Tests/Assert.cs similarity index 99% rename from GamecraftModdingAPI/Tests/Assert.cs rename to TechbloxModdingAPI/Tests/Assert.cs index edc1392..f71b132 100644 --- a/GamecraftModdingAPI/Tests/Assert.cs +++ b/TechbloxModdingAPI/Tests/Assert.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; using Unity.Mathematics; -namespace GamecraftModdingAPI.Tests +namespace TechbloxModdingAPI.Tests { /// /// API test system assertion utilities. diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs similarity index 94% rename from GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs rename to TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 75079a8..292f769 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; -using GamecraftModdingAPI.App; +using TechbloxModdingAPI.App; using HarmonyLib; using IllusionInjector; // test @@ -21,15 +21,8 @@ using UnityEngine; using RobocraftX.Schedulers; using Svelto.Tasks.ExtraLean; using uREPL; - -using GamecraftModdingAPI.Commands; -using GamecraftModdingAPI.Events; -using GamecraftModdingAPI.Utility; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Input; -using GamecraftModdingAPI.Interface.IMGUI; -using GamecraftModdingAPI.Players; -using GamecraftModdingAPI.Tasks; +using TechbloxModdingAPI.Interface.IMGUI; +using TechbloxModdingAPI.Tasks; using RobocraftX.Common.Input; using RobocraftX.CR.MainGame; using RobocraftX.GUI.CommandLine; @@ -38,23 +31,29 @@ using RobocraftX.StateSync; using Svelto.Context; using Svelto.DataStructures; using Svelto.Services; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Commands; +using TechbloxModdingAPI.Events; +using TechbloxModdingAPI.Input; +using TechbloxModdingAPI.Players; +using TechbloxModdingAPI.Utility; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.ResourceManagement.ResourceProviders; using Debug = FMOD.Debug; -using EventType = GamecraftModdingAPI.Events.EventType; -using Label = GamecraftModdingAPI.Interface.IMGUI.Label; +using EventType = TechbloxModdingAPI.Events.EventType; +using Label = TechbloxModdingAPI.Interface.IMGUI.Label; using ScalingPermission = DataLoader.ScalingPermission; -namespace GamecraftModdingAPI.Tests +namespace TechbloxModdingAPI.Tests { #if DEBUG // unused by design /// /// Modding API implemented as a standalone IPA Plugin. - /// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself + /// Ideally, TechbloxModdingAPI should be loaded by another mod; not itself /// public class GamecraftModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin { @@ -69,14 +68,14 @@ namespace GamecraftModdingAPI.Tests public override void OnApplicationQuit() { - GamecraftModdingAPI.Main.Shutdown(); + Main.Shutdown(); } public override void OnApplicationStart() { FileLog.Reset(); Harmony.DEBUG = true; - GamecraftModdingAPI.Main.Init(); + Main.Init(); Logging.MetaDebugLog($"Version group id {(uint)ApiExclusiveGroups.versionGroup}"); // in case Steam is not installed/running // this will crash the game slightly later during startup @@ -173,7 +172,7 @@ namespace GamecraftModdingAPI.Tests foreach (var block in Block.GetLastPlacedBlock().GetConnectedCubes()) block.Position += new Unity.Mathematics.float3(x, y, z); else - GamecraftModdingAPI.Utility.Logging.CommandLogError("Blocks can only be moved in Build mode!"); + Logging.CommandLogError("Blocks can only be moved in Build mode!"); }).Build(); CommandBuilder.Builder() @@ -328,12 +327,12 @@ namespace GamecraftModdingAPI.Tests "SetFOV", "Set the player camera's field of view")); CommandManager.AddCommand(new SimpleCustomCommandEngine( (x, y, z) => { - bool success = GamecraftModdingAPI.Blocks.Movement.MoveConnectedBlocks( - GamecraftModdingAPI.Blocks.BlockIdentifiers.LatestBlockID, + bool success = TechbloxModdingAPI.Blocks.Movement.MoveConnectedBlocks( + TechbloxModdingAPI.Blocks.BlockIdentifiers.LatestBlockID, new Unity.Mathematics.float3(x, y, z)); if (!success) { - GamecraftModdingAPI.Utility.Logging.CommandLogError("Blocks can only be moved in Build mode!"); + TechbloxModdingAPI.Utility.Logging.CommandLogError("Blocks can only be moved in Build mode!"); } }, "MoveLastBlock", "Move the most-recently-placed block, and any connected blocks by the given offset")); CommandManager.AddCommand(new SimpleCustomCommandEngine( diff --git a/GamecraftModdingAPI/Tests/TestRoot.cs b/TechbloxModdingAPI/Tests/TestRoot.cs similarity index 96% rename from GamecraftModdingAPI/Tests/TestRoot.cs rename to TechbloxModdingAPI/Tests/TestRoot.cs index 22f3035..878fdda 100644 --- a/GamecraftModdingAPI/Tests/TestRoot.cs +++ b/TechbloxModdingAPI/Tests/TestRoot.cs @@ -8,12 +8,11 @@ using Svelto.Tasks; using Svelto.Tasks.Lean; using Svelto.Tasks.Enumerators; using UnityEngine; +using TechbloxModdingAPI.App; +using TechbloxModdingAPI.Tasks; +using TechbloxModdingAPI.Utility; -using GamecraftModdingAPI.App; -using GamecraftModdingAPI.Tasks; -using GamecraftModdingAPI.Utility; - -namespace GamecraftModdingAPI.Tests +namespace TechbloxModdingAPI.Tests { /// /// API test system root class. @@ -276,7 +275,7 @@ namespace GamecraftModdingAPI.Tests /// /// Runs the tests. /// - /// Assembly to search for tests. When set to null, this uses the GamecraftModdingAPI assembly. + /// Assembly to search for tests. When set to null, this uses the TechbloxModdingAPI assembly. public static void RunTests(Assembly asm = null) { if (asm == null) asm = Assembly.GetExecutingAssembly(); @@ -285,7 +284,7 @@ namespace GamecraftModdingAPI.Tests // log metadata Assert.Log($"Unity {Application.unityVersion}"); Assert.Log($"Gamecraft {Application.version}"); - Assert.Log($"GamecraftModdingAPI {Assembly.GetExecutingAssembly().GetName().Version}"); + Assert.Log($"TechbloxModdingAPI {Assembly.GetExecutingAssembly().GetName().Version}"); Assert.Log($"Testing {asm.GetName().Name} {asm.GetName().Version}"); Assert.Log($"START: --- {DateTime.Now.ToString()} --- ({testTypes.Count} tests classes detected)"); StartUp(); diff --git a/GamecraftModdingAPI/Tests/TestTest.cs b/TechbloxModdingAPI/Tests/TestTest.cs similarity index 96% rename from GamecraftModdingAPI/Tests/TestTest.cs rename to TechbloxModdingAPI/Tests/TestTest.cs index 02eeda0..5e0ed46 100644 --- a/GamecraftModdingAPI/Tests/TestTest.cs +++ b/TechbloxModdingAPI/Tests/TestTest.cs @@ -4,7 +4,7 @@ using System.Reflection; using HarmonyLib; -namespace GamecraftModdingAPI.Tests +namespace TechbloxModdingAPI.Tests { #if TEST /// diff --git a/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs b/TechbloxModdingAPI/Utility/ApiExclusiveGroups.cs similarity index 74% rename from GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs rename to TechbloxModdingAPI/Utility/ApiExclusiveGroups.cs index 8dc052d..a451673 100644 --- a/GamecraftModdingAPI/Utility/ApiExclusiveGroups.cs +++ b/TechbloxModdingAPI/Utility/ApiExclusiveGroups.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; using Svelto.ECS; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public static class ApiExclusiveGroups { @@ -18,7 +18,7 @@ namespace GamecraftModdingAPI.Utility { if (_eventsExclusiveGroup == null) { - _eventsExclusiveGroup = new ExclusiveGroup("GamecraftModdingAPI EventGroup"); + _eventsExclusiveGroup = new ExclusiveGroup("TechbloxModdingAPI EventGroup"); } return _eventsExclusiveGroup; } @@ -34,7 +34,7 @@ namespace GamecraftModdingAPI.Utility { if (_versionGroup == null) { - _versionGroup = new ExclusiveGroup("GamecraftModdingAPI VersionGroup"); + _versionGroup = new ExclusiveGroup("TechbloxModdingAPI VersionGroup"); } return _versionGroup; } @@ -47,7 +47,7 @@ namespace GamecraftModdingAPI.Utility get { if (_customBlockGroup == null) - _customBlockGroup = new ExclusiveGroup("GamecraftModdingAPI CustomBlockGroup"); + _customBlockGroup = new ExclusiveGroup("TechbloxModdingAPI CustomBlockGroup"); return _customBlockGroup; } } diff --git a/GamecraftModdingAPI/Utility/AsyncUtils.cs b/TechbloxModdingAPI/Utility/AsyncUtils.cs similarity index 95% rename from GamecraftModdingAPI/Utility/AsyncUtils.cs rename to TechbloxModdingAPI/Utility/AsyncUtils.cs index 8fed9ee..4894515 100644 --- a/GamecraftModdingAPI/Utility/AsyncUtils.cs +++ b/TechbloxModdingAPI/Utility/AsyncUtils.cs @@ -2,7 +2,7 @@ using Svelto.ECS; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public static class AsyncUtils { diff --git a/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs b/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs similarity index 96% rename from GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs rename to TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs index 7b6ef1e..b9e6ad3 100644 --- a/GamecraftModdingAPI/Utility/AsyncUtilsEngine.cs +++ b/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs @@ -4,10 +4,9 @@ using System.Threading.Tasks; using RobocraftX.Schedulers; using Svelto.ECS; using Svelto.Tasks.ExtraLean; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public class AsyncUtilsEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Utility/Audio.cs b/TechbloxModdingAPI/Utility/Audio.cs similarity index 97% rename from GamecraftModdingAPI/Utility/Audio.cs rename to TechbloxModdingAPI/Utility/Audio.cs index b2566f2..71b7f66 100644 --- a/GamecraftModdingAPI/Utility/Audio.cs +++ b/TechbloxModdingAPI/Utility/Audio.cs @@ -6,7 +6,7 @@ using FMODUnity; using RobocraftX.Common.Audio; using Unity.Mathematics; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public class Audio { diff --git a/GamecraftModdingAPI/Utility/AudioTools.cs b/TechbloxModdingAPI/Utility/AudioTools.cs similarity index 98% rename from GamecraftModdingAPI/Utility/AudioTools.cs rename to TechbloxModdingAPI/Utility/AudioTools.cs index 4d4af0d..6f78feb 100644 --- a/GamecraftModdingAPI/Utility/AudioTools.cs +++ b/TechbloxModdingAPI/Utility/AudioTools.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; using FMODUnity; using FMOD.Studio; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Common operations on audio objects diff --git a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs b/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs similarity index 94% rename from GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs rename to TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs index 9c14075..24d59b3 100644 --- a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs +++ b/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs @@ -5,15 +5,15 @@ using System.Reflection; using System.Reflection.Emit; using System.Text; using System.Text.Formatting; -using GamecraftModdingAPI.Blocks; -using GamecraftModdingAPI.Engines; -using GamecraftModdingAPI.Players; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Players; using HarmonyLib; using RobocraftX.GUI.Debug; using Svelto.ECS; using Svelto.ECS.Experimental; +using TechbloxModdingAPI.Engines; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public class DebugInterfaceEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Utility/Dependency.cs b/TechbloxModdingAPI/Utility/Dependency.cs similarity index 98% rename from GamecraftModdingAPI/Utility/Dependency.cs rename to TechbloxModdingAPI/Utility/Dependency.cs index c7dd64d..3f33277 100644 --- a/GamecraftModdingAPI/Utility/Dependency.cs +++ b/TechbloxModdingAPI/Utility/Dependency.cs @@ -3,7 +3,7 @@ using IllusionInjector; using IllusionPlugin; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Simple plugin interaction operations diff --git a/GamecraftModdingAPI/Utility/ExceptionUtil.cs b/TechbloxModdingAPI/Utility/ExceptionUtil.cs similarity index 92% rename from GamecraftModdingAPI/Utility/ExceptionUtil.cs rename to TechbloxModdingAPI/Utility/ExceptionUtil.cs index 63d0fef..0809e43 100644 --- a/GamecraftModdingAPI/Utility/ExceptionUtil.cs +++ b/TechbloxModdingAPI/Utility/ExceptionUtil.cs @@ -1,7 +1,7 @@ using System; -using GamecraftModdingAPI.Events; +using TechbloxModdingAPI.Events; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public static class ExceptionUtil { diff --git a/GamecraftModdingAPI/Utility/FullGameFields.cs b/TechbloxModdingAPI/Utility/FullGameFields.cs similarity index 98% rename from GamecraftModdingAPI/Utility/FullGameFields.cs rename to TechbloxModdingAPI/Utility/FullGameFields.cs index ccf80de..e27f501 100644 --- a/GamecraftModdingAPI/Utility/FullGameFields.cs +++ b/TechbloxModdingAPI/Utility/FullGameFields.cs @@ -19,7 +19,7 @@ using UnityEngine; using Unity.Entities; using Unity.Physics.Systems; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Public access to the private variables in RobocraftX.FullGameCompositionRoot diff --git a/GamecraftModdingAPI/Utility/GameClient.cs b/TechbloxModdingAPI/Utility/GameClient.cs similarity index 93% rename from GamecraftModdingAPI/Utility/GameClient.cs rename to TechbloxModdingAPI/Utility/GameClient.cs index 98d8ccb..f63b270 100644 --- a/GamecraftModdingAPI/Utility/GameClient.cs +++ b/TechbloxModdingAPI/Utility/GameClient.cs @@ -1,7 +1,7 @@ using System; -using GamecraftModdingAPI.Blocks; +using TechbloxModdingAPI.Blocks; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { public static class GameClient { diff --git a/GamecraftModdingAPI/Utility/GameEngineManager.cs b/TechbloxModdingAPI/Utility/GameEngineManager.cs similarity index 96% rename from GamecraftModdingAPI/Utility/GameEngineManager.cs rename to TechbloxModdingAPI/Utility/GameEngineManager.cs index cc4973f..603170c 100644 --- a/GamecraftModdingAPI/Utility/GameEngineManager.cs +++ b/TechbloxModdingAPI/Utility/GameEngineManager.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Keeps track of custom game-modifying engines diff --git a/GamecraftModdingAPI/Utility/GameState.cs b/TechbloxModdingAPI/Utility/GameState.cs similarity index 97% rename from GamecraftModdingAPI/Utility/GameState.cs rename to TechbloxModdingAPI/Utility/GameState.cs index ed096c4..50dfb83 100644 --- a/GamecraftModdingAPI/Utility/GameState.cs +++ b/TechbloxModdingAPI/Utility/GameState.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Utility to get the state of the current Gamecraft game diff --git a/GamecraftModdingAPI/Utility/GameStateEngine.cs b/TechbloxModdingAPI/Utility/GameStateEngine.cs similarity index 92% rename from GamecraftModdingAPI/Utility/GameStateEngine.cs rename to TechbloxModdingAPI/Utility/GameStateEngine.cs index be20ba1..3861d00 100644 --- a/GamecraftModdingAPI/Utility/GameStateEngine.cs +++ b/TechbloxModdingAPI/Utility/GameStateEngine.cs @@ -6,10 +6,9 @@ using System.Text; using System.Threading.Tasks; using RobocraftX.SimulationModeState; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { class GameStateEngine : IApiEngine { diff --git a/GamecraftModdingAPI/Utility/Logging.cs b/TechbloxModdingAPI/Utility/Logging.cs similarity index 99% rename from GamecraftModdingAPI/Utility/Logging.cs rename to TechbloxModdingAPI/Utility/Logging.cs index 80ef323..d28fd76 100644 --- a/GamecraftModdingAPI/Utility/Logging.cs +++ b/TechbloxModdingAPI/Utility/Logging.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Utility class to access Gamecraft's built-in logging capabilities. diff --git a/GamecraftModdingAPI/Utility/MenuEngineManager.cs b/TechbloxModdingAPI/Utility/MenuEngineManager.cs similarity index 96% rename from GamecraftModdingAPI/Utility/MenuEngineManager.cs rename to TechbloxModdingAPI/Utility/MenuEngineManager.cs index 9be203d..c3dd29c 100644 --- a/GamecraftModdingAPI/Utility/MenuEngineManager.cs +++ b/TechbloxModdingAPI/Utility/MenuEngineManager.cs @@ -5,10 +5,9 @@ using System.Text; using System.Threading.Tasks; using Svelto.ECS; +using TechbloxModdingAPI.Engines; -using GamecraftModdingAPI.Engines; - -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Keeps track of custom menu-modifying engines diff --git a/GamecraftModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs similarity index 96% rename from GamecraftModdingAPI/Utility/OptionalRef.cs rename to TechbloxModdingAPI/Utility/OptionalRef.cs index 4ac293d..7210d22 100644 --- a/GamecraftModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -3,11 +3,11 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; -using GamecraftModdingAPI.Blocks; +using TechbloxModdingAPI.Blocks; using Svelto.DataStructures; using Svelto.ECS; -namespace GamecraftModdingAPI +namespace TechbloxModdingAPI { public struct OptionalRef where T : unmanaged { diff --git a/GamecraftModdingAPI/Utility/VersionTracking.cs b/TechbloxModdingAPI/Utility/VersionTracking.cs similarity index 96% rename from GamecraftModdingAPI/Utility/VersionTracking.cs rename to TechbloxModdingAPI/Utility/VersionTracking.cs index 32b86dc..82d39d3 100644 --- a/GamecraftModdingAPI/Utility/VersionTracking.cs +++ b/TechbloxModdingAPI/Utility/VersionTracking.cs @@ -4,11 +4,10 @@ using System.Reflection; using RobocraftX.Common; using Svelto.ECS; using Svelto.ECS.Serialization; +using TechbloxModdingAPI.Events; +using TechbloxModdingAPI.Persistence; -using GamecraftModdingAPI.Persistence; -using GamecraftModdingAPI.Events; - -namespace GamecraftModdingAPI.Utility +namespace TechbloxModdingAPI.Utility { /// /// Tracks the API version the current game was built for. From c914b5b393ffe841dbf3feb3db46dfb69be414eb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 2 May 2021 01:56:20 +0200 Subject: [PATCH 46/98] Renamed all references of Gamecraft to Techblox Except those that actually refer to the game's code --- ...ftModdingAPI.sln => TechbloxModdingAPI.sln | 0 TechbloxModdingAPI/App/AppEngine.cs | 2 +- TechbloxModdingAPI/App/AppExceptions.cs | 2 +- TechbloxModdingAPI/App/Client.cs | 8 +++--- TechbloxModdingAPI/App/Game.cs | 2 +- .../App/GameBuildSimEventEngine.cs | 2 +- TechbloxModdingAPI/App/GameGameEngine.cs | 2 +- TechbloxModdingAPI/App/GameMenuEngine.cs | 2 +- TechbloxModdingAPI/Blocks/BlockCloneEngine.cs | 2 +- TechbloxModdingAPI/Blocks/BlockEngine.cs | 2 +- .../Blocks/BlockEventsEngine.cs | 2 +- TechbloxModdingAPI/Blocks/BlockExceptions.cs | 2 +- TechbloxModdingAPI/Blocks/BlockIDs.cs | 2 +- TechbloxModdingAPI/Blocks/BlueprintEngine.cs | 2 +- .../Blocks/CustomBlockEngine.cs | 4 +-- TechbloxModdingAPI/Blocks/MovementEngine.cs | 2 +- TechbloxModdingAPI/Blocks/PlacementEngine.cs | 2 +- TechbloxModdingAPI/Blocks/RemovalEngine.cs | 2 +- TechbloxModdingAPI/Blocks/RotationEngine.cs | 2 +- TechbloxModdingAPI/Blocks/ScalingEngine.cs | 2 +- TechbloxModdingAPI/Blocks/SignalEngine.cs | 2 +- .../Commands/CommandExceptions.cs | 2 +- .../Commands/CommandRegistrationHelper.cs | 2 +- TechbloxModdingAPI/Events/EventExceptions.cs | 2 +- .../Events/GameActivatedComposePatch.cs | 6 ++-- .../Events/GameStateBuildEmitterEngine.cs | 2 +- .../GameStateSimulationEmitterEngine.cs | 2 +- .../Events/MenuActivatedPatch.cs | 4 +-- .../Events/MenuSwitchedToPatch.cs | 2 +- .../GamecraftModdingAPIException.cs | 10 +++---- TechbloxModdingAPI/Input/FakeInputEngine.cs | 2 +- .../Interface/IMGUI/Constants.cs | 6 ++-- .../Interface/IMGUI/IMGUIManager.cs | 2 +- TechbloxModdingAPI/Inventory/HotbarEngine.cs | 2 +- TechbloxModdingAPI/Main.cs | 20 ++++++------- .../DeserializeFromDiskEntitiesEnginePatch.cs | 2 +- .../Persistence/IEntitySerializer.cs | 2 +- .../Persistence/SaveGameEnginePatch.cs | 2 +- .../Persistence/SerializerManager.cs | 2 +- TechbloxModdingAPI/Players/PlayerEngine.cs | 2 +- .../Players/PlayerExceptions.cs | 2 +- TechbloxModdingAPI/Tasks/Scheduler.cs | 6 ++-- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 1 - .../Tests/GamecraftModdingAPIPluginTest.cs | 12 ++++---- TechbloxModdingAPI/Tests/TestRoot.cs | 4 +-- .../Utility/AsyncUtilsEngine.cs | 2 +- .../Utility/DebugInterfaceEngine.cs | 2 +- TechbloxModdingAPI/Utility/GameState.cs | 4 +-- TechbloxModdingAPI/Utility/GameStateEngine.cs | 2 +- TechbloxModdingAPI/Utility/Logging.cs | 28 +++++++++---------- TechbloxModdingAPI/Utility/VersionTracking.cs | 4 +-- 51 files changed, 94 insertions(+), 95 deletions(-) rename GamecraftModdingAPI.sln => TechbloxModdingAPI.sln (100%) diff --git a/GamecraftModdingAPI.sln b/TechbloxModdingAPI.sln similarity index 100% rename from GamecraftModdingAPI.sln rename to TechbloxModdingAPI.sln diff --git a/TechbloxModdingAPI/App/AppEngine.cs b/TechbloxModdingAPI/App/AppEngine.cs index d14f932..74c0d22 100644 --- a/TechbloxModdingAPI/App/AppEngine.cs +++ b/TechbloxModdingAPI/App/AppEngine.cs @@ -16,7 +16,7 @@ namespace TechbloxModdingAPI.App public IEntityFactory Factory { set; private get; } - public string Name => "GamecraftModdingAPIAppEngine"; + public string Name => "TechbloxModdingAPIAppEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/App/AppExceptions.cs b/TechbloxModdingAPI/App/AppExceptions.cs index b3393cb..dfe3afe 100644 --- a/TechbloxModdingAPI/App/AppExceptions.cs +++ b/TechbloxModdingAPI/App/AppExceptions.cs @@ -3,7 +3,7 @@ using System.Runtime.Serialization; namespace TechbloxModdingAPI.App { - public class AppException : GamecraftModdingAPIException + public class AppException : TechbloxModdingAPIException { public AppException() { diff --git a/TechbloxModdingAPI/App/Client.cs b/TechbloxModdingAPI/App/Client.cs index 4887448..420f004 100644 --- a/TechbloxModdingAPI/App/Client.cs +++ b/TechbloxModdingAPI/App/Client.cs @@ -10,7 +10,7 @@ using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.App { /// - /// The Gamecraft application that is running this code right now. + /// The Techblox application that is running this code right now. /// public class Client { @@ -42,7 +42,7 @@ namespace TechbloxModdingAPI.App } /// - /// Gamecraft build version string. + /// Techblox build version string. /// Usually this is in the form YYYY.mm.DD.HH.MM.SS /// /// The version. @@ -75,7 +75,7 @@ namespace TechbloxModdingAPI.App } /// - /// Whether Gamecraft is in the Main Menu + /// Whether Techblox is in the Main Menu /// /// true if in menu; false when loading or in a game. public bool InMenu @@ -85,7 +85,7 @@ namespace TechbloxModdingAPI.App /// /// Open a popup which prompts the user to click a button. - /// This reuses Gamecraft's error dialog popup + /// This reuses Techblox's error dialog popup /// /// The popup to display. Use an instance of SingleChoicePrompt or DualChoicePrompt. public void PromptUser(Error popup) diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index a3099eb..252171d 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -118,7 +118,7 @@ namespace TechbloxModdingAPI.App /// /// An event that fires right before a game returns to the main menu. - /// At this point, Gamecraft is transitioning state so many things are invalid/unstable here. + /// At this point, Techblox is transitioning state so many things are invalid/unstable here. /// public static event EventHandler Exit { diff --git a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs index f4b5766..f710d6f 100644 --- a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs +++ b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs @@ -15,7 +15,7 @@ namespace TechbloxModdingAPI.App public event EventHandler BuildMode; - public string Name => "GamecraftModdingAPIBuildSimEventGameEngine"; + public string Name => "TechbloxModdingAPIBuildSimEventGameEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index d5a2f60..1ed4d48 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -22,7 +22,7 @@ namespace TechbloxModdingAPI.App public event EventHandler ExitGame; - public string Name => "GamecraftModdingAPIGameInfoMenuEngine"; + public string Name => "TechbloxModdingAPIGameInfoMenuEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 9fce3b7..3357984 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -17,7 +17,7 @@ namespace TechbloxModdingAPI.App { public IEntityFactory Factory { set; private get; } - public string Name => "GamecraftModdingAPIGameInfoGameEngine"; + public string Name => "TechbloxModdingAPIGameInfoGameEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs b/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs index 8703953..e1501e8 100644 --- a/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockCloneEngine.cs @@ -100,7 +100,7 @@ namespace TechbloxModdingAPI.Blocks } } - public string Name { get; } = "GamecraftModdingAPIBlockCloneGameEngine"; + public string Name { get; } = "TechbloxModdingAPIBlockCloneGameEngine"; public bool isRemovable { get; } = false; } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs index 956871b..404e72a 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -24,7 +24,7 @@ namespace TechbloxModdingAPI.Blocks /// public partial class BlockEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIBlockGameEngine"; + public string Name { get; } = "TechbloxModdingAPIBlockGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs b/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs index f89768b..3b77075 100644 --- a/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEventsEngine.cs @@ -23,7 +23,7 @@ namespace TechbloxModdingAPI.Blocks { } - public string Name { get; } = "GamecraftModdingAPIBlockEventsEngine"; + public string Name { get; } = "TechbloxModdingAPIBlockEventsEngine"; public bool isRemovable { get; } = false; private bool shouldAddRemove; diff --git a/TechbloxModdingAPI/Blocks/BlockExceptions.cs b/TechbloxModdingAPI/Blocks/BlockExceptions.cs index 409bb02..4029185 100644 --- a/TechbloxModdingAPI/Blocks/BlockExceptions.cs +++ b/TechbloxModdingAPI/Blocks/BlockExceptions.cs @@ -4,7 +4,7 @@ using TechbloxModdingAPI; namespace TechbloxModdingAPI.Blocks { - public class BlockException : GamecraftModdingAPIException + public class BlockException : TechbloxModdingAPIException { public BlockException() { diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 30fa76f..fcb3e41 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -6,7 +6,7 @@ namespace TechbloxModdingAPI.Blocks public enum BlockIDs : ushort { /// - /// Called "nothing" in Gamecraft. (DBID.NOTHING) + /// Called "nothing" in Techblox. (DBID.NOTHING) /// Invalid = ushort.MaxValue, Cube = 0, diff --git a/TechbloxModdingAPI/Blocks/BlueprintEngine.cs b/TechbloxModdingAPI/Blocks/BlueprintEngine.cs index 19e0afc..a6f65f3 100644 --- a/TechbloxModdingAPI/Blocks/BlueprintEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlueprintEngine.cs @@ -248,7 +248,7 @@ namespace TechbloxModdingAPI.Blocks clipboardManager.DecrementRefCount(blueprintID); } - public string Name { get; } = "GamecraftModdingAPIBlueprintGameEngine"; + public string Name { get; } = "TechbloxModdingAPIBlueprintGameEngine"; public bool isRemovable { get; } = false; [HarmonyPatch] diff --git a/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs b/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs index ef3c1e5..b8132a2 100644 --- a/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/CustomBlockEngine.cs @@ -14,7 +14,7 @@ namespace TechbloxModdingAPI.Blocks { public class CustomBlockEntityDescriptor : SerializableEntityDescriptor { - [HashName("GamecraftModdingAPICustomBlockV0")] + [HashName("TechbloxModdingAPICustomBlockV0")] public class _CustomBlockDescriptor : IEntityDescriptor { public IComponentBuilder[] componentsToBuild { get; } = @@ -57,7 +57,7 @@ namespace TechbloxModdingAPI.Blocks _registeredBlocks.Add((id, name)); } - public string Name { get; } = "GamecraftModdingAPICustomBlockEngine"; + public string Name { get; } = "TechbloxModdingAPICustomBlockEngine"; public bool isRemovable { get; } = false; public IEntityFactory Factory { get; set; } }*/ diff --git a/TechbloxModdingAPI/Blocks/MovementEngine.cs b/TechbloxModdingAPI/Blocks/MovementEngine.cs index b01b714..aeeac20 100644 --- a/TechbloxModdingAPI/Blocks/MovementEngine.cs +++ b/TechbloxModdingAPI/Blocks/MovementEngine.cs @@ -14,7 +14,7 @@ namespace TechbloxModdingAPI.Blocks /// public class MovementEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIMovementGameEngine"; + public string Name { get; } = "TechbloxModdingAPIMovementGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Blocks/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/PlacementEngine.cs index 38e27f1..afd5574 100644 --- a/TechbloxModdingAPI/Blocks/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/PlacementEngine.cs @@ -80,7 +80,7 @@ namespace TechbloxModdingAPI.Blocks return structInitializer; } - public string Name => "GamecraftModdingAPIPlacementGameEngine"; + public string Name => "TechbloxModdingAPIPlacementGameEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/Blocks/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/RemovalEngine.cs index 08216fc..858cb8f 100644 --- a/TechbloxModdingAPI/Blocks/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/RemovalEngine.cs @@ -38,7 +38,7 @@ namespace TechbloxModdingAPI.Blocks { } - public string Name { get; } = "GamecraftModdingAPIRemovalGameEngine"; + public string Name { get; } = "TechbloxModdingAPIRemovalGameEngine"; public bool isRemovable => false; diff --git a/TechbloxModdingAPI/Blocks/RotationEngine.cs b/TechbloxModdingAPI/Blocks/RotationEngine.cs index 1f35d17..cef4691 100644 --- a/TechbloxModdingAPI/Blocks/RotationEngine.cs +++ b/TechbloxModdingAPI/Blocks/RotationEngine.cs @@ -14,7 +14,7 @@ namespace TechbloxModdingAPI.Blocks /// public class RotationEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIRotationGameEngine"; + public string Name { get; } = "TechbloxModdingAPIRotationGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Blocks/ScalingEngine.cs b/TechbloxModdingAPI/Blocks/ScalingEngine.cs index 81131e6..7485f7e 100644 --- a/TechbloxModdingAPI/Blocks/ScalingEngine.cs +++ b/TechbloxModdingAPI/Blocks/ScalingEngine.cs @@ -23,7 +23,7 @@ namespace TechbloxModdingAPI.Blocks { } - public string Name { get; } = "GamecraftModdingAPIScalingEngine"; + public string Name { get; } = "TechbloxModdingAPIScalingEngine"; public bool isRemovable { get; } = false; private EntityManager _entityManager; //Unity entity manager diff --git a/TechbloxModdingAPI/Blocks/SignalEngine.cs b/TechbloxModdingAPI/Blocks/SignalEngine.cs index 3b1cf6a..6e40af1 100644 --- a/TechbloxModdingAPI/Blocks/SignalEngine.cs +++ b/TechbloxModdingAPI/Blocks/SignalEngine.cs @@ -16,7 +16,7 @@ namespace TechbloxModdingAPI.Blocks public const float HIGH = 1.0f; public const float ZERO = 0.0f; - public string Name { get; } = "GamecraftModdingAPISignalGameEngine"; + public string Name { get; } = "TechbloxModdingAPISignalGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Commands/CommandExceptions.cs b/TechbloxModdingAPI/Commands/CommandExceptions.cs index 4141a9f..b860093 100644 --- a/TechbloxModdingAPI/Commands/CommandExceptions.cs +++ b/TechbloxModdingAPI/Commands/CommandExceptions.cs @@ -1,7 +1,7 @@ using System; namespace TechbloxModdingAPI.Commands { - public class CommandException : GamecraftModdingAPIException + public class CommandException : TechbloxModdingAPIException { public CommandException() : base() {} diff --git a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs index 633bf75..850322a 100644 --- a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs +++ b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs @@ -10,7 +10,7 @@ using RobocraftX.CommandLine.Custom; namespace TechbloxModdingAPI.Commands { /// - /// Convenient methods for registering commands to Gamecraft. + /// Convenient methods for registering commands to Techblox. /// All methods register to the command line and console block by default. /// public static class CommandRegistrationHelper diff --git a/TechbloxModdingAPI/Events/EventExceptions.cs b/TechbloxModdingAPI/Events/EventExceptions.cs index a796752..1b1d5b3 100644 --- a/TechbloxModdingAPI/Events/EventExceptions.cs +++ b/TechbloxModdingAPI/Events/EventExceptions.cs @@ -1,7 +1,7 @@ using System; namespace TechbloxModdingAPI.Events { - public class EventException : GamecraftModdingAPIException + public class EventException : TechbloxModdingAPIException { public EventException() { diff --git a/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs index 62b5666..8a32f37 100644 --- a/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs +++ b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs @@ -34,18 +34,18 @@ namespace TechbloxModdingAPI.Events // so all event emitters and handlers must be re-registered. EventManager.RegisterEngines(enginesRoot); Logging.Log("Dispatching Game Activated event"); - EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIGameActivatedEventEmitter").Emit(); if (IsGameSwitching) { IsGameSwitching = false; Logging.Log("Dispatching Game Switched To event"); - EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIGameSwitchedToEventEmitter").Emit(); } if (IsGameReloading) { IsGameReloading = false; Logging.Log("Dispatching Game Reloaded event"); - EventManager.GetEventEmitter("GamecraftModdingAPIGameReloadedEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIGameReloadedEventEmitter").Emit(); } } diff --git a/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs b/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs index 29fb418..8dd5d8b 100644 --- a/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/GameStateBuildEmitterEngine.cs @@ -14,7 +14,7 @@ namespace TechbloxModdingAPI.Events [Obsolete] public class GameStateBuildEmitterEngine : IEventEmitterEngine, IUnorderedInitializeOnTimeStoppedModeEntered { - public string Name { get; } = "GamecraftModdingAPIGameStateBuildEventEmitter" ; + public string Name { get; } = "TechbloxModdingAPIGameStateBuildEventEmitter" ; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs b/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs index add45d5..c682812 100644 --- a/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs +++ b/TechbloxModdingAPI/Events/GameStateSimulationEmitterEngine.cs @@ -14,7 +14,7 @@ namespace TechbloxModdingAPI.Events [Obsolete] public class GameStateSimulationEmitterEngine : IEventEmitterEngine, IUnorderedInitializeOnTimeRunningModeEntered { - public string Name { get; } = "GamecraftModdingAPIGameStateSimulationEventEmitter" ; + public string Name { get; } = "TechbloxModdingAPIGameStateSimulationEventEmitter" ; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Events/MenuActivatedPatch.cs b/TechbloxModdingAPI/Events/MenuActivatedPatch.cs index 64aa57f..0951752 100644 --- a/TechbloxModdingAPI/Events/MenuActivatedPatch.cs +++ b/TechbloxModdingAPI/Events/MenuActivatedPatch.cs @@ -33,10 +33,10 @@ namespace TechbloxModdingAPI.Events FullGameFields.Init(__instance); //Application.Application.SetFullGameCompositionRoot(__instance); Logging.Log("Dispatching App Init event"); - EventManager.GetEventEmitter("GamecraftModdingAPIApplicationInitializedEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIApplicationInitializedEventEmitter").Emit(); } Logging.Log("Dispatching Menu Activated event"); - EventManager.GetEventEmitter("GamecraftModdingAPIMenuActivatedEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIMenuActivatedEventEmitter").Emit(); } } } diff --git a/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs b/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs index c8fec0a..23c4b77 100644 --- a/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs +++ b/TechbloxModdingAPI/Events/MenuSwitchedToPatch.cs @@ -22,7 +22,7 @@ namespace TechbloxModdingAPI.Events { // Event emitters and handlers should already be registered by MenuActivated event Logging.Log("Dispatching Menu Switched To event"); - EventManager.GetEventEmitter("GamecraftModdingAPIMenuSwitchedToEventEmitter").Emit(); + EventManager.GetEventEmitter("TechbloxModdingAPIMenuSwitchedToEventEmitter").Emit(); } } } diff --git a/TechbloxModdingAPI/GamecraftModdingAPIException.cs b/TechbloxModdingAPI/GamecraftModdingAPIException.cs index 0b4f7d5..3a1b73f 100644 --- a/TechbloxModdingAPI/GamecraftModdingAPIException.cs +++ b/TechbloxModdingAPI/GamecraftModdingAPIException.cs @@ -3,21 +3,21 @@ using System.Runtime.Serialization; namespace TechbloxModdingAPI { - public class GamecraftModdingAPIException : Exception + public class TechbloxModdingAPIException : Exception { - public GamecraftModdingAPIException() + public TechbloxModdingAPIException() { } - public GamecraftModdingAPIException(string message) : base(message) + public TechbloxModdingAPIException(string message) : base(message) { } - public GamecraftModdingAPIException(string message, Exception innerException) : base(message, innerException) + public TechbloxModdingAPIException(string message, Exception innerException) : base(message, innerException) { } - protected GamecraftModdingAPIException(SerializationInfo info, StreamingContext context) : base(info, context) + protected TechbloxModdingAPIException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/TechbloxModdingAPI/Input/FakeInputEngine.cs b/TechbloxModdingAPI/Input/FakeInputEngine.cs index 0a41fb2..7d2efb7 100644 --- a/TechbloxModdingAPI/Input/FakeInputEngine.cs +++ b/TechbloxModdingAPI/Input/FakeInputEngine.cs @@ -12,7 +12,7 @@ namespace TechbloxModdingAPI.Input { public class FakeInputEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIFakeInputEngine"; + public string Name { get; } = "TechbloxModdingAPIFakeInputEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs index a34d8fe..a966a5f 100644 --- a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs @@ -22,9 +22,9 @@ namespace TechbloxModdingAPI.Interface.IMGUI private static GUISkin _default = null; /// - /// Best-effort imitation of Gamecraft's UI style. + /// Best-effort imitation of Techblox's UI style. /// - public static GUISkin Default + public static GUISkin Default //TODO: Update to Techblox style { get { @@ -122,7 +122,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI _defaultCompletion++; }; _blueBackground = new Texture2D(1, 1); - _blueBackground.SetPixel(0, 0, new Color(0.004f, 0.522f, 0.847f) /* Gamecraft Blue */); + _blueBackground.SetPixel(0, 0, new Color(0.004f, 0.522f, 0.847f) /* Techblox Blue */); _blueBackground.Apply(); _grayBackground = new Texture2D(1, 1); _grayBackground.SetPixel(0, 0, new Color(0.745f, 0.745f, 0.745f) /* Gray */); diff --git a/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs b/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs index d4f3bb7..8b3c865 100644 --- a/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/IMGUIManager.cs @@ -20,7 +20,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI /// public static class IMGUIManager { - internal static OnGuiRunner ImguiScheduler = new OnGuiRunner("GamecraftModdingAPI_IMGUIScheduler"); + internal static OnGuiRunner ImguiScheduler = new OnGuiRunner("TechbloxModdingAPI_IMGUIScheduler"); private static Dictionary _activeElements = new Dictionary(); diff --git a/TechbloxModdingAPI/Inventory/HotbarEngine.cs b/TechbloxModdingAPI/Inventory/HotbarEngine.cs index 764f535..66f8c78 100644 --- a/TechbloxModdingAPI/Inventory/HotbarEngine.cs +++ b/TechbloxModdingAPI/Inventory/HotbarEngine.cs @@ -18,7 +18,7 @@ namespace TechbloxModdingAPI.Inventory { public class HotbarEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIHotbarGameEngine"; + public string Name { get; } = "TechbloxModdingAPIHotbarGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Main.cs b/TechbloxModdingAPI/Main.cs index b81e127..da66884 100644 --- a/TechbloxModdingAPI/Main.cs +++ b/TechbloxModdingAPI/Main.cs @@ -31,7 +31,7 @@ namespace TechbloxModdingAPI /// /// Initializes the TechbloxModdingAPI. - /// Call this as soon as possible after Gamecraft starts up. + /// Call this as soon as possible after Techblox starts up. /// Ideally, this should be called from your main Plugin class's OnApplicationStart() method. /// public static void Init() @@ -43,7 +43,7 @@ namespace TechbloxModdingAPI Logging.LogWarning("TechbloxModdingAPI.Main.Init() called but API is already initialized!"); return; } - Logging.MetaDebugLog($"Patching Gamecraft"); + Logging.MetaDebugLog($"Patching Techblox"); var currentAssembly = Assembly.GetExecutingAssembly(); harmony = new Harmony(currentAssembly.GetName().Name); try @@ -53,7 +53,7 @@ namespace TechbloxModdingAPI catch (Exception e) { //Can't use ErrorBuilder or Logging.LogException (which eventually uses ErrorBuilder) yet Logging.Log(e.ToString()); - Logging.LogWarning("Failed to patch Gamecraft. Attempting to patch to display error..."); + Logging.LogWarning("Failed to patch Techblox. Attempting to patch to display error..."); harmony.Patch(AccessTools.Method(typeof(FullGameCompositionRoot), "OnContextInitialized") .MakeGenericMethod(typeof(UnityContext)), new HarmonyMethod(((Action) OnPatchError).Method)); //Can't use lambdas here :( @@ -67,12 +67,12 @@ namespace TechbloxModdingAPI Utility.VersionTracking.Init(); // create default event emitters Logging.MetaDebugLog($"Initializing Events"); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "GamecraftModdingAPIApplicationInitializedEventEmitter", false)); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Menu, "GamecraftModdingAPIMenuActivatedEventEmitter", false)); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuSwitchedTo, "GamecraftModdingAPIMenuSwitchedToEventEmitter", false)); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Game, "GamecraftModdingAPIGameActivatedEventEmitter", false)); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameReloaded, "GamecraftModdingAPIGameReloadedEventEmitter", false)); - EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameSwitchedTo, "GamecraftModdingAPIGameSwitchedToEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.ApplicationInitialized, "TechbloxModdingAPIApplicationInitializedEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Menu, "TechbloxModdingAPIMenuActivatedEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.MenuSwitchedTo, "TechbloxModdingAPIMenuSwitchedToEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.Game, "TechbloxModdingAPIGameActivatedEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameReloaded, "TechbloxModdingAPIGameReloadedEventEmitter", false)); + EventManager.AddEventEmitter(new SimpleEventEmitterEngine(EventType.GameSwitchedTo, "TechbloxModdingAPIGameSwitchedToEventEmitter", false)); EventManager.AddEventEmitter(GameHostTransitionDeterministicGroupEnginePatch.buildEngine); EventManager.AddEventEmitter(GameHostTransitionDeterministicGroupEnginePatch.simEngine); #pragma warning restore 0612,0618 @@ -100,7 +100,7 @@ namespace TechbloxModdingAPI /// /// Shuts down & cleans up the TechbloxModdingAPI. - /// Call this as late as possible before Gamecraft quits. + /// Call this as late as possible before Techblox quits. /// Ideally, this should be called from your main Plugin class's OnApplicationQuit() method. /// public static void Shutdown() diff --git a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs index f436e56..d998f0e 100644 --- a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs @@ -17,7 +17,7 @@ namespace TechbloxModdingAPI.Persistence { internal static EntitiesDB entitiesDB = null; - private static readonly byte[] frameStart = Encoding.UTF8.GetBytes("\0\0\0GamecraftModdingAPI\0\0\0"); + private static readonly byte[] frameStart = Encoding.UTF8.GetBytes("\0\0\0TechbloxModdingAPI\0\0\0"); public static void Prefix(ref ISerializationData ____serializationData, ref FasterList ____bytesStream, ref IEntitySerialization ____entitySerializer, bool ____spawnBlocksOnly) { diff --git a/TechbloxModdingAPI/Persistence/IEntitySerializer.cs b/TechbloxModdingAPI/Persistence/IEntitySerializer.cs index e7fcd5c..0d6e599 100644 --- a/TechbloxModdingAPI/Persistence/IEntitySerializer.cs +++ b/TechbloxModdingAPI/Persistence/IEntitySerializer.cs @@ -8,7 +8,7 @@ using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Persistence { /// - /// Entity serializer and deserializer interface for storing and retrieving data in a Gamecraft save file (GameSave.GC). + /// Entity serializer and deserializer interface for storing and retrieving data in a Techblox save file (GameSave.GC). /// public interface IEntitySerializer : IDeserializationFactory, IQueryingEntitiesEngine { diff --git a/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs index 74edddf..9371e9b 100644 --- a/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs @@ -15,7 +15,7 @@ namespace TechbloxModdingAPI.Persistence //[HarmonyPatch] - TODO class SaveGameEnginePatch { - private static readonly byte[] frameStart = Encoding.UTF8.GetBytes("\0\0\0GamecraftModdingAPI\0\0\0"); + private static readonly byte[] frameStart = Encoding.UTF8.GetBytes("\0\0\0TechbloxModdingAPI\0\0\0"); public static void Postfix(ref ISerializationData serializationData, EntitiesDB entitiesDB, IEntitySerialization entitySerializer) { diff --git a/TechbloxModdingAPI/Persistence/SerializerManager.cs b/TechbloxModdingAPI/Persistence/SerializerManager.cs index 6177d7c..04079cf 100644 --- a/TechbloxModdingAPI/Persistence/SerializerManager.cs +++ b/TechbloxModdingAPI/Persistence/SerializerManager.cs @@ -11,7 +11,7 @@ namespace TechbloxModdingAPI.Persistence /// /// Keeps track of serializers. /// This is used to add and retrieve serializers. - /// Added IEntitySerializations are used in serializing and deserializing Gamecraft save files (GameSave.GC). + /// Added IEntitySerializations are used in serializing and deserializing Techblox save files (GameSave.GC). /// public static class SerializerManager { diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index cc24650..d71c3ee 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -26,7 +26,7 @@ namespace TechbloxModdingAPI.Players { internal class PlayerEngine : IApiEngine, IFactoryEngine { - public string Name { get; } = "GamecraftModdingAPIPlayerGameEngine"; + public string Name { get; } = "TechbloxModdingAPIPlayerGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Players/PlayerExceptions.cs b/TechbloxModdingAPI/Players/PlayerExceptions.cs index d5bba55..20dbea6 100644 --- a/TechbloxModdingAPI/Players/PlayerExceptions.cs +++ b/TechbloxModdingAPI/Players/PlayerExceptions.cs @@ -1,7 +1,7 @@ using System; namespace TechbloxModdingAPI.Players { - public class PlayerException : GamecraftModdingAPIException + public class PlayerException : TechbloxModdingAPIException { public PlayerException() { diff --git a/TechbloxModdingAPI/Tasks/Scheduler.cs b/TechbloxModdingAPI/Tasks/Scheduler.cs index af47d1d..764e9b7 100644 --- a/TechbloxModdingAPI/Tasks/Scheduler.cs +++ b/TechbloxModdingAPI/Tasks/Scheduler.cs @@ -32,9 +32,9 @@ namespace TechbloxModdingAPI.Tasks } } - public static readonly Svelto.Tasks.ExtraLean.Unity.UpdateMonoRunner extraLeanRunner = new Svelto.Tasks.ExtraLean.Unity.UpdateMonoRunner("GamecraftModdingAPIExtraLean"); + public static readonly Svelto.Tasks.ExtraLean.Unity.UpdateMonoRunner extraLeanRunner = new Svelto.Tasks.ExtraLean.Unity.UpdateMonoRunner("TechbloxModdingAPIExtraLean"); - public static readonly Svelto.Tasks.Lean.Unity.UpdateMonoRunner leanRunner = new Svelto.Tasks.Lean.Unity.UpdateMonoRunner("GamecraftModdingAPILean"); + public static readonly Svelto.Tasks.Lean.Unity.UpdateMonoRunner leanRunner = new Svelto.Tasks.Lean.Unity.UpdateMonoRunner("TechbloxModdingAPILean"); /// /// Schedule a task to run asynchronously. @@ -42,7 +42,7 @@ namespace TechbloxModdingAPI.Tasks /// /// The task to run /// Schedule toRun on an extra lean runner? - /// Schedule toRun on Gamecraft's built-in UI task runner? + /// Schedule toRun on Techblox's built-in UI task runner? public static void Schedule(ISchedulable toRun, bool extraLean = false, bool ui = false) { if (extraLean) diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index 4624c80..bd4135c 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -8,7 +8,6 @@ https://git.exmods.org/modtainers/GamecraftModdingAPI en-CA true - GamecraftModdingAPI diff --git a/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 292f769..2274600 100644 --- a/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -55,7 +55,7 @@ namespace TechbloxModdingAPI.Tests /// Modding API implemented as a standalone IPA Plugin. /// Ideally, TechbloxModdingAPI should be loaded by another mod; not itself /// - public class GamecraftModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin + public class TechbloxModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin { private static Harmony harmony { get; set; } @@ -64,7 +64,7 @@ namespace TechbloxModdingAPI.Tests public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); - public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi"; + public string HarmonyID { get; } = "org.git.exmods.modtainers.techbloxmoddingapi"; public override void OnApplicationQuit() { @@ -367,16 +367,16 @@ namespace TechbloxModdingAPI.Tests } // dependency test - if (Dependency.Hell("GamecraftScripting", new Version("0.0.1.0"))) + if (Dependency.Hell("TechbloxScripting", new Version("0.0.1.0"))) { - Logging.LogWarning("You're in GamecraftScripting dependency hell"); + Logging.LogWarning("You're in TechbloxScripting dependency hell"); } else { - Logging.Log("Compatible GamecraftScripting detected"); + Logging.Log("Compatible TechbloxScripting detected"); } // Interface test - /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "GamecraftModdingAPI_UITestGroup", true); + /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "TechbloxModdingAPI_UITestGroup", true); Interface.IMGUI.Button button = new Button("TEST"); button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; Interface.IMGUI.Button button2 = new Button("TEST2"); diff --git a/TechbloxModdingAPI/Tests/TestRoot.cs b/TechbloxModdingAPI/Tests/TestRoot.cs index 878fdda..9085470 100644 --- a/TechbloxModdingAPI/Tests/TestRoot.cs +++ b/TechbloxModdingAPI/Tests/TestRoot.cs @@ -21,7 +21,7 @@ namespace TechbloxModdingAPI.Tests { public static bool AutoShutdown = true; - public const string ReportFile = "GamecraftModdingAPI_tests.log"; + public const string ReportFile = "TechbloxModdingAPI_tests.log"; private static bool _testsPassed = false; @@ -283,7 +283,7 @@ namespace TechbloxModdingAPI.Tests Logging.MetaLog("Starting test run"); // log metadata Assert.Log($"Unity {Application.unityVersion}"); - Assert.Log($"Gamecraft {Application.version}"); + Assert.Log($"Techblox {Application.version}"); Assert.Log($"TechbloxModdingAPI {Assembly.GetExecutingAssembly().GetName().Version}"); Assert.Log($"Testing {asm.GetName().Name} {asm.GetName().Version}"); Assert.Log($"START: --- {DateTime.Now.ToString()} --- ({testTypes.Count} tests classes detected)"); diff --git a/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs b/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs index b9e6ad3..ee18ced 100644 --- a/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs +++ b/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs @@ -57,7 +57,7 @@ namespace TechbloxModdingAPI.Utility { } - public string Name { get; } = "GamecraftModdingAPIAsyncUtilsGameEngine"; + public string Name { get; } = "TechbloxModdingAPIAsyncUtilsGameEngine"; public bool isRemovable { get; } = false; } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs b/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs index 24d59b3..7f9d97c 100644 --- a/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs +++ b/TechbloxModdingAPI/Utility/DebugInterfaceEngine.cs @@ -31,7 +31,7 @@ namespace TechbloxModdingAPI.Utility public void SetInfo(string id, Func contentGetter) => _extraInfo[id] = contentGetter; public bool RemoveInfo(string id) => _extraInfo.Remove(id); - public string Name => "GamecraftModdingAPIDebugInterfaceGameEngine"; + public string Name => "TechbloxModdingAPIDebugInterfaceGameEngine"; public bool isRemovable => true; [HarmonyPatch] diff --git a/TechbloxModdingAPI/Utility/GameState.cs b/TechbloxModdingAPI/Utility/GameState.cs index 50dfb83..79a72fe 100644 --- a/TechbloxModdingAPI/Utility/GameState.cs +++ b/TechbloxModdingAPI/Utility/GameState.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace TechbloxModdingAPI.Utility { /// - /// Utility to get the state of the current Gamecraft game + /// Utility to get the state of the current Techblox game /// public static class GameState { @@ -34,7 +34,7 @@ namespace TechbloxModdingAPI.Utility /// /// Is a game loaded? /// - /// Whether Gamecraft has a game open (false = Main Menu) + /// Whether Techblox has a game open (false = Main Menu) public static bool IsInGame() { return gameEngine.IsInGame; diff --git a/TechbloxModdingAPI/Utility/GameStateEngine.cs b/TechbloxModdingAPI/Utility/GameStateEngine.cs index 3861d00..936a8ef 100644 --- a/TechbloxModdingAPI/Utility/GameStateEngine.cs +++ b/TechbloxModdingAPI/Utility/GameStateEngine.cs @@ -12,7 +12,7 @@ namespace TechbloxModdingAPI.Utility { class GameStateEngine : IApiEngine { - public string Name { get; } = "GamecraftModdingAPIGameStateGameEngine"; + public string Name { get; } = "TechbloxModdingAPIGameStateGameEngine"; public EntitiesDB entitiesDB { set; private get; } diff --git a/TechbloxModdingAPI/Utility/Logging.cs b/TechbloxModdingAPI/Utility/Logging.cs index d28fd76..8a26759 100644 --- a/TechbloxModdingAPI/Utility/Logging.cs +++ b/TechbloxModdingAPI/Utility/Logging.cs @@ -9,8 +9,8 @@ using System.Threading.Tasks; namespace TechbloxModdingAPI.Utility { /// - /// Utility class to access Gamecraft's built-in logging capabilities. - /// The log is saved to %APPDATA%\..\LocalLow\FreeJam\Gamecraft\Player.Log + /// Utility class to access Techblox's built-in logging capabilities. + /// The log is saved to %APPDATA%\..\LocalLow\FreeJam\Techblox\Player.Log /// public static class Logging { @@ -21,7 +21,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a regular message to Gamecraft's log + /// Write a regular message to Techblox's log /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -37,7 +37,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a debug message to Gamecraft's log + /// Write a debug message to Techblox's log /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -53,7 +53,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a debug message and object to Gamecraft's log + /// Write a debug message and object to Techblox's log /// The reason this method exists in Svelto.Console is beyond my understanding /// /// The type of the extra debug object @@ -72,7 +72,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write an error message to Gamecraft's log + /// Write an error message to Techblox's log /// /// The object to log /// The extra data to pass to the ILogger @@ -83,7 +83,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write an exception to Gamecraft's log and to the screen and exit game + /// Write an exception to Techblox's log and to the screen and exit game /// /// The exception to log /// The extra data to pass to the ILogger. @@ -95,7 +95,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write an exception message to Gamecraft's log and to the screen and exit game + /// Write an exception message to Techblox's log and to the screen and exit game /// /// The object to log /// The exception to log @@ -114,7 +114,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a warning message to Gamecraft's log + /// Write a warning message to Techblox's log /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -144,7 +144,7 @@ namespace TechbloxModdingAPI.Utility // descriptive logging /// - /// Write a descriptive message to Gamecraft's log only when the API is a Debug build + /// Write a descriptive message to Techblox's log only when the API is a Debug build /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -156,7 +156,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a descriptive message to Gamecraft's log including the current time and the calling method's name + /// Write a descriptive message to Techblox's log including the current time and the calling method's name /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -169,7 +169,7 @@ namespace TechbloxModdingAPI.Utility // CLI logging /// - /// Write a message to Gamecraft's command line + /// Write a message to Techblox's command line /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -185,7 +185,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write an error message to Gamecraft's command line + /// Write an error message to Techblox's command line /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -201,7 +201,7 @@ namespace TechbloxModdingAPI.Utility } /// - /// Write a warning message to Gamecraft's command line + /// Write a warning message to Techblox's command line /// /// The object to log [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/TechbloxModdingAPI/Utility/VersionTracking.cs b/TechbloxModdingAPI/Utility/VersionTracking.cs index 82d39d3..01da552 100644 --- a/TechbloxModdingAPI/Utility/VersionTracking.cs +++ b/TechbloxModdingAPI/Utility/VersionTracking.cs @@ -61,7 +61,7 @@ namespace TechbloxModdingAPI.Utility [Obsolete] internal class VersionTrackingEngine : IEventEmitterEngine { - public string Name { get; } = "GamecraftModdingAPIVersionTrackingGameEngine"; + public string Name { get; } = "TechbloxModdingAPIVersionTrackingGameEngine"; public EntitiesDB entitiesDB { set; private get; } @@ -104,7 +104,7 @@ namespace TechbloxModdingAPI.Utility [Obsolete] public class ModVersionDescriptor: SerializableEntityDescriptor { - [HashName("GamecraftModdingAPIVersionV0")] + [HashName("TechbloxModdingAPIVersionV0")] public class _ModVersionDescriptor : IEntityDescriptor { public IComponentBuilder[] componentsToBuild { get; } = new IComponentBuilder[]{ From 5172b13b7c33dc4b064bd91808766b224f909de7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 2 May 2021 02:08:22 +0200 Subject: [PATCH 47/98] Update readme and version --- README.md | 22 ++++++++++---------- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fd3bf5a..a4c0457 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# GamecraftModdingAPI +# TechbloxModdingAPI -Unofficial Gamecraft modding API for interfacing Gamecraft from mods. +Unofficial Techblox modding API for interfacing Techblox from mods. -The GamecraftModdingAPI aims to simplify the mods in two ways: +The TechbloxModdingAPI aims to simplify the mods in two ways: - *Ease-of-Use* The API provides convenient ways to do common tasks such as moving blocks and adding commands. All of the Harmony patching is done for you, so you can focus on writing your mod instead of reading swathes of undocumented code. - *Stability* The API aims to be reliable and consistent between versions. -This means your code won't break when the GamecraftModdingAPI or Gamecraft updates. +This means your code won't break when the TechbloxModdingAPI or Techblox updates. For more info, please check out the [official documentation](https://mod.exmods.org). @@ -16,16 +16,16 @@ For more support, join the ExMods [Discord](https://discord.exmods.org). [Please follow the official mod installation guide](https://www.exmods.org/guides/install.html) or use GCMM. ## Development -To get started, create a symbolic link called `ref` in the root of the project, or one folder higher, linking to the Gamecraft install folder. -This will allow your IDE to resolve references to Gamecraft files for building and IDE tools. +To get started, create a symbolic link called `ref` in the root of the project, or one folder higher, linking to the Techblox install folder. +This will allow your IDE to resolve references to Techblox files for building and IDE tools. -GamecraftModdingAPI version numbers follow the [Semantic Versioning guidelines](https://semver.org/). +TechbloxModdingAPI version numbers follow the [Semantic Versioning guidelines](https://semver.org/). ## External Libraries -GamecraftModdingAPI includes [Harmony](https://github.com/pardeike/Harmony) to modify the behaviour of existing Gamecraft code. +TechbloxModdingAPI includes [Harmony](https://github.com/pardeike/Harmony) to modify the behaviour of existing Techblox code. # Disclaimer -This API is an unofficial modification of Gamecraft software, and is not endorsed or supported by FreeJam or Gamecraft. -The GamecraftModdingAPI developer(s) claim no rights on the Gamecraft code referenced within this project. -All code contained in this project is licensed under the [GNU Public License v3](https://git.exmods.org/modtainers/GamecraftModdingAPI/src/branch/master/LICENSE). +This API is an unofficial modification of Techblox software, and is not endorsed or supported by FreeJam or Techblox. +The TechbloxModdingAPI developer(s) claim no rights on the Techblox code referenced within this project. +All code contained in this project is licensed under the [GNU Public License v3](https://git.exmods.org/modtainers/TechbloxModdingAPI/src/branch/master/LICENSE). diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index bd4135c..4fc1b02 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -2,7 +2,7 @@ net472 true - 1.8.0 + 2.0.0 Exmods GNU General Public Licence 3+ https://git.exmods.org/modtainers/GamecraftModdingAPI From 62afd3b7805dd19ea6b9ce69bbef9245258561ef Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 3 May 2021 00:17:49 +0200 Subject: [PATCH 48/98] Some file renames that were missing --- ...craftModdingAPIException.cs => TechbloxModdingAPIException.cs} | 0 ...aftModdingAPIPluginTest.cs => TechbloxModdingAPIPluginTest.cs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename TechbloxModdingAPI/{GamecraftModdingAPIException.cs => TechbloxModdingAPIException.cs} (100%) rename TechbloxModdingAPI/Tests/{GamecraftModdingAPIPluginTest.cs => TechbloxModdingAPIPluginTest.cs} (100%) diff --git a/TechbloxModdingAPI/GamecraftModdingAPIException.cs b/TechbloxModdingAPI/TechbloxModdingAPIException.cs similarity index 100% rename from TechbloxModdingAPI/GamecraftModdingAPIException.cs rename to TechbloxModdingAPI/TechbloxModdingAPIException.cs diff --git a/TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs similarity index 100% rename from TechbloxModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs rename to TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs From aea3ef36238e22d6c78cf5e5ee376f82de3bcd3c Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 3 May 2021 01:25:26 +0200 Subject: [PATCH 49/98] Remove AsyncUtils, fix FlyCam and GetThingLookedAt() --- .../Events/GameActivatedComposePatch.cs | 2 - TechbloxModdingAPI/Main.cs | 2 +- TechbloxModdingAPI/Player.cs | 8 +-- TechbloxModdingAPI/Players/PlayerEngine.cs | 8 +-- TechbloxModdingAPI/Utility/AsyncUtils.cs | 35 ----------- .../Utility/AsyncUtilsEngine.cs | 63 ------------------- 6 files changed, 9 insertions(+), 109 deletions(-) delete mode 100644 TechbloxModdingAPI/Utility/AsyncUtils.cs delete mode 100644 TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs diff --git a/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs index 8a32f37..3ee1143 100644 --- a/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs +++ b/TechbloxModdingAPI/Events/GameActivatedComposePatch.cs @@ -28,8 +28,6 @@ namespace TechbloxModdingAPI.Events { // register custom game engines GameEngineManager.RegisterEngines(enginesRoot); - // initialize AsyncUtils - AsyncUtils.Setup(enginesRoot); // A new EnginesRoot is always created when ActivateGame is called // so all event emitters and handlers must be re-registered. EventManager.RegisterEngines(enginesRoot); diff --git a/TechbloxModdingAPI/Main.cs b/TechbloxModdingAPI/Main.cs index da66884..d6d6d3e 100644 --- a/TechbloxModdingAPI/Main.cs +++ b/TechbloxModdingAPI/Main.cs @@ -84,11 +84,11 @@ namespace TechbloxModdingAPI Input.FakeInput.Init(); // init object-oriented classes Player.Init(); + FlyCam.Init(); Block.Init(); BlockGroup.Init(); Wire.Init(); GameClient.Init(); - AsyncUtils.Init(); Client.Init(); Game.Init(); //CustomBlock.Init(); diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 2c6b122..01b5c24 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -386,8 +386,8 @@ namespace TechbloxModdingAPI public Block GetBlockLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); - return egid.HasValue && egid.Value.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP - ? new Block(egid.Value) + return egid != EGID.Empty && egid.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP + ? new Block(egid) : null; } @@ -399,8 +399,8 @@ namespace TechbloxModdingAPI public SimBody GetSimBodyLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); - return egid.HasValue && egid.Value.groupID == CommonExclusiveGroups.SIMULATION_BODIES_GROUP - ? new SimBody(egid.Value) + return egid != EGID.Empty && egid.groupID == CommonExclusiveGroups.SIMULATION_BODIES_GROUP + ? new SimBody(egid) : null; } diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index d71c3ee..f0c8a11 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -438,20 +438,20 @@ namespace TechbloxModdingAPI.Players return false; } - public EGID? GetThingLookedAt(uint playerId, float maxDistance = -1f) + public EGID GetThingLookedAt(uint playerId, float maxDistance = -1f) { if (!entitiesDB.TryQueryMappedEntities( CameraExclusiveGroups.CameraGroup, out var mapper)) - return null; + return EGID.Empty; mapper.TryGetEntity(playerId, out CharacterCameraRayCastEntityStruct rayCast); float distance = maxDistance < 0 ? GhostBlockUtils.GetBuildInteractionDistance(entitiesDB, rayCast, GhostBlockUtils.GhostCastMethod.GhostCastProportionalToBlockSize) : maxDistance; if (rayCast.hit && rayCast.distance <= distance) - return rayCast.hitEgid; + return rayCast.hitEgid; //May be EGID.Empty - return null; + return EGID.Empty; } public unsafe Block[] GetSelectedBlocks(uint playerid) diff --git a/TechbloxModdingAPI/Utility/AsyncUtils.cs b/TechbloxModdingAPI/Utility/AsyncUtils.cs deleted file mode 100644 index 4894515..0000000 --- a/TechbloxModdingAPI/Utility/AsyncUtils.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Threading.Tasks; - -using Svelto.ECS; - -namespace TechbloxModdingAPI.Utility -{ - public static class AsyncUtils - { - private static AsyncUtilsEngine gameEngine = new AsyncUtilsEngine(); - - /// - /// Waits for entity submission asynchronously. - /// Use after placing a block or otherwise creating things in the game to access their properties. - /// - public static async Task WaitForSubmission() - { - await gameEngine.WaitForSubmission(); - } - - public static async Task WaitForNextFrame() - { - await gameEngine.WaitForNextFrame(); - } - - public static void Setup(EnginesRoot enginesRoot) - { - gameEngine.Setup(enginesRoot.GenerateEntityFunctions(), enginesRoot.GenerateEntityFactory()); - } - - public static void Init() - { - GameEngineManager.AddGameEngine(gameEngine); - } - } -} \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs b/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs deleted file mode 100644 index ee18ced..0000000 --- a/TechbloxModdingAPI/Utility/AsyncUtilsEngine.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System.Collections; -using System.Threading.Tasks; - -using RobocraftX.Schedulers; -using Svelto.ECS; -using Svelto.Tasks.ExtraLean; -using TechbloxModdingAPI.Engines; - -namespace TechbloxModdingAPI.Utility -{ - public class AsyncUtilsEngine : IApiEngine - { - private IEntityFunctions _efu; - private IEntityFactory _efa; - private IEnumerator WaitForSubmissionInternal(IEntityFunctions efu, IEntityFactory efa, - EntitiesDB entitiesDB, TaskCompletionSource task) - { - /*var waitEnumerator = new WaitForSubmissionEnumerator(efu, efa, entitiesDB); - while (waitEnumerator.MoveNext()) - yield return null; - task.SetResult(null);*/ - yield break; //TODO - } - - private IEnumerator WaitForNextFrameInternal(TaskCompletionSource task) - { - yield return null; - task.SetResult(null); - } - - public Task WaitForSubmission() - { - var task = new TaskCompletionSource(); - WaitForSubmissionInternal(_efu, _efa, entitiesDB, task).RunOn(ExtraLean.EveryFrameStepRunner_TimeStopped); - return task.Task; - } - - public Task WaitForNextFrame() - { - var task = new TaskCompletionSource(); - WaitForNextFrameInternal(task).RunOn(ExtraLean.EveryFrameStepRunner_TimeStopped); - return task.Task; - } - - public void Setup(IEntityFunctions efu, IEntityFactory efa) - { - _efu = efu; - _efa = efa; - } - - public void Ready() - { - } - - public EntitiesDB entitiesDB { get; set; } - public void Dispose() - { - } - - public string Name { get; } = "TechbloxModdingAPIAsyncUtilsGameEngine"; - public bool isRemovable { get; } = false; - } -} \ No newline at end of file From 78ee3b3bcdd33c46341d16cb187b296e3e6cc148 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 10 May 2021 01:38:15 +0200 Subject: [PATCH 50/98] Fix block type check on placement --- TechbloxModdingAPI/Blocks/PlacementEngine.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/PlacementEngine.cs index afd5574..5e1b97c 100644 --- a/TechbloxModdingAPI/Blocks/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/PlacementEngine.cs @@ -49,8 +49,7 @@ namespace TechbloxModdingAPI.Blocks { if (_blockEntityFactory == null) throw new BlockException("The factory is null."); - uint resourceId = (uint) PrefabsID.GenerateResourceID(0, block); - if (!PrefabsID.PrefabIDByResourceIDMap.ContainsKey(resourceId)) + if(!FullGameFields._dataDb.ContainsKey(block)) throw new BlockException("Block with ID " + block + " not found!"); //RobocraftX.CR.MachineEditing.PlaceSingleBlockEngine DBEntityStruct dbEntity = new DBEntityStruct {DBID = block}; From 2d99d1d4783171c9751850a00de0cb355697e35b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 10 May 2021 02:04:59 +0200 Subject: [PATCH 51/98] Generalize optional references and init data Added extension methods to query data from ECS objects Added base class for ECS objects Added support for representing in-construction ECS objects with an OptionalRef --- TechbloxModdingAPI/Block.cs | 10 ++-- TechbloxModdingAPI/Blocks/BlockEngine.cs | 19 ++++--- .../BlockEngineInit.cs => EcsObjectBase.cs} | 30 +++++++---- TechbloxModdingAPI/Utility/ApiExtensions.cs | 53 +++++++++++++++++++ TechbloxModdingAPI/Utility/OptionalRef.cs | 40 ++++++++++---- 5 files changed, 120 insertions(+), 32 deletions(-) rename TechbloxModdingAPI/{Blocks/BlockEngineInit.cs => EcsObjectBase.cs} (58%) create mode 100644 TechbloxModdingAPI/Utility/ApiExtensions.cs diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 4729a91..f99ca28 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -20,7 +20,7 @@ namespace TechbloxModdingAPI /// A single (perhaps scaled) block. Properties may return default values if the block is removed and then setting them is ignored. /// For specific block type operations, use the specialised block classes in the TechbloxModdingAPI.Blocks namespace. /// - public class Block : IEquatable, IEquatable + public class Block : EcsObjectBase, IEquatable, IEquatable { protected static readonly PlacementEngine PlacementEngine = new PlacementEngine(); protected static readonly MovementEngine MovementEngine = new MovementEngine(); @@ -78,8 +78,7 @@ namespace TechbloxModdingAPI var initializer = PlacementEngine.PlaceBlock(block, position, player, autoWire); var egid = initializer.EGID; var bl = New(egid.entityID, egid.groupID); - bl.InitData.Group = BlockEngine.InitGroup(initializer); - bl.InitData.Reference = initializer.reference; + bl.InitData = initializer; Placed += bl.OnPlacedInit; return bl; } @@ -241,13 +240,12 @@ namespace TechbloxModdingAPI throw new BlockException("Blocks can only be placed in build mode."); var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire); Id = initializer.EGID; - InitData.Group = BlockEngine.InitGroup(initializer); + InitData = initializer; Placed += OnPlacedInit; } - public EGID Id { get; } + public override EGID Id { get; } - internal BlockEngine.BlockInitData InitData; private EGID copiedFrom; /// diff --git a/TechbloxModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs index 404e72a..7bade49 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -9,6 +9,7 @@ using RobocraftX.Blocks; using RobocraftX.Common; using RobocraftX.Physics; using RobocraftX.Rendering; +using RobocraftX.Rendering.GPUI; using Svelto.ECS.EntityStructs; using Svelto.DataStructures; @@ -16,6 +17,7 @@ using Svelto.ECS; using Svelto.ECS.Hybrid; using Unity.Mathematics; using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Blocks { @@ -68,14 +70,13 @@ namespace TechbloxModdingAPI.Blocks : entitiesDB.QueryEntity(index, CommonExclusiveGroups.COLOUR_PALETTE_GROUP).Colour; - public ref T GetBlockInfo(EGID blockID) where T : unmanaged, IEntityComponent + public OptionalRef GetBlockInfo(EGID blockID) where T : unmanaged, IEntityComponent { - if (entitiesDB.Exists(blockID)) - return ref entitiesDB.QueryEntity(blockID); - T[] structHolder = new T[1]; //Create something that can be referenced - return ref structHolder[0]; //Gets a default value automatically + return entitiesDB.TryQueryEntitiesAndIndex(blockID, out uint index, out var array) + ? new OptionalRef(array, index) + : new OptionalRef(); } - + public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityViewComponent { if (entitiesDB.Exists(blockID)) @@ -149,6 +150,12 @@ namespace TechbloxModdingAPI.Blocks entitiesDB.QueryEntity(id).matrix = float4x4.TRS(pos.position, rot.rotation, scale.scale); } + internal void UpdatePrefab(Block block, ushort type, byte material, bool flipped) + { + uint pid = PrefabsID.GetOrCreatePrefabID(type, material, 0, flipped); + entitiesDB.QueryEntityOrDefault() + } + public bool BlockExists(EGID blockID) { return entitiesDB.Exists(blockID); diff --git a/TechbloxModdingAPI/Blocks/BlockEngineInit.cs b/TechbloxModdingAPI/EcsObjectBase.cs similarity index 58% rename from TechbloxModdingAPI/Blocks/BlockEngineInit.cs rename to TechbloxModdingAPI/EcsObjectBase.cs index b9b9eae..c96cf25 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngineInit.cs +++ b/TechbloxModdingAPI/EcsObjectBase.cs @@ -1,33 +1,43 @@ -using System; +using System; using System.Linq.Expressions; - using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Internal; +using TechbloxModdingAPI.Blocks; -namespace TechbloxModdingAPI.Blocks +namespace TechbloxModdingAPI { - public partial class BlockEngine + public abstract class EcsObjectBase { + public abstract EGID Id { get; } //Abstract to support the 'place' Block constructor + + protected internal EcsInitData InitData; + /// /// Holds information needed to construct a component initializer /// - internal struct BlockInitData + protected internal struct EcsInitData { - public FasterDictionary Group; - public EntityReference Reference; + private FasterDictionary group; + private EntityReference reference; + + public static implicit operator EcsInitData(EntityInitializer initializer) => new EcsInitData + {group = GetInitGroup(initializer), reference = initializer.reference}; + + public EntityInitializer Initializer(EGID id) => new EntityInitializer(id, group, reference); + public bool Valid => group != null; } - internal delegate FasterDictionary GetInitGroup( + private delegate FasterDictionary GetInitGroupFunc( EntityInitializer initializer); /// /// Accesses the group field of the initializer /// - internal GetInitGroup InitGroup = CreateAccessor("_group"); + private static GetInitGroupFunc GetInitGroup = CreateAccessor("_group"); //https://stackoverflow.com/questions/55878525/unit-testing-ref-structs-with-private-fields-via-reflection - internal static TDelegate CreateAccessor(string memberName) where TDelegate : Delegate + private static TDelegate CreateAccessor(string memberName) where TDelegate : Delegate { var invokeMethod = typeof(TDelegate).GetMethod("Invoke"); if (invokeMethod == null) diff --git a/TechbloxModdingAPI/Utility/ApiExtensions.cs b/TechbloxModdingAPI/Utility/ApiExtensions.cs new file mode 100644 index 0000000..3da1a67 --- /dev/null +++ b/TechbloxModdingAPI/Utility/ApiExtensions.cs @@ -0,0 +1,53 @@ +using Svelto.ECS; +using TechbloxModdingAPI.Blocks; + +namespace TechbloxModdingAPI.Utility +{ + public static class ApiExtensions + { + /// + /// Attempts to query an entity and returns an optional that contains the result if succeeded. + /// + /// The entities DB + /// The EGID to query + /// The component type to query + /// An optional that contains the result on success or is empty if not found + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EGID egid) + where T : unmanaged, IEntityComponent + { + return entitiesDB.TryQueryEntitiesAndIndex(egid, out uint index, out var array) + ? new OptionalRef(array, index) + : new OptionalRef(); + } + + /// + /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// + /// + /// + /// + /// + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj) + where T : unmanaged, IEntityComponent + { + var opt = QueryEntityOptional(entitiesDB, obj.Id); + return opt ? opt : new OptionalRef(obj); + } + + /// + /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// + /// + /// + /// + /// + public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj) + where T : unmanaged, IEntityComponent + { + var opt = QueryEntityOptional(entitiesDB, obj.Id); + if (opt) return ref opt.Get(); + if (obj.InitData.Valid) return ref obj.InitData.Initializer(obj.Id).GetOrCreate(); + return ref opt.Get(); //Default value + } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 7210d22..2323431 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -9,31 +9,51 @@ using Svelto.ECS; namespace TechbloxModdingAPI { - public struct OptionalRef where T : unmanaged + public ref struct OptionalRef where T : unmanaged, IEntityComponent { private bool exists; private NB array; private uint index; + private EntityInitializer initializer; public OptionalRef(NB array, uint index) { exists = true; this.array = array; this.index = index; + initializer = default; } - - public OptionalRef(ref T value) + + /// + /// Wraps the initializer data, if present. + /// + /// The object with the initializer + public OptionalRef(EcsObjectBase obj) { - exists = true; + if (obj.InitData.Valid) + { + initializer = obj.InitData.Initializer(obj.Id); + exists = true; + } + else + { + initializer = default; + exists = false; + } array = default; index = default; } - public ref T Get(T def = default) + /// + /// Returns the value or a default value if empty. Supports objects that are being initialized. + /// + /// The value or the default value + public ref T Get() { - if (exists) + if (!exists) return ref CompRefCache.Default; + if (initializer.EGID == EGID.Empty) return ref array[index]; - return ref CompRefCache._default; + return ref initializer.GetOrCreate(); } public bool Exists => exists; @@ -51,10 +71,10 @@ namespace TechbloxModdingAPI /// /// Creates an instance of a struct T that can be referenced. /// - /// The struct type to cache - private struct CompRefCache where T : unmanaged + /// The struct type to cache + private struct CompRefCache where TR : unmanaged { - public static T _default; + public static TR Default; } } } \ No newline at end of file From 61184145a914ef360350f4df7263709cee19c5c9 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 10 May 2021 22:45:07 +0200 Subject: [PATCH 52/98] Start using new extension methods, code cleanup Removed all of the different block property getter methods --- TechbloxModdingAPI/Block.cs | 8 +- TechbloxModdingAPI/Blocks/BlockEngine.cs | 83 +-------------------- TechbloxModdingAPI/Blocks/MovementEngine.cs | 44 ++++------- TechbloxModdingAPI/Blocks/RotationEngine.cs | 61 ++++++--------- TechbloxModdingAPI/Blocks/SignalEngine.cs | 38 +++------- 5 files changed, 55 insertions(+), 179 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index f99ca28..0e97a03 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -254,10 +254,10 @@ namespace TechbloxModdingAPI /// public float3 Position { - get => MovementEngine.GetPosition(Id, InitData); + get => MovementEngine.GetPosition(this); set { - MovementEngine.MoveBlock(Id, InitData, value); + MovementEngine.MoveBlock(this, value); if (blockGroup != null) blockGroup.PosAndRotCalculated = false; BlockEngine.UpdateDisplayedBlock(Id); @@ -269,10 +269,10 @@ namespace TechbloxModdingAPI /// public float3 Rotation { - get => RotationEngine.GetRotation(Id, InitData); + get => RotationEngine.GetRotation(this); set { - RotationEngine.RotateBlock(Id, InitData, value); + RotationEngine.RotateBlock(this, value); if (blockGroup != null) blockGroup.PosAndRotCalculated = false; BlockEngine.UpdateDisplayedBlock(Id); diff --git a/TechbloxModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs index 7bade49..935e3a1 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -70,75 +70,9 @@ namespace TechbloxModdingAPI.Blocks : entitiesDB.QueryEntity(index, CommonExclusiveGroups.COLOUR_PALETTE_GROUP).Colour; - public OptionalRef GetBlockInfo(EGID blockID) where T : unmanaged, IEntityComponent + public OptionalRef GetBlockInfo(Block block) where T : unmanaged, IEntityComponent { - return entitiesDB.TryQueryEntitiesAndIndex(blockID, out uint index, out var array) - ? new OptionalRef(array, index) - : new OptionalRef(); - } - - public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityViewComponent - { - if (entitiesDB.Exists(blockID)) - return ref entitiesDB.QueryEntity(blockID); - T[] structHolder = new T[1]; //Create something that can be referenced - return ref structHolder[0]; //Gets a default value automatically - } - - public U GetBlockInfo(Block block, Func getter, - U def = default) where T : unmanaged, IEntityComponent - { - if (entitiesDB.Exists(block.Id)) - return getter(entitiesDB.QueryEntity(block.Id)); - return GetBlockInitInfo(block, getter, def); - } - - public U GetBlockInfoViewStruct(Block block, Func getter, - U def = default) where T : struct, IEntityViewComponent - { - if (entitiesDB.Exists(block.Id)) - return getter(entitiesDB.QueryEntity(block.Id)); - return GetBlockInitInfo(block, getter, def); - } - - private U GetBlockInitInfo(Block block, Func getter, U def) where T : struct, IEntityComponent - { - if (block.InitData.Group == null) return def; - var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); - if (initializer.Has()) - return getter(initializer.Get()); - return def; - } - - public delegate void Setter(ref T component, U value) where T : struct, IEntityComponent; - - public void SetBlockInfoViewStruct(Block block, Setter setter, U value) where T : struct, IEntityViewComponent - { - if (entitiesDB.Exists(block.Id)) - setter(ref entitiesDB.QueryEntity(block.Id), value); - else - SetBlockInitInfo(block, setter, value); - } - - public void SetBlockInfo(Block block, Setter setter, U value) where T : unmanaged, IEntityComponent - { - if (entitiesDB.Exists(block.Id)) - setter(ref entitiesDB.QueryEntity(block.Id), value); - else - SetBlockInitInfo(block, setter, value); - } - - private void SetBlockInitInfo(Block block, Setter setter, U value) - where T : struct, IEntityComponent - { - if (block.InitData.Group != null) - { - var initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); - T component = initializer.Has() ? initializer.Get() : default; - ref T structRef = ref component; - setter(ref structRef, value); - initializer.Init(structRef); - } + return entitiesDB.QueryEntityOptional(block); } public void UpdateDisplayedBlock(EGID id) @@ -153,7 +87,8 @@ namespace TechbloxModdingAPI.Blocks internal void UpdatePrefab(Block block, ushort type, byte material, bool flipped) { uint pid = PrefabsID.GetOrCreatePrefabID(type, material, 0, flipped); - entitiesDB.QueryEntityOrDefault() + entitiesDB.QueryEntityOrDefault(block).prefabID = pid; + entitiesDB.QueryEntityOrDefault(block) = new PhysicsPrefabEntityStruct(pid); } public bool BlockExists(EGID blockID) @@ -161,16 +96,6 @@ namespace TechbloxModdingAPI.Blocks return entitiesDB.Exists(blockID); } - public bool GetBlockInfoExists(Block block) where T : struct, IEntityComponent - { - if (entitiesDB.Exists(block.Id)) - return true; - if (block.InitData.Group == null) - return false; - var init = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); - return init.Has(); - } - public SimBody[] GetSimBodiesFromID(byte id) { var ret = new FasterList(4); diff --git a/TechbloxModdingAPI/Blocks/MovementEngine.cs b/TechbloxModdingAPI/Blocks/MovementEngine.cs index aeeac20..7ecf934 100644 --- a/TechbloxModdingAPI/Blocks/MovementEngine.cs +++ b/TechbloxModdingAPI/Blocks/MovementEngine.cs @@ -34,21 +34,12 @@ namespace TechbloxModdingAPI.Blocks // implementations for Movement static class - internal float3 MoveBlock(EGID blockID, BlockEngine.BlockInitData data, float3 vector) + internal float3 MoveBlock(Block block, float3 vector) { - if (!entitiesDB.Exists(blockID)) - { - if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group, data.Reference); - init.GetOrCreate().position = vector; - init.GetOrCreate().position = vector; - init.GetOrCreate().position = vector; - return vector; - } - ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(blockID); - ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntity(blockID); - ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntity(blockID); - ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntity(blockID); + ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntityOrDefault(block); // main (persistent) position posStruct.position = vector; // placement grid position @@ -56,24 +47,21 @@ namespace TechbloxModdingAPI.Blocks // rendered position transStruct.position = vector; // collision position - FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Translation - { - Value = posStruct.position - }); - entitiesDB.QueryEntity(blockID).isProcessed = false; + if (phyStruct.ID != EGID.Empty) + { //It exists + FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Translation + { + Value = posStruct.position + }); + } + + entitiesDB.QueryEntityOrDefault(block).isProcessed = false; return posStruct.position; } - internal float3 GetPosition(EGID blockID, BlockEngine.BlockInitData data) + internal float3 GetPosition(Block block) { - if (!entitiesDB.Exists(blockID)) - { - if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group, data.Reference); - return init.Has() ? init.Get().position : float3.zero; - } - ref PositionEntityStruct posStruct = ref this.entitiesDB.QueryEntity(blockID); - return posStruct.position; + return entitiesDB.QueryEntityOrDefault(block).position; } } } diff --git a/TechbloxModdingAPI/Blocks/RotationEngine.cs b/TechbloxModdingAPI/Blocks/RotationEngine.cs index cef4691..b1e54e5 100644 --- a/TechbloxModdingAPI/Blocks/RotationEngine.cs +++ b/TechbloxModdingAPI/Blocks/RotationEngine.cs @@ -34,55 +34,38 @@ namespace TechbloxModdingAPI.Blocks // implementations for Rotation static class - internal float3 RotateBlock(EGID blockID, BlockEngine.BlockInitData data, Vector3 vector) + internal float3 RotateBlock(Block block, Vector3 vector) { - if (!entitiesDB.Exists(blockID)) - { - if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group, data.Reference); - init.GetOrCreate().rotation = Quaternion.Euler(vector); - init.GetOrCreate().rotation = Quaternion.Euler(vector); - init.GetOrCreate().rotation = Quaternion.Euler(vector); - return vector; - } - ref RotationEntityStruct rotStruct = ref this.entitiesDB.QueryEntity(blockID); - ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntity(blockID); - ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntity(blockID); - ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntity(blockID); - // main (persistent) position + ref RotationEntityStruct rotStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref GridRotationStruct gridStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref LocalTransformEntityStruct transStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + ref UECSPhysicsEntityStruct phyStruct = ref this.entitiesDB.QueryEntityOrDefault(block); + // main (persistent) rotation Quaternion newRotation = rotStruct.rotation; newRotation.eulerAngles = vector; rotStruct.rotation = newRotation; // placement grid rotation - Quaternion newGridRotation = gridStruct.rotation; - newGridRotation.eulerAngles = vector; - gridStruct.rotation = newGridRotation; - // rendered position - Quaternion newTransRotation = rotStruct.rotation; - newTransRotation.eulerAngles = vector; - transStruct.rotation = newTransRotation; - // collision position - FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Unity.Transforms.Rotation - { - Value = rotStruct.rotation - }); - entitiesDB.QueryEntity(blockID).isProcessed = false; + gridStruct.rotation = newRotation; + // rendered rotation + transStruct.rotation = newRotation; + // collision rotation + if (phyStruct.ID != EGID.Empty) + { //It exists + FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, + new Unity.Transforms.Rotation + { + Value = rotStruct.rotation + }); + } + + entitiesDB.QueryEntityOrDefault(block).isProcessed = false; return ((Quaternion)rotStruct.rotation).eulerAngles; } - internal float3 GetRotation(EGID blockID, BlockEngine.BlockInitData data) + internal float3 GetRotation(Block block) { - if (!entitiesDB.Exists(blockID)) - { - if (data.Group == null) return float3.zero; - var init = new EntityInitializer(blockID, data.Group, data.Reference); - return init.Has() - ? (float3) ((Quaternion) init.Get().rotation).eulerAngles - : float3.zero; - } - - ref RotationEntityStruct rotStruct = ref entitiesDB.QueryEntity(blockID); + ref RotationEntityStruct rotStruct = ref entitiesDB.QueryEntityOrDefault(block); return ((Quaternion) rotStruct.rotation).eulerAngles; } } diff --git a/TechbloxModdingAPI/Blocks/SignalEngine.cs b/TechbloxModdingAPI/Blocks/SignalEngine.cs index 6e40af1..f486463 100644 --- a/TechbloxModdingAPI/Blocks/SignalEngine.cs +++ b/TechbloxModdingAPI/Blocks/SignalEngine.cs @@ -3,6 +3,7 @@ using Svelto.ECS; using Svelto.DataStructures; using Gamecraft.Wires; using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Blocks { @@ -87,8 +88,8 @@ namespace TechbloxModdingAPI.Blocks public ref PortEntityStruct GetPortByOffset(Block block, byte portNumber, bool input) { - BlockPortsStruct bps = GetFromDbOrInitData(block, block.Id, out bool exists); - if (!exists) + var bps = entitiesDB.QueryEntityOptional(block); + if (!bps) { throw new BlockException("Block does not exist"); } @@ -208,8 +209,9 @@ namespace TechbloxModdingAPI.Blocks public EGID MatchBlockInputToPort(Block block, byte portUsage, out bool exists) { - BlockPortsStruct ports = GetFromDbOrInitData(block, block.Id, out exists); - return new EGID(ports.firstInputID + portUsage, NamedExclusiveGroup.Group); + var ports = entitiesDB.QueryEntityOptional(block); + exists = ports; + return new EGID(ports.Get().firstInputID + portUsage, NamedExclusiveGroup.Group); } public EGID MatchBlockInputToPort(EGID block, byte portUsage, out bool exists) @@ -226,8 +228,9 @@ namespace TechbloxModdingAPI.Blocks public EGID MatchBlockOutputToPort(Block block, byte portUsage, out bool exists) { - BlockPortsStruct ports = GetFromDbOrInitData(block, block.Id, out exists); - return new EGID(ports.firstOutputID + portUsage, NamedExclusiveGroup.Group); + var ports = entitiesDB.QueryEntityOptional(block); + exists = ports; + return new EGID(ports.Get().firstOutputID + portUsage, NamedExclusiveGroup.Group); } public EGID MatchBlockOutputToPort(EGID block, byte portUsage, out bool exists) @@ -385,29 +388,6 @@ namespace TechbloxModdingAPI.Blocks return results.ToArray(); } - private ref T GetFromDbOrInitData(Block block, EGID id, out bool exists) where T : unmanaged, IEntityComponent - { - T[] defRef = new T[1]; - if (entitiesDB.Exists(id)) - { - exists = true; - return ref entitiesDB.QueryEntity(id); - } - if (block == null || block.InitData.Group == null) - { - exists = false; - return ref defRef[0]; - } - EntityInitializer initializer = new EntityInitializer(block.Id, block.InitData.Group, block.InitData.Reference); - if (initializer.Has()) - { - exists = true; - return ref initializer.Get(); - } - exists = false; - return ref defRef[0]; - } - private EntityCollection GetSignalStruct(uint signalID, out uint index, bool input = true) { ExclusiveGroup group = input From d238c97906eb56dbd3aa0561bdfa2f3d6363289d Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 10 May 2021 23:08:15 +0200 Subject: [PATCH 53/98] Remove block info getters and setters Regex is great GetBlockInfo\(this, \((\w+) (\w+)\) ?=> ?\2(.+)\); GetBlockInfo<$1>(this)$3; SetBlockInfo\(this, \(ref (\w+) (\w+), \w+ (\w+)\) ?=> \2(.*) = \3,\s*value\); GetBlockInfo<$1>(this)$4 = value; --- TechbloxModdingAPI/Block.cs | 13 ++++++------ TechbloxModdingAPI/Blocks/BlockEngine.cs | 7 ++++++- TechbloxModdingAPI/Blocks/DampedSpring.cs | 6 +++--- TechbloxModdingAPI/Blocks/Motor.cs | 12 +++++------ TechbloxModdingAPI/Blocks/MusicBlock.cs | 4 ++-- TechbloxModdingAPI/Blocks/ObjectIdentifier.cs | 4 ++-- TechbloxModdingAPI/Blocks/Piston.cs | 9 ++++----- TechbloxModdingAPI/Blocks/Servo.cs | 16 +++++++-------- TechbloxModdingAPI/Blocks/SfxBlock.cs | 10 +++++----- TechbloxModdingAPI/Blocks/SignalingBlock.cs | 4 ++-- TechbloxModdingAPI/Blocks/SpawnPoint.cs | 16 +++++++-------- TechbloxModdingAPI/Blocks/TextBlock.cs | 6 +++--- TechbloxModdingAPI/Blocks/Timer.cs | 20 ++++++++----------- 13 files changed, 63 insertions(+), 64 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 0e97a03..b2d400d 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -285,14 +285,14 @@ namespace TechbloxModdingAPI /// public float3 Scale { - get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale); + get => BlockEngine.GetBlockInfo(this).scale; set { int uscale = UniformScale; if (value.x < 4e-5) value.x = uscale; if (value.y < 4e-5) value.y = uscale; if (value.z < 4e-5) value.z = uscale; - BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, float3 val) => st.scale = val, value); + BlockEngine.GetBlockInfo(this).scale = value; if (!Exists) return; //UpdateCollision needs the block to exist ScalingEngine.UpdateCollision(Id); BlockEngine.UpdateDisplayedBlock(Id); @@ -305,12 +305,11 @@ namespace TechbloxModdingAPI /// public int UniformScale { - get => BlockEngine.GetBlockInfo(this, (UniformBlockScaleEntityStruct st) => st.scaleFactor); + get => BlockEngine.GetBlockInfo(this).scaleFactor; set { if (value < 1) value = 1; - BlockEngine.SetBlockInfo(this, (ref UniformBlockScaleEntityStruct st, int val) => st.scaleFactor = val, - value); + BlockEngine.GetBlockInfo(this).scaleFactor = value; Scale = new float3(value, value, value); } } @@ -320,7 +319,7 @@ namespace TechbloxModdingAPI */ public bool Flipped { - get => BlockEngine.GetBlockInfo(this, (ScalingEntityStruct st) => st.scale.x < 0); + get => BlockEngine.GetBlockInfo(this).scale.x < 0; set { BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) => @@ -371,7 +370,7 @@ namespace TechbloxModdingAPI /// public float4 CustomColor { - get => BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.paletteColour); + get => BlockEngine.GetBlockInfo(this).paletteColour; set { BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) => diff --git a/TechbloxModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs index 935e3a1..80e14f3 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -70,11 +70,16 @@ namespace TechbloxModdingAPI.Blocks : entitiesDB.QueryEntity(index, CommonExclusiveGroups.COLOUR_PALETTE_GROUP).Colour; - public OptionalRef GetBlockInfo(Block block) where T : unmanaged, IEntityComponent + public OptionalRef GetBlockInfoOptional(Block block) where T : unmanaged, IEntityComponent { return entitiesDB.QueryEntityOptional(block); } + public ref T GetBlockInfo(Block block) where T : unmanaged, IEntityComponent + { + return ref entitiesDB.QueryEntityOrDefault(block); + } + public void UpdateDisplayedBlock(EGID id) { if (!BlockExists(id)) return; diff --git a/TechbloxModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs index 34c7543..3c92f72 100644 --- a/TechbloxModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -19,7 +19,7 @@ namespace TechbloxModdingAPI.Blocks /// public float MaxForce { - get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct dsrs) => dsrs.springFrequency); + get => BlockEngine.GetBlockInfo(this).springFrequency; set => BlockEngine.SetBlockInfo(this, (ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.springFrequency = val, value); @@ -39,7 +39,7 @@ namespace TechbloxModdingAPI.Blocks /// public float Damping { - get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.springDamping); + get => BlockEngine.GetBlockInfo(this).springDamping; set => BlockEngine.SetBlockInfo(this, (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value); @@ -50,7 +50,7 @@ namespace TechbloxModdingAPI.Blocks /// public float MaxExtension { - get => BlockEngine.GetBlockInfo(this, (DampedSpringReadOnlyStruct ljf) => ljf.maxExtent); + get => BlockEngine.GetBlockInfo(this).maxExtent; set => BlockEngine.SetBlockInfo(this, (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.maxExtent = val, value); diff --git a/TechbloxModdingAPI/Blocks/Motor.cs b/TechbloxModdingAPI/Blocks/Motor.cs index 6b1e500..46ed9e4 100644 --- a/TechbloxModdingAPI/Blocks/Motor.cs +++ b/TechbloxModdingAPI/Blocks/Motor.cs @@ -28,12 +28,12 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxVelocity); + return BlockEngine.GetBlockInfo(this).maxVelocity; } set { - BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxVelocity = val, value); + BlockEngine.GetBlockInfo(this).maxVelocity = value; } } @@ -44,12 +44,12 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.maxForce); + return BlockEngine.GetBlockInfo(this).maxForce; } set { - BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, float val) => st.maxForce = val, value); + BlockEngine.GetBlockInfo(this).maxForce = value; } } @@ -60,12 +60,12 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MotorReadOnlyStruct st) => st.reverse); + return BlockEngine.GetBlockInfo(this).reverse; } set { - BlockEngine.SetBlockInfo(this, (ref MotorReadOnlyStruct st, bool val) => st.reverse = val, value); + BlockEngine.GetBlockInfo(this).reverse = value; } } } diff --git a/TechbloxModdingAPI/Blocks/MusicBlock.cs b/TechbloxModdingAPI/Blocks/MusicBlock.cs index 30ca5ab..ea4aeca 100644 --- a/TechbloxModdingAPI/Blocks/MusicBlock.cs +++ b/TechbloxModdingAPI/Blocks/MusicBlock.cs @@ -28,7 +28,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MusicBlockDataEntityStruct st) => st.trackIndx); + return BlockEngine.GetBlockInfo(this).trackIndx; } set @@ -83,7 +83,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MusicBlockDataEntityStruct msdes) => msdes.tweakableVolume); + return BlockEngine.GetBlockInfo(this).tweakableVolume; } set diff --git a/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs index 67e250e..fe2d657 100644 --- a/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs +++ b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs @@ -16,7 +16,7 @@ namespace TechbloxModdingAPI.Blocks public char Identifier { - get => (char) BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.objectId + 'A'); + get => (char) BlockEngine.GetBlockInfo(this).objectId + 'A'; set { BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) => @@ -32,7 +32,7 @@ namespace TechbloxModdingAPI.Blocks /// public byte SimID { - get => BlockEngine.GetBlockInfo(this, (ObjectIdEntityStruct st) => st.simObjectId); + get => BlockEngine.GetBlockInfo(this).simObjectId; } /// diff --git a/TechbloxModdingAPI/Blocks/Piston.cs b/TechbloxModdingAPI/Blocks/Piston.cs index b5953ee..9c1b98a 100644 --- a/TechbloxModdingAPI/Blocks/Piston.cs +++ b/TechbloxModdingAPI/Blocks/Piston.cs @@ -26,12 +26,11 @@ namespace TechbloxModdingAPI.Blocks /// public float MaximumExtension { - get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.maxDeviation); + get => BlockEngine.GetBlockInfo(this).maxDeviation; set { - BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.maxDeviation = val, - value); + BlockEngine.GetBlockInfo(this).maxDeviation = value; } } @@ -40,11 +39,11 @@ namespace TechbloxModdingAPI.Blocks /// public float MaximumForce { - get => BlockEngine.GetBlockInfo(this, (PistonReadOnlyStruct st) => st.pistonVelocity); + get => BlockEngine.GetBlockInfo(this).pistonVelocity; set { - BlockEngine.SetBlockInfo(this, (ref PistonReadOnlyStruct st, float val) => st.pistonVelocity = val, value); + BlockEngine.GetBlockInfo(this).pistonVelocity = value; } } } diff --git a/TechbloxModdingAPI/Blocks/Servo.cs b/TechbloxModdingAPI/Blocks/Servo.cs index 12232de..cdbd87b 100644 --- a/TechbloxModdingAPI/Blocks/Servo.cs +++ b/TechbloxModdingAPI/Blocks/Servo.cs @@ -26,11 +26,11 @@ namespace TechbloxModdingAPI.Blocks /// public float MinimumAngle { - get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.minDeviation); + get => BlockEngine.GetBlockInfo(this).minDeviation; set { - BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.minDeviation = val, value); + BlockEngine.GetBlockInfo(this).minDeviation = value; } } @@ -39,11 +39,11 @@ namespace TechbloxModdingAPI.Blocks /// public float MaximumAngle { - get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.maxDeviation); + get => BlockEngine.GetBlockInfo(this).maxDeviation; set { - BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.maxDeviation = val, value); + BlockEngine.GetBlockInfo(this).maxDeviation = value; } } @@ -52,11 +52,11 @@ namespace TechbloxModdingAPI.Blocks /// public float MaximumForce { - get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.servoVelocity); + get => BlockEngine.GetBlockInfo(this).servoVelocity; set { - BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, float val) => st.servoVelocity = val, value); + BlockEngine.GetBlockInfo(this).servoVelocity = value; } } @@ -65,11 +65,11 @@ namespace TechbloxModdingAPI.Blocks /// public bool Reverse { - get => BlockEngine.GetBlockInfo(this, (ServoReadOnlyStruct st) => st.reverse); + get => BlockEngine.GetBlockInfo(this).reverse; set { - BlockEngine.SetBlockInfo(this, (ref ServoReadOnlyStruct st, bool val) => st.reverse = val, value); + BlockEngine.GetBlockInfo(this).reverse = value; } } } diff --git a/TechbloxModdingAPI/Blocks/SfxBlock.cs b/TechbloxModdingAPI/Blocks/SfxBlock.cs index c72d37a..45453fb 100644 --- a/TechbloxModdingAPI/Blocks/SfxBlock.cs +++ b/TechbloxModdingAPI/Blocks/SfxBlock.cs @@ -22,7 +22,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.tweakableVolume); + return BlockEngine.GetBlockInfo(this).tweakableVolume; } set @@ -36,7 +36,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.tweakablePitch); + return BlockEngine.GetBlockInfo(this).tweakablePitch; } set @@ -50,7 +50,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.is3D); + return BlockEngine.GetBlockInfo(this).is3D; } set @@ -78,7 +78,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.soundEffectIndex); + return BlockEngine.GetBlockInfo(this).soundEffectIndex; } set @@ -162,7 +162,7 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => obj.isLoopedBlock); + return BlockEngine.GetBlockInfo(this).isLoopedBlock; } set diff --git a/TechbloxModdingAPI/Blocks/SignalingBlock.cs b/TechbloxModdingAPI/Blocks/SignalingBlock.cs index b18521a..293e00d 100644 --- a/TechbloxModdingAPI/Blocks/SignalingBlock.cs +++ b/TechbloxModdingAPI/Blocks/SignalingBlock.cs @@ -67,7 +67,7 @@ namespace TechbloxModdingAPI.Blocks /// public uint InputCount { - get => BlockEngine.GetBlockInfo(this, (BlockPortsStruct st) => st.inputCount); + get => BlockEngine.GetBlockInfo(this).inputCount; } /// @@ -75,7 +75,7 @@ namespace TechbloxModdingAPI.Blocks /// public uint OutputCount { - get => BlockEngine.GetBlockInfo(this, (BlockPortsStruct st) => st.outputCount); + get => BlockEngine.GetBlockInfo(this).outputCount; } /// diff --git a/TechbloxModdingAPI/Blocks/SpawnPoint.cs b/TechbloxModdingAPI/Blocks/SpawnPoint.cs index ac6c014..0c5c75a 100644 --- a/TechbloxModdingAPI/Blocks/SpawnPoint.cs +++ b/TechbloxModdingAPI/Blocks/SpawnPoint.cs @@ -28,11 +28,11 @@ namespace TechbloxModdingAPI.Blocks /// public uint Lives { - get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.lives); + get => BlockEngine.GetBlockInfo(this).lives; set { - BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, uint val) => st.lives = val, value); + BlockEngine.GetBlockInfo(this).lives = value; } } @@ -41,11 +41,11 @@ namespace TechbloxModdingAPI.Blocks /// public bool Damageable { - get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.canTakeDamage); + get => BlockEngine.GetBlockInfo(this).canTakeDamage; set { - BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.canTakeDamage = val, value); + BlockEngine.GetBlockInfo(this).canTakeDamage = value; } } @@ -54,11 +54,11 @@ namespace TechbloxModdingAPI.Blocks /// public bool GameOverEnabled { - get => BlockEngine.GetBlockInfo(this, (SpawnPointStatsEntityStruct st) => st.gameOverScreen); + get => BlockEngine.GetBlockInfo(this).gameOverScreen; set { - BlockEngine.SetBlockInfo(this, (ref SpawnPointStatsEntityStruct st, bool val) => st.gameOverScreen = val, value); + BlockEngine.GetBlockInfo(this).gameOverScreen = value; } } @@ -67,11 +67,11 @@ namespace TechbloxModdingAPI.Blocks /// public byte Team { - get => BlockEngine.GetBlockInfo(this, (SpawnPointIdsEntityStruct st) => st.teamId); + get => BlockEngine.GetBlockInfo(this).teamId; set { - BlockEngine.SetBlockInfo(this, (ref SpawnPointIdsEntityStruct st, byte val) => st.teamId = val, value); + BlockEngine.GetBlockInfo(this).teamId = value; } } } diff --git a/TechbloxModdingAPI/Blocks/TextBlock.cs b/TechbloxModdingAPI/Blocks/TextBlock.cs index 0e33b75..c3ee1b0 100644 --- a/TechbloxModdingAPI/Blocks/TextBlock.cs +++ b/TechbloxModdingAPI/Blocks/TextBlock.cs @@ -26,8 +26,8 @@ namespace TechbloxModdingAPI.Blocks /// The text block's current text. /// public string Text - { - get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textCurrent); + { + get => BlockEngine.GetBlockInfo(this).textCurrent; set { @@ -45,7 +45,7 @@ namespace TechbloxModdingAPI.Blocks /// public string TextBlockId { - get => BlockEngine.GetBlockInfo(this, (TextBlockDataStruct st) => st.textBlockID); + get => BlockEngine.GetBlockInfo(this).textBlockID; set { diff --git a/TechbloxModdingAPI/Blocks/Timer.cs b/TechbloxModdingAPI/Blocks/Timer.cs index 6337864..9803258 100644 --- a/TechbloxModdingAPI/Blocks/Timer.cs +++ b/TechbloxModdingAPI/Blocks/Timer.cs @@ -28,12 +28,11 @@ namespace TechbloxModdingAPI.Blocks /// public float Start { - get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime); + get => BlockEngine.GetBlockInfo(this).startTime; set { - BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val, - value); + BlockEngine.GetBlockInfo(this).startTime = value; } } @@ -42,12 +41,11 @@ namespace TechbloxModdingAPI.Blocks /// public float End { - get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime); + get => BlockEngine.GetBlockInfo(this).endTime; set { - BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val, - value); + BlockEngine.GetBlockInfo(this).endTime = value; } } @@ -56,12 +54,11 @@ namespace TechbloxModdingAPI.Blocks /// public bool DisplayMilliseconds { - get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS); + get => BlockEngine.GetBlockInfo(this).outputFormatHasMS; set { - BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val, - value); + BlockEngine.GetBlockInfo(this).outputFormatHasMS = value; } } @@ -70,12 +67,11 @@ namespace TechbloxModdingAPI.Blocks /// public int CurrentTime { - get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS); + get => BlockEngine.GetBlockInfo(this).timeLastRenderFrameMS; set { - BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val, - value); + BlockEngine.GetBlockInfo(this).timeLastRenderFrameMS = value; } } } From 858a5c9b5c4c8494b562548194ac4bf5bff3aa75 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 11 May 2021 00:56:46 +0200 Subject: [PATCH 54/98] Fix remaining errors, add support for managed entity DB --- TechbloxModdingAPI/Block.cs | 77 +++++----- TechbloxModdingAPI/Blocks/BlockEngine.cs | 10 ++ TechbloxModdingAPI/Blocks/DampedSpring.cs | 9 +- TechbloxModdingAPI/Blocks/MusicBlock.cs | 88 +++++------ TechbloxModdingAPI/Blocks/ObjectIdentifier.cs | 9 +- TechbloxModdingAPI/Blocks/SfxBlock.cs | 137 +++++++++--------- TechbloxModdingAPI/Blocks/SignalingBlock.cs | 1 - TechbloxModdingAPI/Blocks/TextBlock.cs | 11 +- TechbloxModdingAPI/Cluster.cs | 16 +- TechbloxModdingAPI/Players/FlyCamEngine.cs | 1 + TechbloxModdingAPI/SimBody.cs | 20 +-- .../Utility/ManagedApiExtensions.cs | 55 +++++++ ...piExtensions.cs => NativeApiExtensions.cs} | 5 +- TechbloxModdingAPI/Utility/OptionalRef.cs | 76 ++++++---- 14 files changed, 282 insertions(+), 233 deletions(-) create mode 100644 TechbloxModdingAPI/Utility/ManagedApiExtensions.cs rename TechbloxModdingAPI/Utility/{ApiExtensions.cs => NativeApiExtensions.cs} (92%) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index b2d400d..5181723 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -322,13 +322,9 @@ namespace TechbloxModdingAPI get => BlockEngine.GetBlockInfo(this).scale.x < 0; set { - BlockEngine.SetBlockInfo(this, (ref ScalingEntityStruct st, bool val) => - st.scale.x = math.abs(st.scale.x) * (val ? -1 : 1), value); - BlockEngine.SetBlockInfo(this, (ref GFXPrefabEntityStructGPUI st, bool val) => - { - uint prefabId = PrefabsID.GetOrCreatePrefabID((ushort) Type, (byte) Material, 0, value); - st.prefabID = prefabId; - }, value); + var st = BlockEngine.GetBlockInfo(this); + st.scale.x = math.abs(st.scale.x) * (value ? -1 : 1); + BlockEngine.UpdatePrefab(this, (ushort) Type, (byte) Material, value); } } @@ -339,7 +335,8 @@ namespace TechbloxModdingAPI { get { - return BlockEngine.GetBlockInfo(this, (DBEntityStruct st) => (BlockIDs) st.DBID, BlockIDs.Invalid); + var opt = BlockEngine.GetBlockInfoOptional(this); + return opt ? (BlockIDs) opt.Get().DBID : BlockIDs.Invalid; } } @@ -350,18 +347,16 @@ namespace TechbloxModdingAPI { get { - byte index = BlockEngine.GetBlockInfo(this, (ColourParameterEntityStruct st) => st.indexInPalette, - byte.MaxValue); - return new BlockColor(index); + var opt = BlockEngine.GetBlockInfoOptional(this); + return new BlockColor(opt ? opt.Get().indexInPalette : byte.MaxValue); } set { - BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, BlockColor val) => - { //TODO: Check if setting to 255 works - color.indexInPalette = val.Index; - color.hasNetworkChange = true; - color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); - }, value); + //TODO: Check if setting to 255 works + var color = BlockEngine.GetBlockInfo(this); + color.indexInPalette = value.Index; + color.hasNetworkChange = true; + color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); } } @@ -373,11 +368,9 @@ namespace TechbloxModdingAPI get => BlockEngine.GetBlockInfo(this).paletteColour; set { - BlockEngine.SetBlockInfo(this, (ref ColourParameterEntityStruct color, float4 val) => - { - color.paletteColour = val; - color.hasNetworkChange = true; - }, value); + ref var color = ref BlockEngine.GetBlockInfo(this); + color.paletteColour = value; + color.hasNetworkChange = true; } } @@ -386,9 +379,16 @@ namespace TechbloxModdingAPI */ public BlockMaterial Material { - get => BlockEngine.GetBlockInfo(this, (CubeMaterialStruct cmst) => (BlockMaterial) cmst.materialId, BlockMaterial.Default); - set => BlockEngine.SetBlockInfo(this, - (ref CubeMaterialStruct cmst, BlockMaterial val) => cmst.materialId = (byte) val, value); + get + { + var opt = BlockEngine.GetBlockInfoOptional(this); + return opt ? (BlockMaterial) opt.Get().materialId : BlockMaterial.Default; + } + set + { + BlockEngine.GetBlockInfo(this).materialId = (byte) value; + BlockEngine.UpdatePrefab(this, (ushort) Type, (byte) value, Flipped); //TODO: Test default + } } /// @@ -397,13 +397,11 @@ namespace TechbloxModdingAPI /// public string Label { - get => BlockEngine.GetBlockInfoViewStruct(this, (TextLabelEntityViewStruct st) => st.textLabelComponent?.text); + get => BlockEngine.GetBlockInfoViewComponent(this).textLabelComponent?.text; set { - BlockEngine.SetBlockInfoViewStruct(this, (ref TextLabelEntityViewStruct text, string val) => - { - if (text.textLabelComponent != null) text.textLabelComponent.text = val; - }, value); + var comp = BlockEngine.GetBlockInfoViewComponent(this).textLabelComponent; + if (comp != null) comp.text = value; } } @@ -421,9 +419,8 @@ namespace TechbloxModdingAPI get { if (blockGroup != null) return blockGroup; - return blockGroup = BlockEngine.GetBlockInfo(this, - (BlockGroupEntityComponent bgec) => - bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this)); + var bgec = BlockEngine.GetBlockInfo(this); + return blockGroup = bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this); } set { @@ -434,9 +431,7 @@ namespace TechbloxModdingAPI return; } blockGroup?.RemoveInternal(this); - BlockEngine.SetBlockInfo(this, - (ref BlockGroupEntityComponent bgec, BlockGroup val) => bgec.currentBlockGroup = val?.Id ?? -1, - value); + BlockEngine.GetBlockInfo(this).currentBlockGroup = value?.Id ?? -1; value?.AddInternal(this); blockGroup = value; } @@ -466,10 +461,10 @@ namespace TechbloxModdingAPI /// The SimBody of the chunk or null if the block doesn't exist or not in simulation mode. public SimBody GetSimBody() { - return BlockEngine.GetBlockInfo(this, - (GridConnectionsEntityStruct st) => st.machineRigidBodyId != uint.MaxValue - ? new SimBody(st.machineRigidBodyId, st.clusterId) - : null); + var st = BlockEngine.GetBlockInfo(this); + return st.machineRigidBodyId != uint.MaxValue + ? new SimBody(st.machineRigidBodyId, st.clusterId) + : null; } /// @@ -555,7 +550,7 @@ namespace TechbloxModdingAPI //Lets improve that using delegates var block = New(Id.entityID, Id.groupID); - if (this.InitData.Group != null) + if (this.InitData.Valid) { block.InitData = this.InitData; Placed += block.OnPlacedInit; //Reset InitData of new object diff --git a/TechbloxModdingAPI/Blocks/BlockEngine.cs b/TechbloxModdingAPI/Blocks/BlockEngine.cs index 80e14f3..c23ee8d 100644 --- a/TechbloxModdingAPI/Blocks/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/BlockEngine.cs @@ -80,6 +80,16 @@ namespace TechbloxModdingAPI.Blocks return ref entitiesDB.QueryEntityOrDefault(block); } + internal ref T GetBlockInfo(EcsObjectBase obj) where T : unmanaged, IEntityComponent + { + return ref entitiesDB.QueryEntityOrDefault(obj); + } + + public ref T GetBlockInfoViewComponent(Block block) where T : struct, IEntityViewComponent + { + return ref entitiesDB.QueryEntityOrDefault(block); + } + public void UpdateDisplayedBlock(EGID id) { if (!BlockExists(id)) return; diff --git a/TechbloxModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs index 3c92f72..4623d6d 100644 --- a/TechbloxModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -21,8 +21,7 @@ namespace TechbloxModdingAPI.Blocks { get => BlockEngine.GetBlockInfo(this).springFrequency; - set => BlockEngine.SetBlockInfo(this, - (ref DampedSpringReadOnlyStruct dsrs, float val) => dsrs.springFrequency = val, value); + set => BlockEngine.GetBlockInfo(this).springFrequency = value; } /// @@ -41,8 +40,7 @@ namespace TechbloxModdingAPI.Blocks { get => BlockEngine.GetBlockInfo(this).springDamping; - set => BlockEngine.SetBlockInfo(this, - (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.springDamping = val, value); + set => BlockEngine.GetBlockInfo(this).springDamping = value; } /// @@ -52,8 +50,7 @@ namespace TechbloxModdingAPI.Blocks { get => BlockEngine.GetBlockInfo(this).maxExtent; - set => BlockEngine.SetBlockInfo(this, - (ref DampedSpringReadOnlyStruct ljf, float val) => ljf.maxExtent = val, value); + set => BlockEngine.GetBlockInfo(this).maxExtent = value; } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/MusicBlock.cs b/TechbloxModdingAPI/Blocks/MusicBlock.cs index ea4aeca..51e96ee 100644 --- a/TechbloxModdingAPI/Blocks/MusicBlock.cs +++ b/TechbloxModdingAPI/Blocks/MusicBlock.cs @@ -33,8 +33,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref MusicBlockDataEntityStruct msdes, byte val) => msdes.trackIndx = val, value); + BlockEngine.GetBlockInfo(this).trackIndx = value; } } @@ -42,24 +41,22 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, - (MusicBlockDataEntityStruct msdes) => msdes.fmod2DEventPaths.Get(msdes.trackIndx)); + var msdes = BlockEngine.GetBlockInfo(this); + return msdes.fmod2DEventPaths.Get(msdes.trackIndx); } set { - BlockEngine.SetBlockInfo(this, (ref MusicBlockDataEntityStruct msdes, Guid val) => + ref var msdes = ref BlockEngine.GetBlockInfo(this); + for (byte i = 0; i < msdes.fmod2DEventPaths.Count(); i++) { - for (byte i = 0; i < msdes.fmod2DEventPaths.Count(); i++) + Guid track = msdes.fmod2DEventPaths.Get(i); + if (track == value) { - Guid track = msdes.fmod2DEventPaths.Get(i); - if (track == val) - { - msdes.trackIndx = i; - break; - } + msdes.trackIndx = i; + break; } - }, value); + } } } @@ -67,15 +64,13 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (MusicBlockDataEntityStruct msdes) => + var msdes = BlockEngine.GetBlockInfo(this); + Guid[] tracks = new Guid[msdes.fmod2DEventPaths.Count()]; + for (byte i = 0; i < tracks.Length; i++) { - Guid[] tracks = new Guid[msdes.fmod2DEventPaths.Count()]; - for (byte i = 0; i < tracks.Length; i++) - { - tracks[i] = msdes.fmod2DEventPaths.Get(i); - } - return tracks; - }); + tracks[i] = msdes.fmod2DEventPaths.Get(i); + } + return tracks; } } @@ -88,8 +83,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref MusicBlockDataEntityStruct msdes, float val) => msdes.tweakableVolume = val, value); + BlockEngine.GetBlockInfo(this).tweakableVolume = value; } } @@ -98,14 +92,12 @@ namespace TechbloxModdingAPI.Blocks get { //Assert.Log("Block exists: " + Exists); - return BlockEngine.GetBlockInfo(this, - (MusicBlockDataEntityStruct msdes) => (ChannelType) msdes.channelType); + return (ChannelType) BlockEngine.GetBlockInfo(this).channelType; } set { - BlockEngine.SetBlockInfo(this, - (ref MusicBlockDataEntityStruct msdes, ChannelType val) => msdes.channelType = (byte) val, value); + BlockEngine.GetBlockInfo(this).channelType = (byte) value; } } @@ -113,33 +105,31 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, - (MusicBlockDataEntityStruct msdes) => msdes.isPlaying); + return BlockEngine.GetBlockInfo(this).isPlaying; } set { - BlockEngine.SetBlockInfo(this, (ref MusicBlockDataEntityStruct msdes, bool val) => + ref var msdes = ref BlockEngine.GetBlockInfo(this); + if (msdes.isPlaying == value) return; + if (value) { - if (msdes.isPlaying == val) return; - if (val) - { - // start playing - EventInstance inst = RuntimeManager.CreateInstance(msdes.fmod2DEventPaths.Get(msdes.trackIndx)); - inst.setVolume(msdes.tweakableVolume / 100f); - inst.start(); - msdes.eventHandle = inst.handle; - } - else - { - // stop playing - EventInstance inst = default(EventInstance); - inst.handle = msdes.eventHandle; - inst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); - inst.release(); - } - msdes.isPlaying = val; - }, value); + // start playing + EventInstance inst = RuntimeManager.CreateInstance(msdes.fmod2DEventPaths.Get(msdes.trackIndx)); + inst.setVolume(msdes.tweakableVolume / 100f); + inst.start(); + msdes.eventHandle = inst.handle; + } + else + { + // stop playing + EventInstance inst = default(EventInstance); + inst.handle = msdes.eventHandle; + inst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); + inst.release(); + } + + msdes.isPlaying = value; } } } diff --git a/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs index fe2d657..046054b 100644 --- a/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs +++ b/TechbloxModdingAPI/Blocks/ObjectIdentifier.cs @@ -16,14 +16,11 @@ namespace TechbloxModdingAPI.Blocks public char Identifier { - get => (char) BlockEngine.GetBlockInfo(this).objectId + 'A'; + get => (char) (BlockEngine.GetBlockInfo(this).objectId + 'A'); set { - BlockEngine.SetBlockInfo(this, (ref ObjectIdEntityStruct st, char val) => - { - st.objectId = (byte) (val - 'A'); - Label = val + ""; //The label isn't updated automatically - }, value); + BlockEngine.GetBlockInfo(this).objectId = (byte) (value - 'A'); + Label = value + ""; //The label isn't updated automatically } } diff --git a/TechbloxModdingAPI/Blocks/SfxBlock.cs b/TechbloxModdingAPI/Blocks/SfxBlock.cs index 45453fb..6b6ab36 100644 --- a/TechbloxModdingAPI/Blocks/SfxBlock.cs +++ b/TechbloxModdingAPI/Blocks/SfxBlock.cs @@ -27,8 +27,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, float val) => obj.tweakableVolume = val, value); + BlockEngine.GetBlockInfo(this).tweakableVolume = value; } } @@ -41,8 +40,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, float val) => obj.tweakablePitch = val, value); + BlockEngine.GetBlockInfo(this).tweakablePitch = value; } } @@ -55,8 +53,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, bool val) => obj.is3D = val, value); + BlockEngine.GetBlockInfo(this).is3D = value; } } @@ -64,13 +61,12 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => (ChannelType)obj.channelType); + return (ChannelType) BlockEngine.GetBlockInfo(this).channelType; } set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, ChannelType val) => obj.tweakableVolume = (byte) val, value); + BlockEngine.GetBlockInfo(this).channelType = (byte) value; } } @@ -83,8 +79,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, byte val) => obj.soundEffectIndex = val, value); + BlockEngine.GetBlockInfo(this).soundEffectIndex = value; } } @@ -93,35 +88,36 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, - (SoundSfxBlockDataEntityStruct obj) => obj.is3D ? obj.fmod3DEventPaths.Get(obj.soundEffectIndex) : obj.fmod2DEventPaths.Get(obj.soundEffectIndex)); + var obj = BlockEngine.GetBlockInfo(this); + return obj.is3D + ? obj.fmod3DEventPaths.Get(obj.soundEffectIndex) + : obj.fmod2DEventPaths.Get(obj.soundEffectIndex); } set { - BlockEngine.SetBlockInfo(this, (ref SoundSfxBlockDataEntityStruct obj, Guid val) => + var obj = BlockEngine.GetBlockInfo(this); + for (byte i = 0; i < obj.fmod2DEventPaths.Count(); i++) { - for (byte i = 0; i < obj.fmod2DEventPaths.Count(); i++) + Guid track = obj.fmod2DEventPaths.Get(i); + if (track == value) { - Guid track = obj.fmod2DEventPaths.Get(i); - if (track == val) - { - obj.soundEffectIndex = i; - obj.is3D = false; - return; - } + obj.soundEffectIndex = i; + obj.is3D = false; + return; } - for (byte i = 0; i < obj.fmod3DEventPaths.Count(); i++) + } + + for (byte i = 0; i < obj.fmod3DEventPaths.Count(); i++) + { + Guid track = obj.fmod3DEventPaths.Get(i); + if (track == value) { - Guid track = obj.fmod3DEventPaths.Get(i); - if (track == val) - { - obj.soundEffectIndex = i; - obj.is3D = true; - return; - } + obj.soundEffectIndex = i; + obj.is3D = true; + return; } - }, value); + } } } @@ -130,31 +126,29 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => + var obj = BlockEngine.GetBlockInfo(this); + Guid[] tracks = new Guid[obj.fmod2DEventPaths.Count()]; + for (byte i = 0; i < tracks.Length; i++) { - Guid[] tracks = new Guid[obj.fmod2DEventPaths.Count()]; - for (byte i = 0; i < tracks.Length; i++) - { - tracks[i] = obj.fmod2DEventPaths.Get(i); - } - return tracks; - }); + tracks[i] = obj.fmod2DEventPaths.Get(i); + } + + return tracks; } } - + public Guid[] Tracks3D { get { - return BlockEngine.GetBlockInfo(this, (SoundSfxBlockDataEntityStruct obj) => + var obj = BlockEngine.GetBlockInfo(this); + Guid[] tracks = new Guid[obj.fmod3DEventPaths.Count()]; + for (byte i = 0; i < tracks.Length; i++) { - Guid[] tracks = new Guid[obj.fmod3DEventPaths.Count()]; - for (byte i = 0; i < tracks.Length; i++) - { - tracks[i] = obj.fmod2DEventPaths.Get(i); - } - return tracks; - }); + tracks[i] = obj.fmod2DEventPaths.Get(i); + } + + return tracks; } } @@ -167,8 +161,7 @@ namespace TechbloxModdingAPI.Blocks set { - BlockEngine.SetBlockInfo(this, - (ref SoundSfxBlockDataEntityStruct obj, bool val) => obj.isLoopedBlock = val, value); + BlockEngine.GetBlockInfo(this).isLoopedBlock = value; } } @@ -176,33 +169,33 @@ namespace TechbloxModdingAPI.Blocks { get { - return BlockEngine.GetBlockInfo(this, - (SoundSfxBlockDataEntityStruct obj) => obj.isPlaying); + return BlockEngine.GetBlockInfo(this).isPlaying; } set { - BlockEngine.SetBlockInfo(this, (ref SoundSfxBlockDataEntityStruct obj, bool val) => + var obj = BlockEngine.GetBlockInfo(this); + if (obj.isPlaying == value) return; + if (value) { - if (obj.isPlaying == val) return; - if (val) - { - // start playing - EventInstance inst = RuntimeManager.CreateInstance(obj.is3D ? obj.fmod3DEventPaths.Get(obj.soundEffectIndex) : obj.fmod2DEventPaths.Get(obj.soundEffectIndex)); - inst.setVolume(obj.tweakableVolume / 100f); - inst.start(); - obj.eventHandle = inst.handle; - } - else - { - // stop playing - EventInstance inst = default(EventInstance); - inst.handle = obj.eventHandle; - inst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); - inst.release(); - } - obj.isPlaying = val; - }, value); + // start playing + EventInstance inst = RuntimeManager.CreateInstance(obj.is3D + ? obj.fmod3DEventPaths.Get(obj.soundEffectIndex) + : obj.fmod2DEventPaths.Get(obj.soundEffectIndex)); + inst.setVolume(obj.tweakableVolume / 100f); + inst.start(); + obj.eventHandle = inst.handle; + } + else + { + // stop playing + EventInstance inst = default(EventInstance); + inst.handle = obj.eventHandle; + inst.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT); + inst.release(); + } + + obj.isPlaying = value; } } } diff --git a/TechbloxModdingAPI/Blocks/SignalingBlock.cs b/TechbloxModdingAPI/Blocks/SignalingBlock.cs index 293e00d..45b5aa6 100644 --- a/TechbloxModdingAPI/Blocks/SignalingBlock.cs +++ b/TechbloxModdingAPI/Blocks/SignalingBlock.cs @@ -109,7 +109,6 @@ namespace TechbloxModdingAPI.Blocks /// The localized port name. public string PortName(byte port, bool input) { - BlockPortsStruct bps = BlockEngine.GetBlockInfo(this, (BlockPortsStruct a) => a); PortEntityStruct pes = SignalEngine.GetPortByOffset(this, port, input); return pes.portNameLocalised; } diff --git a/TechbloxModdingAPI/Blocks/TextBlock.cs b/TechbloxModdingAPI/Blocks/TextBlock.cs index c3ee1b0..99c753a 100644 --- a/TechbloxModdingAPI/Blocks/TextBlock.cs +++ b/TechbloxModdingAPI/Blocks/TextBlock.cs @@ -32,11 +32,9 @@ namespace TechbloxModdingAPI.Blocks set { if (value == null) value = ""; - BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) => - { - tbds.textCurrent.Set(val); - tbds.textStored.Set(val, true); - }, value); + var tbds = BlockEngine.GetBlockInfo(this); + tbds.textCurrent.Set(value); + tbds.textStored.Set(value, true); } } @@ -50,8 +48,7 @@ namespace TechbloxModdingAPI.Blocks set { if (value == null) value = ""; - BlockEngine.SetBlockInfo(this, (ref TextBlockDataStruct tbds, string val) => - tbds.textBlockID.Set(val), value); + BlockEngine.GetBlockInfo(this).textBlockID.Set(value); } } } diff --git a/TechbloxModdingAPI/Cluster.cs b/TechbloxModdingAPI/Cluster.cs index 11b995c..2544194 100644 --- a/TechbloxModdingAPI/Cluster.cs +++ b/TechbloxModdingAPI/Cluster.cs @@ -8,9 +8,9 @@ namespace TechbloxModdingAPI /// Represnts a cluster of blocks in time running mode, meaning blocks that are connected either directly or via joints. /// Only exists if a cluster destruction manager is present. Static blocks like grass and dirt aren't part of a cluster. /// - public class Cluster + public class Cluster : EcsObjectBase { - public EGID Id { get; } + public override EGID Id { get; } public Cluster(EGID id) { @@ -23,20 +23,20 @@ namespace TechbloxModdingAPI public float InitialHealth { - get => Block.BlockEngine.GetBlockInfo(Id).initialHealth; - set => Block.BlockEngine.GetBlockInfo(Id).initialHealth = value; + get => Block.BlockEngine.GetBlockInfo(this).initialHealth; + set => Block.BlockEngine.GetBlockInfo(this).initialHealth = value; } public float CurrentHealth { - get => Block.BlockEngine.GetBlockInfo(Id).currentHealth; - set => Block.BlockEngine.GetBlockInfo(Id).currentHealth = value; + get => Block.BlockEngine.GetBlockInfo(this).currentHealth; + set => Block.BlockEngine.GetBlockInfo(this).currentHealth = value; } public float HealthMultiplier { - get => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier; - set => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier = value; + get => Block.BlockEngine.GetBlockInfo(this).healthMultiplier; + set => Block.BlockEngine.GetBlockInfo(this).healthMultiplier = value; } /// diff --git a/TechbloxModdingAPI/Players/FlyCamEngine.cs b/TechbloxModdingAPI/Players/FlyCamEngine.cs index 0b98071..cd52363 100644 --- a/TechbloxModdingAPI/Players/FlyCamEngine.cs +++ b/TechbloxModdingAPI/Players/FlyCamEngine.cs @@ -1,6 +1,7 @@ using Svelto.ECS; using Techblox.FlyCam; using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Players { diff --git a/TechbloxModdingAPI/SimBody.cs b/TechbloxModdingAPI/SimBody.cs index dd7429e..55c6a9e 100644 --- a/TechbloxModdingAPI/SimBody.cs +++ b/TechbloxModdingAPI/SimBody.cs @@ -12,9 +12,9 @@ namespace TechbloxModdingAPI /// /// A rigid body (like a chunk of connected blocks) during simulation. /// - public class SimBody : IEquatable, IEquatable + public class SimBody : EcsObjectBase, IEquatable, IEquatable { - public EGID Id { get; } + public override EGID Id { get; } /// /// The cluster this chunk belongs to, or null if no cluster destruction manager present or the chunk doesn't exist. @@ -92,26 +92,26 @@ namespace TechbloxModdingAPI public float InitialHealth { - get => Block.BlockEngine.GetBlockInfo(Id).initialHealth; - set => Block.BlockEngine.GetBlockInfo(Id).initialHealth = value; + get => Block.BlockEngine.GetBlockInfo(this).initialHealth; + set => Block.BlockEngine.GetBlockInfo(this).initialHealth = value; } public float CurrentHealth { - get => Block.BlockEngine.GetBlockInfo(Id).currentHealth; - set => Block.BlockEngine.GetBlockInfo(Id).currentHealth = value; + get => Block.BlockEngine.GetBlockInfo(this).currentHealth; + set => Block.BlockEngine.GetBlockInfo(this).currentHealth = value; } public float HealthMultiplier { - get => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier; - set => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier = value; + get => Block.BlockEngine.GetBlockInfo(this).healthMultiplier; + set => Block.BlockEngine.GetBlockInfo(this).healthMultiplier = value; } /// /// Whether the body can be moved or static. /// - public bool Static => Block.BlockEngine.GetBlockInfo(Id).isStatic; //Setting it doesn't have any effect + public bool Static => Block.BlockEngine.GetBlockInfo(this).isStatic; //Setting it doesn't have any effect /// /// The rigid bodies connected to this one via functional joints (broken ones don't count). @@ -132,7 +132,7 @@ namespace TechbloxModdingAPI private ref RigidBodyEntityStruct GetStruct() { - return ref Block.BlockEngine.GetBlockInfo(Id); + return ref Block.BlockEngine.GetBlockInfo(this); } public override string ToString() diff --git a/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs b/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs new file mode 100644 index 0000000..2616ab7 --- /dev/null +++ b/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs @@ -0,0 +1,55 @@ +using Svelto.ECS; +using Svelto.ECS.Hybrid; +using TechbloxModdingAPI.Blocks; + +namespace TechbloxModdingAPI.Utility +{ + public static class ManagedApiExtensions + { + /// + /// Attempts to query an entity and returns an optional that contains the result if succeeded. + /// This overload does not take initializer data into account. + /// + /// The entities DB + /// The EGID to query + /// The component type to query + /// An optional that contains the result on success or is empty if not found + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EGID egid) + where T : struct, IEntityViewComponent + { + return entitiesDB.TryQueryEntitiesAndIndex(egid, out uint index, out var array) + ? new OptionalRef(array, index) + : new OptionalRef(); + } + + /// + /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// + /// + /// + /// + /// + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj) + where T : struct, IEntityViewComponent + { + var opt = QueryEntityOptional(entitiesDB, obj.Id); + return opt ? opt : new OptionalRef(obj, true); + } + + /// + /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// + /// + /// + /// + /// + public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj) + where T : struct, IEntityViewComponent + { + var opt = QueryEntityOptional(entitiesDB, obj.Id); + if (opt) return ref opt.Get(); + if (obj.InitData.Valid) return ref obj.InitData.Initializer(obj.Id).GetOrCreate(); + return ref opt.Get(); //Default value + } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/ApiExtensions.cs b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs similarity index 92% rename from TechbloxModdingAPI/Utility/ApiExtensions.cs rename to TechbloxModdingAPI/Utility/NativeApiExtensions.cs index 3da1a67..701e42f 100644 --- a/TechbloxModdingAPI/Utility/ApiExtensions.cs +++ b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs @@ -3,10 +3,11 @@ using TechbloxModdingAPI.Blocks; namespace TechbloxModdingAPI.Utility { - public static class ApiExtensions + public static class NativeApiExtensions { /// /// Attempts to query an entity and returns an optional that contains the result if succeeded. + /// This overload does not take initializer data into account. /// /// The entities DB /// The EGID to query @@ -31,7 +32,7 @@ namespace TechbloxModdingAPI.Utility where T : unmanaged, IEntityComponent { var opt = QueryEntityOptional(entitiesDB, obj.Id); - return opt ? opt : new OptionalRef(obj); + return opt ? opt : new OptionalRef(obj, true); } /// diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 2323431..c5cfb83 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -1,44 +1,53 @@ using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using TechbloxModdingAPI.Blocks; +using System.Runtime.InteropServices; using Svelto.DataStructures; using Svelto.ECS; -namespace TechbloxModdingAPI +namespace TechbloxModdingAPI.Utility { - public ref struct OptionalRef where T : unmanaged, IEntityComponent + [StructLayout(LayoutKind.Explicit)] //Make the array and managedArray fields take up the same space + public ref struct OptionalRef where T : struct, IEntityComponent { - private bool exists; - private NB array; - private uint index; - private EntityInitializer initializer; + [FieldOffset(0)] private readonly State state; + [FieldOffset(1)] private readonly uint index; + [FieldOffset(5)] private NB array; + [FieldOffset(5)] private MB managedArray; + [FieldOffset(1)] private readonly EntityInitializer initializer; + //The possible fields are: (index && (array || managedArray)) || initializer public OptionalRef(NB array, uint index) { - exists = true; + state = State.Native; this.array = array; this.index = index; initializer = default; } - + + public OptionalRef(MB array, uint index) + { + state = State.Managed; + managedArray = array; + this.index = index; + initializer = default; + this.array = default; + } + /// /// Wraps the initializer data, if present. /// /// The object with the initializer - public OptionalRef(EcsObjectBase obj) + /// Whether the struct is unmanaged + public OptionalRef(EcsObjectBase obj, bool unmanaged) { if (obj.InitData.Valid) { initializer = obj.InitData.Initializer(obj.Id); - exists = true; + state = (unmanaged ? State.Native : State.Managed) | State.Initializer; } else { initializer = default; - exists = false; + state = State.Empty; } array = default; index = default; @@ -50,31 +59,36 @@ namespace TechbloxModdingAPI /// The value or the default value public ref T Get() { - if (!exists) return ref CompRefCache.Default; - if (initializer.EGID == EGID.Empty) - return ref array[index]; - return ref initializer.GetOrCreate(); + if (state == State.Empty) return ref CompRefCache.Default; + if ((state & State.Initializer) != State.Empty) return ref initializer.GetOrCreate(); + if ((state & State.Native) != State.Empty) return ref array[index]; + return ref managedArray[index]; } - public bool Exists => exists; + public bool Exists => state != State.Empty; public static implicit operator T(OptionalRef opt) => opt.Get(); - public static implicit operator bool(OptionalRef opt) => opt.exists; - - /*public delegate ref TR Mapper(ref T component) where TR : unmanaged; - public unsafe delegate TR* PMapper(T* component) where TR : unmanaged; - - public unsafe OptionalRef Map(PMapper mapper) where TR : unmanaged => - exists ? new OptionalRef(ref *mapper(pointer)) : new OptionalRef();*/ + public static implicit operator bool(OptionalRef opt) => opt.state != State.Empty; /// /// Creates an instance of a struct T that can be referenced. /// - /// The struct type to cache - private struct CompRefCache where TR : unmanaged + internal struct CompRefCache { - public static TR Default; + public static T Default; + } + + /// + /// A byte that holds state in its bits. + /// + [Flags] + private enum State : byte + { + Empty, + Native, + Managed, + Initializer = 4 } } } \ No newline at end of file From 3eef859095a289b29bd5ce61faec2302926efdc2 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 11 May 2021 22:56:36 +0200 Subject: [PATCH 55/98] Update gen_csproj script and references --- Automation/gen_csproj.py | 8 ++++---- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Automation/gen_csproj.py b/Automation/gen_csproj.py index af00dd1..515bcda 100755 --- a/Automation/gen_csproj.py +++ b/Automation/gen_csproj.py @@ -27,7 +27,7 @@ def buildReferencesXml(path): return "\n \n" + "".join(result) + " \n" if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Generate GamecraftModdingAPI.csproj") + parser = argparse.ArgumentParser(description="Generate TechbloxModdingAPI.csproj") # TODO (maybe?): add params for custom csproj read and write locations args = parser.parse_args() @@ -35,8 +35,8 @@ if __name__ == "__main__": asmXml = buildReferencesXml("../ref/TechbloxPreview_Data/Managed") # print(asmXml) - with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "r") as xmlFile: - print("Parsing GamecraftModdingAPI.csproj") + with open("../TechbloxModdingAPI/TechbloxModdingAPI.csproj", "r") as xmlFile: + print("Parsing TechbloxModdingAPI.csproj") fileStr = xmlFile.read() # print(fileStr) depsStart = re.search(r"\ + + + + \ No newline at end of file diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 03d03a5..8f5298f 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -13,6 +13,7 @@ using RobocraftX.Common.Input; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Commands; using TechbloxModdingAPI.Input; +using TechbloxModdingAPI.Interface.IMGUI; using TechbloxModdingAPI.Players; using TechbloxModdingAPI.Utility; @@ -210,10 +211,10 @@ namespace TechbloxModdingAPI.Tests Logging.Log("Compatible TechbloxScripting detected"); } // Interface test - /*Interface.IMGUI.Group uiGroup = new Group(new Rect(20, 20, 200, 500), "TechbloxModdingAPI_UITestGroup", true); - Interface.IMGUI.Button button = new Button("TEST"); + /*Group uiGroup = new Group(new Rect(20, 20, 200, 500), "TechbloxModdingAPI_UITestGroup", true); + var button = new Button("TEST"); button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; - Interface.IMGUI.Button button2 = new Button("TEST2"); + var button2 = new Button("TEST2"); button2.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; Text uiText = new Text("This is text!", multiline: true); uiText.OnEdit += (t, txt) => { Logging.MetaDebugLog($"Text in {((Text)t).Name} is now '{txt}'"); }; diff --git a/TechbloxModdingAPI/Tests/TestRoot.cs b/TechbloxModdingAPI/Tests/TestRoot.cs index 2ac7c62..7177818 100644 --- a/TechbloxModdingAPI/Tests/TestRoot.cs +++ b/TechbloxModdingAPI/Tests/TestRoot.cs @@ -66,7 +66,7 @@ namespace TechbloxModdingAPI.Tests // flow control Game.Enter += (sender, args) => { GameTests().RunOn(RobocraftX.Schedulers.Lean.EveryFrameStepRunner_TimeRunningAndStopped); }; Game.Exit += (s, a) => state = "ReturningFromGame"; - Client.EnterMenu += (sender, args) => + Client.EnterMenu += (sender, args) => { if (state == "EnteringMenu") { diff --git a/TechbloxModdingAPI/Utility/ExceptionUtil.cs b/TechbloxModdingAPI/Utility/ExceptionUtil.cs index 0809e43..d11508b 100644 --- a/TechbloxModdingAPI/Utility/ExceptionUtil.cs +++ b/TechbloxModdingAPI/Utility/ExceptionUtil.cs @@ -6,7 +6,7 @@ namespace TechbloxModdingAPI.Utility public static class ExceptionUtil { /// - /// Invokes an event in a try-catch block to avoid propagating exceptions. + /// Invokes an event with a null-check. /// /// The event to emit, can be null /// Event sender @@ -14,16 +14,30 @@ namespace TechbloxModdingAPI.Utility /// Type of the event arguments public static void InvokeEvent(EventHandler handler, object sender, T args) { - try + handler?.Invoke(sender, args); + } + + /// + /// Wraps the event handler in a try-catch block to avoid propagating exceptions. + /// + /// The handler to wrap (not null) + /// Type of the event arguments + /// The wrapped handler + public static EventHandler WrapHandler(EventHandler handler) + { + return (sender, e) => { - handler?.Invoke(sender, args); - } - catch (Exception e) - { - EventRuntimeException wrappedException = - new EventRuntimeException($"EventHandler with arg type {typeof(T).Name} threw an exception", e); - Logging.LogWarning(wrappedException.ToString()); - } + try + { + handler(sender, e); + } + catch (Exception e1) + { + EventRuntimeException wrappedException = + new EventRuntimeException($"EventHandler with arg type {typeof(T).Name} threw an exception", e1); + Logging.LogWarning(wrappedException.ToString()); + } + }; } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/GameEngineManager.cs b/TechbloxModdingAPI/Utility/GameEngineManager.cs index 603170c..fc51861 100644 --- a/TechbloxModdingAPI/Utility/GameEngineManager.cs +++ b/TechbloxModdingAPI/Utility/GameEngineManager.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using RobocraftX.StateSync; using Svelto.ECS; using TechbloxModdingAPI.Engines; @@ -60,18 +61,20 @@ namespace TechbloxModdingAPI.Utility } } - public static void RegisterEngines(EnginesRoot enginesRoot) + public static void RegisterEngines(StateSyncRegistrationHelper helper) { + var enginesRoot = helper.enginesRoot; _lastEngineRoot = enginesRoot; - IEntityFactory factory = enginesRoot.GenerateEntityFactory(); + IEntityFactory factory = enginesRoot.GenerateEntityFactory(); foreach (var key in _gameEngines.Keys) { Logging.MetaDebugLog($"Registering Game IApiEngine {_gameEngines[key].Name}"); - enginesRoot.AddEngine(_gameEngines[key]); - if (typeof(IFactoryEngine).IsAssignableFrom(_gameEngines[key].GetType())) - { - ((IFactoryEngine)_gameEngines[key]).Factory = factory; - } + if (_gameEngines[key] is IDeterministicEngine detEngine) + helper.AddDeterministicEngine(detEngine); + else + enginesRoot.AddEngine(_gameEngines[key]); + if (_gameEngines[key] is IFactoryEngine factEngine) + factEngine.Factory = factory; } } } diff --git a/TechbloxModdingAPI/Utility/MenuEngineManager.cs b/TechbloxModdingAPI/Utility/MenuEngineManager.cs index c3dd29c..3260563 100644 --- a/TechbloxModdingAPI/Utility/MenuEngineManager.cs +++ b/TechbloxModdingAPI/Utility/MenuEngineManager.cs @@ -69,9 +69,9 @@ namespace TechbloxModdingAPI.Utility { Logging.MetaDebugLog($"Registering Menu IApiEngine {_menuEngines[key].Name}"); enginesRoot.AddEngine(_menuEngines[key]); - if (typeof(IFactoryEngine).IsAssignableFrom(_menuEngines[key].GetType())) + if (_menuEngines[key] is IFactoryEngine factEngine) { - ((IFactoryEngine)_menuEngines[key]).Factory = factory; + factEngine.Factory = factory; } } } From 220eb02a1996c38d3c2924ce9f13b692e520e0ed Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 25 May 2021 01:20:46 +0200 Subject: [PATCH 71/98] Return descriptions with command names, selected block/color fix --- TechbloxModdingAPI/Commands/ExistingCommands.cs | 15 ++++++--------- TechbloxModdingAPI/FlyCam.cs | 13 +++++++++++++ TechbloxModdingAPI/Player.cs | 4 ++-- TechbloxModdingAPI/Players/FlyCamEngine.cs | 12 ++++++++++++ 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/TechbloxModdingAPI/Commands/ExistingCommands.cs b/TechbloxModdingAPI/Commands/ExistingCommands.cs index 35dd199..dfd3921 100644 --- a/TechbloxModdingAPI/Commands/ExistingCommands.cs +++ b/TechbloxModdingAPI/Commands/ExistingCommands.cs @@ -1,4 +1,4 @@ -using System; +using System.Linq; using uREPL; @@ -27,16 +27,13 @@ namespace TechbloxModdingAPI.Commands } public static bool Exists(string commandName) - { + { return RuntimeCommands.HasRegistered(commandName); } - public static string[] GetCommandNames() - { - var keys = RuntimeCommands.table.Keys; - string[] res = new string[keys.Count]; - keys.CopyTo(res, 0); - return res; - } + public static (string Name, string Description)[] GetCommandNamesAndDescriptions() + { + return RuntimeCommands.table.Values.Select(command => (command.name, command.description)).ToArray(); + } } } diff --git a/TechbloxModdingAPI/FlyCam.cs b/TechbloxModdingAPI/FlyCam.cs index 201fd0a..edf0691 100644 --- a/TechbloxModdingAPI/FlyCam.cs +++ b/TechbloxModdingAPI/FlyCam.cs @@ -2,6 +2,7 @@ using RobocraftX.Physics; using Svelto.ECS; using Svelto.ECS.EntityStructs; using Techblox.FlyCam; +using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Players; using TechbloxModdingAPI.Utility; using Unity.Mathematics; @@ -111,6 +112,18 @@ namespace TechbloxModdingAPI set => Engine.GetComponent(this).angularVelocity = value; } + /// + /// The player's selected block ID in their hand. + /// + /// The selected block. + public BlockIDs SelectedBlock => (BlockIDs)Engine.GetSelectedBlock(this); + + /// + /// The player's selected block color in their hand. + /// + /// The selected block's color. + public BlockColor SelectedColor => new BlockColor(Engine.GetSelectedColor(this)); + public static void Init() { GameEngineManager.AddGameEngine(Engine); diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index a5e5dc5..7d37f9b 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -313,7 +313,7 @@ namespace TechbloxModdingAPI { get { - return (BlockIDs)playerEngine.GetSelectedBlock(Id); + return BuildCamera.SelectedBlock; } } @@ -325,7 +325,7 @@ namespace TechbloxModdingAPI { get { - return new BlockColor(playerEngine.GetSelectedColor(Id)); + return BuildCamera.SelectedColor; } } diff --git a/TechbloxModdingAPI/Players/FlyCamEngine.cs b/TechbloxModdingAPI/Players/FlyCamEngine.cs index 2db12e5..7cad252 100644 --- a/TechbloxModdingAPI/Players/FlyCamEngine.cs +++ b/TechbloxModdingAPI/Players/FlyCamEngine.cs @@ -23,5 +23,17 @@ namespace TechbloxModdingAPI.Players { return ref entitiesDB.QueryEntityOrDefault(cam); } + + public ushort GetSelectedBlock(FlyCam cam) + { + var oc = entitiesDB.QueryEntityOptional(cam); + return oc ? (ushort) oc.Get().SelectedDBPartID : ushort.MaxValue; + } + + public byte GetSelectedColor(FlyCam cam) + { + var oc = entitiesDB.QueryEntityOptional(cam); + return oc ? oc.Get().indexInPalette : (byte) 255; + } } } \ No newline at end of file From 5bfd0b7f1092c5410be5d28d573c67c411e652e7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 28 May 2021 02:12:54 +0200 Subject: [PATCH 72/98] Integrate FlyCam class into Player Using QueryEntityOptional directly with the player properties Character structs are camera structs in build mode The FlyCam rotation is not updated in build mode, only the camera is --- TechbloxModdingAPI/FlyCam.cs | 132 -------- TechbloxModdingAPI/Main.cs | 1 - TechbloxModdingAPI/Player.FlyCamSettings.cs | 51 +++ TechbloxModdingAPI/Player.cs | 183 +++++----- TechbloxModdingAPI/Players/FlyCamEngine.cs | 39 --- .../Players/PlayerBuildingMode.cs | 3 +- TechbloxModdingAPI/Players/PlayerEngine.cs | 319 ++---------------- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 1 + 8 files changed, 163 insertions(+), 566 deletions(-) delete mode 100644 TechbloxModdingAPI/FlyCam.cs create mode 100644 TechbloxModdingAPI/Player.FlyCamSettings.cs delete mode 100644 TechbloxModdingAPI/Players/FlyCamEngine.cs diff --git a/TechbloxModdingAPI/FlyCam.cs b/TechbloxModdingAPI/FlyCam.cs deleted file mode 100644 index edf0691..0000000 --- a/TechbloxModdingAPI/FlyCam.cs +++ /dev/null @@ -1,132 +0,0 @@ -using RobocraftX.Physics; -using Svelto.ECS; -using Svelto.ECS.EntityStructs; -using Techblox.FlyCam; -using TechbloxModdingAPI.Blocks; -using TechbloxModdingAPI.Players; -using TechbloxModdingAPI.Utility; -using Unity.Mathematics; -using UnityEngine; - -namespace TechbloxModdingAPI -{ - public class FlyCam : EcsObjectBase - { - private static FlyCamEngine Engine = new FlyCamEngine(); - - public override EGID Id { get; } - - public FlyCam(uint id) => Id = new EGID(id, Techblox.FlyCam.FlyCam.Group); - - /// - /// The local player's camera. - /// - public static FlyCam LocalCamera => new FlyCam(Player.LocalPlayer.Id); - - /// - /// The current position of the camera. - /// - public float3 Position - { - get => Engine.GetComponent(this).position; - set - { - Engine.GetComponent(this).position = value; - Engine.GetComponent(this).position = value; - } - } - - /// - /// The current rotation of the camera. - /// - public float3 Rotation - { - get => ((Quaternion) Engine.GetComponent(this).rotation).eulerAngles; - set - { - Engine.GetComponent(this).rotation = Quaternion.Euler(value); - Engine.GetComponent(this).rotation = Quaternion.Euler(value); - } - } - - /// - /// The current direction the camera is moving. - /// - public float3 MovementDirection - { - get => Engine.GetComponent(this).movementDirection; - set => Engine.GetComponent(this).movementDirection = value; - } - - /// - /// Whether the camera (player) is sprinting. - /// - public bool Sprinting - { - get => Engine.GetComponent(this).sprinting; - set => Engine.GetComponent(this).sprinting = value; - } - - /// - /// The speed setting of the camera. - /// - public float Speed - { - get => Engine.GetComponent(this).speed; - set => Engine.GetComponent(this).speed = value; - } - - /// - /// The multiplier setting to use when sprinting. - /// - public float SpeedSprintMultiplier - { - get => Engine.GetComponent(this).speedSprintMultiplier; - set => Engine.GetComponent(this).speedSprintMultiplier = value; - } - - /// - /// The acceleration setting of the camera. - /// - public float Acceleration - { - get => Engine.GetComponent(this).acceleration; - set => Engine.GetComponent(this).acceleration = value; - } - - /// - /// The current velocity of the camera. - /// - public float3 Velocity - { - get => Engine.GetComponent(this).velocity; - set => Engine.GetComponent(this).velocity = value; - } - - /// - /// The current angular velocity of the camera. - /// - public float3 AngularVelocity - { - get => Engine.GetComponent(this).angularVelocity; - set => Engine.GetComponent(this).angularVelocity = value; - } - - /// - /// The player's selected block ID in their hand. - /// - /// The selected block. - public BlockIDs SelectedBlock => (BlockIDs)Engine.GetSelectedBlock(this); - - /// - /// The player's selected block color in their hand. - /// - /// The selected block's color. - public BlockColor SelectedColor => new BlockColor(Engine.GetSelectedColor(this)); - - public static void Init() - { - GameEngineManager.AddGameEngine(Engine); - } - } -} \ No newline at end of file diff --git a/TechbloxModdingAPI/Main.cs b/TechbloxModdingAPI/Main.cs index af25bde..a390021 100644 --- a/TechbloxModdingAPI/Main.cs +++ b/TechbloxModdingAPI/Main.cs @@ -71,7 +71,6 @@ namespace TechbloxModdingAPI Input.FakeInput.Init(); // init object-oriented classes Player.Init(); - FlyCam.Init(); Block.Init(); BlockGroup.Init(); Wire.Init(); diff --git a/TechbloxModdingAPI/Player.FlyCamSettings.cs b/TechbloxModdingAPI/Player.FlyCamSettings.cs new file mode 100644 index 0000000..b947477 --- /dev/null +++ b/TechbloxModdingAPI/Player.FlyCamSettings.cs @@ -0,0 +1,51 @@ +using RobocraftX.Physics; +using Svelto.ECS; +using Svelto.ECS.EntityStructs; +using Techblox.FlyCam; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Players; +using TechbloxModdingAPI.Utility; +using Unity.Mathematics; +using UnityEngine; + +namespace TechbloxModdingAPI +{ + public partial class Player + { + /// + /// Whether the camera (player) is sprinting. + /// + public bool Sprinting + { + get => playerEngine.GetCharacterStruct(Id).Get().sprinting; + set => playerEngine.GetCharacterStruct(Id).Get().sprinting = value; + } + + /// + /// The speed setting of the camera. + /// + public float Speed + { + get => playerEngine.GetCharacterStruct(Id).Get().speed; + set => playerEngine.GetCharacterStruct(Id).Get().speed = value; + } + + /// + /// The multiplier setting to use when sprinting. + /// + public float SpeedSprintMultiplier + { + get => playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier; + set => playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier = value; + } + + /// + /// The acceleration setting of the camera. + /// + public float Acceleration + { + get => playerEngine.GetCharacterStruct(Id).Get().acceleration; + set => playerEngine.GetCharacterStruct(Id).Get().acceleration = value; + } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 7d37f9b..02e28f5 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -1,17 +1,23 @@ using System; +using RobocraftX.Character; using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; +using RobocraftX.Physics; using Svelto.ECS; +using Techblox.Camera; +using Techblox.FlyCam; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Players; +using TechbloxModdingAPI.Utility; +using UnityEngine; namespace TechbloxModdingAPI { /// /// An in-game player character. Any Leo you see is a player. /// - public class Player : IEquatable, IEquatable + public partial class Player : IEquatable, IEquatable { // static functionality private static PlayerEngine playerEngine = new PlayerEngine(); @@ -123,50 +129,33 @@ namespace TechbloxModdingAPI /// The position. public float3 Position { - get - { - return playerEngine.GetLocation(Id); - } - - set - { - playerEngine.SetLocation(Id, value, false); - } - } + get => playerEngine.GetCharacterStruct(Id).Get().position; + set => playerEngine.SetLocation(Id, value, false); + } /// /// The player's current rotation. /// /// The rotation. public float3 Rotation - { - get - { - return playerEngine.GetRotation(Id); - } - - set - { - playerEngine.SetRotation(Id, value); - } - } + { + get => ((Quaternion) (GameState.IsBuildMode() + ? playerEngine.GetCameraStruct(Id).Get().rotation + : playerEngine.GetCharacterStruct(Id).Get().rotation)).eulerAngles; + set => _ = GameState.IsBuildMode() + ? playerEngine.GetCameraStruct(Id).Get().rotation = quaternion.Euler(value) + : playerEngine.GetCharacterStruct(Id).Get().rotation = quaternion.Euler(value); + } /// /// The player's current velocity. /// /// The velocity. public float3 Velocity - { - get - { - return playerEngine.GetLinearVelocity(Id); - } - - set - { - playerEngine.SetLinearVelocity(Id, value); - } - } + { + get => playerEngine.GetCharacterStruct(Id).Get().velocity; + set => playerEngine.GetCharacterStruct(Id).Get().velocity = value; + } /// /// The player's current angular velocity. @@ -174,36 +163,18 @@ namespace TechbloxModdingAPI /// The angular velocity. public float3 AngularVelocity { - get - { - return playerEngine.GetAngularVelocity(Id); - } - - set - { - playerEngine.SetAngularVelocity(Id, value); - } + get => playerEngine.GetCharacterStruct(Id).Get().angularVelocity; + set => playerEngine.GetCharacterStruct(Id).Get().angularVelocity = value; } /// /// The player's mass. /// /// The mass. - public float Mass - { - get - { - return 1f / playerEngine.GetMass(Id).InverseMass; - } + public float Mass => + 1f / playerEngine.GetCharacterStruct(Id).Get().physicsMass.InverseMass; - // FIXME: Setting mass doesn't do anything - /*set - { - playerEngine.SetInverseMass(Id, 1f / value); - }*/ - } - - private float _ping = -1f; + private float _ping = -1f; /// /// The player's latest network ping time. @@ -213,10 +184,10 @@ namespace TechbloxModdingAPI { get { - float? temp = playerEngine.GetLastPingTime(Id, Type); - if (temp.HasValue) + var opt = playerEngine.GetPlayerStruct(Id, Type); + if (opt) { - _ping = temp.Value; + _ping = opt.Get().lastPingTimeSinceLevelLoad ?? _ping; } return _ping; } @@ -227,14 +198,15 @@ namespace TechbloxModdingAPI /// /// The initial health. public float InitialHealth - { - get => playerEngine.GetInitialHealth(Id); + { + get + { + var opt = playerEngine.GetCharacterStruct(Id); + return opt ? opt.Get().initialHealth : -1f; + } - set - { - playerEngine.SetInitialHealth(Id, value); - } - } + set => playerEngine.GetCharacterStruct(Id).Get().initialHealth = value; + } /// /// The player's current health in Simulation (aka Time Running) mode. @@ -242,12 +214,13 @@ namespace TechbloxModdingAPI /// The current health. public float CurrentHealth { - get => playerEngine.GetCurrentHealth(Id); + get + { + var opt = playerEngine.GetCharacterStruct(Id); + return opt ? opt.Get().currentHealth : -1f; + } - set - { - playerEngine.DamagePlayer(Id, CurrentHealth - value); - } + set => playerEngine.GetCharacterStruct(Id).Get().currentHealth = value; } /// @@ -255,14 +228,20 @@ namespace TechbloxModdingAPI /// /// true if damageable; otherwise, false. public bool Damageable - { - get => playerEngine.GetDamageable(Id); + { + get + { + var opt = playerEngine.GetCharacterStruct(Id); + return opt.Get().canTakeDamageStat; + } - set - { - playerEngine.SetDamageable(Id, value); - } - } + set + { + ref var healthStruct = ref playerEngine.GetCharacterStruct(Id).Get(); + healthStruct.canTakeDamage = value; + healthStruct.canTakeDamageStat = value; + } + } /// /// The player's lives when initially entering Simulation (aka Time Running) mode. @@ -270,9 +249,13 @@ namespace TechbloxModdingAPI /// The initial lives. public uint InitialLives { - get => playerEngine.GetInitialLives(Id); + get + { + var opt = playerEngine.GetCharacterStruct(Id); + return opt ? opt.Get().initialLives : uint.MaxValue; + } - set => playerEngine.SetInitialLives(Id, value); + set => playerEngine.GetCharacterStruct(Id).Get().initialLives = value; } /// @@ -281,19 +264,23 @@ namespace TechbloxModdingAPI /// The current lives. public uint CurrentLives { - get => playerEngine.GetCurrentLives(Id); + get + { + var opt = playerEngine.GetCharacterStruct(Id); + return opt ? opt.Get().currentLives : uint.MaxValue; + } - set => playerEngine.SetCurrentLives(Id, value); + set => playerEngine.GetCharacterStruct(Id).Get().currentLives = value; } - /// + /*/// /// Whether the Game Over screen is displayed for the player. /// /// true if game over; otherwise, false. public bool GameOver { get => playerEngine.GetGameOverScreen(Id); - } + }*/ /// /// Whether the player is dead. @@ -313,7 +300,8 @@ namespace TechbloxModdingAPI { get { - return BuildCamera.SelectedBlock; + var optstruct = playerEngine.GetCharacterStruct(Id); + return optstruct ? (BlockIDs) optstruct.Get().SelectedDBPartID : BlockIDs.Invalid; } } @@ -325,7 +313,8 @@ namespace TechbloxModdingAPI { get { - return BuildCamera.SelectedColor; + var optstruct = playerEngine.GetCharacterStruct(Id); + return optstruct ? new BlockColor(optstruct.Get().indexInPalette) : BlockColors.Default; } } @@ -337,7 +326,8 @@ namespace TechbloxModdingAPI { get { - return new BlockColor(playerEngine.GetSelectedColor(Id)); + var optstruct = playerEngine.GetCharacterStruct(Id); + return optstruct ? new BlockColor(optstruct.Get().indexInPalette) : BlockColors.Default; } } @@ -346,9 +336,11 @@ namespace TechbloxModdingAPI /// public Blueprint SelectedBlueprint { - get => playerEngine.GetPlayerStruct(Id, out LocalBlueprintInputStruct lbis) - ? new Blueprint(lbis.selectedBlueprintId) - : null; + get + { + var lbiso = playerEngine.GetPlayerStruct(Id, Type); + return lbiso ? new Blueprint(lbiso.Get().selectedBlueprintId) : null; + } set => BlockGroup._engine.SelectBlueprint(value?.Id ?? uint.MaxValue); } @@ -356,7 +348,7 @@ namespace TechbloxModdingAPI /// The player's mode in time stopped mode, determining what they place. /// public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine - .GetCharacterStruct(Id, out _).timeStoppedContext; + .GetCharacterStruct(Id).Get().timeStoppedContext; // object methods @@ -373,7 +365,7 @@ namespace TechbloxModdingAPI float3 location = new float3(x, y, z); if (relative) { - location += playerEngine.GetLocation(Id); + location += Position; } playerEngine.SetLocation(Id, location, exitSeat: exitSeat); } @@ -395,7 +387,7 @@ namespace TechbloxModdingAPI /// Returns the rigid body the player is currently looking at during simulation. /// /// The maximum distance from the player (default is the player's building reach) - /// The block or null if not found + /// The body or null if not found public SimBody GetSimBodyLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); @@ -413,11 +405,6 @@ namespace TechbloxModdingAPI return playerEngine.GetSelectedBlocks(Id); } - /// - /// The camera of this player used when building. - /// - public FlyCam BuildCamera => new FlyCam(Id); - public bool Equals(Player other) { if (ReferenceEquals(null, other)) return false; diff --git a/TechbloxModdingAPI/Players/FlyCamEngine.cs b/TechbloxModdingAPI/Players/FlyCamEngine.cs deleted file mode 100644 index 7cad252..0000000 --- a/TechbloxModdingAPI/Players/FlyCamEngine.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Svelto.ECS; -using Techblox.FlyCam; -using TechbloxModdingAPI.Engines; -using TechbloxModdingAPI.Utility; - -namespace TechbloxModdingAPI.Players -{ - public class FlyCamEngine : IApiEngine - { - public void Ready() - { - } - - public EntitiesDB entitiesDB { get; set; } - public void Dispose() - { - } - - public string Name => "TechbloxModdingAPIFlyCamEngine"; - public bool isRemovable => false; - - public ref T GetComponent(FlyCam cam) where T : unmanaged, IEntityComponent - { - return ref entitiesDB.QueryEntityOrDefault(cam); - } - - public ushort GetSelectedBlock(FlyCam cam) - { - var oc = entitiesDB.QueryEntityOptional(cam); - return oc ? (ushort) oc.Get().SelectedDBPartID : ushort.MaxValue; - } - - public byte GetSelectedColor(FlyCam cam) - { - var oc = entitiesDB.QueryEntityOptional(cam); - return oc ? oc.Get().indexInPalette : (byte) 255; - } - } -} \ No newline at end of file diff --git a/TechbloxModdingAPI/Players/PlayerBuildingMode.cs b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs index 383e1af..5e75555 100644 --- a/TechbloxModdingAPI/Players/PlayerBuildingMode.cs +++ b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs @@ -5,6 +5,7 @@ BlockMode, ColourMode, ConfigMode, - BlueprintMode + BlueprintMode, + MaterialMode } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index b4df628..f5fbb26 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -21,6 +21,7 @@ using HarmonyLib; using RobocraftX.Common; using Svelto.ECS.DataStructures; using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Players { @@ -98,17 +99,6 @@ namespace TechbloxModdingAPI.Players || entitiesDB.Exists(playerId, PlayersExclusiveGroups.RemotePlayers); } - public float3 GetLocation(uint playerId) - { - if (entitiesDB == null) return float3.zero; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return rbes.position; - } - return float3.zero; - } - public bool SetLocation(uint playerId, float3 location, bool exitSeat = true) { if (entitiesDB == null) return false; @@ -131,233 +121,6 @@ namespace TechbloxModdingAPI.Players return false; } - public float3 GetRotation(uint playerId) - { - if (entitiesDB == null) return float3.zero; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return ((Quaternion) rbes.rotation).eulerAngles; - } - return default(float3); - } - - public bool SetRotation(uint playerId, float3 value) - { - if (entitiesDB == null) return false; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - Quaternion q = rbes.rotation; - q.eulerAngles = value; - rbes.rotation = q; - return true; - } - return false; - } - - public float3 GetLinearVelocity(uint playerId) - { - if (entitiesDB == null) return float3.zero; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return rbes.velocity; - } - return float3.zero; - } - - public bool SetLinearVelocity(uint playerId, float3 value) - { - if (entitiesDB == null) return false; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - rbes.velocity = value; - return true; - } - return false; - } - - public float3 GetAngularVelocity(uint playerId) - { - if (entitiesDB == null) return float3.zero; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return rbes.angularVelocity; - } - return float3.zero; - } - - public bool SetAngularVelocity(uint playerId, float3 value) - { - if (entitiesDB == null) return false; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - rbes.angularVelocity = value; - return true; - } - return false; - } - - public PhysicsMass GetMass(uint playerId) - { - if (entitiesDB == null) return default(PhysicsMass); - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return rbes.physicsMass; - } - return default(PhysicsMass); - } - - public bool SetInverseMass(uint playerId, float inverseMass) - { - if (entitiesDB == null) return false; - ref var rbes = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - rbes.physicsMass.InverseInertia = inverseMass; - return true; - } - return false; - } - - public float? GetLastPingTime(uint playerId, PlayerType type) - { - if (entitiesDB == null) return null; - EGID egid = new EGID(playerId, PlayerGroupFromEnum(type)); - if (entitiesDB.Exists(egid)) - { - //return entitiesDB.QueryEntity(egid).lastPingTimeSinceLevelLoad; - TODO - } - return null; - } - - public float GetInitialHealth(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.initialHealth; - } - return -1f; - } - - public bool SetInitialHealth(uint playerId, float val) - { - if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - c.initialHealth = val; - return true; - } - return false; - } - - public float GetCurrentHealth(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.currentHealth; - } - return -1f; - } - - public bool SetCurrentHealth(uint playerId, float val) - { - if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - c.currentHealth = val; - return true; - } - return false; - } - - public bool DamagePlayer(uint playerId, float amount) - { - if (entitiesDB == null) return false; - return SetCurrentHealth(playerId, GetCurrentHealth(playerId) - amount); - } - - public bool GetDamageable(uint playerId) - { - if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.canTakeDamageStat; - } - return false; - } - - public bool SetDamageable(uint playerId, bool val) - { - if (entitiesDB == null) return false; - ref var ches = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - ches.canTakeDamage = val; - ches.canTakeDamage = val; - return true; - } - return false; - } - - public uint GetInitialLives(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.initialLives; - } - return uint.MaxValue; - } - - public bool SetInitialLives(uint playerId, uint val) - { - if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - c.initialLives = val; - return true; - } - return false; - } - - public uint GetCurrentLives(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.currentLives; - } - return uint.MaxValue; - } - - public bool SetCurrentLives(uint playerId, uint val) - { - if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - c.currentLives = val; - return true; - } - return false; - } - public bool GetGameOverScreen(uint playerId) { if (entitiesDB == null) return false; @@ -372,78 +135,44 @@ namespace TechbloxModdingAPI.Players return entitiesDB.Exists(playerId, CharacterExclusiveGroups.DeadCharacters); } - public int GetSelectedBlock(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.SelectedDBPartID; - } - return ushort.MaxValue; - } - - public byte GetSelectedColor(uint playerId) - { - if (entitiesDB == null) return 0; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.indexInPalette; - } - return 255; - } - // reusable methods [MethodImpl(MethodImplOptions.AggressiveInlining)] - private ExclusiveGroup PlayerGroupFromEnum(PlayerType type) + public OptionalRef GetCharacterStruct(uint playerId) where T : unmanaged, IEntityComponent { - return type == PlayerType.Local ? PlayersExclusiveGroups.LocalPlayers : PlayersExclusiveGroups.RemotePlayers; + if (GameState.IsBuildMode()) + return entitiesDB.QueryEntityOptional(new EGID(playerId, Techblox.FlyCam.FlyCam.Group)); + + var characterGroups = CharacterExclusiveGroups.AllCharacters; + for (int i = 0; i < characterGroups.count; i++) + { + EGID egid = new EGID(playerId, characterGroups[i]); + var opt = entitiesDB.QueryEntityOptional(egid); + if (opt.Exists) + return opt; + } + + return new OptionalRef(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public ref T GetCharacterStruct(uint playerId, out bool exists) where T : unmanaged, IEntityComponent + public OptionalRef GetPlayerStruct(uint playerId, PlayerType type) where T : unmanaged, IEntityComponent { - var characterGroups = CharacterExclusiveGroups.AllCharacters; - for (int i = 0; i < characterGroups.count; i++) - { - EGID egid = new EGID(playerId, characterGroups[i]); - if (entitiesDB.Exists(egid)) - { - exists = true; - return ref entitiesDB.QueryEntity(egid); - } - } - - exists = false; - T[] arr = new T[1]; - return ref arr[0]; //Return default value + var playerGroup = type == PlayerType.Local ? PlayersExclusiveGroups.LocalPlayers : PlayersExclusiveGroups.RemotePlayers; + EGID egid = new EGID(playerId, playerGroup); + return entitiesDB.QueryEntityOptional(egid); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public bool GetPlayerStruct(uint playerId, out T s) where T : unmanaged, IEntityComponent + public OptionalRef GetCameraStruct(uint playerId) where T : unmanaged, IEntityComponent { - var playerGroups = PlayersExclusiveGroups.AllPlayers; - for (int i = 0; i < playerGroups.count; i++) - { - EGID egid = new EGID(playerId, playerGroups[i]); - if (entitiesDB.Exists(egid)) - { - s = entitiesDB.QueryEntity(egid); - return true; - } - } - s = default; - return false; + return entitiesDB.QueryEntityOptional(new EGID(playerId, CameraExclusiveGroups.CameraGroup)); } public EGID GetThingLookedAt(uint playerId, float maxDistance = -1f) { - if (!entitiesDB.TryQueryMappedEntities( - CameraExclusiveGroups.CameraGroup, out var mapper)) - return EGID.Empty; - mapper.TryGetEntity(playerId, out CharacterCameraRayCastEntityStruct rayCast); + var opt = GetCameraStruct(playerId); + if (!opt) return EGID.Empty; + CharacterCameraRayCastEntityStruct rayCast = opt; float distance = maxDistance < 0 ? GhostBlockUtils.GetBuildInteractionDistance(entitiesDB, rayCast, GhostBlockUtils.GhostCastMethod.GhostCastProportionalToBlockSize) diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index 8af0a13..ca99746 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -8,6 +8,7 @@ https://git.exmods.org/modtainers/GamecraftModdingAPI en-CA true + 8 From b8fd14d9348a965bf42732d6bb16386e34bdf074 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 28 May 2021 02:52:42 +0200 Subject: [PATCH 73/98] Move speed settings to Player and make it work with players Probably --- TechbloxModdingAPI/Player.FlyCamSettings.cs | 51 ------------------- TechbloxModdingAPI/Player.cs | 55 ++++++++++++++++++++- 2 files changed, 54 insertions(+), 52 deletions(-) delete mode 100644 TechbloxModdingAPI/Player.FlyCamSettings.cs diff --git a/TechbloxModdingAPI/Player.FlyCamSettings.cs b/TechbloxModdingAPI/Player.FlyCamSettings.cs deleted file mode 100644 index b947477..0000000 --- a/TechbloxModdingAPI/Player.FlyCamSettings.cs +++ /dev/null @@ -1,51 +0,0 @@ -using RobocraftX.Physics; -using Svelto.ECS; -using Svelto.ECS.EntityStructs; -using Techblox.FlyCam; -using TechbloxModdingAPI.Blocks; -using TechbloxModdingAPI.Players; -using TechbloxModdingAPI.Utility; -using Unity.Mathematics; -using UnityEngine; - -namespace TechbloxModdingAPI -{ - public partial class Player - { - /// - /// Whether the camera (player) is sprinting. - /// - public bool Sprinting - { - get => playerEngine.GetCharacterStruct(Id).Get().sprinting; - set => playerEngine.GetCharacterStruct(Id).Get().sprinting = value; - } - - /// - /// The speed setting of the camera. - /// - public float Speed - { - get => playerEngine.GetCharacterStruct(Id).Get().speed; - set => playerEngine.GetCharacterStruct(Id).Get().speed = value; - } - - /// - /// The multiplier setting to use when sprinting. - /// - public float SpeedSprintMultiplier - { - get => playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier; - set => playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier = value; - } - - /// - /// The acceleration setting of the camera. - /// - public float Acceleration - { - get => playerEngine.GetCharacterStruct(Id).Get().acceleration; - set => playerEngine.GetCharacterStruct(Id).Get().acceleration = value; - } - } -} \ No newline at end of file diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 02e28f5..9bab382 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -1,5 +1,6 @@ using System; using RobocraftX.Character; +using RobocraftX.Character.Movement; using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; @@ -17,7 +18,7 @@ namespace TechbloxModdingAPI /// /// An in-game player character. Any Leo you see is a player. /// - public partial class Player : IEquatable, IEquatable + public class Player : IEquatable, IEquatable { // static functionality private static PlayerEngine playerEngine = new PlayerEngine(); @@ -350,6 +351,58 @@ namespace TechbloxModdingAPI public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine .GetCharacterStruct(Id).Get().timeStoppedContext; + /// + /// Whether the player is sprinting. + /// + public bool Sprinting + { + get => GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().sprinting + : playerEngine.GetCharacterStruct(Id).Get().isSprinting; + set => _ = GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().sprinting = value + : playerEngine.GetCharacterStruct(Id).Get().isSprinting = value; + } + + /// + /// Movement speed setting. Build mode (camera) and simulation mode settings are separate. + /// + public float SpeedSetting + { + get => GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().speed + : playerEngine.GetCharacterStruct(Id).Get().moveSpeed; + set => _ = GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().speed = value + : playerEngine.GetCharacterStruct(Id).Get().moveSpeed = value; + } + + /// + /// The multiplier setting to use when sprinting. Build mode (camera) and simulation mode settings are separate. + /// + public float SpeedSprintMultiplierSetting + { + get => GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier + : playerEngine.GetCharacterStruct(Id).Get().sprintSpeedMultiplier; + set => _ = GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier = value + : playerEngine.GetCharacterStruct(Id).Get().sprintSpeedMultiplier = value; + } + + /// + /// The acceleration setting of the player. Build mode (camera) and simulation mode settings are separate. + /// + public float AccelerationSetting + { + get => GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().acceleration + : playerEngine.GetCharacterStruct(Id).Get().acceleration; + set => _ = GameState.IsBuildMode() + ? playerEngine.GetCharacterStruct(Id).Get().acceleration = value + : playerEngine.GetCharacterStruct(Id).Get().acceleration = value; + } + // object methods /// From 94c0c1370b0ca8c793b14687b3993d154eb2e949 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 30 May 2021 01:34:30 +0200 Subject: [PATCH 74/98] Removed 2 non-OOP classes and fixed fly cam teleport Remvoed Hotbar and GameClient since their functions are also implemented in OOP classes Added static methods to add/remove persistent debug info Made some patches and other things internal Added support for FlyCams in SetLocation --- TechbloxModdingAPI/App/Game.cs | 59 +++++++++++++------ .../Blocks/Engines/PlacementEngine.cs | 2 +- .../Blocks/Engines/RemovalEngine.cs | 2 +- .../Blocks/Engines/ScalingEngine.cs | 2 +- TechbloxModdingAPI/Inventory/Hotbar.cs | 46 --------------- TechbloxModdingAPI/Inventory/HotbarEngine.cs | 55 ----------------- .../HotbarSlotSelectionHandlerEnginePatch.cs | 2 +- TechbloxModdingAPI/Main.cs | 3 - .../Persistence/SerializerManager.cs | 2 +- TechbloxModdingAPI/Players/PlayerEngine.cs | 40 +++++++------ .../Tests/TechbloxModdingAPIPluginTest.cs | 4 +- TechbloxModdingAPI/Utility/GameClient.cs | 30 ---------- 12 files changed, 69 insertions(+), 178 deletions(-) delete mode 100644 TechbloxModdingAPI/Inventory/Hotbar.cs delete mode 100644 TechbloxModdingAPI/Inventory/HotbarEngine.cs delete mode 100644 TechbloxModdingAPI/Utility/GameClient.cs diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 4630ed9..1d37945 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -396,19 +396,20 @@ namespace TechbloxModdingAPI.App /// /// Add information to the in-game debug display. - /// When this object is garbage collected, this debug info is automatically removed. + /// When this object is garbage collected, this debug info is automatically removed. + /// The provided getter function is called each frame so make sure it returns quickly. /// /// Debug info identifier. - /// Content getter. - public void AddDebugInfo(string id, Func contentGetter) + /// A function that returns the current information. + public void AddDebugInfo(string id, Func contentGetter) { - if (!VerifyMode()) return; - if (menuMode) - { - throw new GameNotFoundException("Game object references a menu item but AddDebugInfo only works on the currently-loaded game"); - } - debugOverlayEngine.SetInfo(id, contentGetter); - debugIds.Add(id); + if (!VerifyMode()) return; + if (menuMode) + { + throw new GameNotFoundException("Game object references a menu item but AddDebugInfo only works on the currently-loaded game"); + } + debugOverlayEngine.SetInfo("game_" + id, contentGetter); + debugIds.Add(id); } /// @@ -418,14 +419,36 @@ namespace TechbloxModdingAPI.App /// Debug info identifier. public bool RemoveDebugInfo(string id) { - if (!VerifyMode()) return false; - if (menuMode) - { - throw new GameNotFoundException("Game object references a menu item but RemoveDebugInfo only works on the currently-loaded game"); - } - if (!debugIds.Contains(id)) return false; - debugOverlayEngine.RemoveInfo(id); - return debugIds.Remove(id); + if (!VerifyMode()) return false; + if (menuMode) + { + throw new GameNotFoundException("Game object references a menu item but RemoveDebugInfo only works on the currently-loaded game"); + } + if (!debugIds.Contains(id)) return false; + debugOverlayEngine.RemoveInfo("game_" + id); + return debugIds.Remove(id); + } + + /// + /// Add information to the in-game debug display. + /// This debug info will be present for all games until it is manually removed. + /// The provided getter function is called each frame so make sure it returns quickly. + /// + /// Debug info identifier. + /// A function that returns the current information. + public static void AddPersistentDebugInfo(string id, Func contentGetter) + { + debugOverlayEngine.SetInfo("persistent_" + id, contentGetter); + } + + /// + /// Remove persistent information from the in-game debug display. + /// + /// true, if debug info was removed, false otherwise. + /// Debug info identifier. + public static bool RemovePersistentDebugInfo(string id) + { + return debugOverlayEngine.RemoveInfo("persistent_" + id); } /// diff --git a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs index b076d96..196df83 100644 --- a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs @@ -113,7 +113,7 @@ namespace TechbloxModdingAPI.Blocks.Engines public bool isRemovable => false; [HarmonyPatch] - public class FactoryObtainerPatch + class FactoryObtainerPatch { static void Postfix(BlockEntityFactory blockEntityFactory, IEntityFactory entityFactory) { diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index 4d4897f..b753d3f 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -44,7 +44,7 @@ namespace TechbloxModdingAPI.Blocks.Engines public bool isRemovable => false; [HarmonyPatch] - public class FactoryObtainerPatch + class FactoryObtainerPatch { static void Postfix(IEntityFunctions entityFunctions, MachineGraphConnectionEntityFactory machineGraphConnectionEntityFactory) diff --git a/TechbloxModdingAPI/Blocks/Engines/ScalingEngine.cs b/TechbloxModdingAPI/Blocks/Engines/ScalingEngine.cs index 5ab84f2..9ca77f0 100644 --- a/TechbloxModdingAPI/Blocks/Engines/ScalingEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/ScalingEngine.cs @@ -41,7 +41,7 @@ namespace TechbloxModdingAPI.Blocks.Engines } [HarmonyPatch] - public class PhysicsEnginePatch + class PhysicsEnginePatch { static void Postfix(IReactOnAddAndRemove __instance) { diff --git a/TechbloxModdingAPI/Inventory/Hotbar.cs b/TechbloxModdingAPI/Inventory/Hotbar.cs deleted file mode 100644 index 92bca86..0000000 --- a/TechbloxModdingAPI/Inventory/Hotbar.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; - -using RobocraftX.Common.Input; -using RobocraftX.Multiplayer.Input; -using HarmonyLib; -using TechbloxModdingAPI.Blocks; -using TechbloxModdingAPI.Utility; - -namespace TechbloxModdingAPI.Inventory -{ - public static class Hotbar - { - private static readonly HotbarEngine hotbarEngine = new HotbarEngine(); - - /// - /// Switch the block in the player's hand - /// - /// The block to switch to. - /// The player. Omit this to use the local player. - public static void EquipBlock(BlockIDs block, uint playerID = uint.MaxValue) - { - if (playerID == uint.MaxValue) - { - playerID = hotbarEngine.GetLocalPlayerID(); - } - hotbarEngine.SelectBlock((int) block, playerID); - // cubeSelectedByPick = true will crash the game - // (this would be equivalent to mouse middle click pick block action) - // reason: the game expects a Dictionary entry for the tweaked stats - } - - /// - /// Gets the block in the player's hand - /// - /// The equipped block. - public static BlockIDs GetEquippedBlock() - { - return HotbarSlotSelectionHandlerEnginePatch.EquippedPartID; - } - - public static void Init() - { - GameEngineManager.AddGameEngine(hotbarEngine); - } - } -} diff --git a/TechbloxModdingAPI/Inventory/HotbarEngine.cs b/TechbloxModdingAPI/Inventory/HotbarEngine.cs deleted file mode 100644 index 66f8c78..0000000 --- a/TechbloxModdingAPI/Inventory/HotbarEngine.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; - -using RobocraftX.Character; -using RobocraftX.GUI.Hotbar; -using RobocraftX.Players; -using RobocraftX.Common; -using RobocraftX.Common.Input; -using RobocraftX.Common.Players; -using Svelto.ECS; - -using TechbloxModdingAPI.Blocks; -using TechbloxModdingAPI.Utility; -using RobocraftX.Blocks; -using Techblox.FlyCam; -using TechbloxModdingAPI.Engines; - -namespace TechbloxModdingAPI.Inventory -{ - public class HotbarEngine : IApiEngine - { - public string Name { get; } = "TechbloxModdingAPIHotbarGameEngine"; - - public EntitiesDB entitiesDB { set; private get; } - - public bool isRemovable => false; - - public bool IsInGame = false; - - public void Dispose() - { - IsInGame = false; - } - - public void Ready() - { - IsInGame = true; - } - - public bool SelectBlock(int block, uint playerID, bool cubeSelectedByPick = false) - { - if (!entitiesDB.TryQueryEntitiesAndIndex(playerID, Techblox.FlyCam.FlyCam.Group, - out var index, out var inputs)) - return false; - inputs[index].CubeSelectedByPick = cubeSelectedByPick; - inputs[index].SelectedDBPartID = block; - // TODO: expose the rest of the input functionality - return true; - } - - public uint GetLocalPlayerID() - { - return LocalPlayerIDUtility.GetLocalPlayerID(entitiesDB); - } - } -} diff --git a/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs b/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs index 1a068f0..79c6d5a 100644 --- a/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs +++ b/TechbloxModdingAPI/Inventory/HotbarSlotSelectionHandlerEnginePatch.cs @@ -9,7 +9,7 @@ using TechbloxModdingAPI.Blocks; namespace TechbloxModdingAPI.Inventory { [HarmonyPatch] - public class HotbarSlotSelectionHandlerEnginePatch + class HotbarSlotSelectionHandlerEnginePatch { private static int selectedBlockInt = 0; diff --git a/TechbloxModdingAPI/Main.cs b/TechbloxModdingAPI/Main.cs index a390021..610aa8e 100644 --- a/TechbloxModdingAPI/Main.cs +++ b/TechbloxModdingAPI/Main.cs @@ -65,8 +65,6 @@ namespace TechbloxModdingAPI Utility.GameState.Init(); // init block implementors Logging.MetaDebugLog($"Initializing Blocks"); - // init inventory - Inventory.Hotbar.Init(); // init input Input.FakeInput.Init(); // init object-oriented classes @@ -75,7 +73,6 @@ namespace TechbloxModdingAPI BlockGroup.Init(); Wire.Init(); Logging.MetaDebugLog($"Initializing Client"); - GameClient.Init(); Client.Init(); Game.Init(); // init UI diff --git a/TechbloxModdingAPI/Persistence/SerializerManager.cs b/TechbloxModdingAPI/Persistence/SerializerManager.cs index 04079cf..fe11320 100644 --- a/TechbloxModdingAPI/Persistence/SerializerManager.cs +++ b/TechbloxModdingAPI/Persistence/SerializerManager.cs @@ -58,7 +58,7 @@ namespace TechbloxModdingAPI.Persistence return _serializers.Count; } - public static void RegisterSerializers(EnginesRoot enginesRoot) + internal static void RegisterSerializers(EnginesRoot enginesRoot) { _lastEnginesRoot = enginesRoot; IEntitySerialization ies = enginesRoot.GenerateEntitySerializer(); diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index f5fbb26..506c55d 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -102,23 +102,17 @@ namespace TechbloxModdingAPI.Players public bool SetLocation(uint playerId, float3 location, bool exitSeat = true) { if (entitiesDB == null) return false; - var characterGroups = CharacterExclusiveGroups.AllCharacters; - for (int i = 0; i < characterGroups.count; i++) - { - EGID egid = new EGID(playerId, characterGroups[i]); - if (entitiesDB.Exists(egid)) - { - ref RigidBodyEntityStruct rbes = ref entitiesDB.QueryEntity(egid); - if (characterGroups[i] == CharacterExclusiveGroups.InPilotSeatGroup && exitSeat) - { - entitiesDB.QueryEntity(egid).instantExit = true; - entitiesDB.PublishEntityChange(egid); - } - rbes.position = location; - return true; - } - } - return false; + var rbesOpt = GetCharacterStruct(playerId, out var group); + if (!rbesOpt) + return false; + if (group == CharacterExclusiveGroups.InPilotSeatGroup && exitSeat) + { + EGID egid = new EGID(playerId, group); + entitiesDB.QueryEntity(egid).instantExit = true; + entitiesDB.PublishEntityChange(egid); + } + rbesOpt.Get().position = location; + return true; } public bool GetGameOverScreen(uint playerId) @@ -137,9 +131,14 @@ namespace TechbloxModdingAPI.Players // reusable methods - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public OptionalRef GetCharacterStruct(uint playerId) where T : unmanaged, IEntityComponent + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public OptionalRef GetCharacterStruct(uint playerId) where T : unmanaged, IEntityComponent => + GetCharacterStruct(playerId, out _); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public OptionalRef GetCharacterStruct(uint playerId, out ExclusiveGroupStruct group) where T : unmanaged, IEntityComponent { + group = default; if (GameState.IsBuildMode()) return entitiesDB.QueryEntityOptional(new EGID(playerId, Techblox.FlyCam.FlyCam.Group)); @@ -149,7 +148,10 @@ namespace TechbloxModdingAPI.Players EGID egid = new EGID(playerId, characterGroups[i]); var opt = entitiesDB.QueryEntityOptional(egid); if (opt.Exists) + { + group = characterGroups[i]; return opt; + } } return new OptionalRef(); diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 8f5298f..f618211 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -25,7 +25,7 @@ namespace TechbloxModdingAPI.Tests /// Modding API implemented as a standalone IPA Plugin. /// Ideally, TechbloxModdingAPI should be loaded by another mod; not itself /// - public class TechbloxModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin + class TechbloxModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin { private static Harmony harmony { get; set; } @@ -194,7 +194,7 @@ namespace TechbloxModdingAPI.Tests Game.CurrentGame().ToggleTimeMode(); }).Build(); - GameClient.SetDebugInfo("InstalledMods", InstalledMods); + Game.AddPersistentDebugInfo("InstalledMods", InstalledMods); Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Block); Block.Removed += (sender, args) => diff --git a/TechbloxModdingAPI/Utility/GameClient.cs b/TechbloxModdingAPI/Utility/GameClient.cs deleted file mode 100644 index f63b270..0000000 --- a/TechbloxModdingAPI/Utility/GameClient.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using TechbloxModdingAPI.Blocks; - -namespace TechbloxModdingAPI.Utility -{ - public static class GameClient - { - private static DebugInterfaceEngine _engine = new DebugInterfaceEngine(); - - /// - /// Saves the extra information to be displayed on the debug view. - /// The provided getter function is called each time the view updates so make sure it returns quickly. - /// - /// A global ID for the custom information - /// A function that returns the current information - public static void SetDebugInfo(string id, Func contentGetter) => _engine.SetInfo(id, contentGetter); - - /// - /// Removes an information provided by a plugin. - /// - /// The ID of the custom information - /// - public static bool RemoveDebugInfo(string id) => _engine.RemoveInfo(id); - - public static void Init() - { - GameEngineManager.AddGameEngine(_engine); - } - } -} \ No newline at end of file From b31eaa20c08c3abaab1f6021594726e19167dc99 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 30 May 2021 02:12:38 +0200 Subject: [PATCH 75/98] Check if block type is correct --- TechbloxModdingAPI/Block.cs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index ed4e2aa..9d71d24 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -87,23 +87,27 @@ namespace TechbloxModdingAPI remove => BlockEventsEngine.Removed -= value; } - internal static readonly Dictionary> GroupToConstructor = - new Dictionary> + private static readonly Dictionary Constructor, Type Type)> GroupToConstructor = + new Dictionary, Type)> { - {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP, id => new DampedSpring(id)}, - {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, id => new Engine(id)} + {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP, (id => new DampedSpring(id), typeof(DampedSpring))}, + {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))} }; internal static Block New(EGID egid) { return GroupToConstructor.ContainsKey(egid.groupID) - ? GroupToConstructor[egid.groupID](egid) + ? GroupToConstructor[egid.groupID].Constructor(egid) : new Block(egid); } public Block(EGID id) { - Id = id; //TODO: Check if block type is correct + Id = id; + Type expectedType; + if (GroupToConstructor.ContainsKey(id.groupID) && + !GetType().IsAssignableFrom(expectedType = GroupToConstructor[id.groupID].Type)) + throw new BlockSpecializationException($"Incorrect block type! Expected: {expectedType} Actual: {GetType()}"); } /// @@ -111,11 +115,11 @@ namespace TechbloxModdingAPI /// It will throw an exception if the block doesn't exist. /// Use the EGID constructor where possible or subclasses of Block as those specify the group. /// - public Block(uint id) + public Block(uint id) : this(BlockEngine.FindBlockEGID(id) + ?? throw new BlockTypeException( + "Could not find the appropriate group for the block." + + " The block probably doesn't exist or hasn't been submitted.")) { - Id = BlockEngine.FindBlockEGID(id) - ?? throw new BlockTypeException("Could not find the appropriate group for the block." + - " The block probably doesn't exist or hasn't been submitted."); } /// From 06cb911ea34722d5539482e712a538912f9626b8 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Mon, 31 May 2021 17:59:25 -0400 Subject: [PATCH 76/98] Update IMGUI to something roughly TB-like --- .../Interface/IMGUI/Constants.cs | 66 +++++++++---------- .../Tests/TechbloxModdingAPIPluginTest.cs | 2 +- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs index a966a5f..02564a6 100644 --- a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs @@ -33,7 +33,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI } } - private static Font _riffic = null; + private static Font _font = null; private static Texture2D _blueBackground = null; private static Texture2D _grayBackground = null; @@ -49,12 +49,13 @@ namespace TechbloxModdingAPI.Interface.IMGUI private static GUISkin BuildDefaultGUISkin() { _defaultCompletion = 0; - if (_riffic == null) return GUI.skin; + //if (_font == null) return GUI.skin; // build GUISkin GUISkin gui = ScriptableObject.CreateInstance(); - gui.font = _riffic; + gui.font = _font; gui.settings.selectionColor = Color.white; gui.settings.tripleClickSelectsLine = true; + Color textColour = new Color(0.706f, 0.706f, 0.706f); // set properties off all UI elements foreach (PropertyInfo p in typeof(GUISkin).GetProperties()) { @@ -63,29 +64,30 @@ namespace TechbloxModdingAPI.Interface.IMGUI { style.richText = true; style.alignment = TextAnchor.MiddleCenter; - style.fontSize = 30; + style.fontSize = 16; style.wordWrap = true; style.border = new RectOffset(4, 4, 4, 4); style.margin = new RectOffset(4, 4, 4, 4); style.padding = new RectOffset(4, 4, 4, 4); // normal state - style.normal.background = _blueBackground; - style.normal.textColor = Color.white; + style.normal.background = _grayBackground; + style.normal.textColor = textColour; // hover state style.hover.background = _grayBackground; - style.hover.textColor = Color.white; + style.hover.textColor = textColour; // focused style.focused.background = _grayBackground; - style.focused.textColor = Color.white; + style.focused.textColor = textColour; // clicking state style.active.background = _whiteBackground; - style.active.textColor = Color.white; + style.active.textColor = textColour; p.SetValue(gui, style); // probably unnecessary } } // set element-specific styles // label + gui.label.fontSize = 20; gui.label.normal.background = null; gui.label.hover.background = null; gui.label.focused.background = null; @@ -115,35 +117,29 @@ namespace TechbloxModdingAPI.Interface.IMGUI private static void LoadGUIAssets() { - AsyncOperationHandle rifficHandle = Addressables.LoadAssetAsync("Assets/Art/Fonts/riffic-bold.ttf"); - rifficHandle.Completed += handle => + /*AsyncOperationHandle fontHandle = Addressables.LoadAssetAsync("Assets/Plugins/TextMesh Pro/Fonts/LiberationSans.ttf"); + fontHandle.Completed += handle => { - _riffic = handle.Result; - _defaultCompletion++; - }; - _blueBackground = new Texture2D(1, 1); - _blueBackground.SetPixel(0, 0, new Color(0.004f, 0.522f, 0.847f) /* Techblox Blue */); - _blueBackground.Apply(); - _grayBackground = new Texture2D(1, 1); - _grayBackground.SetPixel(0, 0, new Color(0.745f, 0.745f, 0.745f) /* Gray */); - _grayBackground.Apply(); - _whiteBackground = new Texture2D(1, 1); - _whiteBackground.SetPixel(0, 0, new Color(0.898f, 0.898f, 0.898f) /* Very light gray */); - _whiteBackground.Apply(); - _textInputBackground = new Texture2D(1, 1); - _textInputBackground.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.25f) /* Translucent gray */); - _textInputBackground.Apply(); - _areaBackground = new Texture2D(1, 1); - _areaBackground.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.25f) /* Translucent gray */); - _areaBackground.Apply(); - /* // this is actually gray (used for the loading screen) - AsyncOperationHandle backgroundHandle = - Addressables.LoadAssetAsync("Assets/Art/Textures/UI/FrontEndMap/RCX_Blue_Background_5k.jpg"); - backgroundHandle.Completed += handle => - { - _blueBackground = handle.Result; + _font = handle.Result; _defaultCompletion++; };*/ + _font = Resources.Load("Assets/Plugins/TextMesh Pro/Fonts/LiberationSans.ttf"); + // TODO generate larger textures with borders on them so it actually looks more like Techblox + _blueBackground = new Texture2D(1, 1); + _blueBackground.SetPixel(0, 0, new Color(0.004f, 0.522f, 0.847f) /* Gamecraft Blue, unused */); + _blueBackground.Apply(); + _grayBackground = new Texture2D(1, 1); + _grayBackground.SetPixel(0, 0, new Color(0.11f, 0.11f, 0.11f, 1f) /* Very dark gray */); + _grayBackground.Apply(); + _whiteBackground = new Texture2D(1, 1); + _whiteBackground.SetPixel(0, 0, new Color(0.961f, 0.961f, 0.961f) /* Very light gray */); + _whiteBackground.Apply(); + _textInputBackground = new Texture2D(1, 1); + _textInputBackground.SetPixel(0, 0, new Color(0.961f, 0.961f, 0.961f) /* Very light gray */); + _textInputBackground.Apply(); + _areaBackground = new Texture2D(1, 1); + _areaBackground.SetPixel(0, 0, new Color(0.051f, 0.051f, 0.051f, 1f) /* Very very dark gray */); + _areaBackground.Apply(); _defaultCompletion++; } } diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index f618211..d938482 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -216,7 +216,7 @@ namespace TechbloxModdingAPI.Tests button.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; var button2 = new Button("TEST2"); button2.OnClick += (b, __) => { Logging.MetaDebugLog($"Click on {((Interface.IMGUI.Button)b).Name}");}; - Text uiText = new Text("This is text!", multiline: true); + Text uiText = new Text("", multiline: true); uiText.OnEdit += (t, txt) => { Logging.MetaDebugLog($"Text in {((Text)t).Name} is now '{txt}'"); }; Label uiLabel = new Label("Label!"); Image uiImg = new Image(name:"Behold this texture!"); From c1c226ef2a4221d6f35f9f45f3c5da181a576747 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 4 Jun 2021 23:07:06 +0200 Subject: [PATCH 77/98] Added support for setting default color/material and static blocks Also fixed setting game name/description When setting the block color or material to default it will look up the default value to use Blocks can now be set to be static so they don't fall or move at all --- TechbloxModdingAPI/App/GameMenuEngine.cs | 25 +++++++---------- TechbloxModdingAPI/Block.cs | 27 +++++++++++++++---- .../Blocks/Engines/PlacementEngine.cs | 6 ----- .../Interface/IMGUI/Constants.cs | 2 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 9 +++++++ 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 3357984..4738507 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -92,7 +92,7 @@ namespace TechbloxModdingAPI.App { if (!ExistsGameInfo(id)) return false; GetGameInfo(id).GameName.Set(name); - //GetGameViewInfo(id).MyGamesSlotComponent.GameName = StringUtil.SanitiseString(name); - TODO: Input field struct + GetGameViewInfo(id).MyGamesSlotComponent.GameName = StringUtil.SanitiseString(name); return true; } @@ -100,7 +100,7 @@ namespace TechbloxModdingAPI.App { if (!ExistsGameInfo(id)) return false; GetGameInfo(id).GameDescription.Set(name); - //GetGameViewInfo(id).MyGamesSlotComponent.GameDescription = StringUtil.SanitiseString(name); - TODO + GetGameViewInfo(id).MyGamesSlotComponent.GameDescription = StringUtil.SanitiseString(name); return true; } @@ -114,21 +114,14 @@ namespace TechbloxModdingAPI.App return ref GetComponent(id); } - /*public ref MyGamesSlotEntityViewStruct GetGameViewInfo(EGID id) + public dynamic GetGameViewInfo(EGID id) { - EntityCollection entities = - entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.GameSlotGuiEntities); - var entitiesB = entities.ToBuffer().buffer; - for (int i = 0; i < entities.count; i++) - { - if (entitiesB[i].ID.entityID == id.entityID) - { - return ref entitiesB[i]; - } - } - MyGamesSlotEntityViewStruct[] defRef = new MyGamesSlotEntityViewStruct[1]; - return ref defRef[0]; - TODO: The struct is internal now - }*/ + dynamic structOptional = AccessTools.Method("TechbloxModdingAPI.Utility.NativeApiExtensions:QueryEntityOptional", new []{typeof(EntitiesDB), typeof(EGID)}) + .MakeGenericMethod(AccessTools.TypeByName("RobocraftX.GUI.MyGamesScreen.MyGamesSlotEntityViewStruct")) + .Invoke(null, new object[] {entitiesDB, new EGID(id.entityID, MyGamesScreenExclusiveGroups.GameSlotGuiEntities)}); + if (structOptional == null) throw new Exception("Could not get game slot entity"); + return structOptional ? structOptional : null; + } public ref T GetComponent(EGID id) where T: unmanaged, IEntityComponent { diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 9d71d24..c264c17 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -248,11 +248,14 @@ namespace TechbloxModdingAPI } set { - //TODO: Check if setting to 255 works + if (value.Color == BlockColors.Default) + value = new BlockColor(FullGameFields._dataDb.TryGetValue((int) Type, out CubeListData cld) + ? cld.DefaultColour + : throw new BlockTypeException("Unknown block type! Could not set default color.")); ref var color = ref BlockEngine.GetBlockInfo(this); color.indexInPalette = value.Index; color.hasNetworkChange = true; - color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); + color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); //Setting to 255 results in black } } @@ -282,10 +285,15 @@ namespace TechbloxModdingAPI } set { - if (!FullGameFields._dataDb.ContainsKey((byte) value)) + byte val = (byte) value; + if (value == BlockMaterial.Default) + val = FullGameFields._dataDb.TryGetValue((int) Type, out CubeListData cld) + ? cld.DefaultMaterialID + : throw new BlockTypeException("Unknown block type! Could not set default material."); + if (!FullGameFields._dataDb.ContainsKey(val)) throw new BlockException($"Block material {value} does not exist!"); - BlockEngine.GetBlockInfo(this).materialId = (byte) value; - BlockEngine.UpdatePrefab(this, (byte) value, Flipped); //TODO: Test default + BlockEngine.GetBlockInfo(this).materialId = val; + BlockEngine.UpdatePrefab(this, val, Flipped); //The default causes the screen to go black } } @@ -336,6 +344,15 @@ namespace TechbloxModdingAPI } } + /// + /// Whether the block should be static in simulation. If set, it cannot be moved. The effect is temporary, it will not be saved with the block. + /// + public bool Static + { + get => BlockEngine.GetBlockInfo(this).staticIfUnconnected; + set => BlockEngine.GetBlockInfo(this).staticIfUnconnected = value; + } + /// /// Whether the block exists. The other properties will return a default value if the block doesn't exist. /// If the block was just placed, then this will also return false but the properties will work correctly. diff --git a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs index 196df83..b2e5659 100644 --- a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs @@ -77,12 +77,6 @@ namespace TechbloxModdingAPI.Blocks.Engines triggerAutoWiring = autoWire && structInitializer.Has() }); - - /*structInitializer.Init(new OverrideStaticComponent() - { //TODO - staticIfUnconnected = true - });*/ - int nextFilterId = BlockGroupUtility.NextFilterId; structInitializer.Init(new BlockGroupEntityComponent { diff --git a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs index 02564a6..ecb292a 100644 --- a/TechbloxModdingAPI/Interface/IMGUI/Constants.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Constants.cs @@ -24,7 +24,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI /// /// Best-effort imitation of Techblox's UI style. /// - public static GUISkin Default //TODO: Update to Techblox style + public static GUISkin Default { get { diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index d938482..319ec76 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -194,6 +194,15 @@ namespace TechbloxModdingAPI.Tests Game.CurrentGame().ToggleTimeMode(); }).Build(); + CommandBuilder.Builder("testColorBlock", "Tests coloring a block to default color") + .Action(() => Player.LocalPlayer.GetBlockLookedAt().Color = BlockColors.Default).Build(); + CommandBuilder.Builder("testMaterialBlock", "Tests materialing a block to default material") + .Action(() => Player.LocalPlayer.GetBlockLookedAt().Material = BlockMaterial.Default).Build(); + CommandBuilder.Builder("testGameName", "Tests changing the game name") + .Action(() => Game.CurrentGame().Name = "Test").Build(); + CommandBuilder.Builder("makeBlockStatic", "Makes a block you look at static") + .Action(() => Player.LocalPlayer.GetBlockLookedAt().Static = true).Build(); + Game.AddPersistentDebugInfo("InstalledMods", InstalledMods); Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Block); From 99f077a917bfad88e5b5ea19f8b6a12abbfa89d4 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 9 Jun 2021 20:11:31 +0200 Subject: [PATCH 78/98] Update to Techblox 2021.06.08.16.19 Added check for time mode toggle to avoid crashing the game Added support for having the ref folder outside the solution in gen_csproj.py Removed BlockIdentifiers class Added check for invalid player ID when placing blocks Resolved compilation errors --- Automation/gen_csproj.py | 9 +- TechbloxModdingAPI/App/GameGameEngine.cs | 4 +- TechbloxModdingAPI/Block.cs | 4 +- TechbloxModdingAPI/Blocks/BlockIdentifiers.cs | 43 ----- TechbloxModdingAPI/Blocks/DampedSpring.cs | 12 +- TechbloxModdingAPI/Blocks/Engine.cs | 6 +- .../Blocks/Engines/BlueprintEngine.cs | 7 +- .../Blocks/Engines/PlacementEngine.cs | 7 +- .../Blocks/Engines/RemovalEngine.cs | 1 + TechbloxModdingAPI/Input/FakeInput.cs | 46 ++---- TechbloxModdingAPI/Input/FakeInputEngine.cs | 18 +- TechbloxModdingAPI/Interface/IMGUI/Group.cs | 6 +- .../DeserializeFromDiskEntitiesEnginePatch.cs | 2 +- .../Persistence/SaveGameEnginePatch.cs | 2 +- .../Persistence/SimpleEntitySerializer.cs | 4 +- TechbloxModdingAPI/Player.cs | 24 +-- TechbloxModdingAPI/Players/PlayerEngine.cs | 20 +-- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 156 +++++++++++------- .../Tests/TechbloxModdingAPIPluginTest.cs | 2 +- 19 files changed, 181 insertions(+), 192 deletions(-) delete mode 100644 TechbloxModdingAPI/Blocks/BlockIdentifiers.cs diff --git a/Automation/gen_csproj.py b/Automation/gen_csproj.py index 515bcda..9d5dfbc 100755 --- a/Automation/gen_csproj.py +++ b/Automation/gen_csproj.py @@ -3,15 +3,22 @@ import argparse from pathlib import Path, PurePath import re +import os DLL_EXCLUSIONS_REGEX = r"(System|Microsoft|Mono|IronPython|DiscordRPC)\." def getAssemblyReferences(path): asmDir = Path(path) result = list() + addedPath = "" + if not asmDir.exists(): + addedPath = "../" + asmDir = Path(addedPath + path) for child in asmDir.iterdir(): if child.is_file() and re.search(DLL_EXCLUSIONS_REGEX, str(child), re.I) is None and str(child).lower().endswith(".dll"): - result.append(str(child).replace("\\", "/")) + childstr = str(child) + childstr = os.path.relpath(childstr, addedPath).replace("\\", "/") + result.append(childstr) return result def buildReferencesXml(path): diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index 1ed4d48..eceee8b 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -91,7 +91,9 @@ namespace TechbloxModdingAPI.App } public void ToggleTimeMode() - { + { + if (!entitiesDB.FoundInGroups()) + throw new AppStateException("At least one block must exist in the world to enter simulation"); TimeRunningModeUtil.ToggleTimeRunningState(entitiesDB); } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index c264c17..efea216 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -9,6 +9,7 @@ using RobocraftX.Common; using RobocraftX.Blocks; using Unity.Mathematics; using Gamecraft.Blocks.GUI; +using HarmonyLib; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Blocks.Engines; @@ -65,7 +66,8 @@ namespace TechbloxModdingAPI /// The block object or null if doesn't exist public static Block GetLastPlacedBlock() { - EGID? egid = BlockEngine.FindBlockEGID(BlockIdentifiers.LatestBlockID); + uint lastBlockID = (uint) AccessTools.Field(typeof(CommonExclusiveGroups), "_nextBlockEntityID").GetValue(null) - 1; + EGID? egid = BlockEngine.FindBlockEGID(lastBlockID); return egid.HasValue ? New(egid.Value) : null; } diff --git a/TechbloxModdingAPI/Blocks/BlockIdentifiers.cs b/TechbloxModdingAPI/Blocks/BlockIdentifiers.cs deleted file mode 100644 index 10305dc..0000000 --- a/TechbloxModdingAPI/Blocks/BlockIdentifiers.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Svelto.ECS; -using RobocraftX.Common; - -using HarmonyLib; -using Svelto.DataStructures; - -namespace TechbloxModdingAPI.Blocks -{ - /// - /// ExclusiveGroups and IDs used with blocks - /// - public static class BlockIdentifiers - { - /// - /// Blocks placed by the player - /// - public static FasterReadOnlyList OWNED_BLOCKS { get { return CommonExclusiveGroups.REAL_BLOCKS_GROUPS_DON_T_USE_IN_NEW_CODE; } } - - /// - /// Extra parts used in functional blocks - /// - public static ExclusiveGroup FUNCTIONAL_BLOCK_PARTS { get { return CommonExclusiveGroups.FUNCTIONAL_BLOCK_PART_GROUP; } } - - /// - /// Blocks which are disabled in Simulation mode - /// - public static ExclusiveGroup SIM_BLOCKS_DISABLED { get { return CommonExclusiveGroups.DISABLED_JOINTS_IN_SIM_GROUP; } } - - //public static ExclusiveGroup SPAWN_POINTS { get { return CommonExclusiveGroups.SPAWN_POINTS_GROUP; } } - - //public static ExclusiveGroup SPAWN_POINTS_DISABLED { get { return CommonExclusiveGroups.SPAWN_POINTS_DISABLED_GROUP; } } - - /// - /// The ID of the most recently placed block - /// - public static uint LatestBlockID { - get - { //Need the private field as the property increments itself - return ((uint) AccessTools.Field(typeof(CommonExclusiveGroups), "_nextBlockEntityID").GetValue(null)) - 1; - } - } - } -} diff --git a/TechbloxModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs index 7009940..afff30b 100644 --- a/TechbloxModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -15,13 +15,13 @@ namespace TechbloxModdingAPI.Blocks } /// - /// The spring frequency. + /// The spring's stiffness. /// - public float SpringFrequency + public float Stiffness { - get => BlockEngine.GetBlockInfo(this).springFrequency; + get => BlockEngine.GetBlockInfo(this).stiffness; - set => BlockEngine.GetBlockInfo(this).springFrequency = value; + set => BlockEngine.GetBlockInfo(this).stiffness = value; } /// @@ -29,9 +29,9 @@ namespace TechbloxModdingAPI.Blocks /// public float Damping { - get => BlockEngine.GetBlockInfo(this).springDamping; + get => BlockEngine.GetBlockInfo(this).damping; - set => BlockEngine.GetBlockInfo(this).springDamping = value; + set => BlockEngine.GetBlockInfo(this).damping = value; } /// diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index 8396e66..08a8f33 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -20,10 +20,10 @@ namespace TechbloxModdingAPI.Blocks set => BlockEngine.GetBlockInfo(this).engineOn = value; } - public int TorqueDirection + public float CurrentTorque { - get => BlockEngine.GetBlockInfo(this).torqueDirection; - set => BlockEngine.GetBlockInfo(this).torqueDirection = value; + get => BlockEngine.GetBlockInfo(this).currentTorque; + set => BlockEngine.GetBlockInfo(this).currentTorque = value; } public int CurrentGear diff --git a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs index c6ba686..4bc5f5d 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs @@ -12,6 +12,7 @@ using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.DataStructures; using Svelto.ECS.EntityStructs; +using Svelto.ECS.Native; using Svelto.ECS.Serialization; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; @@ -160,10 +161,14 @@ namespace TechbloxModdingAPI.Blocks.Engines private void BuildGhostBlueprint(ICollection blocks, float3 pos, quaternion rot, uint playerID) { GhostChildUtility.ClearGhostChildren(playerID, entitiesDB, entityFunctions); + var bssesopt = entitiesDB.QueryEntityOptional(new EGID(playerID, + BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup)); + if (!bssesopt) + return; foreach (var block in blocks) { GhostChildUtility.BuildGhostChild(in playerID, block.Id, in pos, in rot, entitiesDB, - BuildGhostBlueprintFactory, false); + BuildGhostBlueprintFactory, false, bssesopt.Get().buildingDroneReference); } } diff --git a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs index b2e5659..9ce7d84 100644 --- a/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/PlacementEngine.cs @@ -7,6 +7,7 @@ using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Character; using RobocraftX.Common; +using RobocraftX.CR.MachineEditing.BoxSelect; using RobocraftX.Rendering; using RobocraftX.Rendering.GPUI; using Svelto.ECS; @@ -70,10 +71,14 @@ namespace TechbloxModdingAPI.Blocks.Engines }); structInitializer.Init(new UniformBlockScaleEntityStruct {scaleFactor = 1}); structInitializer.Get().materialId = (byte) BlockMaterial.SteelBodywork; + var bssesopt = entitiesDB.QueryEntityOptional(new EGID(playerId, + BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup)); + if (!bssesopt) + throw new BlockException("Invalid player ID specified for block placement"); structInitializer.Init(new BlockPlacementInfoStruct { loadedFromDisk = false, - placedBy = playerId, + placedByBuildingDrone = bssesopt.Get().buildingDroneReference, triggerAutoWiring = autoWire && structInitializer.Has() }); diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index b753d3f..4322d5e 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -4,6 +4,7 @@ using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Common; using Svelto.ECS; +using Svelto.ECS.Native; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; diff --git a/TechbloxModdingAPI/Input/FakeInput.cs b/TechbloxModdingAPI/Input/FakeInput.cs index 6104a4e..a3d068a 100644 --- a/TechbloxModdingAPI/Input/FakeInput.cs +++ b/TechbloxModdingAPI/Input/FakeInput.cs @@ -15,7 +15,7 @@ namespace TechbloxModdingAPI.Input /// Customize the local input. /// /// The custom input. - public static void CustomInput(LocalInputEntityStruct input) + public static void CustomInput(LocalCosmeticInputEntityComponent input) { inputEngine.SendCustomInput(input); } @@ -34,7 +34,7 @@ namespace TechbloxModdingAPI.Input inputEngine.SendCustomPlayerInput(input, playerID); } - public static LocalInputEntityStruct GetInput() + public static LocalCosmeticInputEntityComponent GetInput() { return inputEngine.GetInput(); } @@ -48,31 +48,23 @@ namespace TechbloxModdingAPI.Input return inputEngine.GetPlayerInput(playerID); } - /// - /// Fake a GUI input. + /// + /// Fake a GUI input. /// Omit any parameter you do not want to affect. /// Parameters that end with "?" don't do anything... yet. - /// - /// The player. Omit this to use the local player. - /// Select the hotbar slot by number. - /// Toggle the command line? - /// Open escape menu? - /// Page return? - /// Toggle debug display? - /// Select next? - /// Select previous? - /// Tab? - /// Toggle to hotbar colour mode? - /// Select the hotbar page by number? - /// Quicksave? - /// Paste? - public static void GuiInput(uint playerID = uint.MaxValue, int hotbar = -1, bool escape = false, bool enter = false, bool debug = false, bool next = false, bool previous = false, bool tab = false, int hotbarPage = -1, bool quickSave = false, bool paste = false) + /// + /// Select the hotbar slot by number. + /// Toggle the command line? + /// Open escape menu? + /// Page return? + /// Toggle debug display? + /// Toggle to hotbar colour mode? + /// Select the hotbar page by number? + /// Quicksave? + /// Paste? + public static void GuiInput(int hotbar = -1, bool escape = false, bool enter = false, bool debug = false, int hotbarPage = -1, bool quickSave = false, bool paste = false) { - if (playerID == uint.MaxValue) - { - playerID = inputEngine.GetLocalPlayerID(); - } - ref LocalInputEntityStruct currentInput = ref inputEngine.GetInputRef(); + ref LocalCosmeticInputEntityComponent currentInput = ref inputEngine.GetInputRef(); //Utility.Logging.CommandLog($"Current sim frame {currentInput.frame}"); // set inputs switch(hotbar) @@ -92,9 +84,6 @@ namespace TechbloxModdingAPI.Input if (escape) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Escape; if (enter) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Return; if (debug) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.ToggleDebugDisplay; - if (next) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.SelectNext; - if (previous) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.SelectPrev; - if (tab) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.Tab; switch (hotbarPage) { case 1: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage1; break; @@ -107,11 +96,10 @@ namespace TechbloxModdingAPI.Input case 8: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage8; break; case 9: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage9; break; case 10: currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.HotbarPage10; break; - default: break; } //RewiredConsts.Action if (quickSave) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.QuickSave; - if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.PasteSelection; + if (paste) currentInput.guiMask |= RobocraftX.Common.Input.GuiInput.SelectLastCopiedBlueprint; } public static void ActionInput(uint playerID = uint.MaxValue, bool toggleMode = false, bool forward = false, bool backward = false, bool up = false, bool down = false, bool left = false, bool right = false, bool sprint = false, bool toggleFly = false, bool alt = false, bool primary = false, bool secondary = false, bool tertiary = false, bool primaryHeld = false, bool secondaryHeld = false, bool toggleUnitGrid = false, bool ctrl = false, bool toggleColourMode = false, bool scaleBlockUp = false, bool scaleBlockDown = false, bool rotateBlockClockwise = false, bool rotateBlockCounterclockwise = false, bool cutSelection = false, bool copySelection = false, bool deleteSelection = false) diff --git a/TechbloxModdingAPI/Input/FakeInputEngine.cs b/TechbloxModdingAPI/Input/FakeInputEngine.cs index 7d2efb7..7b4528c 100644 --- a/TechbloxModdingAPI/Input/FakeInputEngine.cs +++ b/TechbloxModdingAPI/Input/FakeInputEngine.cs @@ -30,12 +30,12 @@ namespace TechbloxModdingAPI.Input IsReady = true; } - public bool SendCustomInput(LocalInputEntityStruct input) + public bool SendCustomInput(LocalCosmeticInputEntityComponent input) { EGID egid = CommonExclusiveGroups.GameStateEGID; - if (entitiesDB.Exists(egid)) + if (entitiesDB.Exists(egid)) { - ref LocalInputEntityStruct ies = ref entitiesDB.QueryEntity(egid); + ref LocalCosmeticInputEntityComponent ies = ref entitiesDB.QueryEntity(egid); ies = input; return true; } @@ -54,14 +54,14 @@ namespace TechbloxModdingAPI.Input else return false; } - public LocalInputEntityStruct GetInput() + public LocalCosmeticInputEntityComponent GetInput() { EGID egid = CommonExclusiveGroups.GameStateEGID; - if (entitiesDB.Exists(egid)) + if (entitiesDB.Exists(egid)) { - return entitiesDB.QueryEntity(egid); + return entitiesDB.QueryEntity(egid); } - else return default(LocalInputEntityStruct); + else return default(LocalCosmeticInputEntityComponent); } public LocalPlayerInputEntityStruct GetPlayerInput(uint playerID, bool remote = false) @@ -74,10 +74,10 @@ namespace TechbloxModdingAPI.Input else return default; } - public ref LocalInputEntityStruct GetInputRef() + public ref LocalCosmeticInputEntityComponent GetInputRef() { EGID egid = CommonExclusiveGroups.GameStateEGID; - return ref entitiesDB.QueryEntity(egid); + return ref entitiesDB.QueryEntity(egid); } public ref LocalPlayerInputEntityStruct GetPlayerInputRef(uint playerID, bool remote = false) diff --git a/TechbloxModdingAPI/Interface/IMGUI/Group.cs b/TechbloxModdingAPI/Interface/IMGUI/Group.cs index bbbbdf1..b1dcccc 100644 --- a/TechbloxModdingAPI/Interface/IMGUI/Group.cs +++ b/TechbloxModdingAPI/Interface/IMGUI/Group.cs @@ -25,7 +25,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI /*if (Constants.Default == null) return; if (Constants.Default.box == null) return;*/ GUIStyle guiStyle = Constants.Default.box; - UIElement[] elems = elements.ToArrayFast(out uint count); + UIElement[] elems = elements.ToArrayFast(out int count); if (automaticLayout) { GUILayout.BeginArea(Box, guiStyle); @@ -132,7 +132,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI { if (index < 0 || index >= elements.count) return false; IMGUIManager.AddElement(elements[index]); // re-add to global manager - elements.RemoveAt(index); + elements.RemoveAt((uint) index); return true; } @@ -143,7 +143,7 @@ namespace TechbloxModdingAPI.Interface.IMGUI /// The element's index, or -1 if not found. public int IndexOf(UIElement element) { - UIElement[] elems = elements.ToArrayFast(out uint count); + UIElement[] elems = elements.ToArrayFast(out int count); for (int i = 0; i < count; i++) { if (elems[i].Name == element.Name) diff --git a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs index d998f0e..166f744 100644 --- a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs @@ -26,7 +26,7 @@ namespace TechbloxModdingAPI.Persistence SerializerManager.RegisterSerializers(SaveAndLoadCompositionRootPatch.currentEnginesRoot); uint originalPos = ____serializationData.dataPos; Logging.MetaDebugLog($"dataPos: {originalPos}"); - BinaryBufferReader bbr = new BinaryBufferReader(____bytesStream.ToArrayFast(out uint count), ____serializationData.dataPos); + BinaryBufferReader bbr = new BinaryBufferReader(____bytesStream.ToArrayFast(out int count), ____serializationData.dataPos); byte[] frameBuffer = new byte[frameStart.Length]; Logging.MetaDebugLog($"serial data count: {____serializationData.data.count} capacity: {____serializationData.data.capacity}"); int i = 0; diff --git a/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs index 9371e9b..4386d3a 100644 --- a/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/SaveGameEnginePatch.cs @@ -26,7 +26,7 @@ namespace TechbloxModdingAPI.Persistence return; } serializationData.data.ExpandBy((uint)frameStart.Length); - BinaryBufferWriter bbw = new BinaryBufferWriter(serializationData.data.ToArrayFast(out uint buffLen), serializationData.dataPos); + BinaryBufferWriter bbw = new BinaryBufferWriter(serializationData.data.ToArrayFast(out int buffLen), serializationData.dataPos); uint originalPos = serializationData.dataPos; Logging.MetaDebugLog($"dataPos: {originalPos}"); // Add frame start so it's easier to find TechbloxModdingAPI-serialized components diff --git a/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs b/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs index 7f605c3..10e7ce1 100644 --- a/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs +++ b/TechbloxModdingAPI/Persistence/SimpleEntitySerializer.cs @@ -32,7 +32,7 @@ namespace TechbloxModdingAPI.Persistence public bool Deserialize(ref ISerializationData serializationData, IEntitySerialization entitySerializer) { - BinaryBufferReader bbr = new BinaryBufferReader(serializationData.data.ToArrayFast(out uint count), serializationData.dataPos); + BinaryBufferReader bbr = new BinaryBufferReader(serializationData.data.ToArrayFast(out int count), serializationData.dataPos); uint entityCount = bbr.ReadUint(); serializationData.dataPos = bbr.Position; for (uint i = 0; i < entityCount; i++) @@ -47,7 +47,7 @@ namespace TechbloxModdingAPI.Persistence public bool Serialize(ref ISerializationData serializationData, EntitiesDB entitiesDB, IEntitySerialization entitySerializer) { serializationData.data.ExpandBy(4u); - BinaryBufferWriter bbw = new BinaryBufferWriter(serializationData.data.ToArrayFast(out uint count), serializationData.dataPos); + BinaryBufferWriter bbw = new BinaryBufferWriter(serializationData.data.ToArrayFast(out int count), serializationData.dataPos); EGID[] toSerialize = getEntitiesToSerialize(entitiesDB); bbw.Write((uint)toSerialize.Length); serializationData.dataPos = bbw.Position; diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 9bab382..de38b9b 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -6,8 +6,8 @@ using RobocraftX.Common; using RobocraftX.Common.Players; using RobocraftX.Physics; using Svelto.ECS; +using Techblox.BuildingDrone; using Techblox.Camera; -using Techblox.FlyCam; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Players; using TechbloxModdingAPI.Utility; @@ -141,10 +141,10 @@ namespace TechbloxModdingAPI public float3 Rotation { get => ((Quaternion) (GameState.IsBuildMode() - ? playerEngine.GetCameraStruct(Id).Get().rotation + ? playerEngine.GetCameraStruct(Id).Get().rotation : playerEngine.GetCharacterStruct(Id).Get().rotation)).eulerAngles; set => _ = GameState.IsBuildMode() - ? playerEngine.GetCameraStruct(Id).Get().rotation = quaternion.Euler(value) + ? playerEngine.GetCameraStruct(Id).Get().rotation = quaternion.Euler(value) : playerEngine.GetCharacterStruct(Id).Get().rotation = quaternion.Euler(value); } @@ -349,7 +349,7 @@ namespace TechbloxModdingAPI /// The player's mode in time stopped mode, determining what they place. /// public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine - .GetCharacterStruct(Id).Get().timeStoppedContext; + .GetCharacterStruct(Id).Get().timeStoppedContext; /// /// Whether the player is sprinting. @@ -357,10 +357,10 @@ namespace TechbloxModdingAPI public bool Sprinting { get => GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().sprinting + ? playerEngine.GetCharacterStruct(Id).Get().sprinting : playerEngine.GetCharacterStruct(Id).Get().isSprinting; set => _ = GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().sprinting = value + ? playerEngine.GetCharacterStruct(Id).Get().sprinting = value : playerEngine.GetCharacterStruct(Id).Get().isSprinting = value; } @@ -370,10 +370,10 @@ namespace TechbloxModdingAPI public float SpeedSetting { get => GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().speed + ? playerEngine.GetCharacterStruct(Id).Get().speed : playerEngine.GetCharacterStruct(Id).Get().moveSpeed; set => _ = GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().speed = value + ? playerEngine.GetCharacterStruct(Id).Get().speed = value : playerEngine.GetCharacterStruct(Id).Get().moveSpeed = value; } @@ -383,10 +383,10 @@ namespace TechbloxModdingAPI public float SpeedSprintMultiplierSetting { get => GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier + ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier : playerEngine.GetCharacterStruct(Id).Get().sprintSpeedMultiplier; set => _ = GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier = value + ? playerEngine.GetCharacterStruct(Id).Get().speedSprintMultiplier = value : playerEngine.GetCharacterStruct(Id).Get().sprintSpeedMultiplier = value; } @@ -396,10 +396,10 @@ namespace TechbloxModdingAPI public float AccelerationSetting { get => GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().acceleration + ? playerEngine.GetCharacterStruct(Id).Get().acceleration : playerEngine.GetCharacterStruct(Id).Get().acceleration; set => _ = GameState.IsBuildMode() - ? playerEngine.GetCharacterStruct(Id).Get().acceleration = value + ? playerEngine.GetCharacterStruct(Id).Get().acceleration = value : playerEngine.GetCharacterStruct(Id).Get().acceleration = value; } diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index 506c55d..aad3612 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using RobocraftX.Character; using RobocraftX.Character.Movement; @@ -13,13 +10,10 @@ using RobocraftX.Blocks.Ghost; using Gamecraft.GUI.HUDFeedbackBlocks; using Svelto.ECS; using Techblox.Camera; -using Techblox.FlyCam; using Unity.Mathematics; -using Unity.Physics; -using UnityEngine; -using HarmonyLib; -using RobocraftX.Common; using Svelto.ECS.DataStructures; +using Techblox.BuildingDrone; + using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; @@ -140,7 +134,7 @@ namespace TechbloxModdingAPI.Players { group = default; if (GameState.IsBuildMode()) - return entitiesDB.QueryEntityOptional(new EGID(playerId, Techblox.FlyCam.FlyCam.Group)); + return entitiesDB.QueryEntityOptional(new EGID(playerId, LocalBuildingDrone.BuildGroup)); var characterGroups = CharacterExclusiveGroups.AllCharacters; for (int i = 0; i < characterGroups.count; i++) @@ -167,14 +161,14 @@ namespace TechbloxModdingAPI.Players public OptionalRef GetCameraStruct(uint playerId) where T : unmanaged, IEntityComponent { - return entitiesDB.QueryEntityOptional(new EGID(playerId, CameraExclusiveGroups.CameraGroup)); + return entitiesDB.QueryEntityOptional(new EGID(playerId, CameraExclusiveGroups.PhysicCameraGroup)); } public EGID GetThingLookedAt(uint playerId, float maxDistance = -1f) { - var opt = GetCameraStruct(playerId); + var opt = GetCameraStruct(playerId); if (!opt) return EGID.Empty; - CharacterCameraRayCastEntityStruct rayCast = opt; + PhysicCameraRayCastEntityStruct rayCast = opt; float distance = maxDistance < 0 ? GhostBlockUtils.GetBuildInteractionDistance(entitiesDB, rayCast, GhostBlockUtils.GhostCastMethod.GhostCastProportionalToBlockSize) diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index ca99746..2de8b34 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -72,6 +72,10 @@ ..\ref\TechbloxPreview_Data\Managed\DDNA.dll ..\..\ref\TechbloxPreview_Data\Managed\DDNA.dll + + ..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll + ..\..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll + ..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll ..\..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll @@ -92,6 +96,10 @@ ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll @@ -144,6 +152,10 @@ ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll @@ -196,6 +208,10 @@ ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll @@ -252,74 +268,10 @@ ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll - - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll - ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll - - - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll - ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll - - - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll - ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll - - ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll - ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll - - - ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll - ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll - - - ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll - ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll - - - ..\ref\TechbloxPreview_Data\Managed\Robocraftx.ObjectIdBlocks.dll - ..\..\ref\TechbloxPreview_Data\Managed\Robocraftx.ObjectIdBlocks.dll - - - ..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll - ..\..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll - - - ..\ref\TechbloxPreview_Data\Managed\Techblox.FlyCam.dll - ..\..\ref\TechbloxPreview_Data\Managed\Techblox.FlyCam.dll - - - ..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll - ..\..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll - - - ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll - ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll - - - ..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll - ..\..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll - - - ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll - ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll - - - ..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll - ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll - - - ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll - ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll - - - ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll - ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll @@ -380,6 +332,10 @@ ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll + + ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll + ..\ref\TechbloxPreview_Data\Managed\JWT.dll ..\..\ref\TechbloxPreview_Data\Managed\JWT.dll @@ -432,6 +388,10 @@ ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll @@ -484,6 +444,10 @@ ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll @@ -540,6 +504,10 @@ ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.ObjectIdBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.ObjectIdBlocks.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll @@ -600,6 +568,10 @@ ..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll ..\..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll + + ..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll + ..\..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll + ..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll @@ -620,6 +592,14 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll @@ -632,6 +612,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll @@ -644,10 +628,22 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll @@ -660,6 +656,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll @@ -688,6 +688,10 @@ ..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll ..\..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll + + ..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll @@ -744,6 +748,10 @@ ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll @@ -796,6 +804,10 @@ ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + + ..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll @@ -852,6 +864,10 @@ ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll @@ -904,6 +920,10 @@ ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll @@ -956,6 +976,10 @@ ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll @@ -1008,6 +1032,10 @@ ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 319ec76..8ed3050 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -267,7 +267,7 @@ namespace TechbloxModdingAPI.Tests if (UnityEngine.Input.GetKeyDown(KeyCode.End)) { Console.WriteLine("Pressed button to toggle console"); - FakeInput.CustomInput(new LocalInputEntityStruct {commandLineToggleInput = true}); + FakeInput.CustomInput(new LocalCosmeticInputEntityComponent {commandLineToggleInput = true}); } } From 0b2ffef0d3793bc479fcc046d1059a93ff512c67 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 9 Jun 2021 22:03:15 +0200 Subject: [PATCH 79/98] Update block IDs --- TechbloxModdingAPI/Blocks/BlockIDs.cs | 52 +++++++++++++++---- TechbloxModdingAPI/Blocks/BlockTests.cs | 2 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 29 +++++++++++ 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index fcb3e41..8d1d443 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -36,11 +36,8 @@ namespace TechbloxModdingAPI.Blocks FrameWedgeS2, FrameWedgeS3, FrameWedgeS4, - SideS0S1, - SideS0S2, - SideS0S3, - SideS0S4, - SideS0S5, + SideS0S3 = 29, + SideS0S5 = 31, SideS1S1, SideS1S2, SideS1S3, @@ -51,11 +48,8 @@ namespace TechbloxModdingAPI.Blocks SideS2S3, SideS2S4, SideS2S5, - WindscreenS1, - WindscreenS2, - WindscreenS3, - WindscreenS4, - WindscreenS5, + WindscreenS3 = 44, + WindscreenS5 = 46, CarWheelArch, CarArchSmallFlare, CarArchFlare, @@ -106,7 +100,43 @@ namespace TechbloxModdingAPI.Blocks WideCylinderDiagonal, NarrowCylinderDiagonal, HeadlampTetrahedron, - CarWheelWideProfile = 200, + GoKartEngine, + Screen5X2Y2Z, + Screen5X2Y3Z, + Screen5X2Y5Z, + Screen9X2Y2Z, + Screen9X3Y2Z, + Screen9X2Y3Z, + Screen9X3Y3Z, + Screen9X2Y5Z, + Screen9X3Y5Z, + Screen11X3Y2Z, + Screen11X3Y3Z, + Screen11X3Y5Z, + Window6X2Y2Z, + Window6X3Y2Z, + Window6X2Y2ZS1, + Window6X3Y2ZS1, + Window6X2Y2ZS2, + Window6X3Y2ZS2, + Window6X2Y2ZS4, + Window6X3Y2ZS4, + FrameSquare, + FrameSkewedSquare, + FrameTriangle, + FrameSkewedTriangle, + GlassFrameSquare, + GlassFrameSkewedSquare, + GlassFrameTriangle, + GlassFrameSkewedTriangle, + GlassPlate, + GlassPlateTriangle, + GoKartWheelRigNoSteering, + GoKartWheelRigWithSteering, + GoKartSeat, + CarWheelWideProfile, CarWheel, + GoKartWheelWideProfile, + GoKartWheel, } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index f69315e..42e8910 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -140,7 +140,7 @@ namespace TechbloxModdingAPI.Blocks Block newBlock = Block.PlaceNew(BlockIDs.DampedSpring, Unity.Mathematics.float3.zero + 1); DampedSpring b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler Assert.Errorless(() => { b = (DampedSpring) newBlock; }, "Casting block to DampedSpring raised an exception: ", "Casting block to DampedSpring completed without issue."); - if (!Assert.CloseTo(b.SpringFrequency, 30f, $"DampedSpring.SpringFrequency {b.SpringFrequency} does not equal default value, possibly because it failed silently.", "DampedSpring.SpringFrequency is close enough to default.")) return; + if (!Assert.CloseTo(b.Stiffness, 30f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; if (!Assert.CloseTo(b.Damping, 30f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; } diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 8ed3050..6a06e42 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -1,7 +1,11 @@ using System; +using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Reflection; using System.Text; +using System.Text.RegularExpressions; +using DataLoader; using TechbloxModdingAPI.App; using HarmonyLib; using IllusionInjector; @@ -10,6 +14,7 @@ using RobocraftX.FrontEnd; using Unity.Mathematics; using UnityEngine; using RobocraftX.Common.Input; +using ServiceLayer; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Commands; using TechbloxModdingAPI.Input; @@ -247,6 +252,30 @@ namespace TechbloxModdingAPI.Tests /*((FasterList)AccessTools.Property(typeof(GuiInputMap), "GuiInputsButtonDown").GetValue(null)) .Add(new GuiInputMap.GuiInputMapElement(RewiredConsts.Action.ToggleCommandLine, GuiIn))*/ + + /*Game.Enter += (sender, e) => + { + ushort lastKey = ushort.MaxValue; + foreach (var kv in FullGameFields._dataDb.GetValues() + .OrderBy(kv=>ushort.Parse(kv.Key))) + { + var data = (CubeListData) kv.Value; + ushort currentKey = ushort.Parse(kv.Key); + var toReplace = new Dictionary + { + {"Scalable", ""}, {"Qtr", "Quarter"}, {"RNeg", "Rounded Negative"}, + {"Neg", "Negative"}, {"Tetra", "Tetrahedron"}, + {"RWedge", "Rounded Wedge"}, {"RTetra", "Rounded Tetrahedron"} + }; + string name = LocalizationService.Localize(data.CubeNameKey).Replace(" ", ""); + foreach (var rkv in toReplace) + { + name = Regex.Replace(name, "([^A-Za-z])" + rkv.Key + "([^A-Za-z])", "$1" + rkv.Value + "$2"); + } + Console.WriteLine($"{name}{(currentKey != lastKey + 1 ? $" = {currentKey}" : "")},"); + lastKey = currentKey; + } + };*/ #if TEST TestRoot.RunTests(); #endif From 52ccbe4dad8090f5be8f524e833c4779273f9c27 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 10 Jun 2021 23:57:06 +0200 Subject: [PATCH 80/98] Fix tests and add new materials --- TechbloxModdingAPI/Blocks/BlockMaterial.cs | 10 +++++++++- TechbloxModdingAPI/Blocks/BlockTests.cs | 5 +++-- TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs | 3 --- .../DeserializeFromDiskEntitiesEnginePatch.cs | 2 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 6 ++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockMaterial.cs b/TechbloxModdingAPI/Blocks/BlockMaterial.cs index 6d00823..7093066 100644 --- a/TechbloxModdingAPI/Blocks/BlockMaterial.cs +++ b/TechbloxModdingAPI/Blocks/BlockMaterial.cs @@ -7,6 +7,14 @@ namespace TechbloxModdingAPI.Blocks RigidSteel, CarbonFiber, Plastic, - Wood = 6 + Wood = 6, + RigidSteelPainted, + RigidSteelRustedPaint, + RigidSteelHeavyRust, + SteelBodyworkMetallicPaint, + SteelBodyworkRustedPaint, + SteelBodyworkHeavyRust, + WoodVarnishedDark, + Chrome } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index 42e8910..536a819 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -72,6 +72,7 @@ namespace TechbloxModdingAPI.Blocks public static IEnumerator TestBlockProperties() { //Uses the result of the previous test case var blocks = Game.CurrentGame().GetBlocksInGame(); + yield return Yield.It; for (var index = 0; index < blocks.Length; index++) { if (index % 50 == 0) yield return Yield.It; //The material or flipped status can only be changed 130 times per submission @@ -140,8 +141,8 @@ namespace TechbloxModdingAPI.Blocks Block newBlock = Block.PlaceNew(BlockIDs.DampedSpring, Unity.Mathematics.float3.zero + 1); DampedSpring b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler Assert.Errorless(() => { b = (DampedSpring) newBlock; }, "Casting block to DampedSpring raised an exception: ", "Casting block to DampedSpring completed without issue."); - if (!Assert.CloseTo(b.Stiffness, 30f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; - if (!Assert.CloseTo(b.Damping, 30f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; + if (!Assert.CloseTo(b.Stiffness, 1f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; + if (!Assert.CloseTo(b.Damping, 0.1f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; } diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs index 39ab2fb..26be582 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs @@ -117,9 +117,6 @@ namespace TechbloxModdingAPI.Blocks.Engines if (block.Exists) entitiesDB.PublishEntityChange(block.Id); //Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData - /*Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues() - .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") - .Aggregate((a, b) => a + "\n" + b));*/ } public bool BlockExists(EGID blockID) diff --git a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs index 166f744..6219ed1 100644 --- a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs @@ -12,7 +12,7 @@ using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Persistence { - [HarmonyPatch] + //[HarmonyPatch] - TODO class DeserializeFromDiskEntitiesEnginePatch { internal static EntitiesDB entitiesDB = null; diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 6a06e42..5bd3a7f 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -276,6 +276,12 @@ namespace TechbloxModdingAPI.Tests lastKey = currentKey; } };*/ + /*Game.Enter += (sender, e) => + { + Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues() + .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") + .Aggregate((a, b) => a + "\n" + b)); + };*/ #if TEST TestRoot.RunTests(); #endif From 76faa69c741924f83139b2490851247f82299fdf Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 11 Jun 2021 19:51:32 +0200 Subject: [PATCH 81/98] Add support for enabling the screenshot taker, even in sim --- TechbloxModdingAPI/App/AppEngine.cs | 1 - TechbloxModdingAPI/App/Game.cs | 9 +++++++++ TechbloxModdingAPI/App/GameGameEngine.cs | 10 ++++++++++ .../Tests/TechbloxModdingAPIPluginTest.cs | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/TechbloxModdingAPI/App/AppEngine.cs b/TechbloxModdingAPI/App/AppEngine.cs index 74c0d22..741c576 100644 --- a/TechbloxModdingAPI/App/AppEngine.cs +++ b/TechbloxModdingAPI/App/AppEngine.cs @@ -1,7 +1,6 @@ using System; using RobocraftX.GUI.MyGamesScreen; -using RobocraftX.GUI; using Svelto.ECS; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 1d37945..e543270 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -473,6 +473,15 @@ namespace TechbloxModdingAPI.App return blocks; } + /// + /// Enable the screenshot taker for updating the game's screenshot. Breaks the pause menu in a new save. + /// + public void EnableScreenshotTaker() + { + if (!VerifyMode()) return; + gameEngine.EnableScreenshotTaker(); + } + ~Game() { foreach (string id in debugIds) diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index eceee8b..51c53c8 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -10,6 +10,7 @@ using Svelto.ECS; using Svelto.Tasks; using Svelto.Tasks.Lean; using RobocraftX.Blocks; +using RobocraftX.ScreenshotTaker; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; @@ -129,5 +130,14 @@ namespace TechbloxModdingAPI.App return blockEGIDs.ToArray(); } } + + public void EnableScreenshotTaker() + { + ref var local = ref entitiesDB.QueryEntity(ScreenshotTakerEgids.ScreenshotTaker); + if (local.enabled) + return; + local.enabled = true; + entitiesDB.PublishEntityChange(ScreenshotTakerEgids.ScreenshotTaker); + } } } diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 5bd3a7f..222331f 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -282,6 +282,12 @@ namespace TechbloxModdingAPI.Tests .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") .Aggregate((a, b) => a + "\n" + b)); };*/ + + CommandBuilder.Builder("takeScreenshot", "Enables the screenshot taker") + .Action(() => + { + Game.CurrentGame().EnableScreenshotTaker(); + }).Build(); #if TEST TestRoot.RunTests(); #endif From 74d5a5c6b167e9d93235caa8401068ae43294691 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 23 Jun 2021 01:58:01 +0200 Subject: [PATCH 82/98] Fix default values getting changed and add test --- TechbloxModdingAPI/Blocks/BlockTests.cs | 19 +++++++++++ .../Tests/TechbloxModdingAPIPluginTest.cs | 34 ++++++++++++++++--- TechbloxModdingAPI/Utility/OptionalRef.cs | 3 +- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index 536a819..f920631 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -135,6 +135,25 @@ namespace TechbloxModdingAPI.Blocks Assert.Pass("Setting all possible properties of all registered API block types succeeded."); } + [APITestCase(TestType.EditMode)] + public static IEnumerator TestDefaultValue() + { + for (int i = 0; i < 2; i++) + { //Tests shared defaults + var block = Block.PlaceNew(BlockIDs.Cube, 1); + while (!block.Exists) + yield return Yield.It; + block.Remove(); + while (block.Exists) + yield return Yield.It; + if(!Assert.Equal(block.Position, default, + $"Block position default value {block.Position} is incorrect, should be 0.", + $"Block position default value {block.Position} matches default.")) + yield break; + block.Position = 4; + } + } + [APITestCase(TestType.EditMode)] public static void TestDampedSpring() { diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 222331f..b98990b 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -1,11 +1,8 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Reflection; using System.Text; -using System.Text.RegularExpressions; -using DataLoader; using TechbloxModdingAPI.App; using HarmonyLib; using IllusionInjector; @@ -14,12 +11,13 @@ using RobocraftX.FrontEnd; using Unity.Mathematics; using UnityEngine; using RobocraftX.Common.Input; -using ServiceLayer; +using Svelto.Tasks; +using Svelto.Tasks.Lean; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Commands; using TechbloxModdingAPI.Input; -using TechbloxModdingAPI.Interface.IMGUI; using TechbloxModdingAPI.Players; +using TechbloxModdingAPI.Tasks; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Tests @@ -288,6 +286,32 @@ namespace TechbloxModdingAPI.Tests { Game.CurrentGame().EnableScreenshotTaker(); }).Build(); + + CommandBuilder.Builder("testPositionDefault", "Tests the Block.Position property's default value.") + .Action(() => + { + IEnumerator Loop() + { + for (int i = 0; i < 2; i++) + { + Console.WriteLine("A"); + var block = Block.PlaceNew(BlockIDs.Cube, 1); + Console.WriteLine("B"); + while (!block.Exists) + yield return Yield.It; + Console.WriteLine("C"); + block.Remove(); + Console.WriteLine("D"); + while (block.Exists) + yield return Yield.It; + Console.WriteLine("E - Pos: " + block.Position); + block.Position = 4; + Console.WriteLine("F - Pos: " + block.Position); + } + } + + Loop().RunOn(Scheduler.leanRunner); + }).Build(); #if TEST TestRoot.RunTests(); #endif diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 8bcbe28..2410f1b 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -58,6 +58,7 @@ namespace TechbloxModdingAPI.Utility /// The value or the default value public ref T Get() { + CompRefCache.Default = default; //The default value can be changed by mods if (state == State.Empty) return ref CompRefCache.Default; if ((state & State.Initializer) != State.Empty) return ref initializer.GetOrCreate(); if ((state & State.Native) != State.Empty) return ref array[index]; @@ -73,7 +74,7 @@ namespace TechbloxModdingAPI.Utility /// /// Creates an instance of a struct T that can be referenced. /// - internal struct CompRefCache + private struct CompRefCache { public static T Default; } From 2a1676ce0f11a64168fb254038611879c77a4864 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 1 Jul 2021 15:41:58 +0200 Subject: [PATCH 83/98] Update block ID list --- TechbloxModdingAPI/Blocks/BlockIDs.cs | 52 +++++++++++++-------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 8d1d443..8c54140 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -25,32 +25,7 @@ namespace TechbloxModdingAPI.Blocks PlateQuarterPyramid, PlateTetrahedron, Sphere, - Frame, - FrameS1, - FrameS2, - FrameS3, - FrameS4, - FrameS5, - FrameWedge, - FrameWedgeS1, - FrameWedgeS2, - FrameWedgeS3, - FrameWedgeS4, - SideS0S3 = 29, - SideS0S5 = 31, - SideS1S1, - SideS1S2, - SideS1S3, - SideS1S4, - SideS1S5, - SideS2S1, - SideS2S2, - SideS2S3, - SideS2S4, - SideS2S5, - WindscreenS3 = 44, - WindscreenS5 = 46, - CarWheelArch, + CarWheelArch = 47, CarArchSmallFlare, CarArchFlare, CarArchExtrudedFlare, @@ -67,8 +42,8 @@ namespace TechbloxModdingAPI.Blocks PlateTriangle = 130, PlateCircle, PlateQuarterCircle, - PlateRWedge, - PlateRTetrahedron, + PlateRoundedWedge, + PlateRoundedTetrahedron, Cone, ConeSegment, DoubleSliced, @@ -138,5 +113,26 @@ namespace TechbloxModdingAPI.Blocks CarWheel, GoKartWheelWideProfile, GoKartWheel, + ANDLogicGate, + ORLogicGate, + NOTLogicGate, + NANDLogicGate, + NORLogicGate, + XORLogicGate, + XNORLogicGate, + AdderMathBlock, + SubtractorMathBlock, + MultiplierMathBlock, + DividerMathBlock, + InverterMathBlock, + AverageMathBlock, + AbsoluteMathBlock, + MinMathBlock, + MaxMathBlock, + SimpleConnector, + Motor, + AxleServo, + HingeServo, + Piston, } } \ No newline at end of file From ece71c45a659a72291a33691876ec35217e435f1 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 22 Jul 2021 22:19:35 +0200 Subject: [PATCH 84/98] Update to Techblox 2021.07.21.16.17 --- TechbloxModdingAPI/Blocks/BlockIDs.cs | 17 +++++ TechbloxModdingAPI/Commands/CommandPatch.cs | 72 ------------------- .../Commands/CommandRegistrationHelper.cs | 11 --- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 48 +++++++++++-- 4 files changed, 59 insertions(+), 89 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 8c54140..3538104 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -134,5 +134,22 @@ namespace TechbloxModdingAPI.Blocks AxleServo, HingeServo, Piston, + Button, + Switch, + Dial, + Lever, + ThreeWaySwitch, + EqualsMathBlock, + LessThanMathBlock, + LessThanOrEqualMathBlock, + GreaterThanMathBlock, + GreaterThanOrEqualMathBlock, + HatchbackWheelRigNoSteering, + HatchbackWheelRigWithSteering, + HatchbackEngine, + HatchbackWheel, + HatchbackWheelArch, + HatchbackArchSmallFlare, + HatchbackArchFlare } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Commands/CommandPatch.cs b/TechbloxModdingAPI/Commands/CommandPatch.cs index 6beb7f7..169891a 100644 --- a/TechbloxModdingAPI/Commands/CommandPatch.cs +++ b/TechbloxModdingAPI/Commands/CommandPatch.cs @@ -23,78 +23,6 @@ namespace TechbloxModdingAPI.Commands /*CommandLineCompositionRoot.Compose(contextHolder, stateSyncReg.enginesRoot, reloadGame, multiplayerParameters, stateSyncReg); - uREPL C# compilation not supported anymore */ var enginesRoot = stateSyncReg.enginesRoot; - var entityFunctions = enginesRoot.GenerateEntityFunctions(); - var entityFactory = enginesRoot.GenerateEntityFactory(); - var entitySerializer = enginesRoot.GenerateEntitySerializer(); - Logging.MetaDebugLog("Adding existing command engines"); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetGravityCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsPrecisionCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetPhysicsFrequencyCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteClearAllPartsCommandEngine"), - entityFunctions)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteHelpCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteSetLinearRestingThresholdCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName( - "RobocraftX.GUI.CommandLine.ExecuteSetAngularRestingThresholdCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteEnableVisualProfilerCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetNetworkJitterFramesEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetSendConnectedEntitiesCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetMaxSimFramesEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetDebugDisplayExtraInfoCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetNetSyncBandwidthLimitCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ThrowExceptionCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetPriorityCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterCommandEngine"), - entityFactory)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTextBlockTextCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCharacterRunSpeedCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetCameraZoomDistanceCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditLightingSettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditSkySettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.EditFogSettingsCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.TeleportCharacterImplementationEngine"), - entityFunctions)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteConnectToServerCommandEngine"), - entityFunctions, entitySerializer, reloadGame, multiplayerParameters)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.SetInputBroadcastCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ExecuteSetJointInertiaTensorCommandEngine"))); - enginesRoot.AddEngine( - (IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.ChangeTeamCommandEngine"))); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DamageCharacterCommandEngine"), entityFactory)); - enginesRoot.AddEngine((IEngine) Activator.CreateInstance( - AccessTools.TypeByName("RobocraftX.GUI.CommandLine.DisableCharacterDamageCommandEngine"))); - Logging.MetaDebugLog("Existing command engines added"); - CommandManager.RegisterEngines(enginesRoot); } diff --git a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs index 850322a..18f3a25 100644 --- a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs +++ b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs @@ -5,7 +5,6 @@ using System.Text; using System.Threading.Tasks; using uREPL; -using RobocraftX.CommandLine.Custom; namespace TechbloxModdingAPI.Commands { @@ -18,8 +17,6 @@ namespace TechbloxModdingAPI.Commands public static void Register(string name, Action action, string desc, bool noConsole = false) { RuntimeCommands.Register(name, action, desc); - if (noConsole) { return; } - ConsoleCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) @@ -40,29 +37,21 @@ namespace TechbloxModdingAPI.Commands public static void Register(string name, Action action, string desc, bool noConsole = false) { RuntimeCommands.Register(name, action, desc); - if (noConsole) { return; } - ConsoleCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) { RuntimeCommands.Register(name, action, desc); - if (noConsole) { return; } - ConsoleCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) { RuntimeCommands.Register(name, action, desc); - if (noConsole) { return; } - ConsoleCommands.Register(name, action, desc); } public static void Unregister(string name, bool noConsole = false) { RuntimeCommands.Unregister(name); - if (noConsole) { return; } - ConsoleCommands.Unregister(name); } public static void Call(string name) diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index 2de8b34..2aca43c 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -56,13 +56,13 @@ ..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll ..\..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll - - ..\ref\TechbloxPreview_Data\Managed\CommandLine.dll - ..\..\ref\TechbloxPreview_Data\Managed\CommandLine.dll + + ..\ref\TechbloxPreview_Data\Managed\Boxophobic.TheVehetationEngine.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Boxophobic.TheVehetationEngine.Runtime.dll - - ..\ref\TechbloxPreview_Data\Managed\CommandLineCompositionRoot.dll - ..\..\ref\TechbloxPreview_Data\Managed\CommandLineCompositionRoot.dll + + ..\ref\TechbloxPreview_Data\Managed\Boxophobic.Utils.Scripts.dll + ..\..\ref\TechbloxPreview_Data\Managed\Boxophobic.Utils.Scripts.dll ..\ref\TechbloxPreview_Data\Managed\DataLoader.dll @@ -580,6 +580,10 @@ ..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll ..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll + + ..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.GUI.dll + ..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll @@ -596,6 +600,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll @@ -604,6 +612,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.ContextSensitiveTextHint.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.ContextSensitiveTextHint.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll @@ -612,6 +624,18 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.MockUps.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.MockUps.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll @@ -656,6 +680,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll @@ -784,6 +812,14 @@ ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll + + ..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.Base.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.Base.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll From 49c3b60963e499263e7695b830ca1689051deaa0 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 29 Jul 2021 00:08:57 +0200 Subject: [PATCH 85/98] Get wire looked at, block class generation --- CodeGenerator/BlockClassGenerator.cs | 68 + CodeGenerator/CodeGenerator.csproj | 1176 +++++++++++++++++ CodeGenerator/Program.cs | 16 + CodeGenerator/Properties/AssemblyInfo.cs | 35 + TechbloxModdingAPI.sln | 8 + TechbloxModdingAPI/App/GameGameEngine.cs | 2 - TechbloxModdingAPI/Blocks/LogicGate.cs | 16 + TechbloxModdingAPI/Blocks/Piston.cs | 50 + TechbloxModdingAPI/Blocks/Servo.cs | 71 + TechbloxModdingAPI/Player.cs | 17 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 15 + 11 files changed, 1471 insertions(+), 3 deletions(-) create mode 100644 CodeGenerator/BlockClassGenerator.cs create mode 100644 CodeGenerator/CodeGenerator.csproj create mode 100644 CodeGenerator/Program.cs create mode 100644 CodeGenerator/Properties/AssemblyInfo.cs create mode 100644 TechbloxModdingAPI/Blocks/LogicGate.cs create mode 100644 TechbloxModdingAPI/Blocks/Piston.cs create mode 100644 TechbloxModdingAPI/Blocks/Servo.cs diff --git a/CodeGenerator/BlockClassGenerator.cs b/CodeGenerator/BlockClassGenerator.cs new file mode 100644 index 0000000..82c3206 --- /dev/null +++ b/CodeGenerator/BlockClassGenerator.cs @@ -0,0 +1,68 @@ +using System.CodeDom; +using System.CodeDom.Compiler; +using System.IO; +using System.Linq; +using RobocraftX.Common; + +namespace CodeGenerator +{ + public class BlockClassGenerator + { + public void Generate(string name, string group) + { + if (group is null) + { + group = GetGroup(name) + "_BLOCK_GROUP"; + if (typeof(CommonExclusiveGroups).GetFields().All(field => field.Name != group)) + group = GetGroup(name) + "_BLOCK_BUILD_GROUP"; + } + + var codeUnit = new CodeCompileUnit(); + var ns = new CodeNamespace("TechbloxModdingAPI.Blocks"); + ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common")); + ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS")); + var cl = new CodeTypeDeclaration(name); + cl.Members.Add(new CodeConstructor + { + Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")}, + Comments = { new CodeCommentStatement($"{name} constructor", true)} + }); + cl.Members.Add(new CodeConstructor + { + Parameters = + { + new CodeParameterDeclarationExpression(typeof(uint), "id") + }, + Comments = {new CodeCommentStatement($"{name} constructor", true)}, + BaseConstructorArgs = + { + new CodeObjectCreateExpression("EGID", new CodeVariableReferenceExpression("id"), + new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("CommonExclusiveGroups"), + group)) + } + }); + ns.Types.Add(cl); + codeUnit.Namespaces.Add(ns); + + var provider = CodeDomProvider.CreateProvider("CSharp"); + using (var sw = new StreamWriter($"{name}.cs")) + { + provider.GenerateCodeFromCompileUnit(codeUnit, sw, new CodeGeneratorOptions {BracingStyle = "C"}); + } + } + + private static string GetGroup(string name) + { + var ret = ""; + foreach (var ch in name) + { + if (char.IsUpper(ch) && ret.Length > 0) + ret += "_" + ch; + else + ret += char.ToUpper(ch); + } + + return ret; + } + } +} \ No newline at end of file diff --git a/CodeGenerator/CodeGenerator.csproj b/CodeGenerator/CodeGenerator.csproj new file mode 100644 index 0000000..826623c --- /dev/null +++ b/CodeGenerator/CodeGenerator.csproj @@ -0,0 +1,1176 @@ + + + + + Debug + AnyCPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10} + Exe + Properties + CodeGenerator + CodeGenerator + v4.7.2 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + ..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll + ..\..\ref\TechbloxPreview_Data\Managed\IllusionInjector.dll + + + ..\ref\TechbloxPreview_Data\Managed\IllusionPlugin.dll + ..\..\ref\TechbloxPreview_Data\Managed\IllusionPlugin.dll + + + ..\ref\TechbloxPreview_Data\Managed\Analytics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Analytics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp-firstpass.dll + ..\..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp-firstpass.dll + + + ..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp.dll + ..\..\ref\TechbloxPreview_Data\Managed\Assembly-CSharp.dll + + + ..\ref\TechbloxPreview_Data\Managed\BevelEffect.dll + ..\..\ref\TechbloxPreview_Data\Managed\BevelEffect.dll + + + ..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Blocks.HUDFeedbackBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Boxophobic.TheVehetationEngine.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Boxophobic.TheVehetationEngine.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Boxophobic.Utils.Scripts.dll + ..\..\ref\TechbloxPreview_Data\Managed\Boxophobic.Utils.Scripts.dll + + + ..\ref\TechbloxPreview_Data\Managed\DataLoader.dll + ..\..\ref\TechbloxPreview_Data\Managed\DataLoader.dll + + + ..\ref\TechbloxPreview_Data\Managed\DDNA.dll + ..\..\ref\TechbloxPreview_Data\Managed\DDNA.dll + + + ..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll + ..\..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll + + + ..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll + ..\..\ref\TechbloxPreview_Data\Managed\FMODUnity.dll + + + ..\ref\TechbloxPreview_Data\Managed\FMODUnityResonance.dll + ..\..\ref\TechbloxPreview_Data\Managed\FMODUnityResonance.dll + + + ..\ref\TechbloxPreview_Data\Managed\FullGame.dll + ..\..\ref\TechbloxPreview_Data\Managed\FullGame.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.AudioBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.AudioBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlockGroups.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerability.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerability.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.ColourPalette.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.ColourPalette.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Damage.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Effects.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintInventoryMock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Blueprints.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Blueprints.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintSets.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.BlueprintSets.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GameOptionsScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.GraphicsScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Blocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.BlueprintsHotbar.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.BlueprintsHotbar.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Hotbar.Colours.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.HUDFeedbackBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.ModeBar.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.OptionsScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Blueprints.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Colours.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TabsBar.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.TimeModeClock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Tweaks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Tweaks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.Wires.Mockup.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.JointBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.JointBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Music.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Music.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.NetStrings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.NetStrings.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PerformanceWarnings.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupBlck.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PickupsCommon.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.PopupMessage.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.PopupMessage.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Projectiles.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Projectiles.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Serialization.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Serialization.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Tweaks.Mockup.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.VisualEffects.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.dll + + + ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.Mockup.dll + ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Wires.Mockup.dll + + + ..\ref\TechbloxPreview_Data\Managed\GameState.dll + ..\..\ref\TechbloxPreview_Data\Managed\GameState.dll + + + ..\ref\TechbloxPreview_Data\Managed\GhostShark.Outline.dll + ..\..\ref\TechbloxPreview_Data\Managed\GhostShark.Outline.dll + + + ..\ref\TechbloxPreview_Data\Managed\GPUInstancer.CrowdAnimations.dll + ..\..\ref\TechbloxPreview_Data\Managed\GPUInstancer.CrowdAnimations.dll + + + ..\ref\TechbloxPreview_Data\Managed\GPUInstancer.dll + ..\..\ref\TechbloxPreview_Data\Managed\GPUInstancer.dll + + + ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Havok.Physics.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\JWT.dll + ..\..\ref\TechbloxPreview_Data\Managed\JWT.dll + + + ..\ref\TechbloxPreview_Data\Managed\LZ4.dll + ..\..\ref\TechbloxPreview_Data\Managed\LZ4.dll + + + ..\ref\TechbloxPreview_Data\Managed\mscorlib.dll + ..\..\ref\TechbloxPreview_Data\Managed\mscorlib.dll + + + ..\ref\TechbloxPreview_Data\Managed\MultiplayerNetworking.dll + ..\..\ref\TechbloxPreview_Data\Managed\MultiplayerNetworking.dll + + + ..\ref\TechbloxPreview_Data\Managed\MultiplayerTest.dll + ..\..\ref\TechbloxPreview_Data\Managed\MultiplayerTest.dll + + + ..\ref\TechbloxPreview_Data\Managed\netstandard.dll + ..\..\ref\TechbloxPreview_Data\Managed\netstandard.dll + + + ..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll + ..\..\ref\TechbloxPreview_Data\Managed\Newtonsoft.Json.dll + + + ..\ref\TechbloxPreview_Data\Managed\RCX.ScreenshotTaker.dll + ..\..\ref\TechbloxPreview_Data\Managed\RCX.ScreenshotTaker.dll + + + ..\ref\TechbloxPreview_Data\Managed\Rewired_Core.dll + ..\..\ref\TechbloxPreview_Data\Managed\Rewired_Core.dll + + + ..\ref\TechbloxPreview_Data\Managed\Rewired_Windows.dll + ..\..\ref\TechbloxPreview_Data\Managed\Rewired_Windows.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftECS.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftECS.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.AccountPreferences.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.AccountPreferences.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Ghost.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Blocks.Triggers.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.BoxSelect.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.BoxSelect.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.Jobs.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Building.Jobs.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Character.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.ControlsScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.ControlsScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Crosshair.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Crosshair.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.FrontEnd.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.FrontEnd.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.BlockLabel.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.BlockLabel.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.DebugDisplay.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Hotbar.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Hotbar.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.BlocksInventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.ColourInventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.Inventory.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.PauseMenu.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.PauseMenu.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.ScaleGhost.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.TabsBar.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.GUI.TabsBar.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Input.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MachineEditor.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MockCharacter.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MockCharacter.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.NetworkEntityStream.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Multiplayer.Serializers.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MultiplayerInput.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.ObjectIdBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.ObjectIdBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Party.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.PilotSeat.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.PilotSeat.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveAndLoad.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveAndLoad.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveGameDialog.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SaveGameDialog.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Services.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Services.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SignalHandling.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SignalHandling.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.SpawnPoints.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.SpawnPoints.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.StateSync.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX_TextBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX_TextBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocratX.SimulationMockCompositionRoot.dll + + + ..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll + ..\..\ref\TechbloxPreview_Data\Managed\SpecializedDescriptors.dll + + + ..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll + ..\..\ref\TechbloxPreview_Data\Managed\StringFormatter.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.ECS.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Services.dll + + + ..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.BuildingDrone.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Camera.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.ContextSensitiveTextHint.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.ContextSensitiveTextHint.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EngineBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.MockUps.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.BuildRules.MockUps.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.InputCapture.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.InputCapture.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.WheelRigBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.WheelRigBlock.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.Addressables.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.Addressables.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.DOTween.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.DOTween.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.Linq.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.Linq.dll + + + ..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll + ..\..\ref\TechbloxPreview_Data\Managed\UniTask.TextMeshPro.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Addressables.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Mdb.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Mdb.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Pdb.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Pdb.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Rocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Cecil.Rocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Unsafe.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Burst.Unsafe.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Collections.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Collections.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Collections.LowLevel.ILSupport.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Deformations.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Deformations.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Entities.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Entities.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.InternalAPIEngineBridge.012.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.InternalAPIEngineBridge.012.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Jobs.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Jobs.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Mathematics.Extensions.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.MemoryProfiler.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.MemoryProfiler.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Physics.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Physics.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Physics.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Physics.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Platforms.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Platforms.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.Reflection.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.Reflection.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Properties.UI.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.Base.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.Base.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.ShaderLibrary.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.HighDefinition.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.ResourceManager.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Scenes.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.ScriptableBuildPipeline.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.ScriptableBuildPipeline.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Serialization.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Serialization.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.TextMeshPro.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.TextMeshPro.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Timeline.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Timeline.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Transforms.Hybrid.dll + + + ..\ref\TechbloxPreview_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.VisualEffectGraph.Runtime.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AccessibilityModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AccessibilityModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AndroidJNIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AndroidJNIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AnimationModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AnimationModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ARModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ARModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AssetBundleModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.AudioModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClothModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterInputModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterInputModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterRendererModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ClusterRendererModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CoreModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.CrashReportingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.CrashReportingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.DirectorModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.DirectorModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.DSPGraphModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.DSPGraphModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GameCenterModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GameCenterModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.GridModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.GridModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.HotReloadModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.HotReloadModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ImageConversionModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.IMGUIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputLegacyModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.InputModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.JSONSerializeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.JSONSerializeModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.LocalizationModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.LocalizationModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ParticleSystemModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ParticleSystemModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.PerformanceReportingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.PerformanceReportingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.Physics2DModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.Physics2DModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.PhysicsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.PhysicsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ProfilerModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ProfilerModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.ScreenCaptureModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.ScreenCaptureModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SharedInternalsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SharedInternalsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteMaskModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SpriteShapeModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.StreamingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubstanceModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubstanceModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubsystemsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.SubsystemsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TerrainPhysicsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextCoreModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextCoreModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextRenderingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TextRenderingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TilemapModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TilemapModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.TLSModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.TLSModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UI.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UI.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsNativeModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIElementsNativeModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UIModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UmbraModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UNETModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityAnalyticsModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityAnalyticsModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityConnectModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityConnectModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityCurlModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityCurlModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityTestProtocolModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityTestProtocolModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAssetBundleModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestAudioModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestTextureModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.UnityWebRequestWWWModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VehiclesModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VehiclesModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VFXModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VFXModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VideoModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VideoModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VirtualTexturingModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VirtualTexturingModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.VRModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.VRModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.WindModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.WindModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll + ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll + + + ..\ref\TechbloxPreview_Data\Managed\uREPL.dll + ..\..\ref\TechbloxPreview_Data\Managed\uREPL.dll + + + ..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll + ..\..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll + + + + + + diff --git a/CodeGenerator/Program.cs b/CodeGenerator/Program.cs new file mode 100644 index 0000000..15a7e1c --- /dev/null +++ b/CodeGenerator/Program.cs @@ -0,0 +1,16 @@ +using System.CodeDom; +using System.CodeDom.Compiler; +using System.IO; + +namespace CodeGenerator +{ + internal class Program + { + public static void Main(string[] args) + { + var bcg = new BlockClassGenerator(); + bcg.Generate("TestBlock", "TEST_BLOCK"); + bcg.Generate("Engine", null); + } + } +} \ No newline at end of file diff --git a/CodeGenerator/Properties/AssemblyInfo.cs b/CodeGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..18681a4 --- /dev/null +++ b/CodeGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CodeGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CodeGenerator")] +[assembly: AssemblyCopyright("Copyright © ExMods 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0EBB6400-95A7-4A3D-B2ED-BF31E364CC10")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/TechbloxModdingAPI.sln b/TechbloxModdingAPI.sln index 2191746..999cac5 100644 --- a/TechbloxModdingAPI.sln +++ b/TechbloxModdingAPI.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.29411.108 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechbloxModdingAPI", "TechbloxModdingAPI\TechbloxModdingAPI.csproj", "{7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeGenerator", "CodeGenerator\CodeGenerator.csproj", "{0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -18,6 +20,12 @@ Global {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Release|Any CPU.Build.0 = Release|Any CPU {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Test|Any CPU.ActiveCfg = Test|Any CPU {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Test|Any CPU.Build.0 = Test|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Release|Any CPU.Build.0 = Release|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Test|Any CPU.ActiveCfg = Debug|Any CPU + {0EBB6400-95A7-4A3D-B2ED-BF31E364CC10}.Test|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index 51c53c8..8ae2aa3 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using HarmonyLib; -using RobocraftX; using RobocraftX.Common; using RobocraftX.Schedulers; using RobocraftX.SimulationModeState; diff --git a/TechbloxModdingAPI/Blocks/LogicGate.cs b/TechbloxModdingAPI/Blocks/LogicGate.cs new file mode 100644 index 0000000..50a819c --- /dev/null +++ b/TechbloxModdingAPI/Blocks/LogicGate.cs @@ -0,0 +1,16 @@ +using RobocraftX.Common; +using Svelto.ECS; + +namespace TechbloxModdingAPI.Blocks +{ + public class LogicGate : SignalingBlock + { + public LogicGate(EGID id) : base(id) + { + } + + public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) + { + } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Piston.cs b/TechbloxModdingAPI/Blocks/Piston.cs new file mode 100644 index 0000000..22ee052 --- /dev/null +++ b/TechbloxModdingAPI/Blocks/Piston.cs @@ -0,0 +1,50 @@ +using System; + +using RobocraftX.Blocks; +using Svelto.ECS; +using Unity.Mathematics; + +using TechbloxModdingAPI.Utility; +using RobocraftX.Common; + +namespace TechbloxModdingAPI.Blocks +{ + public class Piston : SignalingBlock + { + public Piston(EGID id) : base(id) + { + } + + public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) + { + } + + // custom piston properties + + /// + /// The piston's max extension distance. + /// + public float MaximumExtension + { + get => BlockEngine.GetBlockInfo(this).maxDeviation; + + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } + } + + /// + /// The piston's max extension force. + /// + public float MaximumForce + { + get => BlockEngine.GetBlockInfo(this).pistonVelocity; + + set + { + BlockEngine.GetBlockInfo(this).pistonVelocity = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Blocks/Servo.cs b/TechbloxModdingAPI/Blocks/Servo.cs new file mode 100644 index 0000000..613ab65 --- /dev/null +++ b/TechbloxModdingAPI/Blocks/Servo.cs @@ -0,0 +1,71 @@ +using RobocraftX.Blocks; +using RobocraftX.Common; +using Svelto.ECS; + +namespace TechbloxModdingAPI.Blocks +{ + public class Servo : SignalingBlock + { + public Servo(EGID id) : base(id) + { + } + + public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) + { + } + + // custom servo properties + + /// + /// The servo's minimum angle. + /// + public float MinimumAngle + { + get => BlockEngine.GetBlockInfo(this).minDeviation; + + set + { + BlockEngine.GetBlockInfo(this).minDeviation = value; + } + } + + /// + /// The servo's maximum angle. + /// + public float MaximumAngle + { + get => BlockEngine.GetBlockInfo(this).maxDeviation; + + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } + } + + /// + /// The servo's maximum force. + /// + public float MaximumForce + { + get => BlockEngine.GetBlockInfo(this).servoVelocity; + + set + { + BlockEngine.GetBlockInfo(this).servoVelocity = value; + } + } + + /// + /// The servo's direction. + /// + public bool Reverse + { + get => BlockEngine.GetBlockInfo(this).reverse; + + set + { + BlockEngine.GetBlockInfo(this).reverse = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index de38b9b..811056e 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -4,6 +4,7 @@ using RobocraftX.Character.Movement; using Unity.Mathematics; using RobocraftX.Common; using RobocraftX.Common.Players; +using RobocraftX.GUI.Wires; using RobocraftX.Physics; using Svelto.ECS; using Techblox.BuildingDrone; @@ -432,8 +433,9 @@ namespace TechbloxModdingAPI { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); return egid != EGID.Empty && egid.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP + && egid.groupID != WiresGUIExclusiveGroups.WireGroup ? Block.New(egid) - : null; + : null; } /// @@ -449,6 +451,19 @@ namespace TechbloxModdingAPI : null; } + /// + /// Returns the wire the player is currently looking at in build mode. + /// + /// The maximum distance from the player (default is the player's building reach) + /// The wire or null if not found + public Wire GetWireLookedAt(float maxDistance = -1f) + { + var egid = playerEngine.GetThingLookedAt(Id, maxDistance); + return egid != EGID.Empty && egid.groupID == WiresGUIExclusiveGroups.WireGroup + ? new Wire(egid) + : null; + } + /// /// Returns the blocks that are in the player's current selection. /// diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index b98990b..eb9bda4 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -312,6 +312,21 @@ namespace TechbloxModdingAPI.Tests Loop().RunOn(Scheduler.leanRunner); }).Build(); + + CommandBuilder.Builder("importAssetBundle") + .Action(() => + { + Logging.CommandLog("Importing asset bundle..."); + var ab = AssetBundle.LoadFromFile( + @"filepath"); + Logging.CommandLog("Imported asset bundle: " + ab); + var assets = ab.LoadAllAssets(); + Logging.CommandLog("Loaded " + assets.Length + " assets"); + foreach (var asset in assets) + { + Logging.CommandLog(asset); + } + }).Build(); #if TEST TestRoot.RunTests(); #endif From 3351993936877391a61fab47f1ad7bdf3c3e0b9e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 29 Jul 2021 01:04:27 +0200 Subject: [PATCH 86/98] Automatically generate properties, fixes, engine class --- CodeGenerator/BlockClassGenerator.cs | 35 ++++- TechbloxModdingAPI/Blocks/Engine.cs | 217 ++++++++++++++++++++++++--- 2 files changed, 231 insertions(+), 21 deletions(-) diff --git a/CodeGenerator/BlockClassGenerator.cs b/CodeGenerator/BlockClassGenerator.cs index 82c3206..5a2e748 100644 --- a/CodeGenerator/BlockClassGenerator.cs +++ b/CodeGenerator/BlockClassGenerator.cs @@ -3,6 +3,8 @@ using System.CodeDom.Compiler; using System.IO; using System.Linq; using RobocraftX.Common; +using Svelto.ECS; +using Techblox.EngineBlock; namespace CodeGenerator { @@ -22,10 +24,12 @@ namespace CodeGenerator ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common")); ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS")); var cl = new CodeTypeDeclaration(name); + cl.BaseTypes.Add(new CodeTypeReference("Block")); cl.Members.Add(new CodeConstructor { Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")}, - Comments = { new CodeCommentStatement($"{name} constructor", true)} + Comments = {new CodeCommentStatement($"{name} constructor", true)}, + BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")} }); cl.Members.Add(new CodeConstructor { @@ -41,6 +45,7 @@ namespace CodeGenerator group)) } }); + GenerateProperties(cl); ns.Types.Add(cl); codeUnit.Namespaces.Add(ns); @@ -64,5 +69,33 @@ namespace CodeGenerator return ret; } + + private void GenerateProperties(CodeTypeDeclaration cl) where T : IEntityComponent + { + var type = typeof(T); + foreach (var field in type.GetFields()) + { + var propName = char.ToUpper(field.Name[0]) + field.Name.Substring(1); + var structFieldReference = new CodeFieldReferenceExpression(new CodeMethodInvokeExpression( + new CodeMethodReferenceExpression(new CodeSnippetExpression("BlockEngine"), + "GetBlockInfo", new CodeTypeReference(type)), + new CodeThisReferenceExpression()), field.Name); + cl.Members.Add(new CodeMemberProperty + { + Name = propName, + HasGet = true, + HasSet = true, + GetStatements = + { + new CodeMethodReturnStatement(structFieldReference) + }, + SetStatements = + { + new CodeAssignStatement(structFieldReference, new CodePropertySetValueReferenceExpression()) + }, + Type = new CodeTypeReference(field.FieldType) + }); + } + } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index 08a8f33..05c09e6 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -1,35 +1,212 @@ -using RobocraftX.Common; -using Svelto.ECS; -using Techblox.EngineBlock; +//------------------------------------------------------------------------------ +// +// Ezt a kódot eszköz generálta. +// Futásidejű verzió:4.0.30319.42000 +// +// Ennek a fájlnak a módosítása helytelen viselkedést eredményezhet, és elvész, ha +// a kódot újragenerálják. +// +//------------------------------------------------------------------------------ namespace TechbloxModdingAPI.Blocks { - public class Engine : SignalingBlock + using RobocraftX.Common; + using Svelto.ECS; + + + public class Engine : Block { - public Engine(EGID id) : base(id) + + /// Engine constructor + private Engine(EGID egid) : + base(egid) { } - - public Engine(uint id) : base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP)) + + /// Engine constructor + private Engine(uint id) : + base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP)) { } - - public bool On + + private bool EngineOn { - get => BlockEngine.GetBlockInfo(this).engineOn; - set => BlockEngine.GetBlockInfo(this).engineOn = value; + get + { + return BlockEngine.GetBlockInfo(this).engineOn; + } + set + { + BlockEngine.GetBlockInfo(this).engineOn = value; + } } - - public float CurrentTorque + + private int CurrentGear { - get => BlockEngine.GetBlockInfo(this).currentTorque; - set => BlockEngine.GetBlockInfo(this).currentTorque = value; + get + { + return BlockEngine.GetBlockInfo(this).currentGear; + } + set + { + BlockEngine.GetBlockInfo(this).currentGear = value; + } } - - public int CurrentGear + + private float GearChangeCountdown { - get => BlockEngine.GetBlockInfo(this).currentGear; - set => BlockEngine.GetBlockInfo(this).currentGear = value; + get + { + return BlockEngine.GetBlockInfo(this).gearChangeCountdown; + } + set + { + BlockEngine.GetBlockInfo(this).gearChangeCountdown = value; + } + } + + private float CurrentRpmAV + { + get + { + return BlockEngine.GetBlockInfo(this).currentRpmAV; + } + set + { + BlockEngine.GetBlockInfo(this).currentRpmAV = value; + } + } + + private float CurrentRpmLV + { + get + { + return BlockEngine.GetBlockInfo(this).currentRpmLV; + } + set + { + BlockEngine.GetBlockInfo(this).currentRpmLV = value; + } + } + + private float TargetRpmAV + { + get + { + return BlockEngine.GetBlockInfo(this).targetRpmAV; + } + set + { + BlockEngine.GetBlockInfo(this).targetRpmAV = value; + } + } + + private float TargetRpmLV + { + get + { + return BlockEngine.GetBlockInfo(this).targetRpmLV; + } + set + { + BlockEngine.GetBlockInfo(this).targetRpmLV = value; + } + } + + private float CurrentTorque + { + get + { + return BlockEngine.GetBlockInfo(this).currentTorque; + } + set + { + BlockEngine.GetBlockInfo(this).currentTorque = value; + } + } + + private float TotalWheelVelocityAV + { + get + { + return BlockEngine.GetBlockInfo(this).totalWheelVelocityAV; + } + set + { + BlockEngine.GetBlockInfo(this).totalWheelVelocityAV = value; + } + } + + private float TotalWheelVelocityLV + { + get + { + return BlockEngine.GetBlockInfo(this).totalWheelVelocityLV; + } + set + { + BlockEngine.GetBlockInfo(this).totalWheelVelocityLV = value; + } + } + + private int TotalWheelCount + { + get + { + return BlockEngine.GetBlockInfo(this).totalWheelCount; + } + set + { + BlockEngine.GetBlockInfo(this).totalWheelCount = value; + } + } + + private bool LastGearUpInput + { + get + { + return BlockEngine.GetBlockInfo(this).lastGearUpInput; + } + set + { + BlockEngine.GetBlockInfo(this).lastGearUpInput = value; + } + } + + private bool LastGearDownInput + { + get + { + return BlockEngine.GetBlockInfo(this).lastGearDownInput; + } + set + { + BlockEngine.GetBlockInfo(this).lastGearDownInput = value; + } + } + + private float ManualToAutoGearCoolOffCounter + { + get + { + return BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffCounter; + } + set + { + BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffCounter = value; + } + } + + private float Load + { + get + { + return BlockEngine.GetBlockInfo(this).load; + } + set + { + BlockEngine.GetBlockInfo(this).load = value; + } } } -} \ No newline at end of file +} From c0eae774212f18708822359795165dc7d3eab917 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 11 Aug 2021 23:44:26 +0200 Subject: [PATCH 87/98] Finish code generator (mostly) Made the generated members public and final Removed the comment from the start of the files Generating the files directly into the project folder Added comments describing the generated constructors and properties Using SignalingBlock as a base class Added support for renaming properties Added support for getting the name from the tweakable stat name Added/updated functional block classes --- CodeGenerator/BlockClassGenerator.cs | 69 ++++-- CodeGenerator/Program.cs | 35 ++- TechbloxModdingAPI/Blocks/DampedSpring.cs | 80 ++++--- TechbloxModdingAPI/Blocks/Engine.cs | 249 +++++++++++++++++++--- TechbloxModdingAPI/Blocks/LogicGate.cs | 24 ++- TechbloxModdingAPI/Blocks/Piston.cs | 93 ++++---- TechbloxModdingAPI/Blocks/Seat.cs | 56 +++++ TechbloxModdingAPI/Blocks/Servo.cs | 183 +++++++++++----- TechbloxModdingAPI/Blocks/WheelRig.cs | 101 +++++++++ TechbloxModdingAPI/Utility/OptionalRef.cs | 1 - 10 files changed, 716 insertions(+), 175 deletions(-) create mode 100644 TechbloxModdingAPI/Blocks/Seat.cs create mode 100644 TechbloxModdingAPI/Blocks/WheelRig.cs diff --git a/CodeGenerator/BlockClassGenerator.cs b/CodeGenerator/BlockClassGenerator.cs index 5a2e748..c2307a0 100644 --- a/CodeGenerator/BlockClassGenerator.cs +++ b/CodeGenerator/BlockClassGenerator.cs @@ -1,7 +1,11 @@ +using System; using System.CodeDom; using System.CodeDom.Compiler; +using System.Collections.Generic; using System.IO; using System.Linq; +using System.Reflection; +using Gamecraft.Tweaks; using RobocraftX.Common; using Svelto.ECS; using Techblox.EngineBlock; @@ -10,7 +14,7 @@ namespace CodeGenerator { public class BlockClassGenerator { - public void Generate(string name, string group) + public void Generate(string name, string group = null, Dictionary renames = null, params Type[] types) { if (group is null) { @@ -19,17 +23,25 @@ namespace CodeGenerator group = GetGroup(name) + "_BLOCK_BUILD_GROUP"; } + if (!group.Contains(".")) + group = "CommonExclusiveGroups." + group; + var codeUnit = new CodeCompileUnit(); var ns = new CodeNamespace("TechbloxModdingAPI.Blocks"); ns.Imports.Add(new CodeNamespaceImport("RobocraftX.Common")); ns.Imports.Add(new CodeNamespaceImport("Svelto.ECS")); var cl = new CodeTypeDeclaration(name); - cl.BaseTypes.Add(new CodeTypeReference("Block")); + //cl.BaseTypes.Add(baseClass != null ? new CodeTypeReference(baseClass) : new CodeTypeReference("Block")); + cl.BaseTypes.Add(new CodeTypeReference("SignalingBlock")); cl.Members.Add(new CodeConstructor { Parameters = {new CodeParameterDeclarationExpression("EGID", "egid")}, - Comments = {new CodeCommentStatement($"{name} constructor", true)}, - BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")} + Comments = + { + _start, new CodeCommentStatement($"Constructs a(n) {name} object representing an existing block.", true), _end + }, + BaseConstructorArgs = {new CodeVariableReferenceExpression("egid")}, + Attributes = MemberAttributes.Public | MemberAttributes.Final }); cl.Members.Add(new CodeConstructor { @@ -37,23 +49,33 @@ namespace CodeGenerator { new CodeParameterDeclarationExpression(typeof(uint), "id") }, - Comments = {new CodeCommentStatement($"{name} constructor", true)}, + Comments = + { + _start, new CodeCommentStatement($"Constructs a(n) {name} object representing an existing block.", true), _end + }, BaseConstructorArgs = { new CodeObjectCreateExpression("EGID", new CodeVariableReferenceExpression("id"), - new CodeFieldReferenceExpression(new CodeTypeReferenceExpression("CommonExclusiveGroups"), - group)) - } + new CodeVariableReferenceExpression(group)) + }, + Attributes = MemberAttributes.Public | MemberAttributes.Final }); - GenerateProperties(cl); + foreach (var type in types) + { + GenerateProperties(cl, type, name, renames); + } ns.Types.Add(cl); codeUnit.Namespaces.Add(ns); var provider = CodeDomProvider.CreateProvider("CSharp"); - using (var sw = new StreamWriter($"{name}.cs")) + var path = $@"..\..\..\TechbloxModdingAPI\Blocks\{name}.cs"; + using (var sw = new StreamWriter(path)) { provider.GenerateCodeFromCompileUnit(codeUnit, sw, new CodeGeneratorOptions {BracingStyle = "C"}); } + + File.WriteAllLines(path, + File.ReadAllLines(path).SkipWhile(line => line.StartsWith("//") || line.Length == 0)); } private static string GetGroup(string name) @@ -70,12 +92,22 @@ namespace CodeGenerator return ret; } - private void GenerateProperties(CodeTypeDeclaration cl) where T : IEntityComponent + private void GenerateProperties(CodeTypeDeclaration cl, Type type, string baseClass, + Dictionary renames) { - var type = typeof(T); + if (!typeof(IEntityComponent).IsAssignableFrom(type)) + throw new ArgumentException("Type must be an entity component"); foreach (var field in type.GetFields()) { - var propName = char.ToUpper(field.Name[0]) + field.Name.Substring(1); + var attr = field.GetCustomAttribute(); + if (renames == null || !renames.TryGetValue(field.Name, out var propName)) + { + propName = field.Name; + if (attr != null) + propName = attr.propertyName; + } + + propName = char.ToUpper(propName[0]) + propName.Substring(1); var structFieldReference = new CodeFieldReferenceExpression(new CodeMethodInvokeExpression( new CodeMethodReferenceExpression(new CodeSnippetExpression("BlockEngine"), "GetBlockInfo", new CodeTypeReference(type)), @@ -93,9 +125,18 @@ namespace CodeGenerator { new CodeAssignStatement(structFieldReference, new CodePropertySetValueReferenceExpression()) }, - Type = new CodeTypeReference(field.FieldType) + Type = new CodeTypeReference(field.FieldType), + Attributes = MemberAttributes.Public | MemberAttributes.Final, + Comments = + { + _start, new CodeCommentStatement($"Gets or sets the {baseClass}'s {propName} property." + + $" {(attr != null ? "Tweakable stat." : "May not be saved.")}", true), _end + } }); } } + + private static readonly CodeCommentStatement _start = new CodeCommentStatement("", true); + private static readonly CodeCommentStatement _end = new CodeCommentStatement("", true); } } \ No newline at end of file diff --git a/CodeGenerator/Program.cs b/CodeGenerator/Program.cs index 15a7e1c..0af44ab 100644 --- a/CodeGenerator/Program.cs +++ b/CodeGenerator/Program.cs @@ -1,6 +1,8 @@ -using System.CodeDom; -using System.CodeDom.Compiler; -using System.IO; +using System.Collections.Generic; +using RobocraftX.Blocks; +using RobocraftX.PilotSeat; +using Techblox.EngineBlock; +using Techblox.WheelRigBlock; namespace CodeGenerator { @@ -9,8 +11,31 @@ namespace CodeGenerator public static void Main(string[] args) { var bcg = new BlockClassGenerator(); - bcg.Generate("TestBlock", "TEST_BLOCK"); - bcg.Generate("Engine", null); + bcg.Generate("Engine", null, new Dictionary + { + { "engineOn", "On" } + }, typeof(EngineBlockComponent), // Simulation time properties + typeof(EngineBlockTweakableComponent), typeof(EngineBlockReadonlyComponent)); + bcg.Generate("DampedSpring", "DAMPEDSPRING_BLOCK_GROUP", new Dictionary + { + {"maxExtent", "MaxExtension"} + }, + typeof(TweakableJointDampingComponent), typeof(DampedSpringReadOnlyStruct)); + bcg.Generate("LogicGate", "LOGIC_BLOCK_GROUP"); + bcg.Generate("Servo", types: typeof(ServoReadOnlyStruct), renames: new Dictionary + { + {"minDeviation", "MinimumAngle"}, + {"maxDeviation", "MaximumAngle"}, + {"servoVelocity", "MaximumForce"} + }); + bcg.Generate("WheelRig", "WHEELRIG_BLOCK_BUILD_GROUP", null, + typeof(WheelRigTweakableStruct), typeof(WheelRigReadOnlyStruct), + typeof(WheelRigSteerableTweakableStruct), typeof(WheelRigSteerableReadOnlyStruct)); + bcg.Generate("Seat", "RobocraftX.PilotSeat.SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP", null, typeof(SeatFollowCamComponent), typeof(SeatReadOnlySettingsComponent)); + bcg.Generate("Piston", null, new Dictionary + { + {"pistonVelocity", "MaximumForce"} + }, typeof(PistonReadOnlyStruct)); } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/DampedSpring.cs b/TechbloxModdingAPI/Blocks/DampedSpring.cs index afff30b..9408f31 100644 --- a/TechbloxModdingAPI/Blocks/DampedSpring.cs +++ b/TechbloxModdingAPI/Blocks/DampedSpring.cs @@ -1,47 +1,71 @@ -using RobocraftX.Blocks; -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { - public class DampedSpring : Block + using RobocraftX.Common; + using Svelto.ECS; + + + public class DampedSpring : SignalingBlock { - public DampedSpring(EGID id) : base(id) - { - } - - public DampedSpring(uint id) : base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP)) - { - } - + /// - /// The spring's stiffness. + /// Constructs a(n) DampedSpring object representing an existing block. + /// + public DampedSpring(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) DampedSpring object representing an existing block. + /// + public DampedSpring(uint id) : + base(new EGID(id, CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP)) + { + } + + /// + /// Gets or sets the DampedSpring's Stiffness property. Tweakable stat. /// public float Stiffness { - get => BlockEngine.GetBlockInfo(this).stiffness; - - set => BlockEngine.GetBlockInfo(this).stiffness = value; + get + { + return BlockEngine.GetBlockInfo(this).stiffness; + } + set + { + BlockEngine.GetBlockInfo(this).stiffness = value; + } } - + /// - /// The spring's maximum damping force. + /// Gets or sets the DampedSpring's Damping property. Tweakable stat. /// public float Damping { - get => BlockEngine.GetBlockInfo(this).damping; - - set => BlockEngine.GetBlockInfo(this).damping = value; + get + { + return BlockEngine.GetBlockInfo(this).damping; + } + set + { + BlockEngine.GetBlockInfo(this).damping = value; + } } - + /// - /// The spring's maximum extension. + /// Gets or sets the DampedSpring's MaxExtension property. Tweakable stat. /// public float MaxExtension { - get => BlockEngine.GetBlockInfo(this).maxExtent; - - set => BlockEngine.GetBlockInfo(this).maxExtent = value; + get + { + return BlockEngine.GetBlockInfo(this).maxExtent; + } + set + { + BlockEngine.GetBlockInfo(this).maxExtent = value; + } } } -} \ No newline at end of file +} diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index 05c09e6..bb87ba8 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -1,35 +1,32 @@ -//------------------------------------------------------------------------------ -// -// Ezt a kódot eszköz generálta. -// Futásidejű verzió:4.0.30319.42000 -// -// Ennek a fájlnak a módosítása helytelen viselkedést eredményezhet, és elvész, ha -// a kódot újragenerálják. -// -//------------------------------------------------------------------------------ - namespace TechbloxModdingAPI.Blocks { using RobocraftX.Common; using Svelto.ECS; - public class Engine : Block + public class Engine : SignalingBlock { - /// Engine constructor - private Engine(EGID egid) : + /// + /// Constructs a(n) Engine object representing an existing block. + /// + public Engine(EGID egid) : base(egid) { } - /// Engine constructor - private Engine(uint id) : + /// + /// Constructs a(n) Engine object representing an existing block. + /// + public Engine(uint id) : base(new EGID(id, CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP)) { } - private bool EngineOn + /// + /// Gets or sets the Engine's On property. May not be saved. + /// + public bool On { get { @@ -41,7 +38,10 @@ namespace TechbloxModdingAPI.Blocks } } - private int CurrentGear + /// + /// Gets or sets the Engine's CurrentGear property. May not be saved. + /// + public int CurrentGear { get { @@ -53,7 +53,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float GearChangeCountdown + /// + /// Gets or sets the Engine's GearChangeCountdown property. May not be saved. + /// + public float GearChangeCountdown { get { @@ -65,7 +68,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentRpmAV + /// + /// Gets or sets the Engine's CurrentRpmAV property. May not be saved. + /// + public float CurrentRpmAV { get { @@ -77,7 +83,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentRpmLV + /// + /// Gets or sets the Engine's CurrentRpmLV property. May not be saved. + /// + public float CurrentRpmLV { get { @@ -89,7 +98,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TargetRpmAV + /// + /// Gets or sets the Engine's TargetRpmAV property. May not be saved. + /// + public float TargetRpmAV { get { @@ -101,7 +113,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TargetRpmLV + /// + /// Gets or sets the Engine's TargetRpmLV property. May not be saved. + /// + public float TargetRpmLV { get { @@ -113,7 +128,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float CurrentTorque + /// + /// Gets or sets the Engine's CurrentTorque property. May not be saved. + /// + public float CurrentTorque { get { @@ -125,7 +143,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TotalWheelVelocityAV + /// + /// Gets or sets the Engine's TotalWheelVelocityAV property. May not be saved. + /// + public float TotalWheelVelocityAV { get { @@ -137,7 +158,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float TotalWheelVelocityLV + /// + /// Gets or sets the Engine's TotalWheelVelocityLV property. May not be saved. + /// + public float TotalWheelVelocityLV { get { @@ -149,7 +173,10 @@ namespace TechbloxModdingAPI.Blocks } } - private int TotalWheelCount + /// + /// Gets or sets the Engine's TotalWheelCount property. May not be saved. + /// + public int TotalWheelCount { get { @@ -161,7 +188,10 @@ namespace TechbloxModdingAPI.Blocks } } - private bool LastGearUpInput + /// + /// Gets or sets the Engine's LastGearUpInput property. May not be saved. + /// + public bool LastGearUpInput { get { @@ -173,7 +203,10 @@ namespace TechbloxModdingAPI.Blocks } } - private bool LastGearDownInput + /// + /// Gets or sets the Engine's LastGearDownInput property. May not be saved. + /// + public bool LastGearDownInput { get { @@ -185,7 +218,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float ManualToAutoGearCoolOffCounter + /// + /// Gets or sets the Engine's ManualToAutoGearCoolOffCounter property. May not be saved. + /// + public float ManualToAutoGearCoolOffCounter { get { @@ -197,7 +233,10 @@ namespace TechbloxModdingAPI.Blocks } } - private float Load + /// + /// Gets or sets the Engine's Load property. May not be saved. + /// + public float Load { get { @@ -208,5 +247,155 @@ namespace TechbloxModdingAPI.Blocks BlockEngine.GetBlockInfo(this).load = value; } } + + /// + /// Gets or sets the Engine's Power property. Tweakable stat. + /// + public float Power + { + get + { + return BlockEngine.GetBlockInfo(this).power; + } + set + { + BlockEngine.GetBlockInfo(this).power = value; + } + } + + /// + /// Gets or sets the Engine's AutomaticGears property. Tweakable stat. + /// + public bool AutomaticGears + { + get + { + return BlockEngine.GetBlockInfo(this).automaticGears; + } + set + { + BlockEngine.GetBlockInfo(this).automaticGears = value; + } + } + + /// + /// Gets or sets the Engine's GearChangeTime property. May not be saved. + /// + public float GearChangeTime + { + get + { + return BlockEngine.GetBlockInfo(this).gearChangeTime; + } + set + { + BlockEngine.GetBlockInfo(this).gearChangeTime = value; + } + } + + /// + /// Gets or sets the Engine's MinRpm property. May not be saved. + /// + public float MinRpm + { + get + { + return BlockEngine.GetBlockInfo(this).minRpm; + } + set + { + BlockEngine.GetBlockInfo(this).minRpm = value; + } + } + + /// + /// Gets or sets the Engine's MaxRpm property. May not be saved. + /// + public float MaxRpm + { + get + { + return BlockEngine.GetBlockInfo(this).maxRpm; + } + set + { + BlockEngine.GetBlockInfo(this).maxRpm = value; + } + } + + /// + /// Gets or sets the Engine's GearDownRpms property. May not be saved. + /// + public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms + { + get + { + return BlockEngine.GetBlockInfo(this).gearDownRpms; + } + set + { + BlockEngine.GetBlockInfo(this).gearDownRpms = value; + } + } + + /// + /// Gets or sets the Engine's GearUpRpm property. May not be saved. + /// + public float GearUpRpm + { + get + { + return BlockEngine.GetBlockInfo(this).gearUpRpm; + } + set + { + BlockEngine.GetBlockInfo(this).gearUpRpm = value; + } + } + + /// + /// Gets or sets the Engine's MaxRpmChange property. May not be saved. + /// + public float MaxRpmChange + { + get + { + return BlockEngine.GetBlockInfo(this).maxRpmChange; + } + set + { + BlockEngine.GetBlockInfo(this).maxRpmChange = value; + } + } + + /// + /// Gets or sets the Engine's ManualToAutoGearCoolOffTime property. May not be saved. + /// + public float ManualToAutoGearCoolOffTime + { + get + { + return BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffTime; + } + set + { + BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffTime = value; + } + } + + /// + /// Gets or sets the Engine's EngineBlockDataId property. May not be saved. + /// + public int EngineBlockDataId + { + get + { + return BlockEngine.GetBlockInfo(this).engineBlockDataId; + } + set + { + BlockEngine.GetBlockInfo(this).engineBlockDataId = value; + } + } } } diff --git a/TechbloxModdingAPI/Blocks/LogicGate.cs b/TechbloxModdingAPI/Blocks/LogicGate.cs index 50a819c..05cc3bf 100644 --- a/TechbloxModdingAPI/Blocks/LogicGate.cs +++ b/TechbloxModdingAPI/Blocks/LogicGate.cs @@ -1,16 +1,26 @@ -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { + using RobocraftX.Common; + using Svelto.ECS; + + public class LogicGate : SignalingBlock { - public LogicGate(EGID id) : base(id) + + /// + /// Constructs a(n) LogicGate object representing an existing block. + /// + public LogicGate(EGID egid) : + base(egid) { } - - public LogicGate(uint id) : base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) + + /// + /// Constructs a(n) LogicGate object representing an existing block. + /// + public LogicGate(uint id) : + base(new EGID(id, CommonExclusiveGroups.LOGIC_BLOCK_GROUP)) { } } -} \ No newline at end of file +} diff --git a/TechbloxModdingAPI/Blocks/Piston.cs b/TechbloxModdingAPI/Blocks/Piston.cs index 22ee052..c351d59 100644 --- a/TechbloxModdingAPI/Blocks/Piston.cs +++ b/TechbloxModdingAPI/Blocks/Piston.cs @@ -1,49 +1,70 @@ -using System; - -using RobocraftX.Blocks; -using Svelto.ECS; -using Unity.Mathematics; - -using TechbloxModdingAPI.Utility; -using RobocraftX.Common; - namespace TechbloxModdingAPI.Blocks { - public class Piston : SignalingBlock + using RobocraftX.Common; + using Svelto.ECS; + + + public class Piston : SignalingBlock { - public Piston(EGID id) : base(id) - { - } - - public Piston(uint id) : base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) - { - } - - // custom piston properties - + /// - /// The piston's max extension distance. + /// Constructs a(n) Piston object representing an existing block. /// - public float MaximumExtension + public Piston(EGID egid) : + base(egid) { - get => BlockEngine.GetBlockInfo(this).maxDeviation; - - set - { - BlockEngine.GetBlockInfo(this).maxDeviation = value; - } - } - - /// - /// The piston's max extension force. + } + + /// + /// Constructs a(n) Piston object representing an existing block. + /// + public Piston(uint id) : + base(new EGID(id, CommonExclusiveGroups.PISTON_BLOCK_GROUP)) + { + } + + /// + /// Gets or sets the Piston's MaximumForce property. Tweakable stat. /// public float MaximumForce - { - get => BlockEngine.GetBlockInfo(this).pistonVelocity; - + { + get + { + return BlockEngine.GetBlockInfo(this).pistonVelocity; + } set { - BlockEngine.GetBlockInfo(this).pistonVelocity = value; + BlockEngine.GetBlockInfo(this).pistonVelocity = value; + } + } + + /// + /// Gets or sets the Piston's MaxExtension property. Tweakable stat. + /// + public float MaxExtension + { + get + { + return BlockEngine.GetBlockInfo(this).maxDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } + } + + /// + /// Gets or sets the Piston's InputIsExtension property. Tweakable stat. + /// + public bool InputIsExtension + { + get + { + return BlockEngine.GetBlockInfo(this).hasProportionalInput; + } + set + { + BlockEngine.GetBlockInfo(this).hasProportionalInput = value; } } } diff --git a/TechbloxModdingAPI/Blocks/Seat.cs b/TechbloxModdingAPI/Blocks/Seat.cs new file mode 100644 index 0000000..e06077f --- /dev/null +++ b/TechbloxModdingAPI/Blocks/Seat.cs @@ -0,0 +1,56 @@ +namespace TechbloxModdingAPI.Blocks +{ + using RobocraftX.Common; + using Svelto.ECS; + + + public class Seat : SignalingBlock + { + + /// + /// Constructs a(n) Seat object representing an existing block. + /// + public Seat(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) Seat object representing an existing block. + /// + public Seat(uint id) : + base(new EGID(id, RobocraftX.PilotSeat.SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP)) + { + } + + /// + /// Gets or sets the Seat's FollowCam property. Tweakable stat. + /// + public bool FollowCam + { + get + { + return BlockEngine.GetBlockInfo(this).followCam; + } + set + { + BlockEngine.GetBlockInfo(this).followCam = value; + } + } + + /// + /// Gets or sets the Seat's CharacterColliderHeight property. May not be saved. + /// + public float CharacterColliderHeight + { + get + { + return BlockEngine.GetBlockInfo(this).characterColliderHeight; + } + set + { + BlockEngine.GetBlockInfo(this).characterColliderHeight = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Blocks/Servo.cs b/TechbloxModdingAPI/Blocks/Servo.cs index 613ab65..89bd194 100644 --- a/TechbloxModdingAPI/Blocks/Servo.cs +++ b/TechbloxModdingAPI/Blocks/Servo.cs @@ -1,71 +1,146 @@ -using RobocraftX.Blocks; -using RobocraftX.Common; -using Svelto.ECS; - namespace TechbloxModdingAPI.Blocks { - public class Servo : SignalingBlock + using RobocraftX.Common; + using Svelto.ECS; + + + public class Servo : SignalingBlock { - public Servo(EGID id) : base(id) - { - } - - public Servo(uint id) : base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) - { - } - - // custom servo properties - + /// - /// The servo's minimum angle. + /// Constructs a(n) Servo object representing an existing block. /// - public float MinimumAngle + public Servo(EGID egid) : + base(egid) { - get => BlockEngine.GetBlockInfo(this).minDeviation; - - set - { - BlockEngine.GetBlockInfo(this).minDeviation = value; - } - } - - /// - /// The servo's maximum angle. - /// - public float MaximumAngle - { - get => BlockEngine.GetBlockInfo(this).maxDeviation; - - set - { - BlockEngine.GetBlockInfo(this).maxDeviation = value; - } } - - /// - /// The servo's maximum force. + + /// + /// Constructs a(n) Servo object representing an existing block. + /// + public Servo(uint id) : + base(new EGID(id, CommonExclusiveGroups.SERVO_BLOCK_GROUP)) + { + } + + /// + /// Gets or sets the Servo's MaximumForce property. Tweakable stat. /// public float MaximumForce { - get => BlockEngine.GetBlockInfo(this).servoVelocity; - - set - { - BlockEngine.GetBlockInfo(this).servoVelocity = value; - } + get + { + return BlockEngine.GetBlockInfo(this).servoVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).servoVelocity = value; + } } - - /// - /// The servo's direction. + + /// + /// Gets or sets the Servo's MinimumAngle property. Tweakable stat. + /// + public float MinimumAngle + { + get + { + return BlockEngine.GetBlockInfo(this).minDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).minDeviation = value; + } + } + + /// + /// Gets or sets the Servo's MaximumAngle property. Tweakable stat. + /// + public float MaximumAngle + { + get + { + return BlockEngine.GetBlockInfo(this).maxDeviation; + } + set + { + BlockEngine.GetBlockInfo(this).maxDeviation = value; + } + } + + /// + /// Gets or sets the Servo's Reverse property. Tweakable stat. /// public bool Reverse { - get => BlockEngine.GetBlockInfo(this).reverse; - - set - { - BlockEngine.GetBlockInfo(this).reverse = value; - } + get + { + return BlockEngine.GetBlockInfo(this).reverse; + } + set + { + BlockEngine.GetBlockInfo(this).reverse = value; + } + } + + /// + /// Gets or sets the Servo's InputIsAngle property. Tweakable stat. + /// + public bool InputIsAngle + { + get + { + return BlockEngine.GetBlockInfo(this).hasProportionalInput; + } + set + { + BlockEngine.GetBlockInfo(this).hasProportionalInput = value; + } + } + + /// + /// Gets or sets the Servo's DirectionVector property. May not be saved. + /// + public Unity.Mathematics.float3 DirectionVector + { + get + { + return BlockEngine.GetBlockInfo(this).directionVector; + } + set + { + BlockEngine.GetBlockInfo(this).directionVector = value; + } + } + + /// + /// Gets or sets the Servo's RotationAxis property. May not be saved. + /// + public Unity.Mathematics.float3 RotationAxis + { + get + { + return BlockEngine.GetBlockInfo(this).rotationAxis; + } + set + { + BlockEngine.GetBlockInfo(this).rotationAxis = value; + } + } + + /// + /// Gets or sets the Servo's ForceAxis property. May not be saved. + /// + public Unity.Mathematics.float3 ForceAxis + { + get + { + return BlockEngine.GetBlockInfo(this).forceAxis; + } + set + { + BlockEngine.GetBlockInfo(this).forceAxis = value; + } } } } diff --git a/TechbloxModdingAPI/Blocks/WheelRig.cs b/TechbloxModdingAPI/Blocks/WheelRig.cs new file mode 100644 index 0000000..1eb4c0b --- /dev/null +++ b/TechbloxModdingAPI/Blocks/WheelRig.cs @@ -0,0 +1,101 @@ +namespace TechbloxModdingAPI.Blocks +{ + using RobocraftX.Common; + using Svelto.ECS; + + + public class WheelRig : SignalingBlock + { + + /// + /// Constructs a(n) WheelRig object representing an existing block. + /// + public WheelRig(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) WheelRig object representing an existing block. + /// + public WheelRig(uint id) : + base(new EGID(id, CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP)) + { + } + + /// + /// Gets or sets the WheelRig's BrakingStrength property. Tweakable stat. + /// + public float BrakingStrength + { + get + { + return BlockEngine.GetBlockInfo(this).brakingStrength; + } + set + { + BlockEngine.GetBlockInfo(this).brakingStrength = value; + } + } + + /// + /// Gets or sets the WheelRig's MaxVelocity property. May not be saved. + /// + public float MaxVelocity + { + get + { + return BlockEngine.GetBlockInfo(this).maxVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).maxVelocity = value; + } + } + + /// + /// Gets or sets the WheelRig's SteerAngle property. Tweakable stat. + /// + public float SteerAngle + { + get + { + return BlockEngine.GetBlockInfo(this).steerAngle; + } + set + { + BlockEngine.GetBlockInfo(this).steerAngle = value; + } + } + + /// + /// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved. + /// + public float VelocityForMinAngle + { + get + { + return BlockEngine.GetBlockInfo(this).velocityForMinAngle; + } + set + { + BlockEngine.GetBlockInfo(this).velocityForMinAngle = value; + } + } + + /// + /// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved. + /// + public float MinSteerAngleFactor + { + get + { + return BlockEngine.GetBlockInfo(this).minSteerAngleFactor; + } + set + { + BlockEngine.GetBlockInfo(this).minSteerAngleFactor = value; + } + } + } +} diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 2410f1b..79f7175 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -1,5 +1,4 @@ using System; -using System.Runtime.InteropServices; using Svelto.DataStructures; using Svelto.ECS; From 9693341d7ae370c84b2c58d9ad6121474403154e Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 12 Aug 2021 00:34:39 +0200 Subject: [PATCH 88/98] Add block types, run tests, remove unintended properties --- TechbloxModdingAPI/Block.cs | 11 ++++++++++- TechbloxModdingAPI/Blocks/Engine.cs | 25 +++---------------------- TechbloxModdingAPI/Blocks/WheelRig.cs | 5 +++++ 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index efea216..d4dead6 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -10,6 +10,7 @@ using RobocraftX.Blocks; using Unity.Mathematics; using Gamecraft.Blocks.GUI; using HarmonyLib; +using RobocraftX.PilotSeat; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Blocks.Engines; @@ -93,7 +94,13 @@ namespace TechbloxModdingAPI new Dictionary, Type)> { {CommonExclusiveGroups.DAMPEDSPRING_BLOCK_GROUP, (id => new DampedSpring(id), typeof(DampedSpring))}, - {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))} + {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))}, + {CommonExclusiveGroups.LOGIC_BLOCK_GROUP, (id => new LogicGate(id), typeof(LogicGate))}, + {CommonExclusiveGroups.PISTON_BLOCK_GROUP, (id => new Piston(id), typeof(Piston))}, + {SeatGroups.PASSENGER_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, + {SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, + {CommonExclusiveGroups.SERVO_BLOCK_GROUP, (id => new Servo(id), typeof(Servo))}, + {CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP, (id => new WheelRig(id), typeof(WheelRig))} }; internal static Block New(EGID egid) @@ -340,6 +347,8 @@ namespace TechbloxModdingAPI return; } blockGroup?.RemoveInternal(this); + if (!InitData.Valid) + return; BlockEngine.GetBlockInfo(this).currentBlockGroup = (int?) value?.Id.entityID ?? -1; value?.AddInternal(this); blockGroup = value; diff --git a/TechbloxModdingAPI/Blocks/Engine.cs b/TechbloxModdingAPI/Blocks/Engine.cs index bb87ba8..6140b11 100644 --- a/TechbloxModdingAPI/Blocks/Engine.cs +++ b/TechbloxModdingAPI/Blocks/Engine.cs @@ -324,17 +324,13 @@ namespace TechbloxModdingAPI.Blocks } /// - /// Gets or sets the Engine's GearDownRpms property. May not be saved. + /// Gets the Engine's GearDownRpms property. May not be saved. /// - public Svelto.ECS.DataStructures.NativeDynamicArray GearDownRpms + public float[] GearDownRpms { get { - return BlockEngine.GetBlockInfo(this).gearDownRpms; - } - set - { - BlockEngine.GetBlockInfo(this).gearDownRpms = value; + return BlockEngine.GetBlockInfo(this).gearDownRpms.ToManagedArray(); } } @@ -382,20 +378,5 @@ namespace TechbloxModdingAPI.Blocks BlockEngine.GetBlockInfo(this).manualToAutoGearCoolOffTime = value; } } - - /// - /// Gets or sets the Engine's EngineBlockDataId property. May not be saved. - /// - public int EngineBlockDataId - { - get - { - return BlockEngine.GetBlockInfo(this).engineBlockDataId; - } - set - { - BlockEngine.GetBlockInfo(this).engineBlockDataId = value; - } - } } } diff --git a/TechbloxModdingAPI/Blocks/WheelRig.cs b/TechbloxModdingAPI/Blocks/WheelRig.cs index 1eb4c0b..28ba739 100644 --- a/TechbloxModdingAPI/Blocks/WheelRig.cs +++ b/TechbloxModdingAPI/Blocks/WheelRig.cs @@ -1,3 +1,5 @@ +using TechbloxModdingAPI.Tests; + namespace TechbloxModdingAPI.Blocks { using RobocraftX.Common; @@ -56,6 +58,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's SteerAngle property. Tweakable stat. /// + [TestValue(0f)] // Can be 0 for no steer variant public float SteerAngle { get @@ -71,6 +74,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's VelocityForMinAngle property. May not be saved. /// + [TestValue(0f)] public float VelocityForMinAngle { get @@ -86,6 +90,7 @@ namespace TechbloxModdingAPI.Blocks /// /// Gets or sets the WheelRig's MinSteerAngleFactor property. May not be saved. /// + [TestValue(0f)] public float MinSteerAngleFactor { get From 77d5e59ef6012660c26db5c6b161488554851b00 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 12 Aug 2021 00:44:23 +0200 Subject: [PATCH 89/98] Add Motor class --- CodeGenerator/Program.cs | 1 + TechbloxModdingAPI/Blocks/Motor.cs | 71 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 TechbloxModdingAPI/Blocks/Motor.cs diff --git a/CodeGenerator/Program.cs b/CodeGenerator/Program.cs index 0af44ab..0e9dea5 100644 --- a/CodeGenerator/Program.cs +++ b/CodeGenerator/Program.cs @@ -36,6 +36,7 @@ namespace CodeGenerator { {"pistonVelocity", "MaximumForce"} }, typeof(PistonReadOnlyStruct)); + bcg.Generate("Motor", null, null, typeof(MotorReadOnlyStruct)); } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Motor.cs b/TechbloxModdingAPI/Blocks/Motor.cs new file mode 100644 index 0000000..233d5f6 --- /dev/null +++ b/TechbloxModdingAPI/Blocks/Motor.cs @@ -0,0 +1,71 @@ +namespace TechbloxModdingAPI.Blocks +{ + using RobocraftX.Common; + using Svelto.ECS; + + + public class Motor : SignalingBlock + { + + /// + /// Constructs a(n) Motor object representing an existing block. + /// + public Motor(EGID egid) : + base(egid) + { + } + + /// + /// Constructs a(n) Motor object representing an existing block. + /// + public Motor(uint id) : + base(new EGID(id, CommonExclusiveGroups.MOTOR_BLOCK_GROUP)) + { + } + + /// + /// Gets or sets the Motor's TopSpeed property. Tweakable stat. + /// + public float TopSpeed + { + get + { + return BlockEngine.GetBlockInfo(this).maxVelocity; + } + set + { + BlockEngine.GetBlockInfo(this).maxVelocity = value; + } + } + + /// + /// Gets or sets the Motor's Torque property. Tweakable stat. + /// + public float Torque + { + get + { + return BlockEngine.GetBlockInfo(this).maxForce; + } + set + { + BlockEngine.GetBlockInfo(this).maxForce = value; + } + } + + /// + /// Gets or sets the Motor's Reverse property. Tweakable stat. + /// + public bool Reverse + { + get + { + return BlockEngine.GetBlockInfo(this).reverse; + } + set + { + BlockEngine.GetBlockInfo(this).reverse = value; + } + } + } +} From 033ebdb86dcc072f3a434a899799d1eb72267524 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 3 Sep 2021 01:30:15 +0200 Subject: [PATCH 90/98] Fix looking at wires, reduce Wire code Also added two port name properties directly to the wires Also added support for converting OptionalRefs to Nullables --- TechbloxModdingAPI/Block.cs | 6 +- .../Blocks/Engines/SignalEngine.cs | 76 +++---- TechbloxModdingAPI/Blocks/SignalingBlock.cs | 9 +- TechbloxModdingAPI/Blocks/Wire.cs | 198 +++++++----------- TechbloxModdingAPI/Player.cs | 3 +- TechbloxModdingAPI/Utility/OptionalRef.cs | 1 + 6 files changed, 117 insertions(+), 176 deletions(-) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index d4dead6..3ace802 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -103,11 +103,13 @@ namespace TechbloxModdingAPI {CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP, (id => new WheelRig(id), typeof(WheelRig))} }; - internal static Block New(EGID egid) + internal static Block New(EGID egid, bool signaling = false) { return GroupToConstructor.ContainsKey(egid.groupID) ? GroupToConstructor[egid.groupID].Constructor(egid) - : new Block(egid); + : signaling + ? new SignalingBlock(egid) + : new Block(egid); } public Block(EGID id) diff --git a/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs index b5d2083..ee2e42b 100644 --- a/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs @@ -208,48 +208,35 @@ namespace TechbloxModdingAPI.Blocks.Engines } return outputs; } - - public EGID MatchBlockInputToPort(Block block, byte portUsage, out bool exists) + + public OptionalRef MatchBlockIOToPort(Block block, byte portUsage, bool output) { - var ports = entitiesDB.QueryEntityOptional(block); - exists = ports; - return new EGID(ports.Get().firstInputID + portUsage, NamedExclusiveGroup.Group); + return MatchBlockIOToPort(block.Id, portUsage, output); } - public EGID MatchBlockInputToPort(EGID block, byte portUsage, out bool exists) + public OptionalRef MatchBlockIOToPort(EGID block, byte portUsage, bool output) { if (!entitiesDB.Exists(block)) - { - exists = false; return default; - } - exists = true; + var group = output + ? NamedExclusiveGroup.Group + : NamedExclusiveGroup.Group; BlockPortsStruct ports = entitiesDB.QueryEntity(block); - return new EGID(ports.firstInputID + portUsage, NamedExclusiveGroup.Group); - } - - public EGID MatchBlockOutputToPort(Block block, byte portUsage, out bool exists) - { - var ports = entitiesDB.QueryEntityOptional(block); - exists = ports; - return new EGID(ports.Get().firstOutputID + portUsage, NamedExclusiveGroup.Group); - } - - public EGID MatchBlockOutputToPort(EGID block, byte portUsage, out bool exists) - { - if (!entitiesDB.Exists(block)) - { - exists = false; + if (!entitiesDB.TryQueryMappedEntities(group, out var mapper)) return default; + for (uint i = 0; i < (output ? ports.outputCount : ports.inputCount); ++i) + { + uint entityID = (output ? ports.firstOutputID : ports.firstInputID) + i; + if (!mapper.TryGetArrayAndEntityIndex(entityID, out var index, out var array) || + array[index].usage != portUsage) continue; + return new OptionalRef(array, index); } - exists = true; - BlockPortsStruct ports = entitiesDB.QueryEntity(block); - return new EGID(ports.firstOutputID + portUsage, NamedExclusiveGroup.Group); + + return default; } - public ref WireEntityStruct MatchPortToWire(EGID portID, EGID blockID, out bool exists) + public ref WireEntityStruct MatchPortToWire(PortEntityStruct port, EGID blockID, out bool exists) { - ref PortEntityStruct port = ref entitiesDB.QueryEntity(portID); var wires = entitiesDB.QueryEntities(NamedExclusiveGroup.Group); var wiresB = wires.ToBuffer().buffer; for (uint i = 0; i < wires.count; i++) @@ -266,8 +253,7 @@ namespace TechbloxModdingAPI.Blocks.Engines return ref defRef[0]; } - public ref WireEntityStruct MatchBlocksToWire(EGID startBlock, EGID endBlock, out bool exists, byte startPort = byte.MaxValue, - byte endPort = byte.MaxValue) + public EGID MatchBlocksToWire(EGID startBlock, EGID endBlock, byte startPort = byte.MaxValue, byte endPort = byte.MaxValue) { EGID[] startPorts; if (startPort == byte.MaxValue) @@ -306,31 +292,23 @@ namespace TechbloxModdingAPI.Blocks.Engines if ((wiresB[w].destinationPortUsage == endPES.usage && wiresB[w].destinationBlockEGID == endBlock) && (wiresB[w].sourcePortUsage == startPES.usage && wiresB[w].sourceBlockEGID == startBlock)) { - exists = true; - return ref wiresB[w]; + return wiresB[w].ID; } } } } - - exists = false; - WireEntityStruct[] defRef = new WireEntityStruct[1]; - return ref defRef[0]; + + return EGID.Empty; } - public ref ChannelDataStruct GetChannelDataStruct(EGID portID, out bool exists) - { - ref PortEntityStruct port = ref entitiesDB.QueryEntity(portID); + public OptionalRef GetChannelDataStruct(EGID portID) + { + var port = GetPort(portID); var channels = entitiesDB.QueryEntities(NamedExclusiveGroup.Group); var channelsB = channels.ToBuffer(); - if (port.firstChannelIndexCachedInSim < channels.count) - { - exists = true; - return ref channelsB.buffer[port.firstChannelIndexCachedInSim]; - } - exists = false; - ChannelDataStruct[] defRef = new ChannelDataStruct[1]; - return ref defRef[0]; + return port.firstChannelIndexCachedInSim < channels.count + ? new OptionalRef(channelsB.buffer, port.firstChannelIndexCachedInSim) + : default; } public EGID[] GetElectricBlocks() diff --git a/TechbloxModdingAPI/Blocks/SignalingBlock.cs b/TechbloxModdingAPI/Blocks/SignalingBlock.cs index 45b5aa6..7ae6e6a 100644 --- a/TechbloxModdingAPI/Blocks/SignalingBlock.cs +++ b/TechbloxModdingAPI/Blocks/SignalingBlock.cs @@ -46,9 +46,9 @@ namespace TechbloxModdingAPI.Blocks /// The connected wire. /// Port identifier. /// Whether the port has a wire connected to it. - protected ref WireEntityStruct GetConnectedWire(EGID portId, out bool connected) + protected ref WireEntityStruct GetConnectedWire(PortEntityStruct port, out bool connected) { - return ref SignalEngine.MatchPortToWire(portId, Id, out connected); + return ref SignalEngine.MatchPortToWire(port, Id, out connected); } /// @@ -56,10 +56,9 @@ namespace TechbloxModdingAPI.Blocks /// /// The channel data. /// Port identifier. - /// Whether the channel actually exists. - protected ref ChannelDataStruct GetChannelData(EGID portId, out bool exists) + protected OptionalRef GetChannelData(EGID portId) { - return ref SignalEngine.GetChannelDataStruct(portId, out exists); + return SignalEngine.GetChannelDataStruct(portId); } /// diff --git a/TechbloxModdingAPI/Blocks/Wire.cs b/TechbloxModdingAPI/Blocks/Wire.cs index 10b880d..f46ca48 100644 --- a/TechbloxModdingAPI/Blocks/Wire.cs +++ b/TechbloxModdingAPI/Blocks/Wire.cs @@ -43,14 +43,12 @@ namespace TechbloxModdingAPI.Blocks /// The wire, where the end of the wire is the block port specified, or null if does not exist. public static Wire ConnectedToInputPort(SignalingBlock end, byte endPort) { - EGID port = signalEngine.MatchBlockInputToPort(end, endPort, out bool exists); - if (!exists) return null; - WireEntityStruct wire = signalEngine.MatchPortToWire(port, end.Id, out exists); - if (exists) - { - return new Wire(Block.New(wire.sourceBlockEGID), end, wire.sourcePortUsage, endPort); - } - return null; + var port = signalEngine.MatchBlockIOToPort(end, endPort, false); + if (!port) return null; + WireEntityStruct wire = signalEngine.MatchPortToWire(port, end.Id, out var exists); + return exists + ? new Wire(wire.sourceBlockEGID, end.Id, wire.sourcePortUsage, endPort, wire.ID, false) + : null; } /// @@ -62,18 +60,16 @@ namespace TechbloxModdingAPI.Blocks /// The wire, where the start of the wire is the block port specified, or null if does not exist. public static Wire ConnectedToOutputPort(SignalingBlock start, byte startPort) { - EGID port = signalEngine.MatchBlockOutputToPort(start, startPort, out bool exists); - if (!exists) return null; - WireEntityStruct wire = signalEngine.MatchPortToWire(port, start.Id, out exists); - if (exists) - { - return new Wire(start, Block.New(wire.destinationBlockEGID), startPort, wire.destinationPortUsage); - } - return null; + var port = signalEngine.MatchBlockIOToPort(start, startPort, true); + if (!port) return null; + WireEntityStruct wire = signalEngine.MatchPortToWire(port, start.Id, out var exists); + return exists + ? new Wire(start.Id, wire.destinationBlockEGID, startPort, wire.destinationPortUsage, wire.ID, false) + : null; } /// - /// Construct a wire object from an existing connection. + /// Construct a wire object froam n existing connection. /// /// Starting block ID. /// Ending block ID. @@ -84,40 +80,25 @@ namespace TechbloxModdingAPI.Blocks { startBlockEGID = start.Id; endBlockEGID = end.Id; + bool flipped = false; // find block ports - WireEntityStruct wire = signalEngine.MatchBlocksToWire(start.Id, end.Id, out bool exists, startPort, endPort); - if (exists) + EGID wire = signalEngine.MatchBlocksToWire(start.Id, end.Id, startPort, endPort); + if (wire == EGID.Empty) { - wireEGID = wire.ID; - endPortEGID = signalEngine.MatchBlockInputToPort(end, wire.destinationPortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockOutputToPort(start, wire.sourcePortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - inputToOutput = false; - endPort = wire.destinationPortUsage; - startPort = wire.sourcePortUsage; + // flip I/O around and try again + wire = signalEngine.MatchBlocksToWire(end.Id, start.Id, endPort, startPort); + flipped = true; + // NB: start and end are handled exactly as they're received as params. + // This makes wire traversal easier, but makes logic in this class a bit more complex + } + + if (wire != EGID.Empty) + { + Construct(start.Id, end.Id, startPort, endPort, wire, flipped); } else { - // flip I/O around and try again - wire = signalEngine.MatchBlocksToWire(end.Id, start.Id, out exists, endPort, startPort); - if (exists) - { - wireEGID = wire.ID; - endPortEGID = signalEngine.MatchBlockOutputToPort(end, wire.sourcePortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockInputToPort(start, wire.destinationPortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - inputToOutput = true; // end is actually the source - // NB: start and end are handled exactly as they're received as params. - // This makes wire traversal easier, but makes logic in this class a bit more complex - endPort = wire.sourcePortUsage; - startPort = wire.destinationPortUsage; - } - else - { - throw new WireInvalidException("Wire not found"); - } + throw new WireInvalidException("Wire not found"); } } @@ -131,25 +112,25 @@ namespace TechbloxModdingAPI.Blocks /// The wire ID. /// Whether the wire direction goes input -> output (true) or output -> input (false, preferred). public Wire(Block start, Block end, byte startPort, byte endPort, EGID wire, bool inputToOutput) + : this(start.Id, end.Id, startPort, endPort, wire, inputToOutput) { - this.startBlockEGID = start.Id; - this.endBlockEGID = end.Id; + } + + private Wire(EGID startBlock, EGID endBlock, byte startPort, byte endPort, EGID wire, bool inputToOutput) + { + Construct(startBlock, endBlock, startPort, endPort, wire, inputToOutput); + } + + private void Construct(EGID startBlock, EGID endBlock, byte startPort, byte endPort, EGID wire, bool inputToOutput) + { + this.startBlockEGID = startBlock; + this.endBlockEGID = endBlock; this.inputToOutput = inputToOutput; this.wireEGID = wire; - if (inputToOutput) - { - endPortEGID = signalEngine.MatchBlockOutputToPort(start, startPort, out bool exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockInputToPort(end, endPort, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - } - else - { - endPortEGID = signalEngine.MatchBlockInputToPort(end, endPort, out bool exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockOutputToPort(start, startPort, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - } + endPortEGID = signalEngine.MatchBlockIOToPort(startBlock, startPort, inputToOutput).Nullable()?.ID ?? EGID.Empty; + if (endPortEGID == EGID.Empty) throw new WireInvalidException("Wire end port not found"); + startPortEGID = signalEngine.MatchBlockIOToPort(endBlock, endPort, !inputToOutput).Nullable()?.ID ?? EGID.Empty; + if (startPortEGID == EGID.Empty) throw new WireInvalidException("Wire start port not found"); this.startPort = startPort; this.endPort = endPort; } @@ -160,31 +141,14 @@ namespace TechbloxModdingAPI.Blocks /// The wire ID. public Wire(EGID wireEgid) { - this.wireEGID = wireEgid; WireEntityStruct wire = signalEngine.GetWire(wireEGID); - this.startBlockEGID = wire.sourceBlockEGID; - this.endBlockEGID = wire.destinationBlockEGID; - this.inputToOutput = false; - endPortEGID = signalEngine.MatchBlockInputToPort(wire.destinationBlockEGID, wire.destinationPortUsage, out bool exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockOutputToPort(wire.sourceBlockEGID, wire.sourcePortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - this.endPort = wire.destinationPortUsage; - this.startPort = wire.sourcePortUsage; + Construct(wire.sourceBlockEGID, wire.destinationBlockEGID, wire.sourcePortUsage, wire.destinationPortUsage, + wireEgid, false); } - internal Wire(WireEntityStruct wire, SignalingBlock src, SignalingBlock dest) + private Wire(WireEntityStruct wire, SignalingBlock src, SignalingBlock dest) + : this(src, dest, wire.sourcePortUsage, wire.destinationPortUsage, wire.ID, false) { - this.wireEGID = wire.ID; - this.startBlockEGID = wire.sourceBlockEGID; - this.endBlockEGID = wire.destinationBlockEGID; - inputToOutput = false; - endPortEGID = signalEngine.MatchBlockInputToPort(dest, wire.destinationPortUsage, out bool exists); - if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockOutputToPort(src, wire.sourcePortUsage, out exists); - if (!exists) throw new WireInvalidException("Wire start port not found"); - this.endPort = wire.destinationPortUsage; - this.startPort = wire.sourcePortUsage; } /// @@ -202,16 +166,12 @@ namespace TechbloxModdingAPI.Blocks { get { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return 0f; - return cds.valueAsFloat; + return signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsFloat; } set { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return; - cds.valueAsFloat = value; + signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsFloat = value; } } @@ -222,16 +182,12 @@ namespace TechbloxModdingAPI.Blocks { get { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return ""; - return cds.valueAsEcsString; + return signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsEcsString; } set { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return; - cds.valueAsEcsString.Set(value); + signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsEcsString.Set(value); } } @@ -242,16 +198,12 @@ namespace TechbloxModdingAPI.Blocks { get { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return default; - return cds.valueAsEcsString; + return signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsEcsString; } set { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return; - cds.valueAsEcsString = value; + signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsEcsString = value; } } @@ -263,16 +215,12 @@ namespace TechbloxModdingAPI.Blocks { get { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return uint.MaxValue; - return cds.valueAsID; + return signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsID; } - + set { - ref ChannelDataStruct cds = ref signalEngine.GetChannelDataStruct(startPortEGID, out bool exists); - if (!exists) return; - cds.valueAsID = value; + signalEngine.GetChannelDataStruct(startPortEGID).Get().valueAsID = value; } } @@ -281,7 +229,7 @@ namespace TechbloxModdingAPI.Blocks /// public SignalingBlock Start { - get => new SignalingBlock(startBlockEGID); + get => (SignalingBlock)Block.New(startBlockEGID); } /// @@ -291,13 +239,21 @@ namespace TechbloxModdingAPI.Blocks { get => startPort; } + + /// + /// The display name of the start port. + /// + public string StartPortName + { + get => signalEngine.GetPort(startPortEGID).portNameLocalised; + } /// /// The block at the end of the wire. /// public SignalingBlock End { - get => new SignalingBlock(endBlockEGID); + get => (SignalingBlock)Block.New(endBlockEGID); } /// @@ -308,6 +264,14 @@ namespace TechbloxModdingAPI.Blocks get => endPort; } + /// + /// The display name of the end port. + /// + public string EndPortName + { + get => signalEngine.GetPort(endPortEGID).portNameLocalised; + } + /// /// Create a copy of the wire object where the direction of the wire is guaranteed to be from a block output to a block input. /// This is simply a different memory configuration and does not affect the in-game wire (which is always output -> input). @@ -329,15 +293,11 @@ namespace TechbloxModdingAPI.Blocks { inputToOutput = false; // swap inputs and outputs - EGID temp = endBlockEGID; - endBlockEGID = startBlockEGID; - startBlockEGID = temp; - temp = endPortEGID; + (endBlockEGID, startBlockEGID) = (startBlockEGID, endBlockEGID); + var tempPort = endPortEGID; endPortEGID = startPortEGID; - startPortEGID = temp; - byte tempPortNumber = endPort; - endPort = startPort; - startPort = tempPortNumber; + startPortEGID = tempPort; + (endPort, startPort) = (startPort, endPort); } } @@ -345,7 +305,7 @@ namespace TechbloxModdingAPI.Blocks { if (signalEngine.Exists(wireEGID)) { - return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(End.Id)}: {End.Id}, ({Start.Type}::{StartPort} aka {Start.PortName(StartPort, inputToOutput)}) -> ({End.Type}::{EndPort} aka {End.PortName(EndPort, !inputToOutput)})"; + return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(End.Id)}: {End.Id}, ({Start.Type}::{StartPort} aka {(StartPort != byte.MaxValue ? Start.PortName(StartPort, inputToOutput) : "")}) -> ({End.Type}::{EndPort} aka {(EndPort != byte.MaxValue ? End.PortName(EndPort, !inputToOutput) : "")})"; } return $"{nameof(Id)}: {Id}, Start{nameof(Start.Id)}: {Start.Id}, End{nameof(End.Id)}: {End.Id}, ({Start.Type}::{StartPort} -> {End.Type}::{EndPort})"; } diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 811056e..a98f67f 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -1,4 +1,5 @@ using System; +using Gamecraft.Wires; using RobocraftX.Character; using RobocraftX.Character.Movement; using Unity.Mathematics; @@ -460,7 +461,7 @@ namespace TechbloxModdingAPI { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); return egid != EGID.Empty && egid.groupID == WiresGUIExclusiveGroups.WireGroup - ? new Wire(egid) + ? new Wire(new EGID(egid.entityID, NamedExclusiveGroup.Group)) : null; } diff --git a/TechbloxModdingAPI/Utility/OptionalRef.cs b/TechbloxModdingAPI/Utility/OptionalRef.cs index 79f7175..c83e0da 100644 --- a/TechbloxModdingAPI/Utility/OptionalRef.cs +++ b/TechbloxModdingAPI/Utility/OptionalRef.cs @@ -65,6 +65,7 @@ namespace TechbloxModdingAPI.Utility } public bool Exists => state != State.Empty; + public T? Nullable() => this ? Get() : default; public static implicit operator T(OptionalRef opt) => opt.Get(); From 63295f82c97b7f5683a53401f6e9bf18f527e449 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 7 Sep 2021 23:15:03 +0200 Subject: [PATCH 91/98] Update to Techblox 2021.09.03.10.36 Removed old dependencies, including uREPL Added new block IDs Implemented basic command handling to support existing mod commands --- TechbloxModdingAPI/App/Game.cs | 8 ++- TechbloxModdingAPI/App/GameMenuEngine.cs | 7 ++- TechbloxModdingAPI/Block.cs | 2 +- TechbloxModdingAPI/Blocks/BlockIDs.cs | 15 ++++- .../Blocks/Engines/MovementEngine.cs | 2 +- .../Blocks/Engines/RemovalEngine.cs | 5 +- .../Blocks/Engines/RotationEngine.cs | 2 +- .../Blocks/Engines/SignalEngine.cs | 2 +- TechbloxModdingAPI/Blocks/Wire.cs | 12 ++-- .../Commands/CommandRegistrationHelper.cs | 20 +++---- TechbloxModdingAPI/Commands/CustomCommands.cs | 57 +++++++++++++++++++ .../Commands/ExistingCommands.cs | 14 ++--- TechbloxModdingAPI/Player.cs | 6 +- TechbloxModdingAPI/Players/PlayerEngine.cs | 6 +- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 48 ++++++++++++---- .../Tests/TechbloxModdingAPIPluginTest.cs | 5 +- TechbloxModdingAPI/Utility/Logging.cs | 6 +- 17 files changed, 157 insertions(+), 60 deletions(-) create mode 100644 TechbloxModdingAPI/Commands/CustomCommands.cs diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index e543270..18e62bd 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -232,7 +232,9 @@ namespace TechbloxModdingAPI.App else { // this likely breaks things - GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Name, value, GameMode.SaveGameDetails.WorkshopId); + GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, + GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value, + GameMode.SaveGameDetails.WorkshopId); } } } @@ -262,7 +264,9 @@ namespace TechbloxModdingAPI.App else { // this likely breaks things - GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Name, GameMode.SaveGameDetails.Folder, value); + GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, + GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, + GameMode.SaveGameDetails.Folder, value); } } } diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 4738507..86f622b 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -7,7 +7,7 @@ using RobocraftX.GUI; using RobocraftX.GUI.MyGamesScreen; using Svelto.ECS; using Svelto.ECS.Experimental; -using Svelto.DataStructures; +using Techblox.Services.Machines; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; @@ -82,9 +82,10 @@ namespace TechbloxModdingAPI.App public bool EnterGame(string gameName, string path, ulong workshopId = 0uL, bool autoEnterSim = false) { GameMode.CurrentMode = autoEnterSim ? RCXMode.Play : RCXMode.Build; - GameMode.SaveGameDetails = new SaveGameDetails(gameName, path, workshopId); + GameMode.SaveGameDetails = new SaveGameDetails(MachineStorageId.CreateNew().ToString(), + SaveGameMode.NewSave, gameName, path, workshopId); // the private FullGameCompositionRoot.SwitchToGame() method gets passed to menu items for this reason - AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, new object[0]); + AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, Array.Empty()); return true; } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 3ace802..e64fab7 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -417,7 +417,7 @@ namespace TechbloxModdingAPI if (e.ID != Id) return; Placed -= OnPlacedInit; //And we can reference it InitData = default; //Remove initializer as it's no longer valid - if the block gets removed it shouldn't be used again - if (copiedFrom != EGID.Empty) + if (copiedFrom != default) BlockCloneEngine.CopyBlockStats(copiedFrom, Id); } diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 3538104..415e7ec 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -150,6 +150,19 @@ namespace TechbloxModdingAPI.Blocks HatchbackWheel, HatchbackWheelArch, HatchbackArchSmallFlare, - HatchbackArchFlare + HatchbackArchFlare, + TruckWheel = 246, + HatchbackWheelWideProfile, + TruckWheelRigWithSteering = 249, + TruckWheelRigNoSteering, + HatchbackDriverSeat, + HatchbackPassengerSeat, + FormulaEngine, + TruckWheelDouble = 261, + TruckWheelArch, + TruckArchSingleFlare, + FormulaWheel = 270, + FormulaWheelRear, + FormulaSeat = 277 } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Engines/MovementEngine.cs b/TechbloxModdingAPI/Blocks/Engines/MovementEngine.cs index 48e3a23..9351623 100644 --- a/TechbloxModdingAPI/Blocks/Engines/MovementEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/MovementEngine.cs @@ -48,7 +48,7 @@ namespace TechbloxModdingAPI.Blocks.Engines // rendered position transStruct.position = vector; // collision position - if (phyStruct.ID != EGID.Empty) + if (phyStruct.ID != default) { //It exists FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Translation { diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index 4322d5e..4a0ea5b 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -3,6 +3,7 @@ using System.Reflection; using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Common; +using Svelto.Common; using Svelto.ECS; using Svelto.ECS.Native; @@ -22,8 +23,8 @@ namespace TechbloxModdingAPI.Blocks.Engines return false; var connections = entitiesDB.QueryEntity(target); var groups = entitiesDB.FindGroups(); - var connStructMapper = - entitiesDB.QueryNativeMappedEntities(groups); + using var connStructMapper = + entitiesDB.QueryNativeMappedEntities(groups, Allocator.Temp); for (int i = connections.connections.Count() - 1; i >= 0; i--) _connectionFactory.RemoveConnection(connections, i, connStructMapper); _entityFunctions.RemoveEntity(target); diff --git a/TechbloxModdingAPI/Blocks/Engines/RotationEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RotationEngine.cs index 12a8b56..b2be508 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RotationEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RotationEngine.cs @@ -50,7 +50,7 @@ namespace TechbloxModdingAPI.Blocks.Engines // rendered rotation transStruct.rotation = newRotation; // collision rotation - if (phyStruct.ID != EGID.Empty) + if (phyStruct.ID != default) { //It exists FullGameFields._physicsWorld.EntityManager.SetComponentData(phyStruct.uecsEntity, new Unity.Transforms.Rotation diff --git a/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs index ee2e42b..3c2e1cb 100644 --- a/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/SignalEngine.cs @@ -298,7 +298,7 @@ namespace TechbloxModdingAPI.Blocks.Engines } } - return EGID.Empty; + return default; } public OptionalRef GetChannelDataStruct(EGID portID) diff --git a/TechbloxModdingAPI/Blocks/Wire.cs b/TechbloxModdingAPI/Blocks/Wire.cs index f46ca48..4413b4f 100644 --- a/TechbloxModdingAPI/Blocks/Wire.cs +++ b/TechbloxModdingAPI/Blocks/Wire.cs @@ -83,7 +83,7 @@ namespace TechbloxModdingAPI.Blocks bool flipped = false; // find block ports EGID wire = signalEngine.MatchBlocksToWire(start.Id, end.Id, startPort, endPort); - if (wire == EGID.Empty) + if (wire == default) { // flip I/O around and try again wire = signalEngine.MatchBlocksToWire(end.Id, start.Id, endPort, startPort); @@ -92,7 +92,7 @@ namespace TechbloxModdingAPI.Blocks // This makes wire traversal easier, but makes logic in this class a bit more complex } - if (wire != EGID.Empty) + if (wire != default) { Construct(start.Id, end.Id, startPort, endPort, wire, flipped); } @@ -127,10 +127,10 @@ namespace TechbloxModdingAPI.Blocks this.endBlockEGID = endBlock; this.inputToOutput = inputToOutput; this.wireEGID = wire; - endPortEGID = signalEngine.MatchBlockIOToPort(startBlock, startPort, inputToOutput).Nullable()?.ID ?? EGID.Empty; - if (endPortEGID == EGID.Empty) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockIOToPort(endBlock, endPort, !inputToOutput).Nullable()?.ID ?? EGID.Empty; - if (startPortEGID == EGID.Empty) throw new WireInvalidException("Wire start port not found"); + endPortEGID = signalEngine.MatchBlockIOToPort(startBlock, startPort, inputToOutput).Nullable()?.ID ?? default; + if (endPortEGID == default) throw new WireInvalidException("Wire end port not found"); + startPortEGID = signalEngine.MatchBlockIOToPort(endBlock, endPort, !inputToOutput).Nullable()?.ID ?? default; + if (startPortEGID == default) throw new WireInvalidException("Wire start port not found"); this.startPort = startPort; this.endPort = endPort; } diff --git a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs index 18f3a25..e33b232 100644 --- a/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs +++ b/TechbloxModdingAPI/Commands/CommandRegistrationHelper.cs @@ -4,8 +4,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using uREPL; - namespace TechbloxModdingAPI.Commands { /// @@ -16,7 +14,7 @@ namespace TechbloxModdingAPI.Commands { public static void Register(string name, Action action, string desc, bool noConsole = false) { - RuntimeCommands.Register(name, action, desc); + CustomCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) @@ -36,42 +34,42 @@ namespace TechbloxModdingAPI.Commands public static void Register(string name, Action action, string desc, bool noConsole = false) { - RuntimeCommands.Register(name, action, desc); + CustomCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) { - RuntimeCommands.Register(name, action, desc); + CustomCommands.Register(name, action, desc); } public static void Register(string name, Action action, string desc, bool noConsole = false) { - RuntimeCommands.Register(name, action, desc); + CustomCommands.Register(name, action, desc); } public static void Unregister(string name, bool noConsole = false) { - RuntimeCommands.Unregister(name); + CustomCommands.Unregister(name); } public static void Call(string name) { - RuntimeCommands.Call(name); + CustomCommands.Call(name); } public static void Call(string name, Param0 param0) { - RuntimeCommands.Call(name, param0); + CustomCommands.Call(name, param0); } public static void Call(string name, Param0 param0, Param1 param1) { - RuntimeCommands.Call(name, param0, param1); + CustomCommands.Call(name, param0, param1); } public static void Call(string name, Param0 param0, Param1 param1, Param2 param2) { - RuntimeCommands.Call(name, param0, param1, param2); + CustomCommands.Call(name, param0, param1, param2); } } } diff --git a/TechbloxModdingAPI/Commands/CustomCommands.cs b/TechbloxModdingAPI/Commands/CustomCommands.cs new file mode 100644 index 0000000..0cacff8 --- /dev/null +++ b/TechbloxModdingAPI/Commands/CustomCommands.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.InteropServices; + +namespace TechbloxModdingAPI.Commands +{ + internal static class CustomCommands + { + public struct CommandData + { + public string Name; + public string Description; + public Delegate Action; + } + + private static Dictionary _commands = new Dictionary(); + public static void Register(string name, Delegate action, string desc) + { + _commands.Add(name, new CommandData + { + Name = name, + Description = desc, + Action = action + }); + } + + public static void Call(string name, params object[] args) + { + if (_commands.TryGetValue(name, out var command)) + { + var paramz = command.Action.Method.GetParameters(); + if (paramz.Length > args.Length) + throw new CommandParameterMissingException( + $"This command requires {paramz.Length} arguments, {args.Length} given"); + for (var index = 0; index < paramz.Length; index++) + { + args[index] = Convert.ChangeType(args[index], paramz[index].ParameterType); + } + + command.Action.DynamicInvoke(args); + } + else + throw new CommandNotFoundException($"Command {name} does not exist!"); + } + + public static void Unregister(string name) + { + _commands.Remove(name); + } + + public static bool Exists(string name) => _commands.ContainsKey(name); + + public static ReadOnlyDictionary GetAllCommandData() => + new ReadOnlyDictionary(_commands); + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Commands/ExistingCommands.cs b/TechbloxModdingAPI/Commands/ExistingCommands.cs index dfd3921..dd61cc8 100644 --- a/TechbloxModdingAPI/Commands/ExistingCommands.cs +++ b/TechbloxModdingAPI/Commands/ExistingCommands.cs @@ -1,39 +1,37 @@ using System.Linq; -using uREPL; - namespace TechbloxModdingAPI.Commands { public static class ExistingCommands { public static void Call(string commandName) { - RuntimeCommands.Call(commandName); + CustomCommands.Call(commandName); } public static void Call(string commandName, Arg0 arg0) { - RuntimeCommands.Call(commandName, arg0); + CustomCommands.Call(commandName, arg0); } public static void Call(string commandName, Arg0 arg0, Arg1 arg1) { - RuntimeCommands.Call(commandName, arg0, arg1); + CustomCommands.Call(commandName, arg0, arg1); } public static void Call(string commandName, Arg0 arg0, Arg1 arg1, Arg2 arg2) { - RuntimeCommands.Call(commandName, arg0, arg1, arg2); + CustomCommands.Call(commandName, arg0, arg1, arg2); } public static bool Exists(string commandName) { - return RuntimeCommands.HasRegistered(commandName); + return CustomCommands.Exists(commandName); } public static (string Name, string Description)[] GetCommandNamesAndDescriptions() { - return RuntimeCommands.table.Values.Select(command => (command.name, command.description)).ToArray(); + return CustomCommands.GetAllCommandData().Values.Select(command => (command.Name, command.Description)).ToArray(); } } } diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index a98f67f..67d36ca 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -433,7 +433,7 @@ namespace TechbloxModdingAPI public Block GetBlockLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); - return egid != EGID.Empty && egid.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP + return egid != default && egid.groupID != CommonExclusiveGroups.SIMULATION_BODIES_GROUP && egid.groupID != WiresGUIExclusiveGroups.WireGroup ? Block.New(egid) : null; @@ -447,7 +447,7 @@ namespace TechbloxModdingAPI public SimBody GetSimBodyLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); - return egid != EGID.Empty && egid.groupID == CommonExclusiveGroups.SIMULATION_BODIES_GROUP + return egid != default && egid.groupID == CommonExclusiveGroups.SIMULATION_BODIES_GROUP ? new SimBody(egid) : null; } @@ -460,7 +460,7 @@ namespace TechbloxModdingAPI public Wire GetWireLookedAt(float maxDistance = -1f) { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); - return egid != EGID.Empty && egid.groupID == WiresGUIExclusiveGroups.WireGroup + return egid != default && egid.groupID == WiresGUIExclusiveGroups.WireGroup ? new Wire(new EGID(egid.entityID, NamedExclusiveGroup.Group)) : null; } diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index aad3612..bb13308 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -167,16 +167,16 @@ namespace TechbloxModdingAPI.Players public EGID GetThingLookedAt(uint playerId, float maxDistance = -1f) { var opt = GetCameraStruct(playerId); - if (!opt) return EGID.Empty; + if (!opt) return default; PhysicCameraRayCastEntityStruct rayCast = opt; float distance = maxDistance < 0 ? GhostBlockUtils.GetBuildInteractionDistance(entitiesDB, rayCast, GhostBlockUtils.GhostCastMethod.GhostCastProportionalToBlockSize) : maxDistance; if (rayCast.hit && rayCast.distance <= distance) - return rayCast.hitEgid; //May be EGID.Empty + return rayCast.hitEgid; //May be EGID.Empty (default) - return EGID.Empty; + return default; } public unsafe Block[] GetSelectedBlocks(uint playerid) diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index 2aca43c..015c897 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -72,6 +72,10 @@ ..\ref\TechbloxPreview_Data\Managed\DDNA.dll ..\..\ref\TechbloxPreview_Data\Managed\DDNA.dll + + ..\ref\TechbloxPreview_Data\Managed\EasyButtons.dll + ..\..\ref\TechbloxPreview_Data\Managed\EasyButtons.dll + ..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll ..\..\ref\TechbloxPreview_Data\Managed\EOSSDK.dll @@ -524,10 +528,6 @@ ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Player.dll - - ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll - ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.dll - ..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.Rendering.Mock.dll @@ -660,10 +660,6 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll - - ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll - ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.dll - ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll @@ -680,6 +676,26 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Common.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Common.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.DOTS.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.DOTS.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.GPUI.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.GPUI.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Unity.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Unity.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SaveGamesConversion.dll @@ -688,6 +704,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Storage.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Storage.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.SwitchAnimation.dll @@ -820,6 +840,10 @@ ..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.Recorder.dll + + ..\ref\TechbloxPreview_Data\Managed\Unity.Rendering.Hybrid.dll + ..\..\ref\TechbloxPreview_Data\Managed\Unity.Rendering.Hybrid.dll + ..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll ..\..\ref\TechbloxPreview_Data\Managed\Unity.RenderPipelines.Core.Runtime.dll @@ -1140,14 +1164,14 @@ ..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll ..\..\ref\TechbloxPreview_Data\Managed\UnityEngine.XRModule.dll - - ..\ref\TechbloxPreview_Data\Managed\uREPL.dll - ..\..\ref\TechbloxPreview_Data\Managed\uREPL.dll - ..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll ..\..\ref\TechbloxPreview_Data\Managed\VisualProfiler.dll + + ..\ref\TechbloxPreview_Data\Managed\Whinarn.UnityMeshSimplifier.Runtime.dll + ..\..\ref\TechbloxPreview_Data\Managed\Whinarn.UnityMeshSimplifier.Runtime.dll + diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index eb9bda4..f6dba81 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -354,14 +354,15 @@ namespace TechbloxModdingAPI.Tests [HarmonyPatch] public class MinimumSpecsPatch { - public static bool Prefix() + public static bool Prefix(ref bool __result) { + __result = true; return false; } public static MethodInfo TargetMethod() { - return ((Action) MinimumSpecsCheck.CheckRequirementsMet).Method; + return ((Func) MinimumSpecsCheck.CheckRequirementsMet).Method; } } } diff --git a/TechbloxModdingAPI/Utility/Logging.cs b/TechbloxModdingAPI/Utility/Logging.cs index 0788ce6..0147eff 100644 --- a/TechbloxModdingAPI/Utility/Logging.cs +++ b/TechbloxModdingAPI/Utility/Logging.cs @@ -163,7 +163,7 @@ namespace TechbloxModdingAPI.Utility [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CommandLog(string msg) { - uREPL.Log.Output(msg); + Log(msg); } /// @@ -179,7 +179,7 @@ namespace TechbloxModdingAPI.Utility [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CommandLogError(string msg) { - uREPL.Log.Error(msg); + LogError(msg); } /// @@ -195,7 +195,7 @@ namespace TechbloxModdingAPI.Utility [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CommandLogWarning(string msg) { - uREPL.Log.Warn(msg); + LogWarning(msg); } } From aa947eaba1d3cafc716e59fe041ff8168080a533 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 2 Oct 2021 00:01:47 +0200 Subject: [PATCH 92/98] Update to Techblox 2021.09.27.15.17 Fixed block name print regex Made Game.WorkshopId obsolete as it's removed from the game Fixed removing blocks --- TechbloxModdingAPI/App/Game.cs | 21 +++---------------- TechbloxModdingAPI/App/GameMenuEngine.cs | 4 ++-- TechbloxModdingAPI/Blocks/BlockIDs.cs | 6 +++++- .../Blocks/Engines/RemovalEngine.cs | 4 ++-- .../Tests/TechbloxModdingAPIPluginTest.cs | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 18e62bd..5a9cccc 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -233,8 +233,7 @@ namespace TechbloxModdingAPI.App { // this likely breaks things GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, - GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value, - GameMode.SaveGameDetails.WorkshopId); + GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value); } } } @@ -244,30 +243,16 @@ namespace TechbloxModdingAPI.App /// In most cases this is invalid and returns 0, so this can be ignored. /// /// The workshop identifier. + [Obsolete] public ulong WorkshopId { get { - if (!VerifyMode()) return 0uL; - if (menuMode) return 0uL; // MyGames don't have workshop IDs - return GameMode.SaveGameDetails.WorkshopId; + return 0uL; // Not supported anymore } set { - VerifyMode(); - if (menuMode) - { - // MyGames don't have workshop IDs - // menuEngine.GetGameInfo(EGID).GameName.Set(value); - } - else - { - // this likely breaks things - GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, - GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, - GameMode.SaveGameDetails.Folder, value); - } } } diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 86f622b..9d8e448 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -79,11 +79,11 @@ namespace TechbloxModdingAPI.App return EnterGame(mgdes.GameName, mgdes.SavedGamePath); } - public bool EnterGame(string gameName, string path, ulong workshopId = 0uL, bool autoEnterSim = false) + public bool EnterGame(string gameName, string path, bool autoEnterSim = false) { GameMode.CurrentMode = autoEnterSim ? RCXMode.Play : RCXMode.Build; GameMode.SaveGameDetails = new SaveGameDetails(MachineStorageId.CreateNew().ToString(), - SaveGameMode.NewSave, gameName, path, workshopId); + SaveGameMode.NewSave, gameName, path); // the private FullGameCompositionRoot.SwitchToGame() method gets passed to menu items for this reason AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, Array.Empty()); return true; diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 415e7ec..09016aa 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -163,6 +163,10 @@ namespace TechbloxModdingAPI.Blocks TruckArchSingleFlare, FormulaWheel = 270, FormulaWheelRear, - FormulaSeat = 277 + FormulaSeat = 277, + MonsterTruckWheel = 285, + MonsterTruckEngine = 290, + MonsterTruckWheelRigNoSteering = 350, + MonsterTruckWheelRigWithSteering, } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index 4a0ea5b..7999443 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -23,8 +23,8 @@ namespace TechbloxModdingAPI.Blocks.Engines return false; var connections = entitiesDB.QueryEntity(target); var groups = entitiesDB.FindGroups(); - using var connStructMapper = - entitiesDB.QueryNativeMappedEntities(groups, Allocator.Temp); + using var connStructMapper = //The allocator needs to be persistent because that's what is used in the Dispose() method + entitiesDB.QueryNativeMappedEntities(groups, Allocator.Persistent); for (int i = connections.connections.Count() - 1; i >= 0; i--) _connectionFactory.RemoveConnection(connections, i, connStructMapper); _entityFunctions.RemoveEntity(target); diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index f6dba81..32ef656 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -268,7 +268,7 @@ namespace TechbloxModdingAPI.Tests string name = LocalizationService.Localize(data.CubeNameKey).Replace(" ", ""); foreach (var rkv in toReplace) { - name = Regex.Replace(name, "([^A-Za-z])" + rkv.Key + "([^A-Za-z])", "$1" + rkv.Value + "$2"); + name = Regex.Replace(name, rkv.Key + "([A-Z]|$)", rkv.Value + "$1"); } Console.WriteLine($"{name}{(currentKey != lastKey + 1 ? $" = {currentKey}" : "")},"); lastKey = currentKey; From 8a03277d842133328357d0565310daae956c44d7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 2 Oct 2021 03:50:20 +0200 Subject: [PATCH 93/98] Added block placement in sim and ECS object tracking ECS objects are stored in a newly created weak dictionary so that events can be called on them and possibly other things can be done with them --- TechbloxModdingAPI/Block.cs | 11 +- TechbloxModdingAPI/EcsObjectBase.cs | 39 ++++- .../Tests/TechbloxModdingAPIPluginTest.cs | 2 +- TechbloxModdingAPI/Utility/WeakDictionary.cs | 138 ++++++++++++++++++ 4 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 TechbloxModdingAPI/Utility/WeakDictionary.cs diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index e64fab7..44bbc92 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -45,10 +45,12 @@ namespace TechbloxModdingAPI /// The block's position - default block size is 0.2 /// Whether the block should be auto-wired (if functional) /// The player who placed the block + /// /// The placed block or null if failed - public static Block PlaceNew(BlockIDs block, float3 position, bool autoWire = false, Player player = null) + public static Block PlaceNew(BlockIDs block, float3 position, bool autoWire = false, Player player = null, + bool force = false) { - if (PlacementEngine.IsInGame && GameState.IsBuildMode()) + if (PlacementEngine.IsInGame && (GameState.IsBuildMode() || force)) { var initializer = PlacementEngine.PlaceBlock(block, position, player, autoWire); var egid = initializer.EGID; @@ -140,9 +142,10 @@ namespace TechbloxModdingAPI /// The block's position (a block is 0.2 wide in terms of position) /// Whether the block should be auto-wired (if functional) /// The player who placed the block - public Block(BlockIDs type, float3 position, bool autoWire = false, Player player = null) + /// Place even if not in build mode + public Block(BlockIDs type, float3 position, bool autoWire = false, Player player = null, bool force = false) { - if (!PlacementEngine.IsInGame || !GameState.IsBuildMode()) + if (!PlacementEngine.IsInGame || !GameState.IsBuildMode() && !force) throw new BlockException("Blocks can only be placed in build mode."); var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire); Id = initializer.EGID; diff --git a/TechbloxModdingAPI/EcsObjectBase.cs b/TechbloxModdingAPI/EcsObjectBase.cs index c96cf25..6a4db65 100644 --- a/TechbloxModdingAPI/EcsObjectBase.cs +++ b/TechbloxModdingAPI/EcsObjectBase.cs @@ -1,18 +1,45 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.Internal; -using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI { public abstract class EcsObjectBase { public abstract EGID Id { get; } //Abstract to support the 'place' Block constructor - + + private static readonly Dictionary> _instances = + new Dictionary>(); + + private static readonly WeakDictionary _noInstance = + new WeakDictionary(); + + internal static WeakDictionary GetInstances(Type type) + { + return _instances.TryGetValue(type, out var dict) ? dict : null; + } + + protected EcsObjectBase() + { + if (!_instances.TryGetValue(GetType(), out var dict)) + { + dict = new WeakDictionary(); + _instances.Add(GetType(), dict); + } + + // ReSharper disable once VirtualMemberCallInConstructor + // The ID should not depend on the constructor + dict.Add(Id, this); + } + + #region ECS initializer stuff + protected internal EcsInitData InitData; - + /// /// Holds information needed to construct a component initializer /// @@ -22,7 +49,7 @@ namespace TechbloxModdingAPI private EntityReference reference; public static implicit operator EcsInitData(EntityInitializer initializer) => new EcsInitData - {group = GetInitGroup(initializer), reference = initializer.reference}; + { group = GetInitGroup(initializer), reference = initializer.reference }; public EntityInitializer Initializer(EGID id) => new EntityInitializer(id, group, reference); public bool Valid => group != null; @@ -56,8 +83,10 @@ namespace TechbloxModdingAPI returnExpr = Expression.ConvertChecked(memberExpr, invokeMethod.ReturnType); var lambda = - Expression.Lambda(returnExpr, $"Access{paramType.Name}_{memberName}", new[] {objParam}); + Expression.Lambda(returnExpr, $"Access{paramType.Name}_{memberName}", new[] { objParam }); return lambda.Compile(); } + + #endregion } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 32ef656..dd1d2b3 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -91,7 +91,7 @@ namespace TechbloxModdingAPI.Tests .Description("Place a block of aluminium at the given coordinates") .Action((float x, float y, float z) => { - var block = Block.PlaceNew(BlockIDs.Cube, new float3(x, y, z)); + var block = Block.PlaceNew(BlockIDs.Cube, new float3(x, y, z), force: true); Logging.CommandLog("Block placed with type: " + block.Type); }) .Build(); diff --git a/TechbloxModdingAPI/Utility/WeakDictionary.cs b/TechbloxModdingAPI/Utility/WeakDictionary.cs new file mode 100644 index 0000000..287b044 --- /dev/null +++ b/TechbloxModdingAPI/Utility/WeakDictionary.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace TechbloxModdingAPI.Utility +{ + public class WeakDictionary : IDictionary where TValue : class + { + private Dictionary> _dictionary = new Dictionary>(); + + public IEnumerator> GetEnumerator() + { + using var enumerator = _dictionary.GetEnumerator(); + while (enumerator.MoveNext()) + { + if (enumerator.Current.Value.TryGetTarget(out var value)) + yield return new KeyValuePair(enumerator.Current.Key, value); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear() + { + _dictionary.Clear(); + } + + public bool Contains(KeyValuePair item) + { + return TryGetValue(item.Key, out var value) && item.Value == value; + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + throw new System.NotImplementedException(); + } + + public bool Remove(KeyValuePair item) + { + return Contains(item) && Remove(item.Key); + } + + public int Count => _dictionary.Count; + public bool IsReadOnly => false; + + public bool ContainsKey(TKey key) + { + return _dictionary.ContainsKey(key); + } + + public void Add(TKey key, TValue value) + { + _dictionary.Add(key, new WeakReference(value)); + } + + public bool Remove(TKey key) + { + return _dictionary.Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + value = null; + return _dictionary.TryGetValue(key, out var reference) && reference.TryGetTarget(out value); + } + + public TValue this[TKey key] + { + get => TryGetValue(key, out var value) + ? value + : throw new KeyNotFoundException($"Key {key} not found in WeakDictionary."); + set => _dictionary[key] = new WeakReference(value); + } + + public ICollection Keys => _dictionary.Keys; + public ICollection Values => new ValueCollection(this); + + public class ValueCollection : ICollection, IReadOnlyCollection + { + private WeakDictionary _dictionary; + internal ValueCollection(WeakDictionary dictionary) + { + _dictionary = dictionary; + } + + public IEnumerator GetEnumerator() + { + using var enumerator = _dictionary.GetEnumerator(); + while (enumerator.MoveNext()) + { + yield return enumerator.Current.Value; + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(TValue item) + { + throw new NotSupportedException("The value collection is read only."); + } + + public void Clear() + { + throw new NotSupportedException("The value collection is read only."); + } + + public bool Contains(TValue item) + { + return _dictionary.Any(kv => kv.Value == item); + } + + public void CopyTo(TValue[] array, int arrayIndex) + { + throw new NotImplementedException(); + } + + public bool Remove(TValue item) + { + throw new NotSupportedException("The value collection is read only."); + } + + public int Count => _dictionary.Count; + public bool IsReadOnly => true; + } + } +} \ No newline at end of file From 4bd636b8edf75c9032e1f1e4e3a51d6acf39ab83 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 8 Oct 2021 03:58:01 +0200 Subject: [PATCH 94/98] Add wrapped event handler, using the existing ECS object instances - Added a wrapper class that handles the individual wrapping of event handlers to individually handle exceptions - now it tracks the wrapped event handlers so it can unregister them properly - Fixed an exception that happened when two ECS objects were created with the same EGID - Added support for returning an existing ECS object if it exists instead of always creating a new one - Added a parameter to the entity query extension methods to override the group of the ECS object (could be used for the player properties) --- TechbloxModdingAPI/App/AppEngine.cs | 8 +-- TechbloxModdingAPI/App/Client.cs | 4 +- TechbloxModdingAPI/App/Game.cs | 8 +-- .../App/GameBuildSimEventEngine.cs | 8 +-- TechbloxModdingAPI/App/GameGameEngine.cs | 8 +-- TechbloxModdingAPI/Block.cs | 28 +++++++--- .../Blocks/Engines/BlockEventsEngine.cs | 12 ++--- TechbloxModdingAPI/Blocks/Wire.cs | 6 +-- TechbloxModdingAPI/EcsObjectBase.cs | 22 +++++++- TechbloxModdingAPI/Player.cs | 7 +-- TechbloxModdingAPI/SimBody.cs | 5 +- TechbloxModdingAPI/Utility/ExceptionUtil.cs | 43 --------------- .../Utility/ManagedApiExtensions.cs | 35 ++++++------ .../Utility/NativeApiExtensions.cs | 32 ++++++----- TechbloxModdingAPI/Utility/WrappedHandler.cs | 53 +++++++++++++++++++ 15 files changed, 164 insertions(+), 115 deletions(-) delete mode 100644 TechbloxModdingAPI/Utility/ExceptionUtil.cs create mode 100644 TechbloxModdingAPI/Utility/WrappedHandler.cs diff --git a/TechbloxModdingAPI/App/AppEngine.cs b/TechbloxModdingAPI/App/AppEngine.cs index 741c576..3f89f26 100644 --- a/TechbloxModdingAPI/App/AppEngine.cs +++ b/TechbloxModdingAPI/App/AppEngine.cs @@ -9,9 +9,9 @@ namespace TechbloxModdingAPI.App { public class AppEngine : IFactoryEngine { - public event EventHandler EnterMenu; + public WrappedHandler EnterMenu; - public event EventHandler ExitMenu; + public WrappedHandler ExitMenu; public IEntityFactory Factory { set; private get; } @@ -24,13 +24,13 @@ namespace TechbloxModdingAPI.App public void Dispose() { IsInMenu = false; - ExceptionUtil.InvokeEvent(ExitMenu, this, new MenuEventArgs { }); + ExitMenu.Invoke(this, new MenuEventArgs { }); } public void Ready() { IsInMenu = true; - ExceptionUtil.InvokeEvent(EnterMenu, this, new MenuEventArgs { }); + EnterMenu.Invoke(this, new MenuEventArgs { }); } // app functionality diff --git a/TechbloxModdingAPI/App/Client.cs b/TechbloxModdingAPI/App/Client.cs index 9d636eb..026b1a2 100644 --- a/TechbloxModdingAPI/App/Client.cs +++ b/TechbloxModdingAPI/App/Client.cs @@ -28,7 +28,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler EnterMenu { - add => appEngine.EnterMenu += ExceptionUtil.WrapHandler(value); + add => appEngine.EnterMenu += value; remove => appEngine.EnterMenu -= value; } @@ -37,7 +37,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler ExitMenu { - add => appEngine.ExitMenu += ExceptionUtil.WrapHandler(value); + add => appEngine.ExitMenu += value; remove => appEngine.ExitMenu -= value; } diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 5a9cccc..ad7ba33 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -93,7 +93,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler Simulate { - add => buildSimEventEngine.SimulationMode += ExceptionUtil.WrapHandler(value); + add => buildSimEventEngine.SimulationMode += value; remove => buildSimEventEngine.SimulationMode -= value; } @@ -103,7 +103,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler Edit { - add => buildSimEventEngine.BuildMode += ExceptionUtil.WrapHandler(value); + add => buildSimEventEngine.BuildMode += value; remove => buildSimEventEngine.BuildMode -= value; } @@ -112,7 +112,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler Enter { - add => gameEngine.EnterGame += ExceptionUtil.WrapHandler(value); + add => gameEngine.EnterGame += value; remove => gameEngine.EnterGame -= value; } @@ -122,7 +122,7 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler Exit { - add => gameEngine.ExitGame += ExceptionUtil.WrapHandler(value); + add => gameEngine.ExitGame += value; remove => gameEngine.ExitGame -= value; } diff --git a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs index f710d6f..d4697ff 100644 --- a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs +++ b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs @@ -11,9 +11,9 @@ namespace TechbloxModdingAPI.App { public class GameBuildSimEventEngine : IApiEngine, IUnorderedInitializeOnTimeRunningModeEntered, IUnorderedInitializeOnTimeStoppedModeEntered { - public event EventHandler SimulationMode; + public WrappedHandler SimulationMode; - public event EventHandler BuildMode; + public WrappedHandler BuildMode; public string Name => "TechbloxModdingAPIBuildSimEventGameEngine"; @@ -27,13 +27,13 @@ namespace TechbloxModdingAPI.App public JobHandle OnInitializeTimeRunningMode(JobHandle inputDeps) { - ExceptionUtil.InvokeEvent(SimulationMode, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + SimulationMode.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); return inputDeps; } public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps) { - ExceptionUtil.InvokeEvent(BuildMode, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + BuildMode.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); return inputDeps; } } diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index 8ae2aa3..a773d61 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -17,9 +17,9 @@ namespace TechbloxModdingAPI.App { public class GameGameEngine : IApiEngine { - public event EventHandler EnterGame; + public WrappedHandler EnterGame; - public event EventHandler ExitGame; + public WrappedHandler ExitGame; public string Name => "TechbloxModdingAPIGameInfoMenuEngine"; @@ -29,13 +29,13 @@ namespace TechbloxModdingAPI.App public void Dispose() { - ExceptionUtil.InvokeEvent(ExitGame, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + ExitGame.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); IsInGame = false; } public void Ready() { - ExceptionUtil.InvokeEvent(EnterGame, this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + EnterGame.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); IsInGame = true; } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 44bbc92..2cd995b 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -78,8 +78,8 @@ namespace TechbloxModdingAPI /// An event that fires each time a block is placed. /// public static event EventHandler Placed - { - add => BlockEventsEngine.Placed += ExceptionUtil.WrapHandler(value); + { //TODO: Rename and add instance version in 3.0 + add => BlockEventsEngine.Placed += value; remove => BlockEventsEngine.Placed -= value; } @@ -88,7 +88,7 @@ namespace TechbloxModdingAPI /// public static event EventHandler Removed { - add => BlockEventsEngine.Removed += ExceptionUtil.WrapHandler(value); + add => BlockEventsEngine.Removed += value; remove => BlockEventsEngine.Removed -= value; } @@ -105,13 +105,25 @@ namespace TechbloxModdingAPI {CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP, (id => new WheelRig(id), typeof(WheelRig))} }; + /// + /// Returns a correctly typed instance of this block. The instances are shared for a specific block. + /// If an instance is no longer referenced a new instance is returned. + /// + /// The EGID of the block + /// Whether the block is definitely a signaling block + /// internal static Block New(EGID egid, bool signaling = false) { - return GroupToConstructor.ContainsKey(egid.groupID) - ? GroupToConstructor[egid.groupID].Constructor(egid) - : signaling - ? new SignalingBlock(egid) - : new Block(egid); + if (egid == default) return null; + if (GroupToConstructor.ContainsKey(egid.groupID)) + { + var (constructor, type) = GroupToConstructor[egid.groupID]; + return GetInstance(egid, constructor, type); + } + + return signaling + ? GetInstance(egid, e => new SignalingBlock(e)) + : GetInstance(egid, e => new Block(e)); } public Block(EGID id) diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEventsEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEventsEngine.cs index 776f162..4da3f65 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEventsEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEventsEngine.cs @@ -10,8 +10,8 @@ namespace TechbloxModdingAPI.Blocks.Engines { public class BlockEventsEngine : IReactionaryEngine { - public event EventHandler Placed; - public event EventHandler Removed; + public WrappedHandler Placed; + public WrappedHandler Removed; public void Ready() { @@ -31,16 +31,14 @@ namespace TechbloxModdingAPI.Blocks.Engines { if (!(shouldAddRemove = !shouldAddRemove)) return; - ExceptionUtil.InvokeEvent(Placed, this, - new BlockPlacedRemovedEventArgs {ID = egid}); + Placed.Invoke(this, new BlockPlacedRemovedEventArgs {ID = egid}); } public void Remove(ref BlockTagEntityStruct entityComponent, EGID egid) { if (!(shouldAddRemove = !shouldAddRemove)) return; - ExceptionUtil.InvokeEvent(Removed, this, - new BlockPlacedRemovedEventArgs {ID = egid}); + Removed.Invoke(this, new BlockPlacedRemovedEventArgs {ID = egid}); } } @@ -49,6 +47,6 @@ namespace TechbloxModdingAPI.Blocks.Engines public EGID ID; private Block block; - public Block Block => block ?? (block = Block.New(ID)); + public Block Block => block ??= Block.New(ID); } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Wire.cs b/TechbloxModdingAPI/Blocks/Wire.cs index 4413b4f..0c66557 100644 --- a/TechbloxModdingAPI/Blocks/Wire.cs +++ b/TechbloxModdingAPI/Blocks/Wire.cs @@ -8,7 +8,7 @@ using TechbloxModdingAPI.Blocks.Engines; namespace TechbloxModdingAPI.Blocks { - public class Wire + public class Wire : EcsObjectBase { internal static SignalEngine signalEngine; @@ -154,7 +154,7 @@ namespace TechbloxModdingAPI.Blocks /// /// The wire's in-game id. /// - public EGID Id + public override EGID Id { get => wireEGID; } @@ -279,7 +279,7 @@ namespace TechbloxModdingAPI.Blocks /// A copy of the wire object. public Wire OutputToInputCopy() { - return new Wire(wireEGID); + return GetInstance(wireEGID, egid => new Wire(egid)); } /// diff --git a/TechbloxModdingAPI/EcsObjectBase.cs b/TechbloxModdingAPI/EcsObjectBase.cs index 6a4db65..f01561a 100644 --- a/TechbloxModdingAPI/EcsObjectBase.cs +++ b/TechbloxModdingAPI/EcsObjectBase.cs @@ -23,6 +23,22 @@ namespace TechbloxModdingAPI return _instances.TryGetValue(type, out var dict) ? dict : null; } + /// + /// Returns a cached instance if there's an actively used instance of the object already. + /// Objects still get garbage collected and then they will be removed from the cache. + /// + /// The EGID of the entity + /// The constructor to construct the object + /// The object type + /// + internal static T GetInstance(EGID egid, Func constructor, Type type = null) where T : EcsObjectBase + { + var instances = GetInstances(type ?? typeof(T)); + if (instances == null || !instances.TryGetValue(egid, out var instance)) + return constructor(egid); // It will be added by the constructor + return (T)instance; + } + protected EcsObjectBase() { if (!_instances.TryGetValue(GetType(), out var dict)) @@ -31,9 +47,11 @@ namespace TechbloxModdingAPI _instances.Add(GetType(), dict); } - // ReSharper disable once VirtualMemberCallInConstructor + // ReSharper disable VirtualMemberCallInConstructor // The ID should not depend on the constructor - dict.Add(Id, this); + if (!dict.ContainsKey(Id)) // Multiple instances may be created + dict.Add(Id, this); + // ReSharper enable VirtualMemberCallInConstructor } #region ECS initializer stuff diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 67d36ca..3dad9ea 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -21,7 +21,7 @@ namespace TechbloxModdingAPI /// An in-game player character. Any Leo you see is a player. /// public class Player : IEquatable, IEquatable - { + { //TODO: Inherit EcsObjectBase and make Id an EGID, useful for caching // static functionality private static PlayerEngine playerEngine = new PlayerEngine(); private static Player localPlayer; @@ -448,7 +448,7 @@ namespace TechbloxModdingAPI { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); return egid != default && egid.groupID == CommonExclusiveGroups.SIMULATION_BODIES_GROUP - ? new SimBody(egid) + ? EcsObjectBase.GetInstance(egid, e => new SimBody(e)) : null; } @@ -461,7 +461,8 @@ namespace TechbloxModdingAPI { var egid = playerEngine.GetThingLookedAt(Id, maxDistance); return egid != default && egid.groupID == WiresGUIExclusiveGroups.WireGroup - ? new Wire(new EGID(egid.entityID, NamedExclusiveGroup.Group)) + ? EcsObjectBase.GetInstance(new EGID(egid.entityID, NamedExclusiveGroup.Group), + e => new Wire(e)) : null; } diff --git a/TechbloxModdingAPI/SimBody.cs b/TechbloxModdingAPI/SimBody.cs index 55c6a9e..2f2f8b6 100644 --- a/TechbloxModdingAPI/SimBody.cs +++ b/TechbloxModdingAPI/SimBody.cs @@ -20,7 +20,10 @@ namespace TechbloxModdingAPI /// The cluster this chunk belongs to, or null if no cluster destruction manager present or the chunk doesn't exist. /// Get the SimBody from a Block if possible for good performance here. /// - public Cluster Cluster => cluster ?? (cluster = clusterId == uint.MaxValue ? Block.BlockEngine.GetCluster(Id.entityID) : new Cluster(clusterId)); + public Cluster Cluster => cluster ??= clusterId == uint.MaxValue // Return cluster or if it's null then set it + ? Block.BlockEngine.GetCluster(Id.entityID) // If we don't have a clusterId set then get it from the game + : GetInstance(new EGID(clusterId, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP), + egid => new Cluster(egid)); // Otherwise get the cluster from the ID private Cluster cluster; private readonly uint clusterId = uint.MaxValue; diff --git a/TechbloxModdingAPI/Utility/ExceptionUtil.cs b/TechbloxModdingAPI/Utility/ExceptionUtil.cs deleted file mode 100644 index d11508b..0000000 --- a/TechbloxModdingAPI/Utility/ExceptionUtil.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using TechbloxModdingAPI.Events; - -namespace TechbloxModdingAPI.Utility -{ - public static class ExceptionUtil - { - /// - /// Invokes an event with a null-check. - /// - /// The event to emit, can be null - /// Event sender - /// Event arguments - /// Type of the event arguments - public static void InvokeEvent(EventHandler handler, object sender, T args) - { - handler?.Invoke(sender, args); - } - - /// - /// Wraps the event handler in a try-catch block to avoid propagating exceptions. - /// - /// The handler to wrap (not null) - /// Type of the event arguments - /// The wrapped handler - public static EventHandler WrapHandler(EventHandler handler) - { - return (sender, e) => - { - try - { - handler(sender, e); - } - catch (Exception e1) - { - EventRuntimeException wrappedException = - new EventRuntimeException($"EventHandler with arg type {typeof(T).Name} threw an exception", e1); - Logging.LogWarning(wrappedException.ToString()); - } - }; - } - } -} \ No newline at end of file diff --git a/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs b/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs index 2616ab7..6829b2d 100644 --- a/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs +++ b/TechbloxModdingAPI/Utility/ManagedApiExtensions.cs @@ -1,6 +1,5 @@ using Svelto.ECS; using Svelto.ECS.Hybrid; -using TechbloxModdingAPI.Blocks; namespace TechbloxModdingAPI.Utility { @@ -23,32 +22,36 @@ namespace TechbloxModdingAPI.Utility } /// - /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// Attempts to query an entity and returns the result in an optional reference. /// - /// - /// - /// - /// - public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj) + /// The entities DB to query from + /// The ECS object to query + /// The group of the entity if the object can have multiple + /// The component to query + /// A reference to the component or a dummy value + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj, ExclusiveGroupStruct group = default) where T : struct, IEntityViewComponent { - var opt = QueryEntityOptional(entitiesDB, obj.Id); - return opt ? opt : new OptionalRef(obj, true); + EGID id = group == ExclusiveGroupStruct.Invalid ? obj.Id : new EGID(obj.Id.entityID, group); + var opt = QueryEntityOptional(entitiesDB, id); + return opt ? opt : new OptionalRef(obj, false); } /// /// Attempts to query an entity and returns the result or a dummy value that can be modified. /// - /// - /// - /// - /// - public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj) + /// The entities DB to query from + /// The ECS object to query + /// The group of the entity if the object can have multiple + /// The component to query + /// A reference to the component or a dummy value + public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj, ExclusiveGroupStruct group = default) where T : struct, IEntityViewComponent { - var opt = QueryEntityOptional(entitiesDB, obj.Id); + EGID id = group == ExclusiveGroupStruct.Invalid ? obj.Id : new EGID(obj.Id.entityID, group); + var opt = QueryEntityOptional(entitiesDB, id); if (opt) return ref opt.Get(); - if (obj.InitData.Valid) return ref obj.InitData.Initializer(obj.Id).GetOrCreate(); + if (obj.InitData.Valid) return ref obj.InitData.Initializer(id).GetOrCreate(); return ref opt.Get(); //Default value } } diff --git a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs index adc9ee5..8ccb251 100644 --- a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs +++ b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs @@ -21,32 +21,36 @@ namespace TechbloxModdingAPI.Utility } /// - /// Attempts to query an entity and returns the result or a dummy value that can be modified. + /// Attempts to query an entity and returns the result in an optional reference. /// - /// - /// - /// - /// - public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj) + /// The entities DB to query from + /// The ECS object to query + /// The group of the entity if the object can have multiple + /// The component to query + /// A reference to the component or a dummy value + public static OptionalRef QueryEntityOptional(this EntitiesDB entitiesDB, EcsObjectBase obj, ExclusiveGroupStruct group = default) where T : unmanaged, IEntityComponent { - var opt = QueryEntityOptional(entitiesDB, obj.Id); + EGID id = group == ExclusiveGroupStruct.Invalid ? obj.Id : new EGID(obj.Id.entityID, group); + var opt = QueryEntityOptional(entitiesDB, id); return opt ? opt : new OptionalRef(obj, true); } /// /// Attempts to query an entity and returns the result or a dummy value that can be modified. /// - /// - /// - /// - /// - public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj) + /// The entities DB to query from + /// The ECS object to query + /// The group of the entity if the object can have multiple + /// The component to query + /// A reference to the component or a dummy value + public static ref T QueryEntityOrDefault(this EntitiesDB entitiesDB, EcsObjectBase obj, ExclusiveGroupStruct group = default) where T : unmanaged, IEntityComponent { - var opt = QueryEntityOptional(entitiesDB, obj.Id); + EGID id = group == ExclusiveGroupStruct.Invalid ? obj.Id : new EGID(obj.Id.entityID, group); + var opt = QueryEntityOptional(entitiesDB, id); if (opt) return ref opt.Get(); - if (obj.InitData.Valid) return ref obj.InitData.Initializer(obj.Id).GetOrCreate(); + if (obj.InitData.Valid) return ref obj.InitData.Initializer(id).GetOrCreate(); return ref opt.Get(); //Default value } } diff --git a/TechbloxModdingAPI/Utility/WrappedHandler.cs b/TechbloxModdingAPI/Utility/WrappedHandler.cs new file mode 100644 index 0000000..57ff3ba --- /dev/null +++ b/TechbloxModdingAPI/Utility/WrappedHandler.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using TechbloxModdingAPI.Events; + +namespace TechbloxModdingAPI.Utility +{ + /// + /// Wraps the event handler in a try-catch block to avoid propagating exceptions. + /// + /// The event arguments type + public struct WrappedHandler + { + private EventHandler eventHandler; + + /// + /// Store wrappers so we can unregister them properly + /// + private static Dictionary, EventHandler> wrappers = + new Dictionary, EventHandler>(); + + public static WrappedHandler operator +(WrappedHandler original, EventHandler added) + { + EventHandler wrapped = (sender, e) => + { + try + { + added(sender, e); + } + catch (Exception e1) + { + EventRuntimeException wrappedException = + new EventRuntimeException($"EventHandler with arg type {typeof(T).Name} threw an exception", + e1); + Logging.LogWarning(wrappedException.ToString()); + } + }; + wrappers.Add(added, wrapped); + return new WrappedHandler { eventHandler = original.eventHandler + wrapped }; + } + + public static WrappedHandler operator -(WrappedHandler original, EventHandler removed) + { + if (!wrappers.TryGetValue(removed, out var wrapped)) return original; + wrappers.Remove(removed); + return new WrappedHandler { eventHandler = original.eventHandler - wrapped }; + } + + public void Invoke(object sender, T args) + { + eventHandler?.Invoke(sender, args); + } + } +} \ No newline at end of file From 6204b226d17a936906ca46eb2ecf4d22b81d56f7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 11 Oct 2021 01:26:35 +0200 Subject: [PATCH 95/98] Seat events, and everything needed to get there - Added support for seat enter and exit events and a test for them - Added support for entering and exiting seat from code - Changed the Id property of ECS objects to non-abstract, requiring it in the constructor, so that the Player class can inherit EcsObjectBase - Added a weird constructor to EcsObjectBase that allows running code to determine the object Id - Added interface for engines that receive entity functions - Exposed the entity submission scheduler and removed it from FullGameFields because it moved from there - Made the Game.Enter event only fire after the first entity submission so the game is fully initialized and the local player exists - Added all seat groups to the dictionary --- TechbloxModdingAPI/App/GameGameEngine.cs | 63 +++++++++---------- TechbloxModdingAPI/Block.cs | 28 +++++---- TechbloxModdingAPI/BlockGroup.cs | 5 +- TechbloxModdingAPI/Blocks/Wire.cs | 25 ++++---- TechbloxModdingAPI/Cluster.cs | 5 +- TechbloxModdingAPI/EcsObjectBase.cs | 26 +++++--- TechbloxModdingAPI/Engines/EnginePatches.cs | 3 + TechbloxModdingAPI/Engines/IFunEngine.cs | 9 +++ TechbloxModdingAPI/Player.Events.cs | 30 +++++++++ TechbloxModdingAPI/Player.cs | 59 +++++++++++------ TechbloxModdingAPI/Players/PlayerEngine.cs | 44 ++++++++++--- .../Players/PlayerEventsEngine.cs | 33 ++++++++++ TechbloxModdingAPI/Players/PlayerTests.cs | 35 ++++++++++- TechbloxModdingAPI/SimBody.cs | 5 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 8 +++ TechbloxModdingAPI/Utility/FullGameFields.cs | 8 --- .../Utility/GameEngineManager.cs | 11 ++-- .../Utility/MenuEngineManager.cs | 15 +++-- 18 files changed, 284 insertions(+), 128 deletions(-) create mode 100644 TechbloxModdingAPI/Engines/IFunEngine.cs create mode 100644 TechbloxModdingAPI/Player.Events.cs create mode 100644 TechbloxModdingAPI/Players/PlayerEventsEngine.cs diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index a773d61..9ec648e 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using RobocraftX.Common; using RobocraftX.Schedulers; @@ -11,6 +10,7 @@ using RobocraftX.Blocks; using RobocraftX.ScreenshotTaker; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Engines; +using TechbloxModdingAPI.Tasks; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.App @@ -35,6 +35,12 @@ namespace TechbloxModdingAPI.App public void Ready() { + EnteringGame().RunOn(Scheduler.leanRunner); + } + + private IEnumerator EnteringGame() + { + yield return new WaitForSubmissionEnumerator(GameLoadedEnginePatch.Scheduler).Continue(); EnterGame.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); IsInGame = true; } @@ -96,40 +102,29 @@ namespace TechbloxModdingAPI.App TimeRunningModeUtil.ToggleTimeRunningState(entitiesDB); } - public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid) - { - var allBlocks = entitiesDB.QueryEntities(); - List blockEGIDs = new List(); - if (filter == BlockIDs.Invalid) - { - foreach (var (blocks, _) in allBlocks) - { - var buffer = blocks.ToBuffer().buffer; - for (int i = 0; i < buffer.capacity; i++) - blockEGIDs.Add(buffer[i].ID); - } + public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid) + { + var allBlocks = entitiesDB.QueryEntities(); + List blockEGIDs = new List(); + foreach (var (blocks, _) in allBlocks) + { + var (buffer, count) = blocks.ToBuffer(); + for (int i = 0; i < count; i++) + { + uint dbid; + if (filter == BlockIDs.Invalid) + dbid = (uint)filter; + else + dbid = entitiesDB.QueryEntity(buffer[i].ID).DBID; + if (dbid == (ulong)filter) + blockEGIDs.Add(buffer[i].ID); + } + } - return blockEGIDs.ToArray(); - } - else - { - foreach (var (blocks, _) in allBlocks) - { - var array = blocks.ToBuffer().buffer; - for (var index = 0; index < array.capacity; index++) - { - var block = array[index]; - uint dbid = entitiesDB.QueryEntity(block.ID).DBID; - if (dbid == (ulong) filter) - blockEGIDs.Add(block.ID); - } - } + return blockEGIDs.ToArray(); + } - return blockEGIDs.ToArray(); - } - } - - public void EnableScreenshotTaker() + public void EnableScreenshotTaker() { ref var local = ref entitiesDB.QueryEntity(ScreenshotTakerEgids.ScreenshotTaker); if (local.enabled) diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 2cd995b..d94817f 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -99,12 +99,16 @@ namespace TechbloxModdingAPI {CommonExclusiveGroups.ENGINE_BLOCK_BUILD_GROUP, (id => new Engine(id), typeof(Engine))}, {CommonExclusiveGroups.LOGIC_BLOCK_GROUP, (id => new LogicGate(id), typeof(LogicGate))}, {CommonExclusiveGroups.PISTON_BLOCK_GROUP, (id => new Piston(id), typeof(Piston))}, - {SeatGroups.PASSENGER_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, - {SeatGroups.PILOTSEAT_BLOCK_BUILD_GROUP, (id => new Seat(id), typeof(Seat))}, {CommonExclusiveGroups.SERVO_BLOCK_GROUP, (id => new Servo(id), typeof(Servo))}, {CommonExclusiveGroups.WHEELRIG_BLOCK_BUILD_GROUP, (id => new WheelRig(id), typeof(WheelRig))} }; + static Block() + { + foreach (var group in SeatGroups.SEATS_BLOCK_GROUPS) // Adds driver and passenger seats, occupied and unoccupied + GroupToConstructor.Add(group, (id => new Seat(id), typeof(Seat))); + } + /// /// Returns a correctly typed instance of this block. The instances are shared for a specific block. /// If an instance is no longer referenced a new instance is returned. @@ -126,9 +130,8 @@ namespace TechbloxModdingAPI : GetInstance(egid, e => new Block(e)); } - public Block(EGID id) + public Block(EGID id) : base(id) { - Id = id; Type expectedType; if (GroupToConstructor.ContainsKey(id.groupID) && !GetType().IsAssignableFrom(expectedType = GroupToConstructor[id.groupID].Type)) @@ -156,17 +159,18 @@ namespace TechbloxModdingAPI /// The player who placed the block /// Place even if not in build mode public Block(BlockIDs type, float3 position, bool autoWire = false, Player player = null, bool force = false) + : base(block => + { + if (!PlacementEngine.IsInGame || !GameState.IsBuildMode() && !force) + throw new BlockException("Blocks can only be placed in build mode."); + var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire); + block.InitData = initializer; + Placed += ((Block)block).OnPlacedInit; + return initializer.EGID; + }) { - if (!PlacementEngine.IsInGame || !GameState.IsBuildMode() && !force) - throw new BlockException("Blocks can only be placed in build mode."); - var initializer = PlacementEngine.PlaceBlock(type, position, player, autoWire); - Id = initializer.EGID; - InitData = initializer; - Placed += OnPlacedInit; } - public override EGID Id { get; } - private EGID copiedFrom; /// diff --git a/TechbloxModdingAPI/BlockGroup.cs b/TechbloxModdingAPI/BlockGroup.cs index 39233e8..b8943b8 100644 --- a/TechbloxModdingAPI/BlockGroup.cs +++ b/TechbloxModdingAPI/BlockGroup.cs @@ -19,17 +19,16 @@ namespace TechbloxModdingAPI public class BlockGroup : EcsObjectBase, ICollection, IDisposable { internal static BlueprintEngine _engine = new BlueprintEngine(); - public override EGID Id { get; } private readonly Block sourceBlock; private readonly List blocks; private float3 position, rotation; internal bool PosAndRotCalculated; - internal BlockGroup(int id, Block block) + internal BlockGroup(int id, Block block) : base(new EGID((uint)id, + BlockGroupExclusiveGroups.BlockGroupEntityGroup)) { if (id == BlockGroupUtility.GROUP_UNASSIGNED) throw new BlockException("Cannot create a block group for blocks without a group!"); - Id = new EGID((uint) id, BlockGroupExclusiveGroups.BlockGroupEntityGroup); sourceBlock = block; blocks = new List(GetBlocks()); Block.Removed += OnBlockRemoved; diff --git a/TechbloxModdingAPI/Blocks/Wire.cs b/TechbloxModdingAPI/Blocks/Wire.cs index 0c66557..e59312d 100644 --- a/TechbloxModdingAPI/Blocks/Wire.cs +++ b/TechbloxModdingAPI/Blocks/Wire.cs @@ -76,10 +76,11 @@ namespace TechbloxModdingAPI.Blocks /// Starting port number, or guess if omitted. /// Ending port number, or guess if omitted. /// Guessing failed or wire does not exist. - public Wire(Block start, Block end, byte startPort = Byte.MaxValue, byte endPort = Byte.MaxValue) + public Wire(Block start, Block end, byte startPort = Byte.MaxValue, byte endPort = Byte.MaxValue) : base(ecs => { - startBlockEGID = start.Id; - endBlockEGID = end.Id; + var th = (Wire)ecs; + th.startBlockEGID = start.Id; + th.endBlockEGID = end.Id; bool flipped = false; // find block ports EGID wire = signalEngine.MatchBlocksToWire(start.Id, end.Id, startPort, endPort); @@ -94,12 +95,16 @@ namespace TechbloxModdingAPI.Blocks if (wire != default) { - Construct(start.Id, end.Id, startPort, endPort, wire, flipped); + th.Construct(start.Id, end.Id, startPort, endPort, wire, flipped); } else { throw new WireInvalidException("Wire not found"); } + + return th.wireEGID; + }) + { } /// @@ -116,7 +121,7 @@ namespace TechbloxModdingAPI.Blocks { } - private Wire(EGID startBlock, EGID endBlock, byte startPort, byte endPort, EGID wire, bool inputToOutput) + private Wire(EGID startBlock, EGID endBlock, byte startPort, byte endPort, EGID wire, bool inputToOutput) : base(wire) { Construct(startBlock, endBlock, startPort, endPort, wire, inputToOutput); } @@ -139,7 +144,7 @@ namespace TechbloxModdingAPI.Blocks /// Construct a wire object from an existing wire connection. /// /// The wire ID. - public Wire(EGID wireEgid) + public Wire(EGID wireEgid) : base(wireEgid) { WireEntityStruct wire = signalEngine.GetWire(wireEGID); Construct(wire.sourceBlockEGID, wire.destinationBlockEGID, wire.sourcePortUsage, wire.destinationPortUsage, @@ -151,14 +156,6 @@ namespace TechbloxModdingAPI.Blocks { } - /// - /// The wire's in-game id. - /// - public override EGID Id - { - get => wireEGID; - } - /// /// The wire's signal value, as a float. /// diff --git a/TechbloxModdingAPI/Cluster.cs b/TechbloxModdingAPI/Cluster.cs index 2544194..f88cec9 100644 --- a/TechbloxModdingAPI/Cluster.cs +++ b/TechbloxModdingAPI/Cluster.cs @@ -10,11 +10,8 @@ namespace TechbloxModdingAPI /// public class Cluster : EcsObjectBase { - public override EGID Id { get; } - - public Cluster(EGID id) + public Cluster(EGID id) : base(id) { - Id = id; } public Cluster(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP)) diff --git a/TechbloxModdingAPI/EcsObjectBase.cs b/TechbloxModdingAPI/EcsObjectBase.cs index f01561a..9698eaa 100644 --- a/TechbloxModdingAPI/EcsObjectBase.cs +++ b/TechbloxModdingAPI/EcsObjectBase.cs @@ -10,8 +10,8 @@ namespace TechbloxModdingAPI { public abstract class EcsObjectBase { - public abstract EGID Id { get; } //Abstract to support the 'place' Block constructor - + public EGID Id { get; } + private static readonly Dictionary> _instances = new Dictionary>(); @@ -39,7 +39,19 @@ namespace TechbloxModdingAPI return (T)instance; } - protected EcsObjectBase() + protected EcsObjectBase(EGID id) + { + if (!_instances.TryGetValue(GetType(), out var dict)) + { + dict = new WeakDictionary(); + _instances.Add(GetType(), dict); + } + if (!dict.ContainsKey(id)) // Multiple instances may be created + dict.Add(id, this); + Id = id; + } + + protected EcsObjectBase(Func initializer) { if (!_instances.TryGetValue(GetType(), out var dict)) { @@ -47,11 +59,9 @@ namespace TechbloxModdingAPI _instances.Add(GetType(), dict); } - // ReSharper disable VirtualMemberCallInConstructor - // The ID should not depend on the constructor - if (!dict.ContainsKey(Id)) // Multiple instances may be created - dict.Add(Id, this); - // ReSharper enable VirtualMemberCallInConstructor + var id = initializer(this); + if (!dict.ContainsKey(id)) // Multiple instances may be created + dict.Add(id, this); } #region ECS initializer stuff diff --git a/TechbloxModdingAPI/Engines/EnginePatches.cs b/TechbloxModdingAPI/Engines/EnginePatches.cs index f5774d9..8b6e6a5 100644 --- a/TechbloxModdingAPI/Engines/EnginePatches.cs +++ b/TechbloxModdingAPI/Engines/EnginePatches.cs @@ -5,6 +5,7 @@ using RobocraftX.CR.MainGame; using RobocraftX.FrontEnd; using RobocraftX.StateSync; using Svelto.ECS; +using Svelto.ECS.Schedulers; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Engines @@ -12,10 +13,12 @@ namespace TechbloxModdingAPI.Engines [HarmonyPatch] class GameLoadedEnginePatch { + public static EntitiesSubmissionScheduler Scheduler { get; private set; } public static void Postfix(StateSyncRegistrationHelper stateSyncReg) { // register all game engines, including deterministic GameEngineManager.RegisterEngines(stateSyncReg); + Scheduler = stateSyncReg.enginesRoot.scheduler; } public static MethodBase TargetMethod() diff --git a/TechbloxModdingAPI/Engines/IFunEngine.cs b/TechbloxModdingAPI/Engines/IFunEngine.cs new file mode 100644 index 0000000..d9ee7fe --- /dev/null +++ b/TechbloxModdingAPI/Engines/IFunEngine.cs @@ -0,0 +1,9 @@ +using Svelto.ECS; + +namespace TechbloxModdingAPI.Engines +{ + public interface IFunEngine : IApiEngine + { + public IEntityFunctions Functions { set; } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Player.Events.cs b/TechbloxModdingAPI/Player.Events.cs new file mode 100644 index 0000000..1a07c36 --- /dev/null +++ b/TechbloxModdingAPI/Player.Events.cs @@ -0,0 +1,30 @@ +using System; +using Svelto.ECS; +using TechbloxModdingAPI.Blocks; +using TechbloxModdingAPI.Utility; + +namespace TechbloxModdingAPI +{ + public partial class Player + { + internal WrappedHandler seatEntered; + public event EventHandler SeatEntered + { + add => seatEntered += value; + remove => seatEntered -= value; + } + + internal WrappedHandler seatExited; + public event EventHandler SeatExited + { + add => seatExited += value; + remove => seatExited -= value; + } + } + + public struct PlayerSeatEventArgs + { + public EGID SeatId; + public Seat Seat => (Seat)Block.New(SeatId); + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 3dad9ea..4f5607a 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -20,10 +20,11 @@ namespace TechbloxModdingAPI /// /// An in-game player character. Any Leo you see is a player. /// - public class Player : IEquatable, IEquatable - { //TODO: Inherit EcsObjectBase and make Id an EGID, useful for caching + public partial class Player : EcsObjectBase, IEquatable, IEquatable + { // static functionality private static PlayerEngine playerEngine = new PlayerEngine(); + private static PlayerEventsEngine playerEventsEngine = new PlayerEventsEngine(); private static Player localPlayer; /// @@ -79,7 +80,7 @@ namespace TechbloxModdingAPI /// Initializes a new instance of the class. /// /// The player's unique identifier. - public Player(uint id) + public Player(uint id) : base(new EGID(id, CharacterExclusiveGroups.OnFootGroup)) { this.Id = id; if (!Exists(id)) @@ -93,22 +94,31 @@ namespace TechbloxModdingAPI /// Initializes a new instance of the class. /// /// The player type. Chooses the first available player matching the criteria. - public Player(PlayerType player) + public Player(PlayerType player) : base(ecs => { - switch (player) - { - case PlayerType.Local: - this.Id = playerEngine.GetLocalPlayer(); - break; - case PlayerType.Remote: - this.Id = playerEngine.GetRemotePlayer(); - break; - } - if (this.Id == uint.MaxValue) - { - throw new PlayerNotFoundException($"No player of {player} type exists"); - } - this.Type = player; + uint id; + switch (player) + { + case PlayerType.Local: + id = playerEngine.GetLocalPlayer(); + break; + case PlayerType.Remote: + id = playerEngine.GetRemotePlayer(); + break; + default: + id = uint.MaxValue; + break; + } + + if (id == uint.MaxValue) + { + throw new PlayerNotFoundException($"No player of {player} type exists"); + } + + return new EGID(id, CharacterExclusiveGroups.OnFootGroup); + }) + { + this.Type = player; } // object fields & properties @@ -124,7 +134,7 @@ namespace TechbloxModdingAPI /// The player's unique identifier. /// /// The identifier. - public uint Id { get; } + public new uint Id { get; } /// /// The player's current position. @@ -424,6 +434,16 @@ namespace TechbloxModdingAPI } playerEngine.SetLocation(Id, location, exitSeat: exitSeat); } + + public void EnterSeat(Seat seat) + { + playerEngine.EnterSeat(Id, seat.Id); + } + + public void ExitSeat() + { + playerEngine.ExitSeat(Id); + } /// /// Returns the block the player is currently looking at in build mode. @@ -507,6 +527,7 @@ namespace TechbloxModdingAPI internal static void Init() { Utility.GameEngineManager.AddGameEngine(playerEngine); + Utility.GameEngineManager.AddGameEngine(playerEventsEngine); } } } diff --git a/TechbloxModdingAPI/Players/PlayerEngine.cs b/TechbloxModdingAPI/Players/PlayerEngine.cs index bb13308..0dc2298 100644 --- a/TechbloxModdingAPI/Players/PlayerEngine.cs +++ b/TechbloxModdingAPI/Players/PlayerEngine.cs @@ -1,4 +1,5 @@ -using System.Runtime.CompilerServices; +using System; +using System.Runtime.CompilerServices; using RobocraftX.Character; using RobocraftX.Character.Movement; @@ -8,10 +9,13 @@ using RobocraftX.CR.MachineEditing.BoxSelect; using RobocraftX.Physics; using RobocraftX.Blocks.Ghost; using Gamecraft.GUI.HUDFeedbackBlocks; +using RobocraftX.Blocks; +using RobocraftX.PilotSeat; using Svelto.ECS; using Techblox.Camera; using Unity.Mathematics; using Svelto.ECS.DataStructures; +using Svelto.ECS.EntityStructs; using Techblox.BuildingDrone; using TechbloxModdingAPI.Engines; @@ -19,7 +23,7 @@ using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Players { - internal class PlayerEngine : IApiEngine, IFactoryEngine + internal class PlayerEngine : IFunEngine { public string Name { get; } = "TechbloxModdingAPIPlayerGameEngine"; @@ -27,7 +31,7 @@ namespace TechbloxModdingAPI.Players public bool isRemovable => false; - public IEntityFactory Factory { set; private get; } + public IEntityFunctions Functions { get; set; } private bool isReady = false; @@ -101,9 +105,7 @@ namespace TechbloxModdingAPI.Players return false; if (group == CharacterExclusiveGroups.InPilotSeatGroup && exitSeat) { - EGID egid = new EGID(playerId, group); - entitiesDB.QueryEntity(egid).instantExit = true; - entitiesDB.PublishEntityChange(egid); + ExitSeat(playerId); } rbesOpt.Get().position = location; return true; @@ -183,12 +185,12 @@ namespace TechbloxModdingAPI.Players { if (!entitiesDB.Exists(playerid, BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup)) - return new Block[0]; + return Array.Empty(); var state = entitiesDB.QueryEntity(playerid, BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup); var blocks = entitiesDB.QueryEntity(playerid, BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup); - if (!state.active) return new Block[0]; + if (!state.active) return Array.Empty(); var pointer = (EGID*) blocks.selectedBlocks.ToPointer(); var ret = new Block[blocks.count]; for (int j = 0; j < blocks.count; j++) @@ -199,5 +201,31 @@ namespace TechbloxModdingAPI.Players return ret; } + + public void EnterSeat(uint playerId, EGID seatId) + { + PilotSeatGroupUtils.SwapTagTo(Functions, seatId); + var opt = GetCharacterStruct(playerId, out var group); + if (!opt) return; + ref CharacterPilotSeatEntityStruct charSeat = ref opt.Get(); + var charId = new EGID(playerId, group); + charSeat.pilotSeatEntity = entitiesDB.GetEntityReference(seatId); + charSeat.entryPositionOffset = + entitiesDB.QueryEntity(charId).position - + entitiesDB.QueryEntity(seatId).position; + ref var seat = ref entitiesDB.QueryEntity(seatId); + seat.occupyingCharacter = entitiesDB.GetEntityReference(charId); + charSeat.followCam = entitiesDB.QueryEntity(seatId).followCam; + Functions.SwapEntityGroup(charId, CharacterExclusiveGroups.InPilotSeatGroup); + } + + public void ExitSeat(uint playerId) + { + EGID egid = new EGID(playerId, CharacterExclusiveGroups.InPilotSeatGroup); + var opt = entitiesDB.QueryEntityOptional(egid); + if (!opt) return; + opt.Get().instantExit = true; + entitiesDB.PublishEntityChange(egid); + } } } diff --git a/TechbloxModdingAPI/Players/PlayerEventsEngine.cs b/TechbloxModdingAPI/Players/PlayerEventsEngine.cs new file mode 100644 index 0000000..2c80f24 --- /dev/null +++ b/TechbloxModdingAPI/Players/PlayerEventsEngine.cs @@ -0,0 +1,33 @@ +using RobocraftX.Character; +using RobocraftX.Character.Movement; +using Svelto.ECS; +using TechbloxModdingAPI.Engines; + +namespace TechbloxModdingAPI.Players +{ + public class PlayerEventsEngine : IApiEngine, IReactOnSwap + { + public void Ready() + { + } + + public EntitiesDB entitiesDB { get; set; } + public void Dispose() + { + } + + public string Name => "TechbloxModdingAPIPlayerEventsEngine"; + public bool isRemovable => false; + + public void MovedTo(ref CharacterPilotSeatEntityStruct entityComponent, ExclusiveGroupStruct previousGroup, EGID egid) + { + var seatId = entityComponent.pilotSeatEntity.ToEGID(entitiesDB); + var player = EcsObjectBase.GetInstance(new EGID(egid.entityID, CharacterExclusiveGroups.OnFootGroup), + e => new Player(e.entityID)); + if (previousGroup == CharacterExclusiveGroups.InPilotSeatGroup) + player.seatExited.Invoke(this, new PlayerSeatEventArgs { SeatId = seatId}); + else if (egid.groupID == CharacterExclusiveGroups.InPilotSeatGroup) + player.seatEntered.Invoke(this, new PlayerSeatEventArgs { SeatId = seatId }); + } + } +} \ No newline at end of file diff --git a/TechbloxModdingAPI/Players/PlayerTests.cs b/TechbloxModdingAPI/Players/PlayerTests.cs index 8086d96..c974518 100644 --- a/TechbloxModdingAPI/Players/PlayerTests.cs +++ b/TechbloxModdingAPI/Players/PlayerTests.cs @@ -1,8 +1,11 @@ -using System; +using System.Collections.Generic; +using Svelto.Tasks; +using Svelto.Tasks.Enumerators; using Unity.Mathematics; -using TechbloxModdingAPI; +using TechbloxModdingAPI.App; +using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Tests; namespace TechbloxModdingAPI.Players @@ -30,6 +33,34 @@ namespace TechbloxModdingAPI.Players if (!Assert.Errorless(() => { p.Position = float3.zero + 1; }, "Player.Position = origin+1 errored: ", "Player moved to origin+1.")) return; Assert.CloseTo(p.Position, float3.zero + 1, "Player is not close to origin+1 despite being teleported there.", "Player.Position is at origin+1."); } + + [APITestCase(TestType.Game)] + public static void SeatEventTestBuild() + { + Player.LocalPlayer.SeatEntered += Assert.CallsBack("SeatEntered"); + Player.LocalPlayer.SeatExited += Assert.CallsBack("SeatExited"); + Block.PlaceNew(BlockIDs.DriverSeat, -1f); + } + + [APITestCase(TestType.SimulationMode)] + public static IEnumerator SeatEventTestSim() + { + var seats = Game.CurrentGame().GetBlocksInGame(BlockIDs.DriverSeat); + if (seats.Length == 0) + { + Assert.Fail("No driver seat found!"); + yield break; + } + + if (seats[0] is Seat seat) + Assert.Errorless(() => Player.LocalPlayer.EnterSeat(seat), "Failed to enter seat.", + "Entered seat successfully."); + else + Assert.Fail("Found a seat that is not a seat!"); + yield return new WaitForSecondsEnumerator(1).Continue(); + Assert.Errorless(() => Player.LocalPlayer.ExitSeat(), "Failed to exit seat.", + "Exited seat successfully."); + } [APITestCase(TestType.Menu)] public static void InvalidStateTest() diff --git a/TechbloxModdingAPI/SimBody.cs b/TechbloxModdingAPI/SimBody.cs index 2f2f8b6..bb05005 100644 --- a/TechbloxModdingAPI/SimBody.cs +++ b/TechbloxModdingAPI/SimBody.cs @@ -14,8 +14,6 @@ namespace TechbloxModdingAPI /// public class SimBody : EcsObjectBase, IEquatable, IEquatable { - public override EGID Id { get; } - /// /// The cluster this chunk belongs to, or null if no cluster destruction manager present or the chunk doesn't exist. /// Get the SimBody from a Block if possible for good performance here. @@ -28,9 +26,8 @@ namespace TechbloxModdingAPI private Cluster cluster; private readonly uint clusterId = uint.MaxValue; - public SimBody(EGID id) + public SimBody(EGID id) : base(id) { - Id = id; } public SimBody(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_BODIES_GROUP)) diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index dd1d2b3..4c648eb 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -58,6 +58,14 @@ namespace TechbloxModdingAPI.Tests // debug/test handlers Client.EnterMenu += (sender, args) => throw new Exception("Test handler always throws an exception!"); + Client.EnterMenu += (sender, args) => Console.WriteLine("EnterMenu handler after erroring handler"); + Game.Enter += (s, a) => + { + Player.LocalPlayer.SeatEntered += (sender, args) => + Console.WriteLine($"Player {Player.LocalPlayer} entered seat {args.Seat}"); + Player.LocalPlayer.SeatExited += (sender, args) => + Console.WriteLine($"Player {Player.LocalPlayer} exited seat {args.Seat}"); + }; // debug/test commands if (Dependency.Hell("ExtraCommands")) diff --git a/TechbloxModdingAPI/Utility/FullGameFields.cs b/TechbloxModdingAPI/Utility/FullGameFields.cs index e27f501..0a4dd1d 100644 --- a/TechbloxModdingAPI/Utility/FullGameFields.cs +++ b/TechbloxModdingAPI/Utility/FullGameFields.cs @@ -72,14 +72,6 @@ namespace TechbloxModdingAPI.Utility } } - public static SimpleEntitiesSubmissionScheduler _mainGameSubmissionScheduler - { - get - { - return (SimpleEntitiesSubmissionScheduler)fgcr?.Field("_sub").Field("_mainGameSubmissionScheduler").GetValue(); - } - } - public static BuildPhysicsWorld _physicsWorldSystem { get diff --git a/TechbloxModdingAPI/Utility/GameEngineManager.cs b/TechbloxModdingAPI/Utility/GameEngineManager.cs index fc51861..16bf4e2 100644 --- a/TechbloxModdingAPI/Utility/GameEngineManager.cs +++ b/TechbloxModdingAPI/Utility/GameEngineManager.cs @@ -26,10 +26,10 @@ namespace TechbloxModdingAPI.Utility { Logging.MetaDebugLog($"Registering Game IApiEngine {engine.Name}"); _lastEngineRoot.AddEngine(engine); - if (typeof(IFactoryEngine).IsAssignableFrom(engine.GetType())) - { - ((IFactoryEngine)engine).Factory = _lastEngineRoot.GenerateEntityFactory(); - } + if (engine is IFactoryEngine factoryEngine) + factoryEngine.Factory = _lastEngineRoot.GenerateEntityFactory(); + if (engine is IFunEngine funEngine) + funEngine.Functions = _lastEngineRoot.GenerateEntityFunctions(); } } @@ -66,6 +66,7 @@ namespace TechbloxModdingAPI.Utility var enginesRoot = helper.enginesRoot; _lastEngineRoot = enginesRoot; IEntityFactory factory = enginesRoot.GenerateEntityFactory(); + IEntityFunctions functions = enginesRoot.GenerateEntityFunctions(); foreach (var key in _gameEngines.Keys) { Logging.MetaDebugLog($"Registering Game IApiEngine {_gameEngines[key].Name}"); @@ -75,6 +76,8 @@ namespace TechbloxModdingAPI.Utility enginesRoot.AddEngine(_gameEngines[key]); if (_gameEngines[key] is IFactoryEngine factEngine) factEngine.Factory = factory; + if (_gameEngines[key] is IFunEngine funEngine) + funEngine.Functions = functions; } } } diff --git a/TechbloxModdingAPI/Utility/MenuEngineManager.cs b/TechbloxModdingAPI/Utility/MenuEngineManager.cs index 3260563..4358ca8 100644 --- a/TechbloxModdingAPI/Utility/MenuEngineManager.cs +++ b/TechbloxModdingAPI/Utility/MenuEngineManager.cs @@ -26,10 +26,10 @@ namespace TechbloxModdingAPI.Utility { Logging.MetaDebugLog($"Registering Menu IApiEngine {engine.Name}"); _lastEngineRoot.AddEngine(engine); - if (typeof(IFactoryEngine).IsAssignableFrom(engine.GetType())) - { - ((IFactoryEngine)engine).Factory = _lastEngineRoot.GenerateEntityFactory(); - } + if (engine is IFactoryEngine factoryEngine) + factoryEngine.Factory = _lastEngineRoot.GenerateEntityFactory(); + if (engine is IFunEngine funEngine) + funEngine.Functions = _lastEngineRoot.GenerateEntityFunctions(); } } @@ -65,14 +65,13 @@ namespace TechbloxModdingAPI.Utility { _lastEngineRoot = enginesRoot; IEntityFactory factory = enginesRoot.GenerateEntityFactory(); + IEntityFunctions functions = enginesRoot.GenerateEntityFunctions(); foreach (var key in _menuEngines.Keys) { Logging.MetaDebugLog($"Registering Menu IApiEngine {_menuEngines[key].Name}"); enginesRoot.AddEngine(_menuEngines[key]); - if (_menuEngines[key] is IFactoryEngine factEngine) - { - factEngine.Factory = factory; - } + if (_menuEngines[key] is IFactoryEngine factEngine) factEngine.Factory = factory; + if(_menuEngines[key] is IFunEngine funEngine) funEngine.Functions = functions; } } } From 619a5003cf9e1b771ee857895dec68d80cd53cfa Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 4 Nov 2021 20:45:21 +0100 Subject: [PATCH 96/98] Update to Techblox 2021.11.03.15.56 Save game details were changed, they may not work properly Game mode change event no longer sends game data, needs fixing --- TechbloxModdingAPI/App/Game.cs | 22 +--- .../App/GameBuildSimEventEngine.cs | 4 +- TechbloxModdingAPI/App/GameGameEngine.cs | 10 +- TechbloxModdingAPI/App/GameMenuEngine.cs | 15 ++- TechbloxModdingAPI/Block.cs | 9 +- TechbloxModdingAPI/Blocks/BlockIDs.cs | 120 +++++++++++++++++- TechbloxModdingAPI/Blocks/BlockMaterial.cs | 17 ++- .../Blocks/Engines/BlueprintEngine.cs | 75 +++++++++++ TechbloxModdingAPI/Commands/CommandPatch.cs | 5 +- TechbloxModdingAPI/Player.cs | 2 +- TechbloxModdingAPI/TechbloxModdingAPI.csproj | 68 +++++++++- .../Tests/TechbloxModdingAPIPluginTest.cs | 16 ++- .../Utility/NativeApiExtensions.cs | 5 + 13 files changed, 321 insertions(+), 47 deletions(-) diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index ad7ba33..56854b6 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -165,7 +165,7 @@ namespace TechbloxModdingAPI.App { if (!VerifyMode()) return null; if (menuMode) return menuEngine.GetGameInfo(EGID).GameName; - return GameMode.SaveGameDetails.Name; + return gameEngine.GetGameData().saveName; } set @@ -174,11 +174,7 @@ namespace TechbloxModdingAPI.App if (menuMode) { menuEngine.SetGameName(EGID, value); - } - else - { - GameMode.SaveGameDetails.Name = value; - } + } // Save details are directly saved from user input or not changed at all when in game } } @@ -201,11 +197,7 @@ namespace TechbloxModdingAPI.App if (menuMode) { menuEngine.SetGameDescription(EGID, value); - } - else - { - // No description exists in-game - } + } // No description exists in-game } } @@ -219,7 +211,7 @@ namespace TechbloxModdingAPI.App { if (!VerifyMode()) return null; if (menuMode) return menuEngine.GetGameInfo(EGID).SavedGamePath; - return GameMode.SaveGameDetails.Folder; + return gameEngine.GetGameData().gameID; } set @@ -229,12 +221,6 @@ namespace TechbloxModdingAPI.App { menuEngine.GetGameInfo(EGID).SavedGamePath.Set(value); } - else - { - // this likely breaks things - GameMode.SaveGameDetails = new SaveGameDetails(GameMode.SaveGameDetails.Id, - GameMode.SaveGameDetails.SaveMode, GameMode.SaveGameDetails.Name, value); - } } } diff --git a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs index d4697ff..67e6769 100644 --- a/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs +++ b/TechbloxModdingAPI/App/GameBuildSimEventEngine.cs @@ -27,13 +27,13 @@ namespace TechbloxModdingAPI.App public JobHandle OnInitializeTimeRunningMode(JobHandle inputDeps) { - SimulationMode.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + SimulationMode.Invoke(this, new GameEventArgs { GameName = "", GamePath = "" }); // TODO return inputDeps; } public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps) { - BuildMode.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + BuildMode.Invoke(this, new GameEventArgs { GameName = "", GamePath = "" }); return inputDeps; } } diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index 9ec648e..f1ec8e7 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -8,6 +8,7 @@ using Svelto.Tasks; using Svelto.Tasks.Lean; using RobocraftX.Blocks; using RobocraftX.ScreenshotTaker; +using Techblox.GameSelection; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Tasks; @@ -29,7 +30,7 @@ namespace TechbloxModdingAPI.App public void Dispose() { - ExitGame.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + ExitGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); IsInGame = false; } @@ -41,7 +42,7 @@ namespace TechbloxModdingAPI.App private IEnumerator EnteringGame() { yield return new WaitForSubmissionEnumerator(GameLoadedEnginePatch.Scheduler).Continue(); - EnterGame.Invoke(this, new GameEventArgs { GameName = GameMode.SaveGameDetails.Name, GamePath = GameMode.SaveGameDetails.Folder }); + EnterGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); IsInGame = true; } @@ -132,5 +133,10 @@ namespace TechbloxModdingAPI.App local.enabled = true; entitiesDB.PublishEntityChange(ScreenshotTakerEgids.ScreenshotTaker); } + + public GameSelectionComponent GetGameData() + { + return entitiesDB.QueryEntity(GameSelectionConstants.GameSelectionEGID); + } } } diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 9d8e448..2f65016 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -7,9 +7,10 @@ using RobocraftX.GUI; using RobocraftX.GUI.MyGamesScreen; using Svelto.ECS; using Svelto.ECS.Experimental; -using Techblox.Services.Machines; +using Techblox.GameSelection; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; +using GameMode = RobocraftX.Common.GameMode; namespace TechbloxModdingAPI.App { @@ -82,10 +83,16 @@ namespace TechbloxModdingAPI.App public bool EnterGame(string gameName, string path, bool autoEnterSim = false) { GameMode.CurrentMode = autoEnterSim ? RCXMode.Play : RCXMode.Build; - GameMode.SaveGameDetails = new SaveGameDetails(MachineStorageId.CreateNew().ToString(), - SaveGameMode.NewSave, gameName, path); + var data = new GameSelectionData + { + gameMode = Techblox.GameSelection.GameMode.PlayGame, + gameType = GameType.MachineEditor, + saveName = gameName, + saveType = SaveType.ExistingSave, + gameID = path + }; // the private FullGameCompositionRoot.SwitchToGame() method gets passed to menu items for this reason - AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, Array.Empty()); + AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, new object[]{data}); return true; } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index d94817f..c2f8dd8 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -74,6 +74,11 @@ namespace TechbloxModdingAPI return egid.HasValue ? New(egid.Value) : null; } + /*public static Block CreateGhostBlock() + { + return BlockGroup._engine.BuildGhostChild(); + }*/ + /// /// An event that fires each time a block is placed. /// @@ -381,8 +386,8 @@ namespace TechbloxModdingAPI /// public bool Static { - get => BlockEngine.GetBlockInfo(this).staticIfUnconnected; - set => BlockEngine.GetBlockInfo(this).staticIfUnconnected = value; + get => false; + set { } } /// diff --git a/TechbloxModdingAPI/Blocks/BlockIDs.cs b/TechbloxModdingAPI/Blocks/BlockIDs.cs index 09016aa..e454c40 100644 --- a/TechbloxModdingAPI/Blocks/BlockIDs.cs +++ b/TechbloxModdingAPI/Blocks/BlockIDs.cs @@ -151,22 +151,128 @@ namespace TechbloxModdingAPI.Blocks HatchbackWheelArch, HatchbackArchSmallFlare, HatchbackArchFlare, - TruckWheel = 246, + CeilingStripLight, + CardboardBox, + BarrierRail, + BarrierRailEnd, + TruckWheel, HatchbackWheelWideProfile, TruckWheelRigWithSteering = 249, TruckWheelRigNoSteering, HatchbackDriverSeat, HatchbackPassengerSeat, FormulaEngine, - TruckWheelDouble = 261, + SmallGrass, + SmallGrassRoad, + GrassBridge, + SmallGrassTurn, + MediumGrassTurn, + LargeGrassTurn, + ExtraLargeGrassTurn, + TruckWheelDouble, TruckWheelArch, TruckArchSingleFlare, - FormulaWheel = 270, + WoodenDoorWithWindow, + TyreBarrierCorner, + TyreBarrierEdge, + TyreBarrierCenter, + AppleTree, + AppleForestTree, + FormulaWheel, FormulaWheelRear, - FormulaSeat = 277, - MonsterTruckWheel = 285, - MonsterTruckEngine = 290, - MonsterTruckWheelRigNoSteering = 350, + AppleSapling, + GrassHill, + GrassHillInnerCorner, + GrassHillOuterCorner, + GrassRoadHill, + FormulaSeat, + SmallDirt, + SmallDirtRoad, + SmallDirtTurn, + MediumDirtTurn, + LargeDirtTurn, + ExtraLargeDirtTurn, + SmallGrid, + MonsterTruckWheel, + SmallGrassGridStart, + SmallGrassRumbleStripRoad, + SmallGrassRumbleStripEndRoad, + SmallGrassStartLine, + MonsterTruckEngine, + DirtHill, + DirtHillInnerCorner, + DirtHillOuterCorner, + BuildingWindowEdge, + BuildingWindowCorner, + BuildingWindowStraight, + BuildingWindowTJunction, + BuildingWindowCross, + BuildingWindowEdgeSill, + BuildingWindowCornerSill, + BuildingWindowTJunctionSill, + Broadleaf, + ForestBroadleaf, + AzaleaBush, + AzaleaFlowers1, + AzaleaFlowers2, + TreeStump1, + TreeStump2, + FieldJuniper, + ForestJuniper, + JuniperSapling, + JuniperSeedling, + FieldRedMaple, + RedMapleForest1, + RedMapleForest2, + RedMapleSapling, + FieldWhiteSpruce, + ForestWhiteSpruce, + WhiteSpruceSapling, + GirderBase, + GirderStraight, + GirderDiagonal, + GirderCorner, + PostBase, + PostStraight, + PostLShape, + PostTJunction, + PostCross, + PostCorner, + PostDiagonal, + DirtRock1, + DirtRock2, + DirtRock3, + DirtRock4, + DirtRoadHill, + WoodenPalette, + ElderberryBush, + BarrelCactus, + KnapweedFlower, + MarigoldFlowers, + TrampledBushyBluestep, + RoughGrass, + DogRose, + WesternSwordFern, + BackyardGrass, + ThickGrass, + FireExtinguisher, + DirtLowRamp, + DirtTabletopRamp, + MonsterTruckWheelRigNoSteering, MonsterTruckWheelRigWithSteering, + MeadowCloudyDayAtmosphere, + BarrierRailDiagonal, + DirtHighRamp, + GrassRock1, + GrassRock2, + GrassRock3, + GrassRock4, + GreenFieldsSunnyDayAtmosphere, + RedMountainsDawnAtmosphere, + HighFantasySunriseAtmosphere, + /// + /// The grid block used by the world editor, named Small Grid like the other one + /// + SmallGridInWorldEditor } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockMaterial.cs b/TechbloxModdingAPI/Blocks/BlockMaterial.cs index 7093066..777845a 100644 --- a/TechbloxModdingAPI/Blocks/BlockMaterial.cs +++ b/TechbloxModdingAPI/Blocks/BlockMaterial.cs @@ -15,6 +15,21 @@ namespace TechbloxModdingAPI.Blocks SteelBodyworkRustedPaint, SteelBodyworkHeavyRust, WoodVarnishedDark, - Chrome + Chrome, + FenceChainLink, + ConcreteUnpainted, + Grid9x9, + CeramicTileFloor, + PlasticBumpy, + PlasticDustySmeared, + AluminiumGarageDoor, + SteelRigidScratched, + AluminiumBrushedTinted, + AluminiumSheetStained, + ConcretePaintedGrooves, + PlasticSpecklySatin, + SteelBodyworkPaintedChipped, + WoodPainted, + WoodRoughGrungy, } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs index 4bc5f5d..51b9f4c 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs @@ -5,15 +5,20 @@ using Gamecraft.Blocks.BlockGroups; using Gamecraft.GUI.Blueprints; using HarmonyLib; using RobocraftX.Blocks; +using RobocraftX.Blocks.Ghost; using RobocraftX.Common; using RobocraftX.CR.MachineEditing.BoxSelect; using RobocraftX.CR.MachineEditing.BoxSelect.ClipboardOperations; +using RobocraftX.Physics; +using RobocraftX.Rendering; +using RobocraftX.Rendering.GPUI; using Svelto.DataStructures; using Svelto.ECS; using Svelto.ECS.DataStructures; using Svelto.ECS.EntityStructs; using Svelto.ECS.Native; using Svelto.ECS.Serialization; +using Techblox.Blocks; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; using Unity.Collections; @@ -252,6 +257,76 @@ namespace TechbloxModdingAPI.Blocks.Engines { clipboardManager.DecrementRefCount(blueprintID); } + + + //GhostChildUtility.BuildGhostChild + public Block BuildGhostChild() + { + var sourceId = new EGID(Player.LocalPlayer.Id, GHOST_BLOCKS_ENABLED.Group); + var positionEntityStruct = entitiesDB.QueryEntity(sourceId); + var rotationEntityStruct = entitiesDB.QueryEntity(sourceId); + var scalingEntityStruct = entitiesDB.QueryEntity(sourceId); + var dbStruct = entitiesDB.QueryEntity(sourceId); + var colliderStruct = entitiesDB.QueryEntity(sourceId); + var colorStruct = entitiesDB.QueryEntity(sourceId); + uint ghostChildBlockId = CommonExclusiveGroups.GetNewGhostChildBlockID(); + var ghostEntityReference = GhostBlockUtils.GetGhostEntityReference(sourceId.entityID, entitiesDB); + var entityInitializer = BuildGhostBlueprintFactory.Build( + new EGID(ghostChildBlockId, BoxSelectExclusiveGroups.GhostChildEntitiesExclusiveGroup), /*dbStruct.DBID*/ (uint)BlockIDs.Cube); + entityInitializer.Init(dbStruct); + entityInitializer.Init(new GFXPrefabEntityStructGPUI( + PrefabsID.GetOrCreatePrefabID((ushort)entityInitializer.Get().prefabAssetID, + entitiesDB.QueryEntity(sourceId).materialId, 7, + FlippedBlockUtils.IsFlipped(in scalingEntityStruct.scale)), true)); + entityInitializer.Init(entitiesDB.QueryEntity(sourceId)); + entityInitializer.Init(new GhostParentEntityStruct + { + ghostBlockParentEntityReference = ghostEntityReference, + ownerMustSerializeOnAdd = false + }); + entityInitializer.Init(colorStruct); + entityInitializer.Init(colliderStruct); + entityInitializer.Init(new RigidBodyEntityStruct + { + position = positionEntityStruct.position, + rotation = rotationEntityStruct.rotation + }); + entityInitializer.Init(new ScalingEntityStruct + { + scale = scalingEntityStruct.scale + }); + entityInitializer.Init(new LocalTransformEntityStruct + { + position = positionEntityStruct.position, + rotation = rotationEntityStruct.rotation + }); + entityInitializer.Init(new RotationEntityStruct + { + rotation = rotationEntityStruct.rotation + }); + entityInitializer.Init(new PositionEntityStruct + { + position = positionEntityStruct.position + }); + entityInitializer.Init(new SkewComponent + { + skewMatrix = entitiesDB.QueryEntity(sourceId).skewMatrix + }); + entityInitializer.Init(new BlockPlacementInfoStruct + { + placedByBuildingDrone = entitiesDB + .QueryEntityOptional(new EGID(Player.LocalPlayer.Id, + BoxSelectExclusiveGroups.BoxSelectVolumeExclusiveGroup)).Get().buildingDroneReference + }); + entityInitializer.Init(new GridRotationStruct + { + position = float3.zero, + rotation = quaternion.identity + }); + var block = Block.New(entityInitializer.EGID); + block.InitData = entityInitializer; + return block; + } public string Name { get; } = "TechbloxModdingAPIBlueprintGameEngine"; public bool isRemovable { get; } = false; diff --git a/TechbloxModdingAPI/Commands/CommandPatch.cs b/TechbloxModdingAPI/Commands/CommandPatch.cs index 169891a..b928c1d 100644 --- a/TechbloxModdingAPI/Commands/CommandPatch.cs +++ b/TechbloxModdingAPI/Commands/CommandPatch.cs @@ -12,13 +12,12 @@ namespace TechbloxModdingAPI.Commands { /// /// Patch of RobocraftX.CR.MainGame.MainGameCompositionRoot.DeterministicCompose() - /// Initializes existing and custom commands + /// Initializes custom commands /// [HarmonyPatch] static class CommandPatch { - public static void Postfix(Action reloadGame, MultiplayerInitParameters multiplayerParameters, - StateSyncRegistrationHelper stateSyncReg) + public static void Postfix(StateSyncRegistrationHelper stateSyncReg) { /*CommandLineCompositionRoot.Compose(contextHolder, stateSyncReg.enginesRoot, reloadGame, multiplayerParameters, stateSyncReg); - uREPL C# compilation not supported anymore */ diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index 4f5607a..b3b0536 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -314,7 +314,7 @@ namespace TechbloxModdingAPI get { var optstruct = playerEngine.GetCharacterStruct(Id); - return optstruct ? (BlockIDs) optstruct.Get().SelectedDBPartID : BlockIDs.Invalid; + return optstruct ? (BlockIDs) optstruct.Get().selectedDBPartID : BlockIDs.Invalid; } } diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index 015c897..95927f8 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -116,10 +116,6 @@ ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll - - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll - ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LightBlock.dll - ..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll ..\..\ref\TechbloxPreview_Data\Managed\Gamecraft.Blocks.LogicBlock.dll @@ -480,6 +476,10 @@ ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGame.dll + + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGameMock.dll + ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainGameMock.dll + ..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll ..\..\ref\TechbloxPreview_Data\Managed\RobocraftX.MainSimulation.dll @@ -592,6 +592,10 @@ ..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll ..\..\ref\TechbloxPreview_Data\Managed\Svelto.Tasks.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.AtmosphereBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.AtmosphereBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.AutoForward.dll @@ -600,6 +604,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Backend.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Blocks.LightBlock.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Blocks.LightBlock.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Building.Rules.dll @@ -624,6 +632,22 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Environment.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.BuildingEnvironment.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.BuildingEnvironment.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.SimulationWorldEnvironment.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.EnvironmentBlocks.SimulationWorldEnvironment.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GameSelection.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GameSelection.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Building.dll @@ -640,6 +664,18 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.GamePortal.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.GamePortal.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.GamePortal.MockUps.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.GamePortal.MockUps.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Landscapes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Landscapes.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Hotbar.Materials.dll @@ -648,6 +684,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Common.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Landscapes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Landscapes.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Inventory.Materials.dll @@ -656,6 +696,14 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Login.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Mocks.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Mocks.dll + + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Mocks.DynamicListBuild.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Mocks.DynamicListBuild.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.MyGamesScreen.dll @@ -664,6 +712,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.Notifications.MockUps.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Landscapes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Landscapes.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.GUI.TabsBar.Materials.dll @@ -676,6 +728,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Pointer.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.ProceduralReflectionProbes.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.ProceduralReflectionProbes.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Common.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Rendering.Common.dll @@ -704,6 +760,10 @@ ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Eos.dll + + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.GameDetails.dll + ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.GameDetails.dll + ..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Storage.dll ..\..\ref\TechbloxPreview_Data\Managed\Techblox.Services.Storage.dll diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 4c648eb..1557f53 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -49,7 +49,7 @@ namespace TechbloxModdingAPI.Tests FileLog.Reset(); Harmony.DEBUG = true; Main.Init(); - Logging.MetaDebugLog($"Version group id {(uint)ApiExclusiveGroups.versionGroup}"); + Logging.MetaDebugLog($"Version group id {ApiExclusiveGroups.versionGroup}"); // disable background music Logging.MetaDebugLog("Audio Mixers: " + string.Join(",", AudioTools.GetMixers())); //AudioTools.SetVolume(0.0f, "Music"); // The game now sets this from settings again after this is called :( @@ -273,7 +273,9 @@ namespace TechbloxModdingAPI.Tests {"Neg", "Negative"}, {"Tetra", "Tetrahedron"}, {"RWedge", "Rounded Wedge"}, {"RTetra", "Rounded Tetrahedron"} }; - string name = LocalizationService.Localize(data.CubeNameKey).Replace(" ", ""); + string name = LocalizationService.Localize(data.CubeNameKey).Split(' ').Select(str => + str.Length > 0 ? char.ToUpper(str[0]) + str.Substring(1) : str).Aggregate((a, b) => a + b) + .Replace("-", ""); foreach (var rkv in toReplace) { name = Regex.Replace(name, rkv.Key + "([A-Z]|$)", rkv.Value + "$1"); @@ -284,8 +286,16 @@ namespace TechbloxModdingAPI.Tests };*/ /*Game.Enter += (sender, e) => { + ushort lastKey = ushort.MaxValue; Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues() - .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") + .OrderBy(kv => ushort.Parse(kv.Key)) + .Select(kv => + { + ushort currentKey = ushort.Parse(kv.Key); + string result = $"{((MaterialPropertiesData)kv.Value).Name}{(currentKey != lastKey + 1 ? $" = {kv.Key}" : "")},"; + lastKey = currentKey; + return result; + }) .Aggregate((a, b) => a + "\n" + b)); };*/ diff --git a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs index 8ccb251..ff5ca45 100644 --- a/TechbloxModdingAPI/Utility/NativeApiExtensions.cs +++ b/TechbloxModdingAPI/Utility/NativeApiExtensions.cs @@ -51,6 +51,11 @@ namespace TechbloxModdingAPI.Utility var opt = QueryEntityOptional(entitiesDB, id); if (opt) return ref opt.Get(); if (obj.InitData.Valid) return ref obj.InitData.Initializer(id).GetOrCreate(); + /*if (!obj.InitData.Valid) return ref opt.Get(); //Default value + var init = obj.InitData.Initializer(id); + // Do not create the component if missing, as that can trigger Add() listeners that, in some cases, may be + // invalid if (ab)using the classes in an unusual way - TODO: Check entity descriptor or something + if (init.Has()) return ref init.Get();*/ return ref opt.Get(); //Default value } } From f53d0b63e7bada44db801bf0f86b16dc12a855c7 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 6 Nov 2021 04:10:00 +0100 Subject: [PATCH 97/98] Fix issues uncovered by the tests - Fixed the game enter API - Fixed ToggleTimeMode() placing the player underground by using the full switch animation - Fixed the menu enter/exit events only firing once due to the game keeping the menu loaded - Moved everything from AppEngine to GameMenuEngine for consistency - Reimplemented the Block.Static property, it should actually work again too - Made the block property test only use blocks placed during the previous test, improved error handling and temporarily disabled testing the Material and the Flipped properties as they cause the game to crash --- TechbloxModdingAPI/App/AppEngine.cs | 18 ----- TechbloxModdingAPI/App/Client.cs | 23 +++--- TechbloxModdingAPI/App/Game.cs | 2 +- TechbloxModdingAPI/App/GameGameEngine.cs | 3 +- TechbloxModdingAPI/App/GameMenuEngine.cs | 81 ++++++++++++++++--- TechbloxModdingAPI/Block.cs | 4 +- TechbloxModdingAPI/Blocks/BlockTests.cs | 32 ++++++-- .../Tests/TechbloxModdingAPIPluginTest.cs | 4 +- 8 files changed, 115 insertions(+), 52 deletions(-) diff --git a/TechbloxModdingAPI/App/AppEngine.cs b/TechbloxModdingAPI/App/AppEngine.cs index 3f89f26..e4f5dcb 100644 --- a/TechbloxModdingAPI/App/AppEngine.cs +++ b/TechbloxModdingAPI/App/AppEngine.cs @@ -40,23 +40,5 @@ namespace TechbloxModdingAPI.App get; private set; } = false; - - public Game[] GetMyGames() - { - EntityCollection mgsevs = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.MyGames); - var mgsevsB = mgsevs.ToBuffer().buffer; - Game[] games = new Game[mgsevs.count]; - for (int i = 0; i < mgsevs.count; i++) - { - Utility.Logging.MetaDebugLog($"Found game named {mgsevsB[i].GameName}"); - games[i] = new Game(mgsevsB[i].ID); - } - return games; - } - } - - public struct MenuEventArgs - { - } } diff --git a/TechbloxModdingAPI/App/Client.cs b/TechbloxModdingAPI/App/Client.cs index 026b1a2..6fe4b4e 100644 --- a/TechbloxModdingAPI/App/Client.cs +++ b/TechbloxModdingAPI/App/Client.cs @@ -14,22 +14,19 @@ namespace TechbloxModdingAPI.App /// public class Client { - // extensible engine - protected static AppEngine appEngine = new AppEngine(); - - protected static Func ErrorHandlerInstanceGetter; + protected static Func ErrorHandlerInstanceGetter; protected static Action EnqueueError; protected static Action HandleErrorClosed; - /// + /// /// An event that fires whenever the main menu is loaded. /// public static event EventHandler EnterMenu { - add => appEngine.EnterMenu += value; - remove => appEngine.EnterMenu -= value; + add => Game.menuEngine.EnterMenu += value; + remove => Game.menuEngine.EnterMenu -= value; } /// @@ -37,8 +34,8 @@ namespace TechbloxModdingAPI.App /// public static event EventHandler ExitMenu { - add => appEngine.ExitMenu += value; - remove => appEngine.ExitMenu -= value; + add => Game.menuEngine.ExitMenu += value; + remove => Game.menuEngine.ExitMenu -= value; } /// @@ -69,8 +66,8 @@ namespace TechbloxModdingAPI.App { get { - if (!appEngine.IsInMenu) return new Game[0]; - return appEngine.GetMyGames(); + if (!Game.menuEngine.IsInMenu) return Array.Empty(); + return Game.menuEngine.GetMyGames(); } } @@ -80,7 +77,7 @@ namespace TechbloxModdingAPI.App /// true if in menu; false when loading or in a game. public bool InMenu { - get => appEngine.IsInMenu; + get => Game.menuEngine.IsInMenu; } /// @@ -119,8 +116,6 @@ namespace TechbloxModdingAPI.App /*HandleErrorClosed = (Action) AccessTools.Method("TechbloxModdingAPI.App.Client:GenHandlePopupClosed") .MakeGenericMethod(errorHandler) .Invoke(null, new object[0]);*/ - // register engines - MenuEngineManager.AddMenuEngine(appEngine); } // Creating delegates once is faster than reflection every time diff --git a/TechbloxModdingAPI/App/Game.cs b/TechbloxModdingAPI/App/Game.cs index 56854b6..7f52965 100644 --- a/TechbloxModdingAPI/App/Game.cs +++ b/TechbloxModdingAPI/App/Game.cs @@ -23,7 +23,7 @@ namespace TechbloxModdingAPI.App { // extensible engines protected static GameGameEngine gameEngine = new GameGameEngine(); - protected static GameMenuEngine menuEngine = new GameMenuEngine(); + protected internal static GameMenuEngine menuEngine = new GameMenuEngine(); protected static DebugInterfaceEngine debugOverlayEngine = new DebugInterfaceEngine(); protected static GameBuildSimEventEngine buildSimEventEngine = new GameBuildSimEventEngine(); diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index f1ec8e7..2c6e177 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -8,6 +8,7 @@ using Svelto.Tasks; using Svelto.Tasks.Lean; using RobocraftX.Blocks; using RobocraftX.ScreenshotTaker; +using Techblox.Environment.Transition; using Techblox.GameSelection; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Engines; @@ -100,7 +101,7 @@ namespace TechbloxModdingAPI.App { if (!entitiesDB.FoundInGroups()) throw new AppStateException("At least one block must exist in the world to enter simulation"); - TimeRunningModeUtil.ToggleTimeRunningState(entitiesDB); + SwitchAnimationUtil.Start(entitiesDB); } public EGID[] GetAllBlocksInGame(BlockIDs filter = BlockIDs.Invalid) diff --git a/TechbloxModdingAPI/App/GameMenuEngine.cs b/TechbloxModdingAPI/App/GameMenuEngine.cs index 2f65016..ac24e3a 100644 --- a/TechbloxModdingAPI/App/GameMenuEngine.cs +++ b/TechbloxModdingAPI/App/GameMenuEngine.cs @@ -1,8 +1,10 @@ using System; +using System.Reflection; using HarmonyLib; using RobocraftX; using RobocraftX.Common; +using RobocraftX.FrontEnd; using RobocraftX.GUI; using RobocraftX.GUI.MyGamesScreen; using Svelto.ECS; @@ -16,6 +18,9 @@ namespace TechbloxModdingAPI.App { public class GameMenuEngine : IFactoryEngine { + public WrappedHandler EnterMenu; + + public WrappedHandler ExitMenu; public IEntityFactory Factory { set; private get; } public string Name => "TechbloxModdingAPIGameInfoGameEngine"; @@ -24,23 +29,43 @@ namespace TechbloxModdingAPI.App public EntitiesDB entitiesDB { set; private get; } + public GameMenuEngine() + { + MenuEnteredEnginePatch.EnteredExitedMenu = () => + { + if (IsInMenu) + EnterMenu.Invoke(this, new MenuEventArgs { }); + else + ExitMenu.Invoke(this, new MenuEventArgs { }); + }; + } + public void Dispose() { - IsInMenu = false; } public void Ready() { - IsInMenu = true; + MenuEnteredEnginePatch.IsInMenu = true; // At first it uses ActivateMenu(), then GoToMenu() which is patched + MenuEnteredEnginePatch.EnteredExitedMenu(); } // game functionality - public bool IsInMenu + public bool IsInMenu => MenuEnteredEnginePatch.IsInMenu; + + public Game[] GetMyGames() { - get; - private set; - } = false; + EntityCollection mgsevs = entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.MyGames); + var mgsevsB = mgsevs.ToBuffer().buffer; + Game[] games = new Game[mgsevs.count]; + for (int i = 0; i < mgsevs.count; i++) + { + Utility.Logging.MetaDebugLog($"Found game named {mgsevsB[i].GameName}"); + games[i] = new Game(mgsevsB[i].ID); + } + return games; + } public bool CreateMyGame(EGID id, string path = "", uint thumbnailId = 0, string gameName = "", string creatorName = "", string description = "", long createdDate = 0L) { @@ -77,10 +102,10 @@ namespace TechbloxModdingAPI.App { if (!ExistsGameInfo(id)) return false; ref MyGameDataEntityStruct mgdes = ref GetGameInfo(id); - return EnterGame(mgdes.GameName, mgdes.SavedGamePath); + return EnterGame(mgdes.GameName, mgdes.FileId); } - public bool EnterGame(string gameName, string path, bool autoEnterSim = false) + public bool EnterGame(string gameName, string fileId, bool autoEnterSim = false) { GameMode.CurrentMode = autoEnterSim ? RCXMode.Play : RCXMode.Build; var data = new GameSelectionData @@ -89,7 +114,8 @@ namespace TechbloxModdingAPI.App gameType = GameType.MachineEditor, saveName = gameName, saveType = SaveType.ExistingSave, - gameID = path + gameID = "GAMEID_Road_Track", //TODO: Expose to the API + userContentID = fileId }; // the private FullGameCompositionRoot.SwitchToGame() method gets passed to menu items for this reason AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame").Invoke(FullGameFields.Instance, new object[]{data}); @@ -138,4 +164,41 @@ namespace TechbloxModdingAPI.App } internal class MyGameDataEntityDescriptor_DamnItFJWhyDidYouMakeThisInternal : GenericEntityDescriptor { } + + [HarmonyPatch] + static class MenuEnteredEnginePatch + { + internal static bool IsInMenu; + internal static Action EnteredExitedMenu; + public static void Postfix() + { + IsInMenu = true; + EnteredExitedMenu(); + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method(typeof(FullGameCompositionRoot), "GoToMenu"); + } + } + + [HarmonyPatch] + static class MenuExitedEnginePatch + { + public static void Prefix() + { + MenuEnteredEnginePatch.IsInMenu = false; + MenuEnteredEnginePatch.EnteredExitedMenu(); + } + + public static MethodBase TargetMethod() + { + return AccessTools.Method(typeof(FullGameCompositionRoot), "SwitchToGame"); + } + } + + public struct MenuEventArgs + { + + } } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index c2f8dd8..0d730c5 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -386,8 +386,8 @@ namespace TechbloxModdingAPI /// public bool Static { - get => false; - set { } + get => BlockEngine.GetBlockInfo(this).isStatic; + set => BlockEngine.GetBlockInfo(this).isStatic = value; } /// diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index f920631..198011c 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -46,16 +46,20 @@ namespace TechbloxModdingAPI.Blocks "Block ID enum matches the known block types."); } + private static Block[] blocks; // Store placed blocks as some blocks are already present as the workshop and the game save [APITestCase(TestType.EditMode)] public static void TestBlockIDs() { float3 pos = new float3(); - foreach (BlockIDs id in Enum.GetValues(typeof(BlockIDs))) + var values = Enum.GetValues(typeof(BlockIDs)); + blocks = new Block[values.Length - 1]; // Minus the invalid ID + int i = 0; + foreach (BlockIDs id in values) { if (id == BlockIDs.Invalid) continue; try { - Block.PlaceNew(id, pos); + blocks[i++] = Block.PlaceNew(id, pos); pos += 0.2f; } catch (Exception e) @@ -71,8 +75,9 @@ namespace TechbloxModdingAPI.Blocks [APITestCase(TestType.EditMode)] public static IEnumerator TestBlockProperties() { //Uses the result of the previous test case - var blocks = Game.CurrentGame().GetBlocksInGame(); yield return Yield.It; + if (blocks is null) + yield break; for (var index = 0; index < blocks.Length; index++) { if (index % 50 == 0) yield return Yield.It; //The material or flipped status can only be changed 130 times per submission @@ -80,6 +85,7 @@ namespace TechbloxModdingAPI.Blocks if (!block.Exists) continue; foreach (var property in block.GetType().GetProperties()) { + if (property.Name == "Material" || property.Name == "Flipped") continue; // TODO: Crashes in game //Includes specialised block properties if (property.SetMethod == null) continue; var testValues = new (Type, object, Predicate)[] @@ -121,8 +127,24 @@ namespace TechbloxModdingAPI.Blocks yield break; } - property.SetValue(block, valueToUse); - object got = property.GetValue(block); + try + { + property.SetValue(block, valueToUse); + } + catch (Exception e) + { + Assert.Fail($"Failed to set property {block.GetType().Name}.{property.Name} to {valueToUse}\n{e}"); + } + object got; + try + { + got = property.GetValue(block); + } + catch (Exception e) + { + Assert.Fail($"Failed to get property {block.GetType().Name}.{property.Name}\n{e}"); + continue; + } var attr = property.GetCustomAttribute(); if (!predicateToUse(got) && (attr == null || !Equals(attr.PossibleValue, got))) { diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 1557f53..75d0cc4 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -215,10 +215,10 @@ namespace TechbloxModdingAPI.Tests .Action(() => Player.LocalPlayer.GetBlockLookedAt().Static = true).Build(); Game.AddPersistentDebugInfo("InstalledMods", InstalledMods); - Block.Placed += (sender, args) => + /*Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Block); Block.Removed += (sender, args) => - Logging.MetaDebugLog("Removed block " + args.Block); + Logging.MetaDebugLog("Removed block " + args.Block);*/ } // dependency test From e3a7961be47a6bd222cb5c69a91d1a49b3689139 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 25 Nov 2021 01:48:06 +0100 Subject: [PATCH 98/98] Made the Game.Enter event only fire once loading finishes and fixed player building mode Also attempted to fix material changing and updating the rendered block --- TechbloxModdingAPI/App/GameGameEngine.cs | 31 ++++++++------ TechbloxModdingAPI/Block.cs | 5 ++- TechbloxModdingAPI/Blocks/BlockTests.cs | 8 ++++ .../Blocks/Engines/BlockEngine.cs | 41 ++++++++++++++++--- TechbloxModdingAPI/Player.cs | 9 +++- .../Players/PlayerBuildingMode.cs | 3 +- 6 files changed, 76 insertions(+), 21 deletions(-) diff --git a/TechbloxModdingAPI/App/GameGameEngine.cs b/TechbloxModdingAPI/App/GameGameEngine.cs index 2c6e177..2bed201 100644 --- a/TechbloxModdingAPI/App/GameGameEngine.cs +++ b/TechbloxModdingAPI/App/GameGameEngine.cs @@ -7,17 +7,17 @@ using Svelto.ECS; using Svelto.Tasks; using Svelto.Tasks.Lean; using RobocraftX.Blocks; +using RobocraftX.Common.Loading; using RobocraftX.ScreenshotTaker; using Techblox.Environment.Transition; using Techblox.GameSelection; using TechbloxModdingAPI.Blocks; using TechbloxModdingAPI.Engines; -using TechbloxModdingAPI.Tasks; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.App { - public class GameGameEngine : IApiEngine + public class GameGameEngine : IApiEngine, IReactOnAddAndRemove { public WrappedHandler EnterGame; @@ -26,9 +26,11 @@ namespace TechbloxModdingAPI.App public string Name => "TechbloxModdingAPIGameInfoMenuEngine"; public bool isRemovable => false; - + public EntitiesDB entitiesDB { set; private get; } + private bool enteredGame; + public void Dispose() { ExitGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); @@ -37,14 +39,7 @@ namespace TechbloxModdingAPI.App public void Ready() { - EnteringGame().RunOn(Scheduler.leanRunner); - } - - private IEnumerator EnteringGame() - { - yield return new WaitForSubmissionEnumerator(GameLoadedEnginePatch.Scheduler).Continue(); - EnterGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); - IsInGame = true; + enteredGame = true; } // game functionality @@ -139,5 +134,17 @@ namespace TechbloxModdingAPI.App { return entitiesDB.QueryEntity(GameSelectionConstants.GameSelectionEGID); } - } + + public void Add(ref LoadingActionEntityStruct entityComponent, EGID egid) + { + } + + public void Remove(ref LoadingActionEntityStruct entityComponent, EGID egid) + { // Finished loading + if (!enteredGame) return; + EnterGame.Invoke(this, new GameEventArgs { GameName = GetGameData().saveName, GamePath = GetGameData().gameID }); + IsInGame = true; + enteredGame = false; + } + } } diff --git a/TechbloxModdingAPI/Block.cs b/TechbloxModdingAPI/Block.cs index 0d730c5..ec1147a 100644 --- a/TechbloxModdingAPI/Block.cs +++ b/TechbloxModdingAPI/Block.cs @@ -327,7 +327,10 @@ namespace TechbloxModdingAPI : throw new BlockTypeException("Unknown block type! Could not set default material."); if (!FullGameFields._dataDb.ContainsKey(val)) throw new BlockException($"Block material {value} does not exist!"); - BlockEngine.GetBlockInfo(this).materialId = val; + ref var comp = ref BlockEngine.GetBlockInfo(this); + if (comp.materialId == val) + return; + comp.materialId = val; BlockEngine.UpdatePrefab(this, val, Flipped); //The default causes the screen to go black } } diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index 198011c..4bc29db 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -5,7 +5,9 @@ using System.Reflection; using DataLoader; using Svelto.Tasks; +using Svelto.Tasks.Enumerators; using Unity.Mathematics; +using UnityEngine; using TechbloxModdingAPI.App; using TechbloxModdingAPI.Tests; @@ -86,6 +88,12 @@ namespace TechbloxModdingAPI.Blocks foreach (var property in block.GetType().GetProperties()) { if (property.Name == "Material" || property.Name == "Flipped") continue; // TODO: Crashes in game + if (property.Name == "Material" || property.Name == "Flipped") + { + Console.WriteLine("Block type: "+block.Type); + Console.WriteLine("Will set " + property.Name); + yield return new WaitForSecondsEnumerator(1).Continue(); + } //Includes specialised block properties if (property.SetMethod == null) continue; var testValues = new (Type, object, Predicate)[] diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs index 26be582..c7c84cf 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; using System.Linq; +using System.Reflection; +using HarmonyLib; using Gamecraft.ColourPalette; using Gamecraft.TimeRunning; @@ -11,8 +13,8 @@ using RobocraftX.Rendering; using RobocraftX.Rendering.GPUI; using Svelto.DataStructures; using Svelto.ECS; -using Svelto.ECS.EntityStructs; using Svelto.ECS.Hybrid; +using Techblox.BuildingDrone; using Unity.Mathematics; using TechbloxModdingAPI.Engines; @@ -92,10 +94,7 @@ namespace TechbloxModdingAPI.Blocks.Engines public void UpdateDisplayedBlock(EGID id) { if (!BlockExists(id)) return; - var pos = entitiesDB.QueryEntity(id); - var rot = entitiesDB.QueryEntity(id); - var scale = entitiesDB.QueryEntity(id); - entitiesDB.QueryEntity(id).matrix = float4x4.TRS(pos.position, rot.rotation, scale.scale); + RenderingPatch.UpdateBlocks(); } internal void UpdatePrefab(Block block, byte material, bool flipped) @@ -115,7 +114,17 @@ namespace TechbloxModdingAPI.Blocks.Engines PrefabsID.GetOrCreatePrefabID((ushort) prefabAssetID, material, 1, flipped); entitiesDB.QueryEntityOrDefault(block).prefabID = prefabId; if (block.Exists) + { + entitiesDB.PublishEntityChange(block.Id); entitiesDB.PublishEntityChange(block.Id); + + ref BuildingActionComponent local = + ref entitiesDB.QueryEntity(BuildingDroneUtility + .GetLocalBuildingDrone(entitiesDB).ToEGID(entitiesDB)); + local.buildAction = BuildAction.ChangeMaterial; + local.targetPosition = block.Position; + this.entitiesDB.PublishEntityChange(local.ID); + } //Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData } @@ -239,5 +248,27 @@ namespace TechbloxModdingAPI.Blocks.Engines return entitiesDB; } #endif + + [HarmonyPatch] + public static class RenderingPatch + { + private static ComputeRenderingEntitiesMatricesEngine Engine; + + public static void Postfix(ComputeRenderingEntitiesMatricesEngine __instance) + { + Engine = __instance; + } + + public static MethodBase TargetMethod() + { + return typeof(ComputeRenderingEntitiesMatricesEngine).GetConstructors()[0]; + } + + public static void UpdateBlocks() + { + var data = new RenderingDataStruct(); + Engine.Add(ref data, new EGID(0, CommonExclusiveGroups.BUTTON_BLOCK_GROUP)); + } + } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Player.cs b/TechbloxModdingAPI/Player.cs index b3b0536..2ce88f1 100644 --- a/TechbloxModdingAPI/Player.cs +++ b/TechbloxModdingAPI/Player.cs @@ -360,8 +360,8 @@ namespace TechbloxModdingAPI /// /// The player's mode in time stopped mode, determining what they place. /// - public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine - .GetCharacterStruct(Id).Get().timeStoppedContext; + public PlayerBuildingMode BuildingMode => (PlayerBuildingMode)Math.Log((double)playerEngine + .GetCharacterStruct(Id).Get().timeStoppedContext, 2); // It's a bit field in game now /// /// Whether the player is sprinting. @@ -522,6 +522,11 @@ namespace TechbloxModdingAPI return (int) Id; } + public override string ToString() + { + return $"{nameof(Type)}: {Type}, {nameof(Id)}: {Id}, {nameof(Position)}: {Position}, {nameof(Rotation)}: {Rotation}, {nameof(Mass)}: {Mass}"; + } + // internal methods internal static void Init() diff --git a/TechbloxModdingAPI/Players/PlayerBuildingMode.cs b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs index 5e75555..7bc25a8 100644 --- a/TechbloxModdingAPI/Players/PlayerBuildingMode.cs +++ b/TechbloxModdingAPI/Players/PlayerBuildingMode.cs @@ -6,6 +6,7 @@ ColourMode, ConfigMode, BlueprintMode, - MaterialMode + MaterialMode, + LandscapeMode } } \ No newline at end of file