Exemplo n.º 1
0
        private void HandleMoveSimple(ref SimpleMoverNode mover)
        {
            var entity = mover.Entity;

            if (entity.IsDestroyed() || !entity.Tags.Contain(EntityTags.Moving))
            {
                return;
            }
            var target = mover.MoveTarget;

            if (target == null)
            {
                return;
            }
            var tr = mover.Tr;

            if (tr == null)
            {
                return;
            }
            var targetPos = target.GetTargetPosition;
            var dir       = targetPos - tr.position;

            mover.Entity.Post(new SetTransformPosition(mover.Tr,
                                                       Vector3.MoveTowards(tr.position, targetPos, mover.MoveSpeed.Speed * TimeManager.DeltaTime)));
            var targetRotation = Quaternion.LookRotation(dir);

            mover.Entity.Post(new SetTransformRotation(mover.Tr, Quaternion.RotateTowards(tr.rotation, targetRotation, mover.RotationSpeed
                                                                                          .Speed * TimeManager.DeltaTime)));
            if (Vector3.Distance(targetPos, tr.position) < ReachedDestination)
            {
                FinishMove(entity, targetPos);
            }
        }
Exemplo n.º 2
0
        public MoverSystem()
        {
            NodeFilter <ForwardMoverNode> .Setup(ForwardMoverNode.GetTypes());

            _forwardMovers = EntityController.GetNodeList <ForwardMoverNode>();
            NodeFilter <RotateToNode> .Setup(RotateToNode.GetTypes());

            _rotators = EntityController.GetNodeList <RotateToNode>();
            NodeFilter <SimpleMoverNode> .Setup(SimpleMoverNode.GetTypes());

            _simpleMovers = EntityController.GetNodeList <SimpleMoverNode>();
            NodeFilter <ArcMoverNode> .Setup(ArcMoverNode.GetTypes());

            _arcMovers = EntityController.GetNodeList <ArcMoverNode>();
        }