fix: complete actor behavior timelines
This commit is contained in:
@@ -115,6 +115,50 @@ namespace XWorld.Framework.Tests.ActorBehavior
|
||||
Assert.Contains(events, e => e.Kind == BehaviorEventKind.BuffRemoved && e.TargetActorId == 2);
|
||||
Assert.Equal(0, world.ActiveBuffCount(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClientPresentation_BuffTickDoesNotEmitAuthoritativeAttributeRequests()
|
||||
{
|
||||
BehaviorWorld world = TestWorld.CreatePresentationWorld();
|
||||
|
||||
Assert.True(world.ApplyBuff(2, "fighter", "slow_01", 1));
|
||||
world.DrainEvents();
|
||||
world.Tick(1.0f);
|
||||
var events = world.DrainEvents();
|
||||
|
||||
Assert.Contains(events, e => e.Kind == BehaviorEventKind.BuffTicked && e.TargetActorId == 2);
|
||||
Assert.DoesNotContain(events, e => e.Kind == BehaviorEventKind.AttributeEffectRequested);
|
||||
Assert.DoesNotContain(events, e => e.Kind == BehaviorEventKind.LogicEffectApplied);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BehaviorTimelineBuff_AppliesConfiguredBuff()
|
||||
{
|
||||
BehaviorConfigCatalog catalog = BehaviorConfigCatalog.LoadFromJson("fighter", TestBehaviorJson.SkillWithBuffTimeline, TestBehaviorJson.FlyObject, TestBehaviorJson.Buff);
|
||||
var world = new BehaviorWorld(new BehaviorWorldOptions { Mode = BehaviorRunMode.ServerLogic });
|
||||
world.RegisterCatalog(catalog);
|
||||
world.AddActor(new BehaviorActorState { ActorId = 1, CatalogType = "fighter", TeamId = 1, Position = new BehaviorVector3(0, 0, 0), Forward = new BehaviorVector3(1, 0, 0), Radius = 0.3f, Alive = true });
|
||||
world.AddActor(new BehaviorActorState { ActorId = 2, CatalogType = "fighter", TeamId = 2, Position = new BehaviorVector3(1, 0, 0), Forward = new BehaviorVector3(-1, 0, 0), Radius = 0.3f, Alive = true });
|
||||
|
||||
world.TryStartBehavior(1, "slow_cast", BehaviorInput.FromTargetActor(2));
|
||||
world.Tick(0.01f);
|
||||
var events = world.DrainEvents();
|
||||
|
||||
Assert.Contains(events, e => e.Kind == BehaviorEventKind.BuffAdded && e.TargetActorId == 2 && e.BuffId == "slow_01");
|
||||
Assert.Equal(1, world.ActiveBuffCount(2));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProjectileTimelineEffect_FiresInClientPresentation()
|
||||
{
|
||||
BehaviorWorld world = TestWorld.CreatePresentationWorld();
|
||||
|
||||
world.TryStartBehavior(1, "slash", BehaviorInput.FromDirection(1, 0));
|
||||
world.Tick(0.33f);
|
||||
var events = world.DrainEvents();
|
||||
|
||||
Assert.Contains(events, e => e.Kind == BehaviorEventKind.TimelineEffect && e.FlyObjectId == "blade_wave" && e.Prefab == "Assets/Game/Art/Effect/blade_wave.prefab");
|
||||
}
|
||||
}
|
||||
|
||||
internal static class TestWorld
|
||||
|
||||
Reference in New Issue
Block a user