Fix tests and add new materials

This commit is contained in:
Norbi Peti 2021-06-10 23:57:06 +02:00
parent 0b2ffef0d3
commit 52ccbe4dad
5 changed files with 19 additions and 7 deletions

View file

@ -7,6 +7,14 @@ namespace TechbloxModdingAPI.Blocks
RigidSteel,
CarbonFiber,
Plastic,
Wood = 6
Wood = 6,
RigidSteelPainted,
RigidSteelRustedPaint,
RigidSteelHeavyRust,
SteelBodyworkMetallicPaint,
SteelBodyworkRustedPaint,
SteelBodyworkHeavyRust,
WoodVarnishedDark,
Chrome
}
}

View file

@ -72,6 +72,7 @@ namespace TechbloxModdingAPI.Blocks
public static IEnumerator<TaskContract> 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;
}

View file

@ -117,9 +117,6 @@ namespace TechbloxModdingAPI.Blocks.Engines
if (block.Exists)
entitiesDB.PublishEntityChange<GFXPrefabEntityStructGPUI>(block.Id);
//Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData
/*Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues<MaterialPropertiesData>()
.Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}")
.Aggregate((a, b) => a + "\n" + b));*/
}
public bool BlockExists(EGID blockID)

View file

@ -12,7 +12,7 @@ using TechbloxModdingAPI.Utility;
namespace TechbloxModdingAPI.Persistence
{
[HarmonyPatch]
//[HarmonyPatch] - TODO
class DeserializeFromDiskEntitiesEnginePatch
{
internal static EntitiesDB entitiesDB = null;

View file

@ -276,6 +276,12 @@ namespace TechbloxModdingAPI.Tests
lastKey = currentKey;
}
};*/
/*Game.Enter += (sender, e) =>
{
Console.WriteLine("Materials:\n" + FullGameFields._dataDb.GetValues<MaterialPropertiesData>()
.Select(kv => $"{kv.Key}: {((MaterialPropertiesData) kv.Value).Name}")
.Aggregate((a, b) => a + "\n" + b));
};*/
#if TEST
TestRoot.RunTests();
#endif