fix: harden actor behavior authority logic

This commit is contained in:
ud18010
2026-07-30 13:38:10 +08:00
parent bc52b74ff8
commit f898cbab10
5 changed files with 222 additions and 22 deletions
@@ -32,6 +32,38 @@ namespace XWorld.Framework.Tests.ActorBehavior
Assert.Contains(world.DrainEvents(), e =>
e.Kind == BehaviorEventKind.AttributeEffectRequested && e.TargetActorId == 3);
}
[Theory]
[InlineData("sector_test")]
[InlineData("line_test")]
public void DirectionalShapes_UseInputDirectionInsteadOfActorForward(string behaviorId)
{
BehaviorWorld world = TestTargetWorld.Create();
world.TryStartBehavior(1, behaviorId, BehaviorInput.FromDirection(0, 1));
world.Tick(0.01f);
var events = world.DrainEvents();
Assert.Contains(events, e =>
e.Kind == BehaviorEventKind.AttributeEffectRequested && e.TargetActorId == 4);
Assert.DoesNotContain(events, e =>
e.Kind == BehaviorEventKind.AttributeEffectRequested && e.TargetActorId == 2);
}
[Fact]
public void DirectionalShapes_UseTargetPositionDirectionInsteadOfActorForward()
{
BehaviorWorld world = TestTargetWorld.Create();
world.TryStartBehavior(1, "sector_test", BehaviorInput.FromTargetPosition(0, 0, 2));
world.Tick(0.01f);
var events = world.DrainEvents();
Assert.Contains(events, e =>
e.Kind == BehaviorEventKind.AttributeEffectRequested && e.TargetActorId == 4);
Assert.DoesNotContain(events, e =>
e.Kind == BehaviorEventKind.AttributeEffectRequested && e.TargetActorId == 2);
}
}
internal static class TestTargetWorld