Browse Source

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
tags/v1.8.0
NorbiPeti 4 years ago
parent
commit
4e16f251ee
1 changed files with 24 additions and 13 deletions
  1. +24
    -13
      GamecraftModdingAPI/Blocks/CustomBlock.cs

+ 24
- 13
GamecraftModdingAPI/Blocks/CustomBlock.cs 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;
@@ -246,23 +247,33 @@ namespace GamecraftModdingAPI.Blocks
[HarmonyPatch]
public static class MGPatch
{
internal static (World, BlobAssetStore) data;
internal static (World, BlobAssetStore) data;
public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB)
{
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()


Loading…
Cancel
Save