From 78f0ea01620cbb590588380a7e3c4bb8bf359eaf Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 12 Dec 2020 23:08:56 +0100 Subject: [PATCH] Use the intended method to create a CubeListData The block can be selected but not placed --- GamecraftModdingAPI/Blocks/CustomBlock.cs | 31 ++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/GamecraftModdingAPI/Blocks/CustomBlock.cs b/GamecraftModdingAPI/Blocks/CustomBlock.cs index 2cf6b72..7a79345 100644 --- a/GamecraftModdingAPI/Blocks/CustomBlock.cs +++ b/GamecraftModdingAPI/Blocks/CustomBlock.cs @@ -111,9 +111,8 @@ namespace GamecraftModdingAPI.Blocks /*var res = Addressables.LoadContentCatalogAsync("customCatalog.json"); while (!res.IsDone) yield return Yield.It;*/ - for (int i = 0; i < prefabData.Count; i++) + foreach (var gameObject in prefabs) { - var gameObject = prefabs[i]; switch (gameObject.name) { case "Cube": @@ -251,21 +250,19 @@ namespace GamecraftModdingAPI.Blocks public static void Prefix(World physicsWorld, BlobAssetStore blobStore, IDataDB dataDB) { data = (physicsWorld, blobStore); - var blocks = dataDB.GetValues(); - blocks.Add("modded_ConsoleBlock", new CubeListData - { - cubeType = CubeType.Block, - cubeCategory = CubeCategory.ConsoleBlock, - inventoryCategory = InventoryCategory.Logic, - 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 - }); + //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; } public static MethodBase TargetMethod()