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:
Norbi Peti 2020-12-13 20:21:46 +01:00
parent 78f0ea0162
commit 4e16f251ee

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using DataLoader;
using GamecraftModdingAPI.Utility;
using GPUInstancer;
using HarmonyLib;
using RobocraftX.Blocks;
@ -251,18 +252,28 @@ namespace GamecraftModdingAPI.Blocks
{
data = (physicsWorld, blobStore);
//RobocraftX.CR.MachineEditing.UpdateSelectedGhostBlockEngine.UpdateGhostBlock
var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null);
cld.cubeType = CubeType.Block;
cld.cubeCategory = CubeCategory.General;
cld.inventoryCategory = InventoryCategory.Shapes;
cld.ID = 500;
cld.Path = "Assets/Prefabs/Cube.prefab"; //Index out of range exception: Asset failed to load (wrong path)
cld.SpriteName = "CTR_CommandBlock";
cld.CubeNameKey = "strConsoleBlock";
cld.SelectableFaces = new[] {0, 1, 2, 3, 4, 5};
cld.GridScale = new[] {1, 1, 1};
cld.Mass = 1;
cld.JointBreakAngle = 1;
//var cld = (CubeListData) ((DataImplementor) dataDB).CreateDataObject("500", typeof(CubeListData), null);
var abd = dataDB.GetValue<CubeListData>((int) BlockIDs.AluminiumCube);
var cld = new CubeListData
{
cubeType = CubeType.Block,
cubeCategory = CubeCategory.General,
inventoryCategory = InventoryCategory.Shapes,
ID = 500,
Path = "Assets/Prefabs/Cube.prefab", //Index out of range exception: Asset failed to load (wrong path)
SpriteName = "CTR_CommandBlock",
CubeNameKey = "strConsoleBlock",
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()