public void TriggerComponentTest_warp() { // Initializing trigger Entity Entity l_testTriggerEntity = Entity.alloc(); l_testTriggerEntity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc()); EntityComponent.add_component(l_testTriggerEntity, NavigationEngineTestTriggerComponent.alloc()); EntityComponent.add_component(l_testTriggerEntity, Locomotion.alloc(new LocomotionData())); // We warp the l_testTriggeredEntity to a random NavigationNode EventQueue.enqueueEvent( TestEventQueue, NavigationNodeWarpEntityEvent.alloc( l_testTriggerEntity, NavigationGraphAlgorithm.pickRandomNode(NavigationGraphContainer.UniqueNavigationGraph) ) ); EventQueue.iterate(TestEventQueue); // We create the Entity that will be involved in the trigger Entity l_entity = Entity.alloc(); l_entity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc()); EntityComponent.add_component(l_entity, Locomotion.alloc(new LocomotionData())); EventQueue.enqueueEvent( TestEventQueue, NavigationNodeWarpEntityEvent.alloc( l_entity, l_testTriggerEntity.CurrentNavigationNode ) ); EventQueue.iterate(TestEventQueue); NavigationEngineTestTriggerComponent l_triggerComponent = EntityComponent.get_component <NavigationEngineTestTriggerComponent>(l_testTriggerEntity); Assert.IsTrue(l_triggerComponent.IsTriggered); Assert.IsTrue(l_triggerComponent.TriggeredEntity == l_entity); }
public void TriggerComponentTest_navigationNodeMove() { // Initializing trigger Entity Entity l_testTriggerEntity = Entity.alloc(); l_testTriggerEntity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc()); EntityComponent.add_component(l_testTriggerEntity, NavigationEngineTestTriggerComponent.alloc()); EntityComponent.add_component(l_testTriggerEntity, Locomotion.alloc(new LocomotionData() { Speed = float.MaxValue * 0.1f })); // We warp the l_testTriggeredEntity to a random NavigationNode EventQueue.enqueueEvent( TestEventQueue, NavigationNodeWarpEntityEvent.alloc( l_testTriggerEntity, NavigationGraphAlgorithm.pickRandomNode(NavigationGraphContainer.UniqueNavigationGraph) ) ); EventQueue.iterate(TestEventQueue); // We create the Entity that will be involved in the trigger Entity l_entity = Entity.alloc(); l_entity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc()); EntityComponent.add_component(l_entity, Locomotion.alloc(new LocomotionData() { Speed = float.MaxValue * 0.1f })); ActionPointData l_actionPointdata = new ActionPointData() { InitialActionPoints = 999f, CurrentActionPoints = 999f }; EntityComponent.add_component(l_entity, ActionPoint.alloc(ref l_actionPointdata)); var l_entityNavigationNodeEnumerator = NavigationGraphAlgorithm.getReachableNeighborNavigationNodes(NavigationGraphContainer.UniqueNavigationGraph, l_testTriggerEntity.CurrentNavigationNode, NavigationGraphFlag.CURRENT).GetEnumerator(); l_entityNavigationNodeEnumerator.MoveNext(); EventQueue.enqueueEvent( TestEventQueue, NavigationNodeWarpEntityEvent.alloc( l_entity, l_entityNavigationNodeEnumerator.Current ) ); NavigationNodeMoveEvent l_navigationNodeMoveEvent = NavigationNodeMoveEvent.alloc(l_entity, l_testTriggerEntity.CurrentNavigationNode); EventQueue.enqueueEvent( TestEventQueue, l_navigationNodeMoveEvent ); while (!l_navigationNodeMoveEvent.IsCompleted()) { LocomotionSystemV2Container.Tick(1.0f); EventQueue.iterate(TestEventQueue); } NavigationEngineTestTriggerComponent l_triggerComponent = EntityComponent.get_component <NavigationEngineTestTriggerComponent>(l_testTriggerEntity); Assert.IsTrue(l_triggerComponent.IsTriggered); Assert.IsTrue(l_triggerComponent.TriggeredEntity == l_entity); }