From 89f354b647d1f2fcefa8db82828318d76af3b28c Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Thu, 13 Aug 2020 10:12:36 -0400 Subject: [PATCH 1/6] Fix Game Over detection --- GamecraftModdingAPI/Players/PlayerEngine.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index 805ae21..f0aa31d 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Reflection; using System.Runtime.CompilerServices; using RobocraftX.Character; @@ -12,12 +14,16 @@ using RobocraftX.Character.Camera; using RobocraftX.Character.Factories; using Gamecraft.CharacterVulnerability; using Gamecraft.CharacterVulnerability.Entities; +using Gamecraft.GUI.HUDFeedbackBlocks; using Svelto.ECS; using Unity.Mathematics; using Unity.Physics; using UnityEngine; using GamecraftModdingAPI.Engines; +using HarmonyLib; +using RobocraftX.Common; +using Svelto.ECS.DataStructures; namespace GamecraftModdingAPI.Players { @@ -365,15 +371,12 @@ namespace GamecraftModdingAPI.Players public bool GetGameOverScreen(uint playerId) { if (entitiesDB == null) return false; - ref var c = ref GetCharacterStruct(playerId, out bool exists); - if (exists) - { - return c.gameOverScreen; - } - return false; + ref HudActivatedBlocksEntityStruct habes = ref entitiesDB.QueryEntity(HUDFeedbackBlocksGUIExclusiveGroups.GameOverHudEgid); + NativeDynamicArrayCast nativeDynamicArrayCast = new NativeDynamicArrayCast(habes.activatedBlocksOrdered); + return nativeDynamicArrayCast.count > 0; } - public bool IsDead(uint playerId) + public bool IsDead(uint playerId) { if (entitiesDB == null) return true; return entitiesDB.Exists(playerId, CharacterExclusiveGroups.DeadCharacters); From fd9719490329670ea33288f754bbc5170f442273 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Fri, 7 Aug 2020 13:55:00 -0400 Subject: [PATCH 2/6] Fix build issues for latest Gamecraft preview version --- GamecraftModdingAPI/App/GameMenuEngine.cs | 17 ++- GamecraftModdingAPI/Block.cs | 4 +- GamecraftModdingAPI/Blocks/BlockEngine.cs | 70 ++++++++++- GamecraftModdingAPI/Blocks/SignalEngine.cs | 4 +- .../GamecraftModdingAPI.csproj | 109 ++++++++++++++++++ GamecraftModdingAPI/Players/PlayerEngine.cs | 9 +- 6 files changed, 195 insertions(+), 18 deletions(-) diff --git a/GamecraftModdingAPI/App/GameMenuEngine.cs b/GamecraftModdingAPI/App/GameMenuEngine.cs index fc2c35f..74bc42a 100644 --- a/GamecraftModdingAPI/App/GameMenuEngine.cs +++ b/GamecraftModdingAPI/App/GameMenuEngine.cs @@ -10,6 +10,7 @@ using Svelto.ECS.Experimental; using GamecraftModdingAPI.Engines; using GamecraftModdingAPI.Utility; +using Svelto.DataStructures; namespace GamecraftModdingAPI.App { @@ -114,11 +115,21 @@ namespace GamecraftModdingAPI.App } public ref MyGamesSlotEntityViewStruct GetGameViewInfo(EGID id) - { - return ref GetComponent(new EGID(id.entityID, MyGamesScreenExclusiveGroups.GameSlotGuiEntities)); + { + EntityCollection entities = + entitiesDB.QueryEntities(MyGamesScreenExclusiveGroups.GameSlotGuiEntities); + for (int i = 0; i < entities.count; i++) + { + if (entities[i].ID.entityID == id.entityID) + { + return ref entities[i]; + } + } + MyGamesSlotEntityViewStruct[] defRef = new MyGamesSlotEntityViewStruct[1]; + return ref defRef[0]; } - public ref T GetComponent(EGID id) where T: struct, IEntityComponent + public ref T GetComponent(EGID id) where T: unmanaged, IEntityComponent { return ref entitiesDB.QueryEntity(id); } diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index 0194bae..c7b5d0d 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -337,10 +337,10 @@ namespace GamecraftModdingAPI /// public string Label { - get => BlockEngine.GetBlockInfo(this, (TextLabelEntityViewStruct st) => st.textLabelComponent?.text); + get => BlockEngine.GetBlockInfoViewStruct(this, (TextLabelEntityViewStruct st) => st.textLabelComponent?.text); set { - BlockEngine.SetBlockInfo(this, (ref TextLabelEntityViewStruct text, string val) => + BlockEngine.SetBlockInfoViewStruct(this, (ref TextLabelEntityViewStruct text, string val) => { if (text.textLabelComponent != null) text.textLabelComponent.text = val; }, value); diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index f97e405..33c4002 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -59,16 +59,34 @@ namespace GamecraftModdingAPI.Blocks color.paletteColour = paletteEntry.Colour; } - public ref T GetBlockInfo(EGID blockID) where T : struct, IEntityComponent + public ref T 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 } + + public ref T GetBlockInfoViewStruct(EGID blockID) where T : struct, INeedEGID, IEntityComponent + { + if (entitiesDB.Exists(blockID)) + { + // TODO: optimize by using EntitiesDB internal calls instead of iterating over everything + EntityCollection entities = entitiesDB.QueryEntities(blockID.groupID); + for (int i = 0; i < entities.count; i++) + { + if (entities[i].ID == blockID) + { + return ref entities[i]; + } + } + } + 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 : struct, IEntityComponent + U def = default) where T : unmanaged, IEntityComponent { if (entitiesDB.Exists(block.Id)) return getter(entitiesDB.QueryEntity(block.Id)); @@ -78,10 +96,56 @@ namespace GamecraftModdingAPI.Blocks return getter(initializer.Get()); return def; } + + public U GetBlockInfoViewStruct(Block block, Func getter, + U def = default) where T : struct, INeedEGID, IEntityComponent + { + if (entitiesDB.Exists(block.Id)) + { + // TODO: optimize by using EntitiesDB internal calls instead of iterating over everything + EntityCollection entities = entitiesDB.QueryEntities(block.Id.groupID); + for (int i = 0; i < entities.count; i++) + { + if (entities[i].ID == block.Id) + { + return getter(entities[i]); + } + } + } + if (block.InitData.Group == null) return def; + var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); + if (initializer.Has()) + return getter(initializer.Get()); + return def; + } public delegate void Setter(ref T component, U value) where T : struct, IEntityComponent; - public void SetBlockInfo(Block block, Setter setter, U value) where T : struct, IEntityComponent + public void SetBlockInfoViewStruct(Block block, Setter setter, U value) where T : struct, INeedEGID, IEntityComponent + { + if (entitiesDB.Exists(block.Id)) + { + EntityCollection entities = entitiesDB.QueryEntities(block.Id.groupID); + for (int i = 0; i < entities.count; i++) + { + if (entities[i].ID == block.Id) + { + setter(ref entities[i], value); + return; + } + } + } + else if (block.InitData.Group != null) + { + var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); + T component = initializer.Has() ? initializer.Get() : default; + ref T structRef = ref component; + setter(ref structRef, value); + initializer.Init(structRef); + } + } + + 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); diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs index e961423..763a1a1 100644 --- a/GamecraftModdingAPI/Blocks/SignalEngine.cs +++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs @@ -96,7 +96,7 @@ namespace GamecraftModdingAPI.Blocks return ref GetPortByOffset(bps, portNumber, input); } - public ref T GetComponent(EGID egid) where T : struct, IEntityComponent + public ref T GetComponent(EGID egid) where T : unmanaged, IEntityComponent { return ref entitiesDB.QueryEntity(egid); } @@ -372,7 +372,7 @@ namespace GamecraftModdingAPI.Blocks return results.ToArray(); } - private ref T GetFromDbOrInitData(Block block, EGID id, out bool exists) where T : struct, IEntityComponent + private ref T GetFromDbOrInitData(Block block, EGID id, out bool exists) where T : unmanaged, IEntityComponent { T[] defRef = new T[1]; if (entitiesDB.Exists(id)) diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 32c780b..49a3a6a 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -22,6 +22,7 @@ +<<<<<<< HEAD @@ -55,6 +56,21 @@ ..\ref\Gamecraft_Data\Managed\Accessibility.dll ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll +======= + + + + + + + + ..\ref\GamecraftPreview_Data\Managed\IllusionInjector.dll + ..\..\ref\GamecraftPreview_Data\Managed\IllusionInjector.dll + + + ..\ref\GamecraftPreview_Data\Managed\IllusionPlugin.dll + ..\..\ref\GamecraftPreview_Data\Managed\IllusionPlugin.dll +>>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version ..\ref\Gamecraft_Data\Managed\Analytics.dll @@ -72,10 +88,13 @@ ..\ref\Gamecraft_Data\Managed\Authentication.dll ..\..\ref\Gamecraft_Data\Managed\Authentication.dll +<<<<<<< HEAD ..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll ..\..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll +======= +>>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version ..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll @@ -84,6 +103,18 @@ ..\ref\Gamecraft_Data\Managed\CommandLine.dll ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll + + ..\ref\GamecraftPreview_Data\Managed\CommandLineCompositionRoot.dll + ..\..\ref\GamecraftPreview_Data\Managed\CommandLineCompositionRoot.dll + + + ..\ref\GamecraftPreview_Data\Managed\ConsoleBlockComposotionRoot.dll + ..\..\ref\GamecraftPreview_Data\Managed\ConsoleBlockComposotionRoot.dll + + + ..\ref\GamecraftPreview_Data\Managed\ConsoleCommand.dll + ..\..\ref\GamecraftPreview_Data\Managed\ConsoleCommand.dll + ..\ref\Gamecraft_Data\Managed\DataLoader.dll ..\..\ref\Gamecraft_Data\Managed\DataLoader.dll @@ -108,6 +139,14 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockCompositionRoot.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockCompositionRoot.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll @@ -116,6 +155,10 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.GenericPhysicsBlocks.dll @@ -128,10 +171,18 @@ ..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll ..\..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.TimerBlock.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll @@ -140,10 +191,22 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Damage.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Damage.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Effects.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll @@ -172,6 +235,14 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.JointBlocks.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.JointBlocks.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll @@ -180,6 +251,22 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupBlck.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupBlck.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupsCommon.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupsCommon.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PopupMessage.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PopupMessage.dll + + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Projectiles.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Projectiles.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll @@ -188,6 +275,10 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll + + ..\ref\GamecraftPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll @@ -196,10 +287,13 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll +<<<<<<< HEAD ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Input.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Input.dll +======= +>>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll @@ -424,6 +518,14 @@ ..\ref\Gamecraft_Data\Managed\RobocratX.SimulationCompositionRoot.dll ..\..\ref\Gamecraft_Data\Managed\RobocratX.SimulationCompositionRoot.dll + + ..\ref\GamecraftPreview_Data\Managed\SpawningPointCompositionRoot.dll + ..\..\ref\GamecraftPreview_Data\Managed\SpawningPointCompositionRoot.dll + + + ..\ref\GamecraftPreview_Data\Managed\SpecializedDescriptors.dll + ..\..\ref\GamecraftPreview_Data\Managed\SpecializedDescriptors.dll + ..\ref\Gamecraft_Data\Managed\StringFormatter.dll ..\..\ref\Gamecraft_Data\Managed\StringFormatter.dll @@ -444,6 +546,10 @@ ..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll ..\..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll + + ..\ref\GamecraftPreview_Data\Managed\UltimateDecals.dll + ..\..\ref\GamecraftPreview_Data\Managed\UltimateDecals.dll + ..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll ..\..\ref\Gamecraft_Data\Managed\Unity.Addressables.dll @@ -816,6 +922,7 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll +<<<<<<< HEAD ..\ref\Gamecraft_Data\Managed\uREPL.dll ..\..\ref\Gamecraft_Data\Managed\uREPL.dll @@ -824,6 +931,8 @@ ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll ..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll +======= +>>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version \ No newline at end of file diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index f0aa31d..948c6e9 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -288,14 +288,7 @@ namespace GamecraftModdingAPI.Players public bool DamagePlayer(uint playerId, float amount) { if (entitiesDB == null) return false; - Factory.BuildEntity( - new EGID(CharacterVulnerabilityExclusiveGroups.NextDamageEntityId, CharacterVulnerabilityExclusiveGroups.CharacterDamageExclusiveGroup) - ).Init(new DamageEntityStruct - { - damage = amount, - targetPlayerEntityId = playerId, - }); - return true; + return SetCurrentHealth(playerId, GetCurrentHealth(playerId) - amount); } public bool GetDamageable(uint playerId) From cfdc5e8c26701bd452a63b8a591cbeba1559151b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 13 Aug 2020 16:59:13 +0200 Subject: [PATCH 3/6] Fixes, block IDs, cluster & chunk health support --- GamecraftModdingAPI/Block.cs | 2 +- GamecraftModdingAPI/Blocks/BlockEngine.cs | 91 +++++++++++-------- GamecraftModdingAPI/Blocks/BlockIDs.cs | 5 + GamecraftModdingAPI/Cluster.cs | 41 +++++++++ GamecraftModdingAPI/SimBody.cs | 37 ++++++++ .../Tests/GamecraftModdingAPIPluginTest.cs | 10 ++ .../Utility/DebugInterfaceEngine.cs | 11 ++- 7 files changed, 154 insertions(+), 43 deletions(-) create mode 100644 GamecraftModdingAPI/Cluster.cs diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index c7b5d0d..b901f81 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -372,7 +372,7 @@ namespace GamecraftModdingAPI public SimBody GetSimBody() { return BlockEngine.GetBlockInfo(this, - (GridConnectionsEntityStruct st) => new SimBody(st.machineRigidBodyId)); + (GridConnectionsEntityStruct st) => new SimBody(st.machineRigidBodyId, st.clusterId)); } private void OnPlacedInit(object sender, BlockPlacedRemovedEventArgs e) diff --git a/GamecraftModdingAPI/Blocks/BlockEngine.cs b/GamecraftModdingAPI/Blocks/BlockEngine.cs index 33c4002..2622d41 100644 --- a/GamecraftModdingAPI/Blocks/BlockEngine.cs +++ b/GamecraftModdingAPI/Blocks/BlockEngine.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using Gamecraft.Wires; using RobocraftX.Blocks; @@ -9,6 +10,7 @@ using RobocraftX.Physics; using RobocraftX.Scene.Simulation; using Svelto.DataStructures; using Svelto.ECS; +using Svelto.ECS.Hybrid; using GamecraftModdingAPI.Engines; @@ -90,28 +92,19 @@ namespace GamecraftModdingAPI.Blocks { if (entitiesDB.Exists(block.Id)) return getter(entitiesDB.QueryEntity(block.Id)); - if (block.InitData.Group == null) return def; - var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); - if (initializer.Has()) - return getter(initializer.Get()); - return def; + return GetBlockInitInfo(block, getter, def); } public U GetBlockInfoViewStruct(Block block, Func getter, - U def = default) where T : struct, INeedEGID, IEntityComponent + U def = default) where T : struct, IEntityViewComponent { if (entitiesDB.Exists(block.Id)) - { - // TODO: optimize by using EntitiesDB internal calls instead of iterating over everything - EntityCollection entities = entitiesDB.QueryEntities(block.Id.groupID); - for (int i = 0; i < entities.count; i++) - { - if (entities[i].ID == block.Id) - { - return getter(entities[i]); - } - } - } + 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 EntityComponentInitializer(block.Id, block.InitData.Group); if (initializer.Has()) @@ -121,35 +114,26 @@ namespace GamecraftModdingAPI.Blocks 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, INeedEGID, IEntityComponent + public void SetBlockInfoViewStruct(Block block, Setter setter, U value) where T : struct, IEntityViewComponent { if (entitiesDB.Exists(block.Id)) - { - EntityCollection entities = entitiesDB.QueryEntities(block.Id.groupID); - for (int i = 0; i < entities.count; i++) - { - if (entities[i].ID == block.Id) - { - setter(ref entities[i], value); - return; - } - } - } - else if (block.InitData.Group != null) - { - var initializer = new EntityComponentInitializer(block.Id, block.InitData.Group); - T component = initializer.Has() ? initializer.Get() : default; - ref T structRef = ref component; - setter(ref structRef, value); - initializer.Init(structRef); - } + 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 if (block.InitData.Group != null) + 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 EntityComponentInitializer(block.Id, block.InitData.Group); T component = initializer.Has() ? initializer.Get() : default; @@ -222,6 +206,22 @@ namespace GamecraftModdingAPI.Blocks return list.ToArray(); } + public SimBody[] GetClusterBodies(uint cid) + { + var groups = entitiesDB.QueryEntities(); + var bodies = new HashSet(); + foreach (var (coll, _) in groups) + { + foreach (var conn in coll) + { + if (conn.clusterId == cid) + bodies.Add(conn.machineRigidBodyId); + } + } + + return bodies.Select(id => new SimBody(id)).ToArray(); + } + public EGID? FindBlockEGID(uint id) { var groups = entitiesDB.FindGroups(); @@ -234,6 +234,21 @@ namespace GamecraftModdingAPI.Blocks return null; } + public Cluster GetCluster(uint sbid) + { + var groups = entitiesDB.QueryEntities(); + foreach (var (coll, _) in groups) + { + foreach (var conn in coll) + { + if (conn.machineRigidBodyId == sbid) + return new Cluster(conn.clusterId); + } + } + + return null; + } + #if DEBUG public EntitiesDB GetEntitiesDB() { diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index 596fb38..33f9522 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -192,6 +192,9 @@ namespace GamecraftModdingAPI.Blocks PlayerFilter, TeamFilter, Number2Text, //193 + DestructionManager = 260, + ChunkHealthModifier, + ClusterHealthModifier, //262 BeachTree1 = 200, BeachTree2, BeachTree3, @@ -243,6 +246,8 @@ namespace GamecraftModdingAPI.Blocks AdvancedRotator, MusicBlock, //256 PlasmaCannonBlock, + QuantumRiflePickup = 300, + QuantumRifleAmmoPickup, MagmaRockCube=777, MagmaRockCubeSliced, MagmaRockSlope, diff --git a/GamecraftModdingAPI/Cluster.cs b/GamecraftModdingAPI/Cluster.cs new file mode 100644 index 0000000..074c26c --- /dev/null +++ b/GamecraftModdingAPI/Cluster.cs @@ -0,0 +1,41 @@ +using Gamecraft.Damage; +using RobocraftX.Common; +using Svelto.ECS; + +namespace GamecraftModdingAPI +{ + /// + /// Represnts a cluster of blocks in time running mode, meaning blocks that are connected either directly or via joints. + /// + public class Cluster + { + public EGID Id { get; } + + public Cluster(EGID id) + { + Id = id; + } + + public Cluster(uint id) : this(new EGID(id, CommonExclusiveGroups.SIMULATION_CLUSTERS_GROUP)) + { + } + + public float InitialHealth + { + get => Block.BlockEngine.GetBlockInfo(Id).initialHealth; + set => Block.BlockEngine.GetBlockInfo(Id).initialHealth = value; + } + + public float CurrentHealth + { + get => Block.BlockEngine.GetBlockInfo(Id).currentHealth; + set => Block.BlockEngine.GetBlockInfo(Id).currentHealth = value; + } + + public float HealthMultiplier + { + get => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier; + set => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier = value; + } + } +} \ No newline at end of file diff --git a/GamecraftModdingAPI/SimBody.cs b/GamecraftModdingAPI/SimBody.cs index 19f4285..a3f6d55 100644 --- a/GamecraftModdingAPI/SimBody.cs +++ b/GamecraftModdingAPI/SimBody.cs @@ -3,6 +3,7 @@ using Svelto.ECS; using Unity.Mathematics; using UnityEngine; +using Gamecraft.Damage; using RobocraftX.Common; using RobocraftX.Physics; @@ -15,6 +16,14 @@ namespace GamecraftModdingAPI { public EGID Id { get; } + /// + /// The cluster this chunk belongs to, or null if 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)); + + private Cluster cluster; + private uint clusterId; + public SimBody(EGID id) { Id = id; @@ -24,6 +33,11 @@ namespace GamecraftModdingAPI { } + internal SimBody(uint id, uint clusterID) : this(id) + { + clusterId = clusterID; + } + /// /// The position of this body. When setting the position, update the position of the connected bodies as well, /// otherwise unexpected forces may arise. @@ -70,6 +84,29 @@ namespace GamecraftModdingAPI //set => GetStruct().physicsMass.CenterOfMass = value; } + public float Volume + { + get => GetStruct().volume; + } + + public float InitialHealth + { + get => Block.BlockEngine.GetBlockInfo(Id).initialHealth; + set => Block.BlockEngine.GetBlockInfo(Id).initialHealth = value; + } + + public float CurrentHealth + { + get => Block.BlockEngine.GetBlockInfo(Id).currentHealth; + set => Block.BlockEngine.GetBlockInfo(Id).currentHealth = value; + } + + public float HealthMultiplier + { + get => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier; + set => Block.BlockEngine.GetBlockInfo(Id).healthMultiplier = value; + } + /// /// Whether the body can be moved or static. /// diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 639125c..7002605 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -268,6 +268,16 @@ namespace GamecraftModdingAPI.Tests }) .Build(); + CommandBuilder.Builder("TestChunkHealth", "Sets the chunk looked at to the given health.") + .Action((float val, float max) => + { + var body = new Player(PlayerType.Local).GetSimBodyLookedAt(); + if (body == null) return; + body.CurrentHealth = val; + body.InitialHealth = max; + Logging.CommandLog("Health set to: " + val); + }).Build(); + GameClient.SetDebugInfo("InstalledMods", InstalledMods); Block.Placed += (sender, args) => Logging.MetaDebugLog("Placed block " + args.Type + " with ID " + args.ID); diff --git a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs b/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs index c604c34..0e4d023 100644 --- a/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs +++ b/GamecraftModdingAPI/Utility/DebugInterfaceEngine.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; +using System.Text; using System.Text.Formatting; using GamecraftModdingAPI.Blocks; using GamecraftModdingAPI.Engines; @@ -46,9 +47,9 @@ namespace GamecraftModdingAPI.Utility var array = new CodeInstruction[] { new CodeInstruction(OpCodes.Ldloc_0), //StringBuffer - new CodeInstruction(OpCodes.Call, ((Action)AddInfo).Method) + new CodeInstruction(OpCodes.Call, ((Action)AddInfo).Method) }; - list.InsertRange(index, array); + list.InsertRange(index - 1, array); //-1: ldloc.1 ("local") before ldfld } catch (Exception e) { @@ -58,13 +59,15 @@ namespace GamecraftModdingAPI.Utility return list; } - public static void AddInfo(StringBuffer sb) + public static void AddInfo(StringBuilder sb) { foreach (var info in _extraInfo) { try { - sb.Append(info.Value() + "\n"); + string text = info.Value().Trim(); + if (text.Length != 0) + sb.Append(text + "\n"); } catch (Exception e) { From 11b94e384ee9a0d21966b1eeefde696c4d24caa2 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 22 Aug 2020 09:25:14 -0400 Subject: [PATCH 4/6] Update refs --- .../GamecraftModdingAPI.csproj | 266 +++++++++--------- 1 file changed, 137 insertions(+), 129 deletions(-) diff --git a/GamecraftModdingAPI/GamecraftModdingAPI.csproj b/GamecraftModdingAPI/GamecraftModdingAPI.csproj index 49a3a6a..8be57a7 100644 --- a/GamecraftModdingAPI/GamecraftModdingAPI.csproj +++ b/GamecraftModdingAPI/GamecraftModdingAPI.csproj @@ -22,8 +22,8 @@ -<<<<<<< HEAD - + + ..\ref\Gamecraft_Data\Managed\IllusionInjector.dll @@ -33,45 +33,6 @@ ..\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\Unity.Burst.Unsafe.dll - ..\..\ref\Gamecraft_Data\Managed\Unity.Burst.Unsafe.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\mscorlib.dll - ..\..\ref\Gamecraft_Data\Managed\mscorlib.dll - - - ..\ref\Gamecraft_Data\Managed\Accessibility.dll - ..\..\ref\Gamecraft_Data\Managed\Accessibility.dll -======= - - - - - - - - ..\ref\GamecraftPreview_Data\Managed\IllusionInjector.dll - ..\..\ref\GamecraftPreview_Data\Managed\IllusionInjector.dll - - - ..\ref\GamecraftPreview_Data\Managed\IllusionPlugin.dll - ..\..\ref\GamecraftPreview_Data\Managed\IllusionPlugin.dll ->>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version - ..\ref\Gamecraft_Data\Managed\Analytics.dll ..\..\ref\Gamecraft_Data\Managed\Analytics.dll @@ -88,13 +49,6 @@ ..\ref\Gamecraft_Data\Managed\Authentication.dll ..\..\ref\Gamecraft_Data\Managed\Authentication.dll -<<<<<<< HEAD - - ..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll - ..\..\ref\Gamecraft_Data\Managed\BlockEntityFactory.dll - -======= ->>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version ..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll ..\..\ref\Gamecraft_Data\Managed\Blocks.HUDFeedbackBlocks.dll @@ -104,16 +58,16 @@ ..\..\ref\Gamecraft_Data\Managed\CommandLine.dll - ..\ref\GamecraftPreview_Data\Managed\CommandLineCompositionRoot.dll - ..\..\ref\GamecraftPreview_Data\Managed\CommandLineCompositionRoot.dll + ..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\CommandLineCompositionRoot.dll - ..\ref\GamecraftPreview_Data\Managed\ConsoleBlockComposotionRoot.dll - ..\..\ref\GamecraftPreview_Data\Managed\ConsoleBlockComposotionRoot.dll + ..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\ConsoleBlockComposotionRoot.dll - ..\ref\GamecraftPreview_Data\Managed\ConsoleCommand.dll - ..\..\ref\GamecraftPreview_Data\Managed\ConsoleCommand.dll + ..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll + ..\..\ref\Gamecraft_Data\Managed\ConsoleCommand.dll ..\ref\Gamecraft_Data\Managed\DataLoader.dll @@ -123,10 +77,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 @@ -140,12 +90,12 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.AudioBlocks.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockCompositionRoot.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockCompositionRoot.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockCompositionRoot.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlockEntityFactory.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.ConsoleBlock.dll @@ -156,8 +106,8 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Blocks.DamagingSurfaceBlock.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.DestructionBlocks.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 @@ -172,16 +122,16 @@ ..\..\ref\Gamecraft_Data\Managed\GameCraft.Blocks.ProjectileBlock.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Blocks.TextBlock.CompositionRoot.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\GamecraftPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.BlocksEntityDescriptors.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerability.dll @@ -192,20 +142,20 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.CharacterVulnerabilityGui.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Damage.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Damage.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\GamecraftPreview_Data\Managed\Gamecraft.ExplosionFragments.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.ExplosionFragments.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.GraphicsSettings.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GraphicsSettings.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.ConsoleBlock.dll @@ -236,12 +186,12 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.GUI.WorldSpaceGuis.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.InventoryTimeRunning.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.JointBlocks.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.JointBlocks.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.JointBlocks.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.Music.dll @@ -252,20 +202,20 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PerformanceWarnings.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupBlck.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupBlck.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupBlck.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupsCommon.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PickupsCommon.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PickupsCommon.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.PopupMessage.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.PopupMessage.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.PopupMessage.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.Projectiles.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.Projectiles.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Projectiles.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.dll @@ -276,8 +226,8 @@ ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Tweaks.Mockup.dll - ..\ref\GamecraftPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll - ..\..\ref\GamecraftPreview_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll + ..\..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.Decals.dll ..\ref\Gamecraft_Data\Managed\Gamecraft.VisualEffects.dll @@ -287,13 +237,6 @@ ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.dll -<<<<<<< HEAD - - ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Input.dll - ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Input.dll - -======= ->>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version ..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll ..\..\ref\Gamecraft_Data\Managed\Gamecraft.Wires.Mockup.dll @@ -326,18 +269,6 @@ ..\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 @@ -519,12 +450,12 @@ ..\..\ref\Gamecraft_Data\Managed\RobocratX.SimulationCompositionRoot.dll - ..\ref\GamecraftPreview_Data\Managed\SpawningPointCompositionRoot.dll - ..\..\ref\GamecraftPreview_Data\Managed\SpawningPointCompositionRoot.dll + ..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll + ..\..\ref\Gamecraft_Data\Managed\SpawningPointCompositionRoot.dll - ..\ref\GamecraftPreview_Data\Managed\SpecializedDescriptors.dll - ..\..\ref\GamecraftPreview_Data\Managed\SpecializedDescriptors.dll + ..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll + ..\..\ref\Gamecraft_Data\Managed\SpecializedDescriptors.dll ..\ref\Gamecraft_Data\Managed\StringFormatter.dll @@ -547,13 +478,41 @@ ..\..\ref\Gamecraft_Data\Managed\Svelto.Tasks.dll - ..\ref\GamecraftPreview_Data\Managed\UltimateDecals.dll - ..\..\ref\GamecraftPreview_Data\Managed\UltimateDecals.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 @@ -566,6 +525,10 @@ ..\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 @@ -594,6 +557,10 @@ ..\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 @@ -678,6 +645,62 @@ ..\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\UnityEngine.AccessibilityModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.AccessibilityModule.dll @@ -846,10 +869,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 @@ -922,17 +941,6 @@ ..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll ..\..\ref\Gamecraft_Data\Managed\UnityEngine.XRModule.dll -<<<<<<< HEAD - - ..\ref\Gamecraft_Data\Managed\uREPL.dll - ..\..\ref\Gamecraft_Data\Managed\uREPL.dll - - - ..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - ..\..\ref\Gamecraft_Data\Managed\VisualProfiler.dll - -======= ->>>>>>> 50ebf4f... Fix build issues for latest Gamecraft preview version - + \ No newline at end of file From daf4a24bc90f333c35cba1d3af576f82a2867ced Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sat, 22 Aug 2020 09:26:51 -0400 Subject: [PATCH 5/6] Fix namespace build error from unused using statement (I deleted it) --- GamecraftModdingAPI/Players/PlayerEngine.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/GamecraftModdingAPI/Players/PlayerEngine.cs b/GamecraftModdingAPI/Players/PlayerEngine.cs index 948c6e9..6d461f2 100644 --- a/GamecraftModdingAPI/Players/PlayerEngine.cs +++ b/GamecraftModdingAPI/Players/PlayerEngine.cs @@ -12,8 +12,6 @@ using RobocraftX.Physics; using RobocraftX.Blocks.Ghost; using RobocraftX.Character.Camera; using RobocraftX.Character.Factories; -using Gamecraft.CharacterVulnerability; -using Gamecraft.CharacterVulnerability.Entities; using Gamecraft.GUI.HUDFeedbackBlocks; using Svelto.ECS; using Unity.Mathematics; From aae20579723070aaa2fba9f26e1cdd980bd8c4e5 Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 23 Aug 2020 09:59:13 -0400 Subject: [PATCH 6/6] Convert relevant blocks to wireable blocks and fix wire connect during block init --- GamecraftModdingAPI/Blocks/ConsoleBlock.cs | 2 +- GamecraftModdingAPI/Blocks/Motor.cs | 2 +- GamecraftModdingAPI/Blocks/MusicBlock.cs | 2 +- GamecraftModdingAPI/Blocks/Piston.cs | 2 +- GamecraftModdingAPI/Blocks/Servo.cs | 2 +- GamecraftModdingAPI/Blocks/TextBlock.cs | 2 +- GamecraftModdingAPI/Blocks/Timer.cs | 2 +- GamecraftModdingAPI/Blocks/Wire.cs | 8 +++--- .../Tests/GamecraftModdingAPIPluginTest.cs | 27 +++++-------------- 9 files changed, 18 insertions(+), 31 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs b/GamecraftModdingAPI/Blocks/ConsoleBlock.cs index edf3e76..c8982e4 100644 --- a/GamecraftModdingAPI/Blocks/ConsoleBlock.cs +++ b/GamecraftModdingAPI/Blocks/ConsoleBlock.cs @@ -10,7 +10,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class ConsoleBlock : Block + public class ConsoleBlock : SignalingBlock { public ConsoleBlock(EGID id): base(id) { diff --git a/GamecraftModdingAPI/Blocks/Motor.cs b/GamecraftModdingAPI/Blocks/Motor.cs index fdadd26..3c38a52 100644 --- a/GamecraftModdingAPI/Blocks/Motor.cs +++ b/GamecraftModdingAPI/Blocks/Motor.cs @@ -9,7 +9,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class Motor : Block + public class Motor : SignalingBlock { public Motor(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/MusicBlock.cs b/GamecraftModdingAPI/Blocks/MusicBlock.cs index 2128a45..185913b 100644 --- a/GamecraftModdingAPI/Blocks/MusicBlock.cs +++ b/GamecraftModdingAPI/Blocks/MusicBlock.cs @@ -14,7 +14,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class MusicBlock : Block + public class MusicBlock : SignalingBlock { public MusicBlock(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/Piston.cs b/GamecraftModdingAPI/Blocks/Piston.cs index aed8c33..c3f2497 100644 --- a/GamecraftModdingAPI/Blocks/Piston.cs +++ b/GamecraftModdingAPI/Blocks/Piston.cs @@ -9,7 +9,7 @@ using RobocraftX.Common; namespace GamecraftModdingAPI.Blocks { - public class Piston : Block + public class Piston : SignalingBlock { public Piston(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/Servo.cs b/GamecraftModdingAPI/Blocks/Servo.cs index 730749a..1177fb6 100644 --- a/GamecraftModdingAPI/Blocks/Servo.cs +++ b/GamecraftModdingAPI/Blocks/Servo.cs @@ -9,7 +9,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class Servo : Block + public class Servo : SignalingBlock { public Servo(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/TextBlock.cs b/GamecraftModdingAPI/Blocks/TextBlock.cs index 6096dd4..e4b4c73 100644 --- a/GamecraftModdingAPI/Blocks/TextBlock.cs +++ b/GamecraftModdingAPI/Blocks/TextBlock.cs @@ -10,7 +10,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class TextBlock : Block + public class TextBlock : SignalingBlock { public TextBlock(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/Timer.cs b/GamecraftModdingAPI/Blocks/Timer.cs index 5766a41..1aeecd9 100644 --- a/GamecraftModdingAPI/Blocks/Timer.cs +++ b/GamecraftModdingAPI/Blocks/Timer.cs @@ -11,7 +11,7 @@ using GamecraftModdingAPI.Utility; namespace GamecraftModdingAPI.Blocks { - public class Timer : Block + public class Timer : SignalingBlock { public Timer(EGID id) : base(id) { diff --git a/GamecraftModdingAPI/Blocks/Wire.cs b/GamecraftModdingAPI/Blocks/Wire.cs index c29795f..e58a625 100644 --- a/GamecraftModdingAPI/Blocks/Wire.cs +++ b/GamecraftModdingAPI/Blocks/Wire.cs @@ -31,7 +31,7 @@ namespace GamecraftModdingAPI.Blocks public static Wire Connect(SignalingBlock start, byte startPort, SignalingBlock end, byte endPort) { WireEntityStruct wire = signalEngine.CreateNewWire(start.Id, startPort, end.Id, endPort); - return new Wire(wire); + return new Wire(wire, start, end); } /// @@ -173,15 +173,15 @@ namespace GamecraftModdingAPI.Blocks this.startPort = wire.sourcePortUsage; } - internal Wire(WireEntityStruct wire) + internal Wire(WireEntityStruct wire, SignalingBlock src, SignalingBlock dest) { this.wireEGID = wire.ID; this.startBlockEGID = wire.sourceBlockEGID; this.endBlockEGID = wire.destinationBlockEGID; inputToOutput = false; - endPortEGID = signalEngine.MatchBlockInputToPort(wire.destinationBlockEGID, wire.destinationPortUsage, out bool exists); + endPortEGID = signalEngine.MatchBlockInputToPort(dest, wire.destinationPortUsage, out bool exists); if (!exists) throw new WireInvalidException("Wire end port not found"); - startPortEGID = signalEngine.MatchBlockOutputToPort(wire.sourceBlockEGID, wire.sourcePortUsage, out exists); + 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; diff --git a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs index 7002605..4a5547f 100644 --- a/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs +++ b/GamecraftModdingAPI/Tests/GamecraftModdingAPIPluginTest.cs @@ -22,33 +22,29 @@ using GamecraftModdingAPI.Players; namespace GamecraftModdingAPI.Tests { +#if DEBUG // unused by design /// /// Modding API implemented as a standalone IPA Plugin. /// Ideally, GamecraftModdingAPI should be loaded by another mod; not itself /// - public class GamecraftModdingAPIPluginTest -#if DEBUG - : IllusionPlugin.IEnhancedPlugin -#endif + public class GamecraftModdingAPIPluginTest : IllusionPlugin.IEnhancedPlugin { private static Harmony harmony { get; set; } - public string[] Filter { get; } = new string[] { "Gamecraft", "GamecraftPreview" }; + public override string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; - public string Name { get; } = Assembly.GetExecutingAssembly().GetName().Name; - - public string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); + public override string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version.ToString(); public string HarmonyID { get; } = "org.git.exmods.modtainers.gamecraftmoddingapi"; - public void OnApplicationQuit() + public override void OnApplicationQuit() { GamecraftModdingAPI.Main.Shutdown(); } - public void OnApplicationStart() + public override void OnApplicationStart() { FileLog.Reset(); Harmony.DEBUG = true; @@ -387,16 +383,6 @@ namespace GamecraftModdingAPI.Tests } } - public void OnFixedUpdate() { } - - public void OnLateUpdate() { } - - public void OnLevelWasInitialized(int level) { } - - public void OnLevelWasLoaded(int level) { } - - public void OnUpdate() { } - [HarmonyPatch] public class MinimumSpecsPatch { @@ -411,4 +397,5 @@ namespace GamecraftModdingAPI.Tests } } } +#endif }