Fix issues and add new block IDs
This commit is contained in:
parent
878ebdb491
commit
eba490fbe8
5 changed files with 32 additions and 12 deletions
|
@ -7,8 +7,7 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
{
|
{
|
||||||
AluminiumCube,
|
AluminiumCube,
|
||||||
AxleS,
|
AxleS,
|
||||||
Battery,
|
HingeS = 3,
|
||||||
HingeS,
|
|
||||||
MotorS,
|
MotorS,
|
||||||
HingeM,
|
HingeM,
|
||||||
MotorM,
|
MotorM,
|
||||||
|
@ -68,8 +67,7 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
GlassConeSegment,
|
GlassConeSegment,
|
||||||
GlassCylinder,
|
GlassCylinder,
|
||||||
GlassSphere,
|
GlassSphere,
|
||||||
Lever,
|
Lever, //63 - two IDs skipped
|
||||||
Reactor, //64 - one ID is skipped
|
|
||||||
PlayerSpawn = 66, //Crashes without special handling
|
PlayerSpawn = 66, //Crashes without special handling
|
||||||
SmallSpawn,
|
SmallSpawn,
|
||||||
MediumSpawn,
|
MediumSpawn,
|
||||||
|
@ -154,6 +152,17 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
ConcreteSlicedCube,
|
ConcreteSlicedCube,
|
||||||
ConcreteSlope,
|
ConcreteSlope,
|
||||||
ConcreteCorner,
|
ConcreteCorner,
|
||||||
|
RoadCarTyre,
|
||||||
|
OffRoadCarTyre,
|
||||||
|
RacingCarTyre,
|
||||||
|
BicycleTyre,
|
||||||
|
FrontBikeTyre,
|
||||||
|
RearBikeTyre,
|
||||||
|
ChopperBikeTyre,
|
||||||
|
TractorTyre,
|
||||||
|
MonsterTruckTyre,
|
||||||
|
MotocrossBikeTyre,
|
||||||
|
CartTyre,
|
||||||
BeachTree1 = 200,
|
BeachTree1 = 200,
|
||||||
BeachTree2,
|
BeachTree2,
|
||||||
BeachTree3,
|
BeachTree3,
|
||||||
|
|
|
@ -38,8 +38,9 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
uREPL.Log.Output(e.Message);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Logging.LogException(e);
|
//Logging.LogException(e);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,9 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
if (scale.x < 4e-5) scale.x = uscale;
|
if (scale.x < 4e-5) scale.x = uscale;
|
||||||
if (scale.y < 4e-5) scale.y = uscale;
|
if (scale.y < 4e-5) scale.y = uscale;
|
||||||
if (scale.z < 4e-5) scale.z = 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
|
//RobocraftX.CR.MachineEditing.PlaceBlockEngine
|
||||||
ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale};
|
ScalingEntityStruct scaling = new ScalingEntityStruct {scale = scale};
|
||||||
Quaternion rotQ = Quaternion.Euler(rot);
|
Quaternion rotQ = Quaternion.Euler(rot);
|
||||||
|
@ -74,7 +77,6 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
{position = position, rotation = rotQ};
|
{position = position, rotation = rotQ};
|
||||||
CubeCategoryStruct category = new CubeCategoryStruct
|
CubeCategoryStruct category = new CubeCategoryStruct
|
||||||
{category = CubeCategory.General, type = CubeType.Block};
|
{category = CubeCategory.General, type = CubeType.Block};
|
||||||
uint dbid = block;
|
|
||||||
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid};
|
DBEntityStruct dbEntity = new DBEntityStruct {DBID = dbid};
|
||||||
uint num = PrefabsID.DBIDMAP[dbid];
|
uint num = PrefabsID.DBIDMAP[dbid];
|
||||||
GFXPrefabEntityStructGO gfx = new GFXPrefabEntityStructGO {prefabID = num};
|
GFXPrefabEntityStructGO gfx = new GFXPrefabEntityStructGO {prefabID = num};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -9,24 +10,31 @@ using RobocraftX;
|
||||||
using Svelto.ECS;
|
using Svelto.ECS;
|
||||||
|
|
||||||
using GamecraftModdingAPI.Utility;
|
using GamecraftModdingAPI.Utility;
|
||||||
|
using RobocraftX.CR.MainGame;
|
||||||
|
|
||||||
namespace GamecraftModdingAPI.Events
|
namespace GamecraftModdingAPI.Events
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
|
/// Patch of RobocraftX.FullGameCompositionRoot.ActivateGame()
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(FullGameCompositionRoot), "ActivateGame")]
|
[HarmonyPatch]
|
||||||
class GameActivatedPatch
|
class GameActivatedPatch
|
||||||
{
|
{
|
||||||
public static void Postfix(ref EnginesRoot ____mainGameEnginesRoot)
|
public static void Postfix(ref EnginesRoot enginesRoot)
|
||||||
{
|
{
|
||||||
// register custom game engines
|
// register custom game engines
|
||||||
GameEngineManager.RegisterEngines(____mainGameEnginesRoot);
|
GameEngineManager.RegisterEngines(enginesRoot);
|
||||||
// A new EnginesRoot is always created when ActivateGame is called
|
// A new EnginesRoot is always created when ActivateGame is called
|
||||||
// so all event emitters and handlers must be re-registered.
|
// so all event emitters and handlers must be re-registered.
|
||||||
EventManager.RegisterEngines(____mainGameEnginesRoot);
|
EventManager.RegisterEngines(enginesRoot);
|
||||||
Logging.Log("Dispatching Game Activated event");
|
Logging.Log("Dispatching Game Activated event");
|
||||||
EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
|
EventManager.GetEventEmitter("GamecraftModdingAPIGameActivatedEventEmitter").Emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MethodBase TargetMethod()
|
||||||
|
{
|
||||||
|
return typeof(MainGameCompositionRoot).GetMethods().First(m => m.Name == "Compose")
|
||||||
|
.MakeGenericMethod(typeof(object));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace GamecraftModdingAPI.Events
|
||||||
public static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
// Event emitters and handlers should already be registered by GameActivated event
|
// Event emitters and handlers should already be registered by GameActivated event
|
||||||
Logging.Log("Dispatching Game Switched To event");
|
Logging.Log("Not dispatching Game Switched To event");
|
||||||
EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit();
|
//EventManager.GetEventEmitter("GamecraftModdingAPIGameSwitchedToEventEmitter").Emit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue