From 52ccbe4dad8090f5be8f524e833c4779273f9c27 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Thu, 10 Jun 2021 23:57:06 +0200 Subject: [PATCH] Fix tests and add new materials --- TechbloxModdingAPI/Blocks/BlockMaterial.cs | 10 +++++++++- TechbloxModdingAPI/Blocks/BlockTests.cs | 5 +++-- TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs | 3 --- .../DeserializeFromDiskEntitiesEnginePatch.cs | 2 +- .../Tests/TechbloxModdingAPIPluginTest.cs | 6 ++++++ 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/TechbloxModdingAPI/Blocks/BlockMaterial.cs b/TechbloxModdingAPI/Blocks/BlockMaterial.cs index 6d00823..7093066 100644 --- a/TechbloxModdingAPI/Blocks/BlockMaterial.cs +++ b/TechbloxModdingAPI/Blocks/BlockMaterial.cs @@ -7,6 +7,14 @@ namespace TechbloxModdingAPI.Blocks RigidSteel, CarbonFiber, Plastic, - Wood = 6 + Wood = 6, + RigidSteelPainted, + RigidSteelRustedPaint, + RigidSteelHeavyRust, + SteelBodyworkMetallicPaint, + SteelBodyworkRustedPaint, + SteelBodyworkHeavyRust, + WoodVarnishedDark, + Chrome } } \ No newline at end of file diff --git a/TechbloxModdingAPI/Blocks/BlockTests.cs b/TechbloxModdingAPI/Blocks/BlockTests.cs index 42e8910..536a819 100644 --- a/TechbloxModdingAPI/Blocks/BlockTests.cs +++ b/TechbloxModdingAPI/Blocks/BlockTests.cs @@ -72,6 +72,7 @@ namespace TechbloxModdingAPI.Blocks public static IEnumerator TestBlockProperties() { //Uses the result of the previous test case var blocks = Game.CurrentGame().GetBlocksInGame(); + yield return Yield.It; for (var index = 0; index < blocks.Length; index++) { if (index % 50 == 0) yield return Yield.It; //The material or flipped status can only be changed 130 times per submission @@ -140,8 +141,8 @@ namespace TechbloxModdingAPI.Blocks Block newBlock = Block.PlaceNew(BlockIDs.DampedSpring, Unity.Mathematics.float3.zero + 1); DampedSpring b = null; // Note: the assignment operation is a lambda, which slightly confuses the compiler Assert.Errorless(() => { b = (DampedSpring) newBlock; }, "Casting block to DampedSpring raised an exception: ", "Casting block to DampedSpring completed without issue."); - if (!Assert.CloseTo(b.Stiffness, 30f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; - if (!Assert.CloseTo(b.Damping, 30f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; + if (!Assert.CloseTo(b.Stiffness, 1f, $"DampedSpring.Stiffness {b.Stiffness} does not equal default value, possibly because it failed silently.", "DampedSpring.Stiffness is close enough to default.")) return; + if (!Assert.CloseTo(b.Damping, 0.1f, $"DampedSpring.Damping {b.Damping} does not equal default value, possibly because it failed silently.", "DampedSpring.Damping is close enough to default.")) return; if (!Assert.CloseTo(b.MaxExtension, 0.3f, $"DampedSpring.MaxExtension {b.MaxExtension} does not equal default value, possibly because it failed silently.", "DampedSpring.MaxExtension is close enough to default.")) return; } diff --git a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs index 39ab2fb..26be582 100644 --- a/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs +++ b/TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs @@ -117,9 +117,6 @@ namespace TechbloxModdingAPI.Blocks.Engines if (block.Exists) entitiesDB.PublishEntityChange(block.Id); //Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData - /*Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues() - .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") - .Aggregate((a, b) => a + "\n" + b));*/ } public bool BlockExists(EGID blockID) diff --git a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs index 166f744..6219ed1 100644 --- a/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs +++ b/TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs @@ -12,7 +12,7 @@ using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Persistence { - [HarmonyPatch] + //[HarmonyPatch] - TODO class DeserializeFromDiskEntitiesEnginePatch { internal static EntitiesDB entitiesDB = null; diff --git a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs index 6a06e42..5bd3a7f 100644 --- a/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs +++ b/TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs @@ -276,6 +276,12 @@ namespace TechbloxModdingAPI.Tests lastKey = currentKey; } };*/ + /*Game.Enter += (sender, e) => + { + Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues() + .Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}") + .Aggregate((a, b) => a + "\n" + b)); + };*/ #if TEST TestRoot.RunTests(); #endif