Add MrGameEng.AI utility-AI module; format codebase with CSharpier New MrGameEng.AI module (ResponseCurve, Consideration, UtilityAction, UtilityAi selector, Blackboard) plus CSharpier formatting applied across the whole engine. Documents the CSharpier convention in CLAUDE.md. @
This commit is contained in:
@@ -26,7 +26,12 @@ public class CameraMathTests
|
||||
public void ScreenToWorld_RoundTripsWithWorldToScreen()
|
||||
{
|
||||
var camera = new Camera(new Vector2(123f, -45f), zoom: 1.5f, rotation: 0.3f);
|
||||
var state = CameraMath.Compute(camera, 1280, 720, new ViewportMapping(new Vector2(0f, 60f), 1.5f));
|
||||
var state = CameraMath.Compute(
|
||||
camera,
|
||||
1280,
|
||||
720,
|
||||
new ViewportMapping(new Vector2(0f, 60f), 1.5f)
|
||||
);
|
||||
|
||||
var screen = new Vector2(200f, 500f);
|
||||
var world = state.ScreenToWorld(screen);
|
||||
@@ -49,8 +54,18 @@ public class CameraMathTests
|
||||
[Fact]
|
||||
public void Rotation_ExpandsCullRectToCoverRotatedView()
|
||||
{
|
||||
var straight = CameraMath.Compute(new Camera(Vector2.Zero), 800, 600, ViewportMapping.Identity);
|
||||
var rotated = CameraMath.Compute(new Camera(Vector2.Zero, rotation: MathF.PI / 4f), 800, 600, ViewportMapping.Identity);
|
||||
var straight = CameraMath.Compute(
|
||||
new Camera(Vector2.Zero),
|
||||
800,
|
||||
600,
|
||||
ViewportMapping.Identity
|
||||
);
|
||||
var rotated = CameraMath.Compute(
|
||||
new Camera(Vector2.Zero, rotation: MathF.PI / 4f),
|
||||
800,
|
||||
600,
|
||||
ViewportMapping.Identity
|
||||
);
|
||||
|
||||
Assert.True(rotated.CullRect.Width > straight.CullRect.Width);
|
||||
Assert.True(rotated.CullRect.Height > straight.CullRect.Height);
|
||||
|
||||
@@ -22,7 +22,12 @@ public class CullingTests
|
||||
{
|
||||
var transform = Transform2D.At(new Vector2(50f, 50f));
|
||||
|
||||
var (center, _) = CullingMath.SpriteBoundingCircle(transform, 64f, 32f, new Vector2(32f, 16f));
|
||||
var (center, _) = CullingMath.SpriteBoundingCircle(
|
||||
transform,
|
||||
64f,
|
||||
32f,
|
||||
new Vector2(32f, 16f)
|
||||
);
|
||||
|
||||
Assert.Equal(new Vector2(50f, 50f), center);
|
||||
}
|
||||
@@ -41,7 +46,11 @@ public class CullingTests
|
||||
public void BoundingCircle_RegionOverload_MatchesSizeOverload_ForUniformScale()
|
||||
{
|
||||
var region = new Texture2DRegion(null!, new Rectangle(0, 0, 48, 24));
|
||||
var transform = new Transform2D(new Vector2(10f, 20f), rotation: 0.6f, scale: new Vector2(1.5f, 1.5f));
|
||||
var transform = new Transform2D(
|
||||
new Vector2(10f, 20f),
|
||||
rotation: 0.6f,
|
||||
scale: new Vector2(1.5f, 1.5f)
|
||||
);
|
||||
var origin = new Vector2(5f, 7f);
|
||||
|
||||
var (centerA, radiusA) = CullingMath.SpriteBoundingCircle(transform, 48f, 24f, origin);
|
||||
@@ -59,16 +68,20 @@ public class CullingTests
|
||||
var transform = new Transform2D(Vector2.Zero, scale: new Vector2(1f, 3f));
|
||||
|
||||
var (_, exact) = CullingMath.SpriteBoundingCircle(transform, 100f, 10f, Vector2.Zero);
|
||||
var (_, conservative) = CullingMath.SpriteBoundingCircle(in transform, region, Vector2.Zero);
|
||||
var (_, conservative) = CullingMath.SpriteBoundingCircle(
|
||||
in transform,
|
||||
region,
|
||||
Vector2.Zero
|
||||
);
|
||||
|
||||
Assert.True(conservative >= exact);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(50f, 50f, true)] // inside
|
||||
[InlineData(-4f, 50f, true)] // touching from the left (radius 5)
|
||||
[InlineData(-20f, 50f, false)] // far left
|
||||
[InlineData(50f, 130f, false)] // far below
|
||||
[InlineData(50f, 50f, true)] // inside
|
||||
[InlineData(-4f, 50f, true)] // touching from the left (radius 5)
|
||||
[InlineData(-20f, 50f, false)] // far left
|
||||
[InlineData(50f, 130f, false)] // far below
|
||||
public void CircleIntersectsRect_DetectsOverlap(float x, float y, bool expected)
|
||||
{
|
||||
var rect = new RectF(0f, 0f, 100f, 100f);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -15,5 +14,4 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\MrGameEng.Graphics\MrGameEng.Graphics.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -31,7 +31,9 @@ public class SortKeyTests
|
||||
[InlineData(-0.5f, 0.5f)]
|
||||
public void DepthBits_PreserveFloatOrder(float smaller, float larger)
|
||||
{
|
||||
Assert.True(SpriteSortKey.DepthToSortableBits(smaller) < SpriteSortKey.DepthToSortableBits(larger));
|
||||
Assert.True(
|
||||
SpriteSortKey.DepthToSortableBits(smaller) < SpriteSortKey.DepthToSortableBits(larger)
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -42,7 +42,8 @@ public class SpriteAnimationTests
|
||||
this.UseSpriteAnimation();
|
||||
Animated = Store.CreateEntity(
|
||||
new Sprite { Color = Color.White },
|
||||
new SpriteAnimator(Clip));
|
||||
new SpriteAnimator(Clip)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,9 +122,9 @@ public class SpriteBatcherTests
|
||||
Assert.Equal(3, accepted);
|
||||
Assert.Equal(1, batcher.LastChunkCulled);
|
||||
var order = batcher.Sort();
|
||||
Assert.Equal(1, batcher[order[0]].Layer); // сначала чанк 0...
|
||||
Assert.Equal(1, batcher[order[0]].Layer); // сначала чанк 0...
|
||||
Assert.Equal(2, batcher[order[1]].Layer);
|
||||
Assert.Equal(10, batcher[order[2]].Layer); // ...затем чанк 1 — стабильно
|
||||
Assert.Equal(10, batcher[order[2]].Layer); // ...затем чанк 1 — стабильно
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user