From 99f077a917bfad88e5b5ea19f8b6a12abbfa89d4 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 9 Jun 2021 20:11:31 +0200 Subject: [PATCH] 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}); } }