diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs index cbe581d..4915041 100644 --- a/GamecraftModdingAPI/Blocks/BlockIDs.cs +++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs @@ -7,8 +7,7 @@ namespace GamecraftModdingAPI.Blocks { AluminiumCube, AxleS, - Battery, - HingeS, + HingeS = 3, MotorS, HingeM, MotorM, @@ -68,8 +67,7 @@ namespace GamecraftModdingAPI.Blocks GlassConeSegment, GlassCylinder, GlassSphere, - Lever, - Reactor, //64 - one ID is skipped + Lever, //63 - two IDs skipped PlayerSpawn = 66, //Crashes without special handling SmallSpawn, MediumSpawn, @@ -154,6 +152,17 @@ namespace GamecraftModdingAPI.Blocks ConcreteSlicedCube, ConcreteSlope, ConcreteCorner, + RoadCarTyre, + OffRoadCarTyre, + RacingCarTyre, + BicycleTyre, + FrontBikeTyre, + RearBikeTyre, + ChopperBikeTyre, + TractorTyre, + MonsterTruckTyre, + MotocrossBikeTyre, + CartTyre, BeachTree1 = 200, BeachTree2, BeachTree3, diff --git a/GamecraftModdingAPI/Blocks/Placement.cs b/GamecraftModdingAPI/Blocks/Placement.cs index d91d214..4e3083b 100644 --- a/GamecraftModdingAPI/Blocks/Placement.cs +++ b/GamecraftModdingAPI/Blocks/Placement.cs @@ -38,8 +38,9 @@ namespace GamecraftModdingAPI.Blocks } catch (Exception e) { + uREPL.Log.Output(e.Message); #if DEBUG - Logging.LogException(e); + //Logging.LogException(e); #endif return false; } diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs index 0bcf890..683d14f 100644 --- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs +++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs @@ -66,6 +66,9 @@ namespace GamecraftModdingAPI.Blocks if (scale.x < 4e-5) scale.x = uscale; if (scale.y < 4e-5) scale.y = uscale; if (scale.z < 4e-5) scale.z = uscale; + uint dbid = block; + if (!PrefabsID.DBIDMAP.ContainsKey(dbid)) + throw new Exception("Block with ID " + dbid + " not found!"); //RobocraftX.CR.MachineEditing.PlaceBlockEngine ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale}; Quaternion rotQ = Quaternion.Euler(rot); @@ -74,7 +77,6 @@ namespace GamecraftModdingAPI.Blocks {position = position, rotation = rotQ}; CubeCategoryStruct category = new CubeCategoryStruct {category = CubeCategory.General, type = CubeType.Block}; - uint dbid = block; DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid}; uint num = PrefabsID.DBIDMAP[dbid]; GFXPrefabEntityStructGO gfx = new GFXPrefabEntityStructGO {prefabID = num}; diff --git a/GamecraftModdingAPI/Events/GameActivatedPatch.cs b/GamecraftModdingAPI/Events/GameActivatedPatch.cs index b85a6e6..13f4c59 100644 --- a/GamecraftModdingAPI/Events/GameActivatedPatch.cs +++ b/GamecraftModdingAPI/Events/GameActivatedPatch.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -9,24 +10,31 @@ using RobocraftX; using Svelto.ECS; using GamecraftModdingAPI.Utility; +using RobocraftX.CR.MainGame; namespace GamecraftModdingAPI.Events { /// /// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame() /// - [HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")] + [HarmonyPatch] class GameActivatedPatch { - public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot) + public static void Postfix(ref EnginesRoot enginesRoot) { // register custom game engines - GameEngineManager.RegisterEngines(____mainGameEnginesRoot); + GameEngineManager.RegisterEngines(enginesRoot); // A new EnginesRoot is always created when ActivateGame is called // so all event emitters and handlers must be re-registered. - EventManager.RegisterEngines(____mainGameEnginesRoot); + EventManager.RegisterEngines(enginesRoot); Logging.Log("Dispatching Game Activated event"); EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit(); } + + public static MethodBase TargetMethod() + { + return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose") + .MakeGenericMethod(typeof(object)); + } } } diff --git a/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs b/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs index 04cf065..69b6aff 100644 --- a/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs +++ b/GamecraftModdingAPI/Events/GameSwitchedToPatch.cs @@ -20,8 +20,8 @@ namespace GamecraftModdingAPI.Events public static void Postfix() { // Event emitters and handlers should already be registered by GameActivated event - Logging.Log("Dispatching Game Switched To event"); - EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit(); + Logging.Log("Not dispatching Game Switched To event"); + //EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit(); } } }