Restore the stable legacy Unity project
This commit is contained in:
parent
56a156ee87
commit
7006a6b0dd
2070 changed files with 180490 additions and 169303 deletions
|
|
@ -1,41 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using NUnit.Framework;
|
||||
|
||||
public sealed class AetheriaRuntimeAssetBundleLayoutTests
|
||||
{
|
||||
[Test]
|
||||
public void SharedPresentationAssetsHaveStableBundleOwners()
|
||||
{
|
||||
var manifest = AetheriaRuntimeAssets.ProjectManifest(null);
|
||||
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityShaderBundle, BundleFor("shader.environment.gravity-fog"));
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityShaderBundle, BundleFor("texture.environment.volume-dither"));
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityUiBundle, BundleFor("map.entity.player"));
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityUiBundle, BundleFor("font.ui.primary"));
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityCoreBundle, BundleFor("texture.environment.reflection"));
|
||||
Assert.AreEqual(AetheriaRuntimeAssets.UnityCoreBundle, BundleFor("texture.core.sun.surface-flow"));
|
||||
|
||||
string BundleFor(string assetKey)
|
||||
{
|
||||
var entry = manifest.Assets.Single(asset =>
|
||||
string.Equals(asset.Ref.AssetKey, assetKey, StringComparison.Ordinal));
|
||||
return AetheriaRuntimeAssets.ResolveUnityBundleName(entry);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntityContentIsPartitionedByAuthoredSource()
|
||||
{
|
||||
var manifest = AetheriaRuntimeAssets.ProjectManifest(null);
|
||||
var player = manifest.Assets.Single(asset => asset.Ref.AssetKey == "prefab.entity.player");
|
||||
var ship = manifest.Assets.Single(asset => asset.Ref.AssetKey == "prefab.entity.ship");
|
||||
var station = manifest.Assets.Single(asset => asset.Ref.AssetKey == "prefab.entity.station");
|
||||
|
||||
var playerBundle = AetheriaRuntimeAssets.ResolveUnityBundleName(player);
|
||||
Assert.AreEqual(playerBundle, AetheriaRuntimeAssets.ResolveUnityBundleName(ship));
|
||||
Assert.AreNotEqual(playerBundle, AetheriaRuntimeAssets.ResolveUnityBundleName(station));
|
||||
StringAssert.StartsWith("aetheria-content-", playerBundle);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20642d787904fb94aa7ae63109f417ce
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
using CultMath;
|
||||
using NUnit.Framework;
|
||||
using static CultMath.math;
|
||||
|
||||
public sealed class CultMathPrimitiveTests
|
||||
{
|
||||
[Test]
|
||||
public void Int2SupportsAetheriaGridArithmetic()
|
||||
{
|
||||
var cell = int2(2, 3);
|
||||
|
||||
Assert.AreEqual(new int2(3, 5), cell + int2(1, 2));
|
||||
Assert.AreEqual(new float2(2.0f, 3.0f), (float2)cell);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AetheriaMathRotatesItemDirectionsOnShipPlane()
|
||||
{
|
||||
var forward = float2(0, 1);
|
||||
|
||||
Assert.AreEqual(float2(-1, 0), AetheriaMath.Rotate(forward, ItemRotation.CounterClockwise));
|
||||
Assert.AreEqual(float2(0, -1), AetheriaMath.Rotate(forward, ItemRotation.Reversed));
|
||||
Assert.AreEqual(float2(1, 0), AetheriaMath.Rotate(forward, ItemRotation.Clockwise));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ItemRotationDirectionsAreCultVectors()
|
||||
{
|
||||
Assert.AreEqual(float2(0, 1), ItemRotation.None.Direction());
|
||||
Assert.AreEqual(float2(1, 0), ItemRotation.Clockwise.Direction());
|
||||
Assert.AreEqual(float2(0, -1), ItemRotation.Reversed.Direction());
|
||||
Assert.AreEqual(float2(-1, 0), ItemRotation.CounterClockwise.Direction());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AetheriaMathProjectsUnityVectorsOntoShipPlane()
|
||||
{
|
||||
var world = new Unity.Mathematics.float3(2, 99, 3);
|
||||
|
||||
Assert.AreEqual(float2(2, 3), AetheriaMath.ToCultXZ(world));
|
||||
Assert.AreEqual(new Unity.Mathematics.float3(2, 0, 3), AetheriaMath.ToUnityXZ(float2(2, 3)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AetheriaMathCalculatesStableAngles()
|
||||
{
|
||||
Assert.That(AetheriaMath.AngleDegrees(float2(1, 0), float2(0, 1)), Is.EqualTo(90).Within(0.0001f));
|
||||
Assert.That(AetheriaMath.AngleRadians(float2(1, 0), float2(0, 1)), Is.EqualTo(PI / 2).Within(0.0001f));
|
||||
Assert.That(AetheriaMath.AngleDegrees(float3(1, 0, 0), float3(1, 0, 0)), Is.EqualTo(0).Within(0.0001f));
|
||||
Assert.That(AetheriaMath.AngleDegrees(float3(0, 0, 0), float3(1, 0, 0)), Is.EqualTo(0).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ColorMathUsesCultVectorsAndSharedUnityBridge()
|
||||
{
|
||||
var rgb = ColorMath.HsvToRgb(float3(0, 1, 1));
|
||||
|
||||
Assert.AreEqual(float3(1, 0, 0), rgb);
|
||||
Assert.AreEqual(new Unity.Mathematics.float3(1, 0, 0), AetheriaMath.ToUnity(rgb));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RectNormalizesBoundsAndContainsPoints()
|
||||
{
|
||||
var viewport = rect(10, 20, -5, -2);
|
||||
|
||||
Assert.AreEqual(float2(-5, -2), viewport.min);
|
||||
Assert.AreEqual(float2(10, 20), viewport.max);
|
||||
Assert.AreEqual(float2(15, 22), viewport.size);
|
||||
Assert.AreEqual(float2(2.5f, 9), viewport.center);
|
||||
Assert.IsTrue(viewport.Contains(float2(0, 0)));
|
||||
Assert.IsFalse(viewport.Contains(float2(11, 0)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d4fc4667d3155a843b610a24d40fa6f0
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da50d4a5bedc04148a6912cff6d6f02d
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Mesh;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public class StarbridgePlayerSeatDocumentTests
|
||||
{
|
||||
[Test]
|
||||
public void StarbridgePlayerSeatRoundTripsCrashReconnectState()
|
||||
{
|
||||
var createdAt = DateTimeOffset.Parse("2026-06-27T10:00:00Z");
|
||||
var disconnectedAt = createdAt.AddMinutes(3);
|
||||
var reconnectedAt = disconnectedAt.AddMinutes(1);
|
||||
|
||||
var seat = AetheriaRuntimeStarbridgePlayerSeatDocument.Create(
|
||||
"seat-alpha",
|
||||
"player-7",
|
||||
"session-1",
|
||||
"scenario-1",
|
||||
"run-1",
|
||||
AetheriaRuntimeStarbridgePlayerSeatRoles.Support,
|
||||
"unity-runtime-old",
|
||||
createdAt);
|
||||
seat.PlayerDisplayName = "Vega";
|
||||
seat.ControlledEntityKey = "entity:ship:7";
|
||||
seat.ShipEntityKey = "entity:ship:7";
|
||||
seat.CockpitItemKey = "item:cockpit:7";
|
||||
seat.EscapePodEntityKey = "entity:pod:7";
|
||||
seat.LoadoutDocumentKey = "loadout:ship:7";
|
||||
seat.AuthorityLeaseId = "lease:seat-alpha";
|
||||
seat.ClaimKinds = new[] { AetheriaRuntimeClaimKinds.Movement, AetheriaRuntimeClaimKinds.Combat };
|
||||
|
||||
seat.MarkDisconnected(disconnectedAt);
|
||||
|
||||
Assert.AreEqual(AetheriaRuntimeStarbridgePlayerSeatConnectionStates.Grace, seat.ConnectionState);
|
||||
Assert.IsTrue(seat.IsResumeGraceActive(disconnectedAt.AddSeconds(30), TimeSpan.FromMinutes(2)));
|
||||
Assert.IsFalse(seat.IsResumeGraceActive(disconnectedAt.AddMinutes(3), TimeSpan.FromMinutes(2)));
|
||||
|
||||
seat.AttachRuntime("unity-runtime-new", reconnectedAt);
|
||||
|
||||
Assert.AreEqual(AetheriaRuntimeStarbridgePlayerSeatConnectionStates.Connected, seat.ConnectionState);
|
||||
Assert.AreEqual("unity-runtime-new", seat.RuntimeId);
|
||||
Assert.Contains("unity-runtime-old", seat.PreviousRuntimeIds);
|
||||
Assert.AreEqual("entity:ship:7", seat.ControlledEntityKey);
|
||||
Assert.AreEqual("item:cockpit:7", seat.CockpitItemKey);
|
||||
Assert.AreEqual("entity:pod:7", seat.EscapePodEntityKey);
|
||||
Assert.AreEqual("loadout:ship:7", seat.LoadoutDocumentKey);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StarbridgePlayerSeatCanBeReadAsManagedCultMeshDocument()
|
||||
{
|
||||
var statePath = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
"aetheria-starbridge-seat-reactive-tests",
|
||||
Path.GetRandomFileName(),
|
||||
"state.cc");
|
||||
var seat = AetheriaRuntimeStarbridgePlayerSeatDocument.Create(
|
||||
"seat-support",
|
||||
"player-support",
|
||||
"session-1",
|
||||
"scenario-1",
|
||||
"run-1",
|
||||
AetheriaRuntimeStarbridgePlayerSeatRoles.Support,
|
||||
"unity-support",
|
||||
DateTimeOffset.Parse("2026-06-27T11:00:00Z"));
|
||||
seat.CockpitItemKey = "item:cockpit:support";
|
||||
seat.EscapePodEntityKey = "entity:pod:support";
|
||||
|
||||
using var client = AetheriaRuntimeVerseClient
|
||||
.OpenAsync(statePath, "unity-support", startServer: false, pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
client
|
||||
.MutableDocument<AetheriaRuntimeStarbridgePlayerSeatDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seat.SeatId))
|
||||
.ReplaceAsync(seat)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var handle = client.Document<AetheriaRuntimeStarbridgePlayerSeatDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seat.SeatId));
|
||||
using var reactive = handle.Reactive();
|
||||
using var aetheriaSeat = client.Aetheria().StarbridgePlayerSeat(seat.SeatId).Reactive();
|
||||
|
||||
Assert.AreEqual("seat-support", handle.Latest().SeatId);
|
||||
Assert.AreEqual(
|
||||
"seat-support",
|
||||
ReadLatest(client.Aetheria().StarbridgePlayerSeat(seat.SeatId)).SeatId);
|
||||
Assert.AreEqual("item:cockpit:support", reactive.Current.CockpitItemKey);
|
||||
Assert.AreEqual("item:cockpit:support", aetheriaSeat.Current.CockpitItemKey);
|
||||
Assert.AreEqual("entity:pod:support", reactive.Current.EscapePodEntityKey);
|
||||
Assert.AreEqual("entity:pod:support", aetheriaSeat.Current.EscapePodEntityKey);
|
||||
Assert.AreEqual("unity-support", reactive.Document.Context.RuntimeId);
|
||||
}
|
||||
|
||||
private static TDocument ReadLatest<TDocument>(CultMeshDocumentHandle<TDocument> document)
|
||||
where TDocument : class
|
||||
{
|
||||
return document.LatestAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ea79e799fe047618b652b9d835a4425
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using NUnit.Framework;
|
||||
|
||||
public class StatRecipeSurfaceCommandTests
|
||||
{
|
||||
private const string TestUpdatedAtUtc = "2026-06-18T00:00:00.0000000Z";
|
||||
|
||||
[Test]
|
||||
public void ToggleConditionCreatesEnabledInfluenceForSelectedRecipe()
|
||||
{
|
||||
var state = StateWithRecipe();
|
||||
|
||||
var next = AetheriaRuntimeStatRecipes.ToggleCondition(
|
||||
state,
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Range,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
var influence = next.SelectedRecipe.Influences.Single();
|
||||
Assert.AreEqual(AetheriaRuntimeStatRecipeConditions.Range, influence.Condition);
|
||||
Assert.AreEqual(AetheriaRuntimeStatRecipeOperations.Add, influence.Operation);
|
||||
Assert.IsTrue(influence.Enabled);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CycleInfluenceOperationAdvancesAddMultiplyOverride()
|
||||
{
|
||||
var state = AetheriaRuntimeStatRecipes.ToggleCondition(
|
||||
StateWithRecipe(),
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Quality,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
state = AetheriaRuntimeStatRecipes.CycleInfluenceOperation(
|
||||
state,
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Quality,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
Assert.AreEqual(AetheriaRuntimeStatRecipeOperations.Multiply, state.SelectedRecipe.Influences[0].Operation);
|
||||
|
||||
state = AetheriaRuntimeStatRecipes.CycleInfluenceOperation(
|
||||
state,
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Quality,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
Assert.AreEqual(AetheriaRuntimeStatRecipeOperations.Override, state.SelectedRecipe.Influences[0].Operation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetInfluenceAmountAndCurveUpdateOnlyTargetInfluence()
|
||||
{
|
||||
var state = AetheriaRuntimeStatRecipes.ToggleCondition(
|
||||
StateWithRecipe(),
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Heat,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
state = AetheriaRuntimeStatRecipes.SetInfluenceAmount(
|
||||
state,
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Heat,
|
||||
3.5,
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
state = AetheriaRuntimeStatRecipes.SetInfluenceCurve(
|
||||
state,
|
||||
"weapon.damage",
|
||||
AetheriaRuntimeStatRecipeConditions.Heat,
|
||||
"easeOut",
|
||||
updatedAtUtc: TestUpdatedAtUtc);
|
||||
|
||||
var influence = state.SelectedRecipe.Influences.Single();
|
||||
Assert.AreEqual(3.5, influence.Amount, 0.0001);
|
||||
Assert.AreEqual("easeOut", influence.CurveLabel);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetPreviewConditionUpdatesRequestedPreviewAxis()
|
||||
{
|
||||
var next = AetheriaRuntimeStatRecipes.SetPreviewCondition(
|
||||
StateWithRecipe(),
|
||||
AetheriaRuntimeStatRecipeConditions.Charge,
|
||||
0.25,
|
||||
TestUpdatedAtUtc);
|
||||
|
||||
Assert.AreEqual(0.25, next.Preview.Charge, 0.0001);
|
||||
Assert.AreEqual(AetheriaRuntimeStatRecipePreviewState.Default.Quality, next.Preview.Quality, 0.0001);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeStatRecipeSurfaceState StateWithRecipe()
|
||||
{
|
||||
return new AetheriaRuntimeStatRecipeSurfaceState(
|
||||
new[]
|
||||
{
|
||||
new AetheriaRuntimeStatRecipeState(
|
||||
"weapon.damage",
|
||||
"Weapon Damage",
|
||||
10,
|
||||
new AetheriaRuntimeStatInfluenceState[0])
|
||||
},
|
||||
"Weapon Damage",
|
||||
AetheriaRuntimeStatRecipePreviewState.Default,
|
||||
"");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 45bf0c07c6a63554a949f3605ff81d13
|
||||
|
|
@ -1,254 +0,0 @@
|
|||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using NUnit.Framework;
|
||||
|
||||
public class StatRecipeTests
|
||||
{
|
||||
[Test]
|
||||
public void AddModifierScalesByConditionSample()
|
||||
{
|
||||
var recipe = new StatRecipe
|
||||
{
|
||||
BaseValue = 10,
|
||||
Modifiers = new[]
|
||||
{
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Quality,
|
||||
Operation = StatModifierOperation.Add,
|
||||
Amount = 6
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var value = recipe.Evaluate(new StatEvaluationContext(quality: 0.5f, durability: 1, heat: 1));
|
||||
|
||||
Assert.AreEqual(13, value, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultiplyModifierInterpolatesFromIdentity()
|
||||
{
|
||||
var recipe = new StatRecipe
|
||||
{
|
||||
BaseValue = 10,
|
||||
Modifiers = new[]
|
||||
{
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Durability,
|
||||
Operation = StatModifierOperation.Multiply,
|
||||
Amount = 2
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var value = recipe.Evaluate(new StatEvaluationContext(quality: 1, durability: 0.25f, heat: 1));
|
||||
|
||||
Assert.AreEqual(12.5f, value, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverrideModifierInterpolatesTowardTargetValue()
|
||||
{
|
||||
var recipe = new StatRecipe
|
||||
{
|
||||
BaseValue = 10,
|
||||
Modifiers = new[]
|
||||
{
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Heat,
|
||||
Operation = StatModifierOperation.Override,
|
||||
Amount = 20
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var value = recipe.Evaluate(new StatEvaluationContext(quality: 1, durability: 1, heat: 0.25f));
|
||||
|
||||
Assert.AreEqual(12.5f, value, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DependencyMaskOnlyIncludesEnabledConditions()
|
||||
{
|
||||
var recipe = new StatRecipe
|
||||
{
|
||||
Modifiers = new[]
|
||||
{
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Quality,
|
||||
Enabled = false
|
||||
},
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Range,
|
||||
Enabled = true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Assert.AreEqual(StatConditionMask.Range, recipe.DependencyMask);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DisabledAndConditionlessModifiersDoNotAffectEvaluation()
|
||||
{
|
||||
var recipe = new StatRecipe
|
||||
{
|
||||
BaseValue = 10,
|
||||
Modifiers = new[]
|
||||
{
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Quality,
|
||||
Operation = StatModifierOperation.Add,
|
||||
Amount = 100,
|
||||
Enabled = false
|
||||
},
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.None,
|
||||
Operation = StatModifierOperation.Add,
|
||||
Amount = 100,
|
||||
Enabled = true
|
||||
},
|
||||
new StatRecipeModifier
|
||||
{
|
||||
Condition = StatConditionMask.Heat,
|
||||
Operation = StatModifierOperation.Add,
|
||||
Amount = 4,
|
||||
Enabled = true
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var value = recipe.Evaluate(new StatEvaluationContext(quality: 1, durability: 1, heat: 0.25f));
|
||||
|
||||
Assert.AreEqual(11, value, 0.0001f);
|
||||
Assert.AreEqual(StatConditionMask.Heat, recipe.DependencyMask);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ContextOverrideReplacesSingleCondition()
|
||||
{
|
||||
var context = new StatEvaluationContext(quality: 0.2f, durability: 0.3f, heat: 0.4f, range: 0.5f);
|
||||
|
||||
var next = context.WithCondition(StatConditionMask.Range, 0.75f);
|
||||
|
||||
Assert.AreEqual(0.2f, next.Quality, 0.0001f);
|
||||
Assert.AreEqual(0.3f, next.Durability, 0.0001f);
|
||||
Assert.AreEqual(0.4f, next.Heat, 0.0001f);
|
||||
Assert.AreEqual(0.75f, next.Range, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RecipeTokensMapCatalogStringsToRuntimeEnums()
|
||||
{
|
||||
Assert.AreEqual(StatConditionMask.Quality, StatRecipeTokens.ToConditionMask("quality"));
|
||||
Assert.AreEqual(StatConditionMask.PilotSkill, StatRecipeTokens.ToConditionMask("pilotSkill"));
|
||||
Assert.AreEqual(StatConditionMask.None, StatRecipeTokens.ToConditionMask("unknown"));
|
||||
Assert.AreEqual(StatModifierOperation.Multiply, StatRecipeTokens.ToModifierOperation("multiply"));
|
||||
Assert.AreEqual(StatModifierOperation.Override, StatRecipeTokens.ToModifierOperation("override"));
|
||||
Assert.AreEqual(StatModifierOperation.Add, StatRecipeTokens.ToModifierOperation("unknown"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LegacyStatDependencyMaskIncludesOnlyActiveLegacyInputs()
|
||||
{
|
||||
var stat = new PerformanceStat
|
||||
{
|
||||
QualityExponent = 2,
|
||||
DurabilityExponentMultiplier = 0,
|
||||
HeatExponentMultiplier = 3
|
||||
};
|
||||
|
||||
Assert.AreEqual(StatConditionMask.Quality, stat.GetDependencyMask(includeHeat: false));
|
||||
Assert.AreEqual(StatConditionMask.Quality | StatConditionMask.Heat, stat.GetDependencyMask(includeHeat: true));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LegacyStatEvaluationUsesExplicitContextExponents()
|
||||
{
|
||||
var stat = new PerformanceStat
|
||||
{
|
||||
Min = 0,
|
||||
Max = 100,
|
||||
QualityExponent = 2,
|
||||
DurabilityExponentMultiplier = 1,
|
||||
HeatExponentMultiplier = 1
|
||||
};
|
||||
|
||||
var value = stat.EvaluateRecipeOrLegacy(
|
||||
new StatEvaluationContext(quality: 0.5f, durability: 0.5f, heat: 0.5f),
|
||||
durabilityExponent: 2,
|
||||
thermalExponent: 2,
|
||||
includeHeat: true);
|
||||
|
||||
Assert.AreEqual(3.125f, value, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConsumableBaselinePreservesLinearEffectivenessCompatibility()
|
||||
{
|
||||
var stat = new PerformanceStat
|
||||
{
|
||||
Min = 10,
|
||||
Max = 30,
|
||||
QualityExponent = 2,
|
||||
DurabilityExponentMultiplier = 10
|
||||
};
|
||||
|
||||
var value = stat.EvaluateConsumableBaseline(
|
||||
new StatEvaluationContext(quality: 0.5f, durability: 0.5f, heat: 1));
|
||||
|
||||
Assert.AreEqual(12.5f, value, 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntityModifierApplicationLeavesBaseValueWhenNoEntityModifiersExist()
|
||||
{
|
||||
var stat = new PerformanceStat();
|
||||
|
||||
Assert.AreEqual(42f, stat.ApplyEntityModifiers(null, 42f), 0.0001f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BehaviorValueReaderReadsEnumFromString()
|
||||
{
|
||||
var value = BehaviorValue("multiply", 0);
|
||||
|
||||
var operation = AetheriaRuntimeBehaviorValueReader.ReadEnum(value, StatModifierOperation.Add);
|
||||
|
||||
Assert.AreEqual(StatModifierOperation.Multiply, operation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BehaviorValueReaderReadsEnumFromNumberOrFallback()
|
||||
{
|
||||
var value = BehaviorValue("", (int)StatModifierOperation.Override);
|
||||
var unknown = BehaviorValue("", 999);
|
||||
|
||||
Assert.AreEqual(
|
||||
StatModifierOperation.Override,
|
||||
AetheriaRuntimeBehaviorValueReader.ReadEnum(value, StatModifierOperation.Add));
|
||||
Assert.AreEqual(
|
||||
StatModifierOperation.Add,
|
||||
AetheriaRuntimeBehaviorValueReader.ReadEnum(unknown, StatModifierOperation.Add));
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeBehaviorValue BehaviorValue(string stringValue, double numberValue)
|
||||
{
|
||||
return new AetheriaRuntimeBehaviorValue(
|
||||
"",
|
||||
stringValue,
|
||||
numberValue,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeBehaviorValue>(),
|
||||
Array.Empty<AetheriaRuntimeBehaviorMapEntry>());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 53a35efb3a0d3d646a1ea27845e4391f
|
||||
|
|
@ -5,14 +5,7 @@
|
|||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"Unity.Mathematics",
|
||||
"CultMath",
|
||||
"Aetheria.Shared.Unity",
|
||||
"GameCult.Aetheria.EveRuntime",
|
||||
"GameCult.Aetheria.State.Unity",
|
||||
"GameCult.Caching",
|
||||
"GameCult.Mesh",
|
||||
"GameCult.Eve.Surface",
|
||||
"GameCult.Eve.UnityScene"
|
||||
"Aetheria.Shared.Unity"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
|
|
@ -21,35 +14,12 @@
|
|||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"ConcurrentCollections.dll",
|
||||
"GameCult.Caching.MessagePack.dll",
|
||||
"GameCult.Caching.dll",
|
||||
"GameCult.Logging.dll",
|
||||
"GameCult.Mesh.dll",
|
||||
"GameCult.Networking.dll",
|
||||
"Isopoh.Cryptography.Argon2.dll",
|
||||
"Isopoh.Cryptography.Blake2b.dll",
|
||||
"Isopoh.Cryptography.SecureArray.dll",
|
||||
"LiteNetLib.dll",
|
||||
"Microsoft.Bcl.AsyncInterfaces.dll",
|
||||
"Microsoft.Bcl.TimeProvider.dll",
|
||||
"Microsoft.NET.StringTools.dll",
|
||||
"MessagePack.Annotations.dll",
|
||||
"MessagePack.CultMesh.dll",
|
||||
"R3.dll",
|
||||
"System.Collections.Immutable.dll",
|
||||
"System.ComponentModel.Annotations.dll",
|
||||
"System.IO.Pipelines.dll",
|
||||
"System.Text.Encodings.Web.dll",
|
||||
"System.Text.Json.dll",
|
||||
"System.Threading.Channels.dll",
|
||||
"System.Threading.Tasks.Extensions.dll",
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"AETHERIA_FOSSIL_TESTS"
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
}
|
||||
|
|
@ -1,482 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
|
||||
public sealed class YmirPhysicsQueryTests
|
||||
{
|
||||
[Test]
|
||||
public void StepIntegratesDynamicBodiesWithoutMutatingInputWorld()
|
||||
{
|
||||
var body = PhysicsBody("ship", 1, 2, 1);
|
||||
body.velocity = Vec2(3, -4);
|
||||
var world = World(body);
|
||||
|
||||
var result = YmirPhysicsQueries.Step(world, 0.5f);
|
||||
|
||||
Assert.That(result.world.time, Is.EqualTo(0.5f).Within(0.0001f));
|
||||
Assert.That(result.world.bodies[0].position.x, Is.EqualTo(2.5f).Within(0.0001f));
|
||||
Assert.That(result.world.bodies[0].position.y, Is.EqualTo(0.0f).Within(0.0001f));
|
||||
Assert.That(world.bodies[0].position.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(world.bodies[0].position.y, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StepAppliesRadialFieldsWithLinearFalloff()
|
||||
{
|
||||
var body = PhysicsBody("ship", 5, 0, 1);
|
||||
var world = World(body);
|
||||
world.fields = new[]
|
||||
{
|
||||
new YmirRadialField
|
||||
{
|
||||
id = "push",
|
||||
position = Vec2(0, 0),
|
||||
strength = 10,
|
||||
radius = 10
|
||||
}
|
||||
};
|
||||
|
||||
var result = YmirPhysicsQueries.Step(world, 1.0f);
|
||||
|
||||
Assert.That(result.world.bodies[0].velocity.x, Is.EqualTo(5.0f).Within(0.0001f));
|
||||
Assert.That(result.world.bodies[0].position.x, Is.EqualTo(10.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StepReportsContactsAndSeparatesDynamicBodyFromStaticBody()
|
||||
{
|
||||
var mover = PhysicsBody("mover", 0, 0, 1);
|
||||
mover.velocity = Vec2(2, 0);
|
||||
mover.mass = 1;
|
||||
var wall = PhysicsBody("wall", 1.5f, 0, 1);
|
||||
wall.isStatic = true;
|
||||
var world = World(mover, wall);
|
||||
|
||||
var result = YmirPhysicsQueries.Step(world, 0.1f);
|
||||
|
||||
Assert.That(result.contacts, Has.Length.EqualTo(1));
|
||||
Assert.AreEqual("mover", result.contacts[0].bodyA);
|
||||
Assert.AreEqual("wall", result.contacts[0].bodyB);
|
||||
Assert.That(result.contacts[0].normal.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(result.contacts[0].penetration, Is.GreaterThan(0));
|
||||
Assert.That(result.world.bodies[0].position.x, Is.EqualTo(-0.5f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StepSkipsInvalidInput()
|
||||
{
|
||||
var result = YmirPhysicsQueries.Step((YmirStepRequest)null);
|
||||
|
||||
Assert.That(result.world.bodies, Is.Empty);
|
||||
Assert.That(result.contacts, Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.Step(World(PhysicsBody("ship", 1, 0, 1)), -1).contacts, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapSphereReturnsHitsSortedBySurfaceDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapSphere(
|
||||
new[]
|
||||
{
|
||||
Body("far", 4, 0, 0, 2),
|
||||
Body("near", 1, 0, 0, 0.25f),
|
||||
Body("miss", 10, 0, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
Assert.That(hits[0].distance, Is.EqualTo(0.75f).Within(0.0001f));
|
||||
Assert.That(hits[1].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapSphereBreaksEqualDistanceTiesByBodyId()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapSphere(
|
||||
new[]
|
||||
{
|
||||
Body("b", -2, 0, 0, 1),
|
||||
Body("a", 2, 0, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapSphereReportsPenetrationAndContactPoint()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapSphere(
|
||||
new[] { Body("target", 2, 0, 0, 1) },
|
||||
Vec3(0, 0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].penetration, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].normal.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].point.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapSphereCanReuseCallerOwnedHitBuffer()
|
||||
{
|
||||
var hits = new List<YmirSphereOverlapHit> { new YmirSphereOverlapHit { bodyId = "stale" } };
|
||||
|
||||
var count = YmirPhysicsQueries.OverlapSphere(
|
||||
new[]
|
||||
{
|
||||
Body("b", -2, 0, 0, 1),
|
||||
Body("a", 2, 0, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
3,
|
||||
hits);
|
||||
|
||||
Assert.That(count, Is.EqualTo(2));
|
||||
Assert.That(hits, Has.Count.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapSphereSkipsInvalidInput()
|
||||
{
|
||||
Assert.That(YmirPhysicsQueries.OverlapSphere(null, Vec3(0, 0, 0), 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.OverlapSphere(new[] { Body("bad", 0, 0, 0, -1) }, Vec3(0, 0, 0), 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.OverlapSphere(new[] { Body("target", 0, 0, 0, 1) }, Vec3(0, 0, 0), -1), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapCircleReturnsHitsSortedBySurfaceDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("far", 4, 0, 2),
|
||||
PhysicsBody("near", 1, 0, 0.25f),
|
||||
PhysicsBody("miss", 10, 0, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
Assert.That(hits[0].distance, Is.EqualTo(0.75f).Within(0.0001f));
|
||||
Assert.That(hits[1].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapCircleBreaksEqualDistanceTiesByBodyId()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("b", -2, 0, 1),
|
||||
PhysicsBody("a", 2, 0, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapCircleReportsPenetrationAndContactPoint()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.OverlapCircle(
|
||||
new[] { PhysicsBody("target", 2, 0, 1) },
|
||||
Vec2(0, 0),
|
||||
3);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].penetration, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].normal.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].point.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapCircleCanReuseCallerOwnedHitBuffer()
|
||||
{
|
||||
var hits = new List<YmirCircleOverlapHit> { new YmirCircleOverlapHit { bodyId = "stale" } };
|
||||
|
||||
var count = YmirPhysicsQueries.OverlapCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("b", -2, 0, 1),
|
||||
PhysicsBody("a", 2, 0, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
3,
|
||||
hits);
|
||||
|
||||
Assert.That(count, Is.EqualTo(2));
|
||||
Assert.That(hits, Has.Count.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OverlapCircleSkipsInvalidInput()
|
||||
{
|
||||
Assert.That(YmirPhysicsQueries.OverlapCircle(null, Vec2(0, 0), 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.OverlapCircle(new[] { PhysicsBody("bad", 0, 0, -1) }, Vec2(0, 0), 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.OverlapCircle(new[] { PhysicsBody("target", 0, 0, 1) }, Vec2(0, 0), -1), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereReturnsHitsSortedByImpactDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastSphere(
|
||||
new[]
|
||||
{
|
||||
Body("far", 8, 0, 0, 1),
|
||||
Body("near", 4, 0, 0, 1),
|
||||
Body("miss", 4, 4, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(1, 0, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
Assert.That(hits[0].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[1].distance, Is.EqualTo(6.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereBreaksEqualDistanceTiesByBodyId()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastSphere(
|
||||
new[]
|
||||
{
|
||||
Body("b", 4, 1, 0, 1),
|
||||
Body("a", 4, -1, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(1, 0, 0),
|
||||
10,
|
||||
0);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereReportsImpactPointAndNormal()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastSphere(
|
||||
new[] { Body("target", 4, 0, 0, 1) },
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(2, 0, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].normal.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].point.x, Is.EqualTo(3.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereReportsInitialOverlapAtZeroDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastSphere(
|
||||
new[] { Body("inside", 0.5f, 0, 0, 1) },
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(1, 0, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].distance, Is.EqualTo(0.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereCanReuseCallerOwnedHitBuffer()
|
||||
{
|
||||
var hits = new List<YmirSphereCastHit> { new YmirSphereCastHit { bodyId = "stale" } };
|
||||
|
||||
var count = YmirPhysicsQueries.CastSphere(
|
||||
new[]
|
||||
{
|
||||
Body("far", 8, 0, 0, 1),
|
||||
Body("near", 4, 0, 0, 1)
|
||||
},
|
||||
Vec3(0, 0, 0),
|
||||
Vec3(1, 0, 0),
|
||||
10,
|
||||
1,
|
||||
hits);
|
||||
|
||||
Assert.That(count, Is.EqualTo(2));
|
||||
Assert.That(hits, Has.Count.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastSphereSkipsInvalidInput()
|
||||
{
|
||||
Assert.That(YmirPhysicsQueries.CastSphere(null, Vec3(0, 0, 0), Vec3(1, 0, 0), 1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastSphere(new[] { Body("target", 0, 0, 0, 1) }, Vec3(0, 0, 0), Vec3(0, 0, 0), 1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastSphere(new[] { Body("target", 0, 0, 0, 1) }, Vec3(0, 0, 0), Vec3(1, 0, 0), -1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastSphere(new[] { Body("bad", 0, 0, 0, -1) }, Vec3(0, 0, 0), Vec3(1, 0, 0), 1, 1), Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleReturnsHitsSortedByImpactDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("far", 8, 0, 1),
|
||||
PhysicsBody("near", 4, 0, 1),
|
||||
PhysicsBody("miss", 4, 4, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
Vec2(1, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
Assert.That(hits[0].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[1].distance, Is.EqualTo(6.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleBreaksEqualDistanceTiesByBodyId()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("b", 4, 1, 1),
|
||||
PhysicsBody("a", 4, -1, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
Vec2(1, 0),
|
||||
10,
|
||||
0);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(2));
|
||||
Assert.AreEqual("a", hits[0].bodyId);
|
||||
Assert.AreEqual("b", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleReportsImpactPointAndNormal()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastCircle(
|
||||
new[] { PhysicsBody("target", 4, 0, 1) },
|
||||
Vec2(0, 0),
|
||||
Vec2(2, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].distance, Is.EqualTo(2.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].normal.x, Is.EqualTo(1.0f).Within(0.0001f));
|
||||
Assert.That(hits[0].point.x, Is.EqualTo(3.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleReportsInitialOverlapAtZeroDistance()
|
||||
{
|
||||
var hits = YmirPhysicsQueries.CastCircle(
|
||||
new[] { PhysicsBody("inside", 0.5f, 0, 1) },
|
||||
Vec2(0, 0),
|
||||
Vec2(1, 0),
|
||||
10,
|
||||
1);
|
||||
|
||||
Assert.That(hits, Has.Length.EqualTo(1));
|
||||
Assert.That(hits[0].distance, Is.EqualTo(0.0f).Within(0.0001f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleCanReuseCallerOwnedHitBuffer()
|
||||
{
|
||||
var hits = new List<YmirCircleCastHit> { new YmirCircleCastHit { bodyId = "stale" } };
|
||||
|
||||
var count = YmirPhysicsQueries.CastCircle(
|
||||
new[]
|
||||
{
|
||||
PhysicsBody("far", 8, 0, 1),
|
||||
PhysicsBody("near", 4, 0, 1)
|
||||
},
|
||||
Vec2(0, 0),
|
||||
Vec2(1, 0),
|
||||
10,
|
||||
1,
|
||||
hits);
|
||||
|
||||
Assert.That(count, Is.EqualTo(2));
|
||||
Assert.That(hits, Has.Count.EqualTo(2));
|
||||
Assert.AreEqual("near", hits[0].bodyId);
|
||||
Assert.AreEqual("far", hits[1].bodyId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CastCircleSkipsInvalidInput()
|
||||
{
|
||||
Assert.That(YmirPhysicsQueries.CastCircle(null, Vec2(0, 0), Vec2(1, 0), 1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastCircle(new[] { PhysicsBody("target", 0, 0, 1) }, Vec2(0, 0), Vec2(0, 0), 1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastCircle(new[] { PhysicsBody("target", 0, 0, 1) }, Vec2(0, 0), Vec2(1, 0), -1, 1), Is.Empty);
|
||||
Assert.That(YmirPhysicsQueries.CastCircle(new[] { PhysicsBody("bad", 0, 0, -1) }, Vec2(0, 0), Vec2(1, 0), 1, 1), Is.Empty);
|
||||
}
|
||||
|
||||
private static YmirSphereQueryBody Body(string id, float x, float y, float z, float radius)
|
||||
{
|
||||
return new YmirSphereQueryBody
|
||||
{
|
||||
id = id,
|
||||
position = Vec3(x, y, z),
|
||||
radius = radius
|
||||
};
|
||||
}
|
||||
|
||||
private static YmirPhysicsBody PhysicsBody(string id, float x, float y, float radius)
|
||||
{
|
||||
return new YmirPhysicsBody
|
||||
{
|
||||
id = id,
|
||||
position = Vec2(x, y),
|
||||
direction = Vec2(1, 0),
|
||||
radius = radius,
|
||||
mass = 1,
|
||||
momentOfInertia = 1
|
||||
};
|
||||
}
|
||||
|
||||
private static YmirWorld World(params YmirPhysicsBody[] bodies)
|
||||
{
|
||||
return new YmirWorld
|
||||
{
|
||||
time = 0,
|
||||
bodies = bodies,
|
||||
fields = new YmirRadialField[0]
|
||||
};
|
||||
}
|
||||
|
||||
private static YmirVec3 Vec3(float x, float y, float z)
|
||||
{
|
||||
return new YmirVec3 { x = x, y = y, z = z };
|
||||
}
|
||||
|
||||
private static YmirVec2 Vec2(float x, float y)
|
||||
{
|
||||
return new YmirVec2 { x = x, y = y };
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 97ea5fc21683ebf409292b94fcb4cf6a
|
||||
Loading…
Reference in a new issue