Browse Source

Fix issues and add new block IDs

tags/v0.1.3.0
NorbiPeti 4 years ago
parent
commit
eba490fbe8
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
5 changed files with 32 additions and 12 deletions
  1. +13
    -4
      GamecraftModdingAPI/Blocks/BlockIDs.cs
  2. +2
    -1
      GamecraftModdingAPI/Blocks/Placement.cs
  3. +3
    -1
      GamecraftModdingAPI/Blocks/PlacementEngine.cs
  4. +12
    -4
      GamecraftModdingAPI/Events/GameActivatedPatch.cs
  5. +2
    -2
      GamecraftModdingAPI/Events/GameSwitchedToPatch.cs

+ 13
- 4
GamecraftModdingAPI/Blocks/BlockIDs.cs 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,


+ 2
- 1
GamecraftModdingAPI/Blocks/Placement.cs 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;
}


+ 3
- 1
GamecraftModdingAPI/Blocks/PlacementEngine.cs 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};


+ 12
- 4
GamecraftModdingAPI/Events/GameActivatedPatch.cs 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));
}
}
}

+ 2
- 2
GamecraftModdingAPI/Events/GameSwitchedToPatch.cs 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();
}
}
}

Loading…
Cancel
Save