Don't use the intended method to create a CubeListData
It adds it with its ID as key but the ID hasn't been set at that point It works until the second simulation start now
This commit is contained in:
parent
78f0ea0162
commit
4e16f251ee
1 changed files with 24 additions and 13 deletions
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using DataLoader;
|
using DataLoader;
|
||||||
|
using GamecraftModdingAPI.Utility;
|
||||||
using GPUInstancer;
|
using GPUInstancer;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using RobocraftX.Blocks;
|
using RobocraftX.Blocks;
|
||||||
|
@ -246,23 +247,33 @@ namespace GamecraftModdingAPI.Blocks
|
||||||
[HarmonyPatch]
|
[HarmonyPatch]
|
||||||
public static class MGPatch
|
public static class MGPatch
|
||||||
{
|
{
|
||||||
internal static (World, BlobAssetStore) data;
|
internal static (World, BlobAssetStore) data;
|
||||||
public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB)
|
public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB)
|
||||||
{
|
{
|
||||||
data = (physicsWorld, blobStore);
|
data = (physicsWorld, blobStore);
|
||||||
//RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock
|
//RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock
|
||||||
var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null);
|
//var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null);
|
||||||
cld.cubeType = CubeType.Block;
|
var abd = dataDB.GetValue<CubeListData>((int) BlockIDs.AluminiumCube);
|
||||||
cld.cubeCategory = CubeCategory.General;
|
var cld = new CubeListData
|
||||||
cld.inventoryCategory = InventoryCategory.Shapes;
|
{
|
||||||
cld.ID = 500;
|
cubeType = CubeType.Block,
|
||||||
cld.Path = "Assets/Prefabs/Cube.prefab"; //Index out of range exception: Asset failed to load (wrong path)
|
cubeCategory = CubeCategory.General,
|
||||||
cld.SpriteName = "CTR_CommandBlock";
|
inventoryCategory = InventoryCategory.Shapes,
|
||||||
cld.CubeNameKey = "strConsoleBlock";
|
ID = 500,
|
||||||
cld.SelectableFaces = new[] {0, 1, 2, 3, 4, 5};
|
Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path)
|
||||||
cld.GridScale = new[] {1, 1, 1};
|
SpriteName = "CTR_CommandBlock",
|
||||||
cld.Mass = 1;
|
CubeNameKey = "strConsoleBlock",
|
||||||
cld.JointBreakAngle = 1;
|
SelectableFaces = new[] {0, 1, 2, 3, 4, 5},
|
||||||
|
GridScale = new[] {1, 1, 1},
|
||||||
|
Mass = 1,
|
||||||
|
JointBreakAngle = 1,
|
||||||
|
Material = abd.Material
|
||||||
|
};
|
||||||
|
Console.WriteLine("Aluminium block data:\n" + abd);
|
||||||
|
Console.WriteLine("Material: " + abd.Material);
|
||||||
|
dataDB.GetValues<CubeListData>().Add("500", cld); //The registration needs to happen after the ID has been set
|
||||||
|
dataDB.GetFasterValues<CubeListData>().Add(500, cld);
|
||||||
|
//RobocraftX.ExplosionFragments.Engines.PlayFragmentExplodeEngine.PlayRigidBodyEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MethodBase TargetMethod()
|
public static MethodBase TargetMethod()
|
||||||
|
|
Loading…
Reference in a new issue