Browse Source

Fix tests and add new materials

tags/v2.0
NorbiPeti 2 years ago
parent
commit
52ccbe4dad
5 changed files with 19 additions and 7 deletions
  1. +9
    -1
      TechbloxModdingAPI/Blocks/BlockMaterial.cs
  2. +3
    -2
      TechbloxModdingAPI/Blocks/BlockTests.cs
  3. +0
    -3
      TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs
  4. +1
    -1
      TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs
  5. +6
    -0
      TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs

+ 9
- 1
TechbloxModdingAPI/Blocks/BlockMaterial.cs View File

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

+ 3
- 2
TechbloxModdingAPI/Blocks/BlockTests.cs 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;
}


+ 0
- 3
TechbloxModdingAPI/Blocks/Engines/BlockEngine.cs 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)


+ 1
- 1
TechbloxModdingAPI/Persistence/DeserializeFromDiskEntitiesEnginePatch.cs View File

@@ -12,7 +12,7 @@ using TechbloxModdingAPI.Utility;

namespace TechbloxModdingAPI.Persistence
{
[HarmonyPatch]
//[HarmonyPatch] - TODO
class DeserializeFromDiskEntitiesEnginePatch
{
internal static EntitiesDB entitiesDB = null;


+ 6
- 0
TechbloxModdingAPI/Tests/TechbloxModdingAPIPluginTest.cs 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


Loading…
Cancel
Save