Ejemplo n.º 1
0
    public void TriggerComponentTest_executionOrder()
    {
        // Initializing trigger Entity
        Entity l_testTriggerEntity = Entity.alloc();

        l_testTriggerEntity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc());

        NavigationEngineTestTriggerComponent_Order1st l_firstTrigger  = NavigationEngineTestTriggerComponent_Order1st.alloc();
        NavigationEngineTestTriggerComponent_Order2nd l_secondTrigger = NavigationEngineTestTriggerComponent_Order2nd.alloc(l_firstTrigger);

        EntityComponent.add_component(l_testTriggerEntity, l_secondTrigger);
        EntityComponent.add_component(l_testTriggerEntity, l_firstTrigger);
        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_secondTrigger.ExecutedAfterTriggerSupposedToBeBefore);
    }
Ejemplo n.º 2
0
        private void onEntityCreated(Entity p_entity)
        {
            AssociatedEntity = p_entity;
            AssociatedEntity.EntityGameWorldInstanceID = new EntityGameWorldInstanceID()
            {
                ID = GetInstanceID()
            };

            AssociatedEntity.EntityGameWorld = EntityGameWorld.build(TransformComponent.alloc());
            TransformComponentSynchronizer.alloc(AssociatedEntity.EntityGameWorld.RootGround);
            EntityModelTransformSynchronizer = TransformSynchronizer.alloc(transform,
                                                                           AssociatedEntity.EntityGameWorld.RootGround.TransformComponentSynchronizer);
            TransformSynchronizerContainer.TransformSynchronizers.Add(EntityModelTransformSynchronizer);

            MyEvent <Entity> .IEventCallback l_onEntityDestroyed = OnEntityDestroyed.build(this);
            MyEvent <Entity> .register(
                ref this.AssociatedEntity.OnEntityDestroyed,
                ref l_onEntityDestroyed);

            // Initializing Entity components
            EntityDefinition.Initialize(
                ref this.EntityDefinition,
                ref this.AssociatedEntity,
                this.RuntimeObject.RuntimeObjectRootComponent);

            NavigationNode l_randomNavigationNode = NavigationGraphAlgorithm.pickRandomNode(NavigationGraphComponentContainer.UniqueNavigationGraphComponent.NavigationGraph);

            EventQueue.enqueueEvent(EventQueueContainer.TurnTimelineQueue, NavigationNodeWarpEntityEvent.alloc(AssociatedEntity, l_randomNavigationNode));

            AnimationVisualFeedback l_animationVisualFeedbackComponent = EntityComponent.get_component <AnimationVisualFeedback>(AssociatedEntity);

            if (l_animationVisualFeedbackComponent != null)
            {
                EventQueue.enqueueEvent(EventQueueContainer.TurnTimelineQueue,
                                        AnimationVisualFeedbackPlayAsyncEvent.alloc(l_animationVisualFeedbackComponent, AnimationLayers.BASE,
                                                                                    l_animationVisualFeedbackComponent.AnimationVisualFeedbackData.GetAnimation(AnimationLookupTag.IDLE).GetAnimationInput()));
            }
        }
Ejemplo n.º 3
0
    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);
    }