Fix issues and add new block IDs

This commit is contained in:
Norbi Peti 2020-02-08 22:05:16 +01:00
parent 878ebdb491
commit eba490fbe8
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
5 changed files with 32 additions and 12 deletions

View file

@ -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,

View file

@ -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;
}

View file

@ -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};

View file

@ -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
{
/// <summary>
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
/// </summary>
[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));
}
}
}

View file

@ -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();
}
}
}