// Generates random pixel to go to.
        private void GoSomewhere()
        {
            Map currentMap = this.MyCreature.InhabitedMap;
            RandomStuff randomator = currentMap.Randomator;
            Coords targetPixel = new Coords(CoordsType.Pixel, (Int32)randomator.NSidedDice((UInt16)currentMap.PixelBoundX, 1) - 1,
                (Int32)randomator.NSidedDice((UInt16)currentMap.PixelBoundY, 1) - 1);

            //Coords targetTile = new Coords(CoordsType.Tile, targetPixel);
            List<Creature> clipCheck = _owner.MyCollider.CreatureClippingCheck(this.MyCreature, targetPixel, false);
            if (clipCheck != null && clipCheck.Count == 0)
            {
                MyNavigator = new Navigator(this.MyCreature, targetPixel, false);
                _thinkingCounter = (int)randomator.NSidedDice(1000, 1);
            }
        }
 public void MoveOrder(Coords targetPixel)
 {
     MyNavigator = new Navigator(this.MyCreature, targetPixel, true);
 }
        // Checks if there are valid contextual actions to be taken.
        private void ObtainAction()
        {
            // take care of forced target, if any
            if (_targetForced != null)
            {
                if (TargetIsInRange(_targetForced))
                {
                    AddAction(new ActionAttack(_owner, _targetForced, _owner.StatAttackTime));
                    return;
                }
                else if (_owner.Team.EnemyIsObserved(_targetForced))
                {
                    ++_routeToForcedTargetRecalcTimer;
                    if (_routeToForcedTargetRecalcTimer % Constants.DefaultRouteToForcedTargetRecalcTimer == 1)
                    {
                        _myNavigator = new Navigator(_owner, _targetForced.PositionPixel, false);
                        return;
                    }
                }
                else 
                {
                    if (!_targetForced.Dead)
                    {
                        _myNavigator = new Navigator(_owner, _targetForced.PositionPixel, false);
                    }
                    _targetForced = null;
                    _routeToForcedTargetRecalcTimer = 0;
                }
            }


            // check for enemies
            if (_observedEnemies.Count > 0)
            {
                if (_target != null)
                {
                    if (TargetIsInRange(_target))
                    {
                        AddAction(new ActionAttack(_owner, _target, _owner.StatAttackTime));
                        return;
                    }
                }

                // pick target
                _target = NearestEnemy();
                if (TargetIsInRange(_target))
                {
                    AddAction(new ActionAttack(_owner, _target, _owner.StatAttackTime));
                    return;
                }
                else
                {
                    _myNavigator = new Navigator(_owner, _target.PositionPixel, false);
                    return;
                }
            }
            else
            {
                if (_target != null)
                {
                    if (!_target.Dead)
                    {
                        _myNavigator = new Navigator(_owner, _target.PositionPixel, false);
                    }
                    _target = null;
                    return;
                }
            }
        }
 public void OrderMove(Coords targetPixel)
 {
     this._myNavigator = new Navigator(this.MyCreature, targetPixel, true);
 }
        protected void UpdateMovement()
        {
            // check if there is no explicit move request
            if (!_moveRequested)
            {
                // obtain a move from active Navigators:
                if (_myNavigator != null)
                {
                    // Navigator found. Accelerate.
                    this.Accelerate();

                    Nullable<Vector> moveDir = _myNavigator.Navigate();
                    if (moveDir == null)
                    {
                        // we've hit an impediment. kill the navigator and stop the ship.
                        _myNavigator = null;
                        _moveDir = null;
                        _owner.MoveSpeedCurrent = 0;
                    }
                    else if (moveDir.Value.X == Double.PositiveInfinity)
                    {
                        // goal attained. stop the navigator.
                        _myNavigator = null;
                    }
                    else
                    {
                        // request move from self
                        this.MoveRequest(moveDir.Value, true, true);
                    }
                }
            }

            // Time to do the move. Check if there is an active vector:
            if (_moveDir != null)
            {
                // do move
                this.Move();

                // if there is no move request, we need to decelerate and normalize the dir-vector.
                if (!_moveRequested && _myNavigator == null)
                {
                    this.Decelerate();
                    // careful with the boxing
                    if (_owner.MoveSpeedCurrent > 0)
                    {
                        Vector normalized = _moveDir.Value;
                        normalized.ScaleToLength(_owner.MoveSpeedCurrent);
                        this._moveDir = normalized;
                    }
                    else
                    {
                        this._moveDir = null;
                    }
                }
            }

            // Flush flags.
            _moveRequested = false;
            _moveClipChecked = false;
        }