From 64aace3bdec62ffffd303f5d7a761bb835871045 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 2 Oct 2020 01:54:59 +0200 Subject: [PATCH] Remove ScalingEngine.Setup() and add object ID to dict --- GamecraftModdingAPI/Block.cs | 5 +---- GamecraftModdingAPI/Blocks/ScalingEngine.cs | 9 +++------ GamecraftModdingAPI/Events/GameActivatedComposePatch.cs | 2 -- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/GamecraftModdingAPI/Block.cs b/GamecraftModdingAPI/Block.cs index f827e09..f63e96c 100644 --- a/GamecraftModdingAPI/Block.cs +++ b/GamecraftModdingAPI/Block.cs @@ -120,6 +120,7 @@ namespace GamecraftModdingAPI {typeof(LogicGate), new [] {CommonExclusiveGroups.BUILD_LOGIC_BLOCK_GROUP}}, {typeof(Motor), new[] {CommonExclusiveGroups.BUILD_MOTOR_BLOCK_GROUP}}, {typeof(MusicBlock), new[] {CommonExclusiveGroups.BUILD_MUSIC_BLOCK_GROUP}}, + {typeof(ObjectIdentifier), new[]{CommonExclusiveGroups.BUILD_OBJID_BLOCK_GROUP}}, {typeof(Piston), new[] {CommonExclusiveGroups.BUILD_PISTON_BLOCK_GROUP}}, {typeof(Servo), new[] {CommonExclusiveGroups.BUILD_SERVO_BLOCK_GROUP}}, { @@ -460,9 +461,5 @@ namespace GamecraftModdingAPI } } #endif - internal static void Setup(World physicsWorld) - { - ScalingEngine.Setup(physicsWorld.EntityManager); - } } } \ No newline at end of file diff --git a/GamecraftModdingAPI/Blocks/ScalingEngine.cs b/GamecraftModdingAPI/Blocks/ScalingEngine.cs index a531865..fcbf900 100644 --- a/GamecraftModdingAPI/Blocks/ScalingEngine.cs +++ b/GamecraftModdingAPI/Blocks/ScalingEngine.cs @@ -27,10 +27,12 @@ namespace GamecraftModdingAPI.Blocks public string Name { get; } = "GamecraftModdingAPIScalingEngine"; public bool isRemovable { get; } = false; - private static EntityManager _entityManager; //Unity entity manager + private EntityManager _entityManager; //Unity entity manager public void UpdateCollision(EGID egid) { + if (_entityManager == default) + _entityManager = FullGameFields._physicsWorld.EntityManager; //Assuming the block exists var entity = entitiesDB.QueryEntity(egid).uecsEntity; var pes = new UECSPhysicsEntityCreationStruct(); @@ -38,11 +40,6 @@ namespace GamecraftModdingAPI.Blocks _entityManager.DestroyEntity(entity); } - internal void Setup(EntityManager entityManager) - { - _entityManager = entityManager; - } - [HarmonyPatch] public class PhysicsEnginePatch { diff --git a/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs b/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs index 4142fb3..c3a5fb5 100644 --- a/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs +++ b/GamecraftModdingAPI/Events/GameActivatedComposePatch.cs @@ -31,8 +31,6 @@ namespace GamecraftModdingAPI.Events GameEngineManager.RegisterEngines(enginesRoot); // initialize AsyncUtils AsyncUtils.Setup(enginesRoot); - // initialize Block - Block.Setup(physicsWorld); // A new EnginesRoot is always created when ActivateGame is called // so all event emitters and handlers must be re-registered. EventManager.RegisterEngines(enginesRoot);