It works! It places a pink axle
This commit is contained in:
parent
a122b38bf9
commit
ac75bdd371
3 changed files with 49 additions and 6 deletions
|
@ -26,7 +26,7 @@ namespace GCMC
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEntitiesDB entitiesDB { get; set; }
|
public IEntitiesDB entitiesDB { get; set; }
|
||||||
private readonly BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine - TODO
|
internal static BlockEntityFactory _blockEntityFactory; //Injected from PlaceBlockEngine
|
||||||
|
|
||||||
private void ImportWorld(string name)
|
private void ImportWorld(string name)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,8 @@ namespace GCMC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlaceBlock(ushort block, byte color, uint playerId)
|
private void PlaceBlock(ushort block, byte color, uint playerId)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
BuildBlock(block, color).Init(new BlockPlacementInfoStruct()
|
BuildBlock(block, color).Init(new BlockPlacementInfoStruct()
|
||||||
{
|
{
|
||||||
|
@ -41,9 +43,17 @@ namespace GCMC
|
||||||
placedBy = playerId
|
placedBy = playerId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e);
|
||||||
|
Log.Error(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private EntityStructInitializer BuildBlock(ushort block, byte color)
|
private EntityStructInitializer BuildBlock(ushort block, byte color)
|
||||||
{
|
{
|
||||||
|
if (_blockEntityFactory == null)
|
||||||
|
throw new Exception("The factory is null.");
|
||||||
//RobocraftX.CR.MachineEditing.PlaceBlockEngine
|
//RobocraftX.CR.MachineEditing.PlaceBlockEngine
|
||||||
ScalingEntityStruct scaling = new ScalingEntityStruct {scale = new float3(1, 1, 1)};
|
ScalingEntityStruct scaling = new ScalingEntityStruct {scale = new float3(1, 1, 1)};
|
||||||
RotationEntityStruct rotation = new RotationEntityStruct {rotation = quaternion.identity};
|
RotationEntityStruct rotation = new RotationEntityStruct {rotation = quaternion.identity};
|
||||||
|
@ -99,6 +109,6 @@ namespace GCMC
|
||||||
return new JobHandle();
|
return new JobHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string name { get; }
|
public string name { get; } = "Cube placer engine";
|
||||||
}
|
}
|
||||||
}
|
}
|
31
GCMC/FactoryObtainerPatch.cs
Normal file
31
GCMC/FactoryObtainerPatch.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using DataLoader;
|
||||||
|
using Harmony;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using RobocraftX.Blocks;
|
||||||
|
using RobocraftX.Blocks.GUI;
|
||||||
|
using RobocraftX.Common;
|
||||||
|
using RobocraftX.CR.MachineEditing;
|
||||||
|
using RobocraftX.StateSync;
|
||||||
|
using Svelto.ECS;
|
||||||
|
using Unity.Entities;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace GCMC
|
||||||
|
{
|
||||||
|
[HarmonyPatch]
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class FactoryObtainerPatch
|
||||||
|
{
|
||||||
|
static void Postfix(BlockEntityFactory blockEntityFactory)
|
||||||
|
{
|
||||||
|
CubePlacerEngine._blockEntityFactory = blockEntityFactory;
|
||||||
|
Debug.Log("Block entity factory injected.");
|
||||||
|
}
|
||||||
|
|
||||||
|
static MethodBase TargetMethod(HarmonyInstance instance)
|
||||||
|
{
|
||||||
|
return typeof(PlaceBlockEngine).GetConstructors()[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using DataLoader;
|
using DataLoader;
|
||||||
using Harmony;
|
using Harmony;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using RobocraftX.Blocks.GUI;
|
using RobocraftX.Blocks.GUI;
|
||||||
using RobocraftX.Common;
|
using RobocraftX.Common;
|
||||||
using RobocraftX.CR.MachineEditing;
|
using RobocraftX.CR.MachineEditing;
|
||||||
|
@ -12,6 +13,7 @@ using UnityEngine;
|
||||||
namespace GCMC
|
namespace GCMC
|
||||||
{
|
{
|
||||||
[HarmonyPatch]
|
[HarmonyPatch]
|
||||||
|
[UsedImplicitly]
|
||||||
public class PlaceBlockPatch
|
public class PlaceBlockPatch
|
||||||
{
|
{
|
||||||
static void Postfix(EnginesRoot enginesRoot, ref StateSyncRegistrationHelper stateSyncReg, bool isAuthoritative)
|
static void Postfix(EnginesRoot enginesRoot, ref StateSyncRegistrationHelper stateSyncReg, bool isAuthoritative)
|
||||||
|
|
Loading…
Reference in a new issue