diff --git a/Automation/gen_csproj.py b/Automation/gen_csproj.py index c70b002..fc854b8 100755 --- a/Automation/gen_csproj.py +++ b/Automation/gen_csproj.py @@ -5,7 +5,7 @@ from pathlib import Path, PurePath import re import os -DLL_EXCLUSIONS_REGEX = r"(System|Microsoft|Mono|IronPython|DiscordRPC)\." +DLL_EXCLUSIONS_REGEX = r"(System|Microsoft|Mono|IronPython|DiscordRPC|IllusionInjector|IllusionPlugin|netstandard)\." def getAssemblyReferences(path): asmDir = Path(path) @@ -15,10 +15,12 @@ def getAssemblyReferences(path): 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"): + if child.is_file() and re.search(DLL_EXCLUSIONS_REGEX, str(child)) is None and str(child).lower().endswith(".dll"): childstr = str(child) childstr = os.path.relpath(childstr, addedPath).replace("\\", "/") result.append(childstr) + result.sort(key=str.lower) + result = [path + "/IllusionInjector.dll", path + "/IllusionPlugin.dll"] + result # Always put it on top return result def buildReferencesXml(path): @@ -51,7 +53,7 @@ if __name__ == "__main__": if depsStart is None or depsEnd is None: print("Unable to find dependency XML comments, aborting!") exit(1) - newFileStr = fileStr[:depsStart.start()] + "\n" + asmXml + "\n" + fileStr[depsEnd.end() + 1:] + newFileStr = fileStr[:depsStart.start() - 1] + "\n" + asmXml + "\n" + fileStr[depsEnd.end() + 1:] with open("../TechbloxModdingAPI/TechbloxModdingAPI.csproj", "w") as xmlFile: print("Writing Assembly references") xmlFile.write(newFileStr) diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs index a368e6f..7a15226 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using HarmonyLib; using Gamecraft.ColourPalette; -using Gamecraft.TimeRunning; using Gamecraft.Wires; using RobocraftX.Blocks; using RobocraftX.Common; @@ -58,7 +56,8 @@ namespace TechbloxModdingAPI.Blocks.Engines ecoll[i].isProcessed = false; } } - + + //TODO: GetConnectedCubesUtility ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID, cubeStack, cubes, (in GridConnectionsEntityStruct _) => false); diff --git a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs index 6bd48c8..e40f998 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlueprintEngine.cs @@ -18,7 +18,7 @@ using Svelto.ECS.DataStructures; using Svelto.ECS.EntityStructs; using Svelto.ECS.Native; using Svelto.ECS.Serialization; -using Techblox.Blocks; +using Techblox.Blocks.Connections; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; using Unity.Collections; @@ -48,7 +48,8 @@ namespace TechbloxModdingAPI.Blocks.Engines private static readonly MethodInfo SerializeGhostBlueprint = AccessTools.Method(SerializeGhostBlueprintType, "SerializeClipboardGhostEntities"); - private static NativeEntityRemove nativeRemove; + private static NativeEntityRemove nativeBlockRemove; + private static NativeEntityRemove nativeConnectionRemove; private static MachineGraphConnectionEntityFactory connectionFactory; private static IEntityFunctions entityFunctions; private static ClipboardSerializationDataResourceManager clipboardManager; @@ -88,8 +89,8 @@ namespace TechbloxModdingAPI.Blocks.Engines public void RemoveBlockGroup(int id) { - BlockGroupUtility.RemoveAllBlocksInBlockGroup(id, entitiesDB, removedConnections, nativeRemove, - connectionFactory, default).Complete(); + BlockGroupUtility.RemoveAllBlocksInBlockGroup(id, entitiesDB, removedConnections, nativeBlockRemove, + nativeConnectionRemove, connectionFactory, default).Complete(); } public int CreateBlockGroup(float3 position, quaternion rotation) @@ -339,7 +340,8 @@ namespace TechbloxModdingAPI.Blocks.Engines public static void Prefix(IEntityFunctions entityFunctions, MachineGraphConnectionEntityFactory machineGraphConnectionEntityFactory) { - nativeRemove = entityFunctions.ToNativeRemove("GCAPI" + nameof(BlueprintEngine)); + nativeBlockRemove = entityFunctions.ToNativeRemove("TBAPI" + nameof(BlueprintEngine)); + nativeConnectionRemove = entityFunctions.ToNativeRemove("TBAPI" + nameof(BlueprintEngine)); connectionFactory = machineGraphConnectionEntityFactory; BlueprintEngine.entityFunctions = entityFunctions; } diff --git a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs index 7999443..0610a18 100644 --- a/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/RemovalEngine.cs @@ -1,32 +1,43 @@ using System.Reflection; +using Gamecraft.Blocks.BlockGroups; using HarmonyLib; using RobocraftX.Blocks; using RobocraftX.Common; -using Svelto.Common; +using RobocraftX.GroupTags; +using RobocraftX.StateSync; using Svelto.ECS; using Svelto.ECS.Native; +using Techblox.Blocks.Connections; +using Unity.Collections; +using Unity.Jobs; +using Allocator = Unity.Collections.Allocator; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Blocks.Engines { - public class RemovalEngine : IApiEngine + public class RemovalEngine : IApiEngine, IDeterministicTimeStopped { private static IEntityFunctions _entityFunctions; private static MachineGraphConnectionEntityFactory _connectionFactory; + private NativeHashSet removedConnections = new(2000, Allocator.Persistent); public bool RemoveBlock(EGID target) { if (!entitiesDB.Exists(target)) return false; - var connections = entitiesDB.QueryEntity(target); - var groups = entitiesDB.FindGroups(); - 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); + using var connStructMapper = + entitiesDB.QueryNativeMappedEntities(GroupTag.Groups, + Svelto.Common.Allocator.Temp); + if (entitiesDB.TryQueryNativeMappedEntities( + ConnectionsExclusiveGroups.MACHINE_CONNECTION_GROUP, out var mapper)) + { + BlockGroupUtility.RemoveBlockConnections(target, removedConnections, _connectionFactory, + connStructMapper, mapper, entitiesDB.GetEntityReferenceMap(), _entityFunctions); + } + _entityFunctions.RemoveEntity(target); return true; } @@ -39,9 +50,11 @@ namespace TechbloxModdingAPI.Blocks.Engines public void Dispose() { + removedConnections.Dispose(); } - public string Name { get; } = "TechbloxModdingAPIRemovalGameEngine"; + public string Name => "TechbloxModdingAPIRemovalGameEngine"; + public string name => Name; public bool isRemovable => false; @@ -61,5 +74,11 @@ namespace TechbloxModdingAPI.Blocks.Engines return AccessTools.TypeByName("RobocraftX.CR.MachineEditing.RemoveBlockEngine").GetConstructors()[0]; } } + + public JobHandle DeterministicStep(in float deltaTime, JobHandle inputDeps) + { + removedConnections.Clear(); + return default; + } } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Cluster.cs b/TechbloxModdingAPI/Cluster.cs index 79eb7b9..378d4db 100644 --- a/TechbloxModdingAPI/Cluster.cs +++ b/TechbloxModdingAPI/Cluster.cs @@ -1,7 +1,5 @@ -using Gamecraft.Damage; -using RobocraftX.Common; -using Svelto.ECS; -using Techblox.Physics; +using Svelto.ECS; +using Techblox.TimeRunning.Clusters; namespace TechbloxModdingAPI { @@ -15,26 +13,26 @@ namespace TechbloxModdingAPI { } - public Cluster(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP)) + public Cluster(uint id) : this(new EGID(id, ClustersExclusiveGroups.SIMULATION_CLUSTERS_GROUP)) { } - public float InitialHealth + public float InitialHealth //TODO { - get => Block.BlockEngine.GetBlockInfo(this).initialHealth; - set => Block.BlockEngine.GetBlockInfo(this).initialHealth = value; + get => 0f; + set { } } public float CurrentHealth { - get => Block.BlockEngine.GetBlockInfo(this).currentHealth; - set => Block.BlockEngine.GetBlockInfo(this).currentHealth = value; + get => 0f; + set { } } public float HealthMultiplier { - get => Block.BlockEngine.GetBlockInfo(this).healthMultiplier; - set => Block.BlockEngine.GetBlockInfo(this).healthMultiplier = value; + get => 0f; + set { } } /// diff --git a/TechbloxModdingAPI/SimBody.cs b/TechbloxModdingAPI/SimBody.cs index 06e152b..1120103 100644 --- a/TechbloxModdingAPI/SimBody.cs +++ b/TechbloxModdingAPI/SimBody.cs @@ -6,6 +6,7 @@ using UnityEngine; using Gamecraft.Damage; using RobocraftX.Common; using RobocraftX.Physics; +using Techblox.TimeRunning.Clusters; namespace TechbloxModdingAPI { @@ -20,7 +21,7 @@ namespace TechbloxModdingAPI /// 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), + : GetInstance(new EGID(clusterId, ClustersExclusiveGroups.SIMULATION_CLUSTERS_GROUP), egid => new Cluster(egid)); // Otherwise get the cluster from the ID private Cluster cluster; @@ -82,7 +83,7 @@ namespace TechbloxModdingAPI public float3 CenterOfMass { - get => Block.BlockEngine.GetBlockInfo(this).centreOfMass; + get => 0f; //TODO //set => GetStruct().physicsMass.CenterOfMass = value; } @@ -93,20 +94,20 @@ namespace TechbloxModdingAPI public float InitialHealth { - get => Block.BlockEngine.GetBlockInfo(this).initialHealth; - set => Block.BlockEngine.GetBlockInfo(this).initialHealth = value; + get => 0f; + set { } } public float CurrentHealth { - get => Block.BlockEngine.GetBlockInfo(this).currentHealth; - set => Block.BlockEngine.GetBlockInfo(this).currentHealth = value; + get => 0f; + set { } } public float HealthMultiplier { - get => Block.BlockEngine.GetBlockInfo(this).healthMultiplier; - set => Block.BlockEngine.GetBlockInfo(this).healthMultiplier = value; + get => 0f; + set { } } /// diff --git a/TechbloxModdingAPI/TechbloxModdingAPI.csproj b/TechbloxModdingAPI/TechbloxModdingAPI.csproj index aa1d39b..456a019 100644 --- a/TechbloxModdingAPI/TechbloxModdingAPI.csproj +++ b/TechbloxModdingAPI/TechbloxModdingAPI.csproj @@ -415,6 +415,10 @@ ..\ref\Techblox_Data\Managed\RobocraftX.GUI.PauseMenu.dll ..\..\ref\Techblox_Data\Managed\RobocraftX.GUI.PauseMenu.dll + + ..\ref\Techblox_Data\Managed\RobocraftX.GUI.QuitConfirmation.dll + ..\..\ref\Techblox_Data\Managed\RobocraftX.GUI.QuitConfirmation.dll + ..\ref\Techblox_Data\Managed\RobocraftX.GUI.ScaleGhost.dll ..\..\ref\Techblox_Data\Managed\RobocraftX.GUI.ScaleGhost.dll @@ -591,10 +595,6 @@ ..\ref\Techblox_Data\Managed\Techblox.Blocks.Connections.dll ..\..\ref\Techblox_Data\Managed\Techblox.Blocks.Connections.dll - - ..\ref\Techblox_Data\Managed\Techblox.Blocks.Debug.Client.Monobehaviours.dll - ..\..\ref\Techblox_Data\Managed\Techblox.Blocks.Debug.Client.Monobehaviours.dll - ..\ref\Techblox_Data\Managed\Techblox.Blocks.LightBlock.dll ..\..\ref\Techblox_Data\Managed\Techblox.Blocks.LightBlock.dll @@ -603,6 +603,10 @@ ..\ref\Techblox_Data\Managed\Techblox.Building.Rules.dll ..\..\ref\Techblox_Data\Managed\Techblox.Building.Rules.dll + + ..\ref\Techblox_Data\Managed\Techblox.Building.Shift.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Building.Shift.dll + ..\ref\Techblox_Data\Managed\Techblox.BuildingDrone.dll ..\..\ref\Techblox_Data\Managed\Techblox.BuildingDrone.dll @@ -727,6 +731,14 @@ ..\ref\Techblox_Data\Managed\Techblox.GUI.BuildRules.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.BuildRules.dll + + ..\ref\Techblox_Data\Managed\Techblox.GUI.Collection.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.Collection.dll + + + ..\ref\Techblox_Data\Managed\Techblox.GUI.Commands.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.Commands.dll + ..\ref\Techblox_Data\Managed\Techblox.GUI.Controls.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.Controls.dll @@ -771,18 +783,26 @@ ..\ref\Techblox_Data\Managed\Techblox.GUI.MainGame.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.MainGame.dll + + ..\ref\Techblox_Data\Managed\Techblox.GUI.MainGame.StateMachine.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.MainGame.StateMachine.dll + ..\ref\Techblox_Data\Managed\Techblox.GUI.MyGamesScreen.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.MyGamesScreen.dll - - ..\ref\Techblox_Data\Managed\Techblox.GUI.PauseMenuCommands.dll - ..\..\ref\Techblox_Data\Managed\Techblox.GUI.PauseMenuCommands.dll + + ..\ref\Techblox_Data\Managed\Techblox.GUI.PauseMenu.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.PauseMenu.dll ..\ref\Techblox_Data\Managed\Techblox.GUI.Progression.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.Progression.dll + + ..\ref\Techblox_Data\Managed\Techblox.GUI.ScreenCanvas.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.ScreenCanvas.dll + ..\ref\Techblox_Data\Managed\Techblox.GUI.TabsBar.Landscapes.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.TabsBar.Landscapes.dll @@ -795,6 +815,10 @@ ..\ref\Techblox_Data\Managed\Techblox.GUI.UsernameDisplay.dll ..\..\ref\Techblox_Data\Managed\Techblox.GUI.UsernameDisplay.dll + + ..\ref\Techblox_Data\Managed\Techblox.GUI.WorldCanvas.dll + ..\..\ref\Techblox_Data\Managed\Techblox.GUI.WorldCanvas.dll + ..\ref\Techblox_Data\Managed\Techblox.InputCapture.dll ..\..\ref\Techblox_Data\Managed\Techblox.InputCapture.dll @@ -943,10 +967,30 @@ ..\ref\Techblox_Data\Managed\Techblox.Services.Progression.Client.dll ..\..\ref\Techblox_Data\Managed\Techblox.Services.Progression.Client.dll + + ..\ref\Techblox_Data\Managed\Techblox.Services.Progression.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Services.Progression.dll + ..\ref\Techblox_Data\Managed\Techblox.Services.Storage.dll ..\..\ref\Techblox_Data\Managed\Techblox.Services.Storage.dll + + ..\ref\Techblox_Data\Managed\Techblox.Services.Users.Client.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Services.Users.Client.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Services.Users.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Services.Users.dll + + + ..\ref\Techblox_Data\Managed\Techblox.ServoBlocksServer.dll + ..\..\ref\Techblox_Data\Managed\Techblox.ServoBlocksServer.dll + + + ..\ref\Techblox_Data\Managed\Techblox.ServosServer.dll + ..\..\ref\Techblox_Data\Managed\Techblox.ServosServer.dll + ..\ref\Techblox_Data\Managed\Techblox.SignalHandling.Audio.dll ..\..\ref\Techblox_Data\Managed\Techblox.SignalHandling.Audio.dll @@ -955,6 +999,10 @@ ..\ref\Techblox_Data\Managed\Techblox.SignalHandling.Common.dll ..\..\ref\Techblox_Data\Managed\Techblox.SignalHandling.Common.dll + + ..\ref\Techblox_Data\Managed\Techblox.Simulation.Clusters.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Simulation.Clusters.dll + ..\ref\Techblox_Data\Managed\Techblox.SpawnBlock.Client.dll ..\..\ref\Techblox_Data\Managed\Techblox.SpawnBlock.Client.dll @@ -1023,6 +1071,30 @@ ..\ref\Techblox_Data\Managed\Techblox.VisualEffects.VFXGraph.dll ..\..\ref\Techblox_Data\Managed\Techblox.VisualEffects.VFXGraph.dll + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.Aiming.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.Aiming.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.DisablerBlock.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.DisablerBlock.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.Projectiles.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.Projectiles.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.Projectiles.Server.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.Projectiles.Server.dll + + + ..\ref\Techblox_Data\Managed\Techblox.Weapons.Server.dll + ..\..\ref\Techblox_Data\Managed\Techblox.Weapons.Server.dll + ..\ref\Techblox_Data\Managed\Techblox.WheelFX.dll ..\..\ref\Techblox_Data\Managed\Techblox.WheelFX.dll @@ -1403,6 +1475,10 @@ ..\ref\Techblox_Data\Managed\UnityEngine.TextCoreFontEngineModule.dll ..\..\ref\Techblox_Data\Managed\UnityEngine.TextCoreFontEngineModule.dll + + ..\ref\Techblox_Data\Managed\UnityEngine.TextCoreModule.dll + ..\..\ref\Techblox_Data\Managed\UnityEngine.TextCoreModule.dll + ..\ref\Techblox_Data\Managed\UnityEngine.TextCoreTextEngineModule.dll ..\..\ref\Techblox_Data\Managed\UnityEngine.TextCoreTextEngineModule.dll