Пример #1
0
        private void mineDetector_OnEntityPositionChange(MyEntityDetector sender, MyEntity entity, Vector3 newposition)
        {
            if (sender.Closed)
                return;

            if (entity == MySession.PlayerShip)
            {
                if (m_beepCue == null || !m_beepCue.Value.IsPlaying)
                {
                    m_beepCue = MyAudio.AddCue2D(MySoundCuesEnum.SfxHudAlarmDamageA);
                }

                float distance = (entity.GetPosition() - sender.GetPosition()).Length();

                if (distance < m_mineStartRadius)
                {
                    uint mineId = 0;
                    for (int i = 0; i < m_mines.GetLength(0); i++)
                    {
                        if (m_mines[i, 1] == sender.Parent.EntityId.Value.NumericValue)
                        {
                            mineId = m_mines[i, 0];
                        }
                    }
                    ExplodeMine(mineId);
                    sender.Off();
                    sender.Parent.MarkForClose();
                }

            }
        }
Пример #2
0
 public override void Load(MyMissionBase sender)
 {
     base.Load(sender);
     m_ship = m_shipId.HasValue ? MyScriptWrapper.GetEntity(m_shipId.Value) : MyScriptWrapper.GetEntity(m_shipName);
     m_trajectory = new MyLine(m_ship.GetPosition(), MyScriptWrapper.GetEntity(m_targetId).GetPosition());
     
     if (m_isShip)
     {
         MyScriptWrapper.PrepareMotherShipForMove(m_ship);
     }
     m_shipMoving = true;
 }
 bool MoveMotherShipForwardDest(MyEntity entity, float speed, Vector3 destination)
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
     {
         MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
         return false;
     }
     return true;
 }
Пример #4
0
        void MoveMotherShip(MyEntity entity, Vector3 destination, List<uint> AdditionalStuffToMove) //helps to move even non prefab entities with the ship, like thruster particles and spawnpoints
        {
            MyScriptWrapper.Move(entity, destination);

            Vector3 delta = destination - entity.GetPosition();

            foreach (var item in AdditionalStuffToMove)
            {
                MyEntity Item = MyScriptWrapper.GetEntity(item);
                if (Item != null)
                {
                    MyScriptWrapper.Move(Item, Item.GetPosition() + delta);
                }
            }
        }
Пример #5
0
 bool MoveMotherShipForward(MyEntity entity, float speed, Vector3 destination, List<uint> AdditionalStuffToMove) //helps to move even non prefab entities with the ship, like thruster particles and spawnpoints
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
     {
         //Render.MyRender.ClearEnhancedStats();
         MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS); // recalculate position
         foreach (var item in AdditionalStuffToMove)
         {
             MyEntity Item = MyScriptWrapper.GetEntity(item);
             if (Item != null)
             {
                 MyScriptWrapper.Move(Item, Item.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
             }
         }
         //MyScriptWrapper.GetEntity((uint)EntityID.CrashingMothershipSmoke).SetPosition(MyScriptWrapper.GetEntity((uint)EntityID.CrashingMothershipSmoke).GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
         //Render.MyRender.ClearEnhancedStats();
         return false;
     }
     return true;
 }
Пример #6
0
 /// <summary>
 /// Chceck if ship can see target
 /// </summary>
 /// <param name="position">Target position</param>
 /// <param name="target">Target entity.</param>
 /// <returns>True, if bot can see position.</returns>
 public static MyEntity CanSee(MyEntity source, MyEntity target)
 {
     return CanSee(source, target.GetPosition(), target);
 }
Пример #7
0
        public bool CanSeeTarget(MyEntity target)
        {
            bool canSeeTarget = true;
            if (MyFakes.ENABLE_BOTS_FOV_WHEN_RADAR_JAMMER)
            {
                MySmallShip smallShipTarget = target as MySmallShip;
                if (smallShipTarget != null && !smallShipTarget.IsHologram && smallShipTarget.HasRadarJammerActive())
                {
                    float distanceSqr = (GetPosition() - GetPosition()).LengthSquared();
                    float rangeOfViewSqr = smallShipTarget.IsHiddenFromBots() ? MyAIConstants.BOT_FOV_RANGE_HIDDEN : MyAIConstants.BOT_FOV_RANGE;
                    float targetRange = Vector3.Dot(WorldMatrix.Forward, target.GetPosition() - GetPosition());

                    canSeeTarget =
                        targetRange <= rangeOfViewSqr &&
                        Vector3.Dot(WorldMatrix.Forward, Vector3.Normalize(target.GetPosition() - GetPosition())) >= MyAIConstants.BOT_FOV_COS;
                }
            }
            return canSeeTarget;
        }
Пример #8
0
        public void AddSeenEnemy(MyEntity enemy)
        {
            if (enemy != null)
            {
                Debug.Assert(!enemy.Closed);

                if (LeaderLostEnabled && Leader != null && Vector3.DistanceSquared(Leader.GetPosition(), enemy.GetPosition()) > MyAIConstants.FAR_LEADER_DISTANCE_SQR)
                    return;

                MyBotDesire desire = null;
                foreach (var item in m_desires)
                {
                    if (item.DesireType == BotDesireType.SEE_ENEMY && item.GetEnemy() == enemy)
                    {
                        desire = item;
                        break;
                    }
                }

                if (desire == null)
                {
                    desire = new MySeeEnemyDesire(enemy);
                    AddDesire(desire);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Damage is first taken from armor, at full rate. The amount taken from armor is then multiplied by armor
        /// ratio to get how much damage armor absorbed. The rest is taken from ship health.
        /// </summary>
        /// <param name="healthDamage">Damage which should be taken from player health</param>
        /// <param name="damage">Damage to be taken from ship/entity</param>
        /// <param name="damageType"></param>
        /// <param name="ammoType"></param>
        /// <param name="damageSource"></param>
        protected override void DoDamageInternal(float healthDamage, float damage, float empDamage, MyDamageType damageType, MyAmmoType ammoType, MyEntity damageSource, bool justDeactivate)
        {
            if (HasSunWindArmor && damageType == MyDamageType.Sunwind)
            {
                return;
            }

            HandleAttack(damageSource);

            // Mantis 5877: There will be "friendly fire" voice notification, but nobody will get hurt.
            // It will work only on small ships.

            if (damageSource is MySmallShip && damageSource != this)
            {
                var factionRelation = MyFactions.GetFactionsRelation(this, damageSource);
                if (factionRelation == MyFactionRelationEnum.Friend || factionRelation == MyFactionRelationEnum.Neutral)
                {
                    // Report friendly fire on friendly units, when too much damage over time is done, friends will aggro
                    if (damageSource == MySession.PlayerShip && (this.PersistentFlags & MyPersistentEntityFlags.Parked) == 0)
                    {
                        MySession.PlayerShip.AddFriendlyFireDamage(this, damage);
                    }

                    healthDamage = damage = empDamage = 0;
                }
            }
            
            // When ship damages itself and it's player ship, don't do damage
            if (damageSource == this && damageSource == MySession.PlayerShip)
            {
                healthDamage = damage = empDamage = 0;
            }

            bool isPlayerShip = this == MySession.PlayerShip;

#if RENDER_PROFILING
            if (isPlayerShip)
                return;
#endif
            // Invincibility for player in editor or when profiling
            if (isPlayerShip && MyGuiScreenGamePlay.Static.IsEditorActive())
            {
                return;
            }


            if (isPlayerShip && (MyGuiScreenGamePlay.Static.IsCheatEnabled(MyGameplayCheatsEnum.PLAYER_SHIP_INDESTRUCTIBLE)))
            {
                damage = empDamage = 0;
            }

            if (MyFakes.TEST_MISSION_GAMEPLAY && (damage != 10000 || damageType != MyDamageType.Explosion))
            {
                damage = empDamage = healthDamage = 0;
            }

            if (isPlayerShip)
            {
                if (damageType != MyDamageType.Unknown)
                {
                    damage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerMultiplicator;
                }
            }

            //how much armor absorbs damage (0.0 no absorbtion, 1.0 full absorbtion)
            float armorReduction = m_armorProperties.HasValue ? m_armorProperties.Value.Resistance : 0;

            if (ammoType == MyAmmoType.Piercing)
            {
                armorReduction *= MyAmmoConstants.ArmorEffectivityVsPiercingAmmo; // Armor effectivity is lower against piercing ammo
            }

            //actual damage armor absorbed
            float armorDamage = Math.Min(ArmorHealth, damage);

            //update armor health value
            ArmorHealth -= armorDamage;

            //calculate actual damage to the ship (decrease it by the absorbed damage by armor)
            float shipDamage = damage - armorDamage * armorReduction;


            if (this == MySession.PlayerShip)
            {
                if (MySession.Static.Player.Medicines[(int)MyMedicineType.HEALTH_ENHANCING_MEDICINE].IsActive())
                    healthDamage *= MyMedicineConstants.HEALTH_ENHANCING_MEDICINE_DAMAGE_MULTIPLIER;

                if (damageType == MyDamageType.Radioactivity || damageType == MyDamageType.Sunwind)
                {
                    // activate if not active
                    if (!MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].IsActive())
                    {
                        MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].ActivateIfInInventory(Inventory);
                    }
                    // if active, modify health damage
                    if (MySession.Static.Player.Medicines[(int)MyMedicineType.ANTIRADIATION_MEDICINE].IsActive())
                    {
                        healthDamage *= MyMedicineConstants.ANTIRADIATION_MEDICINE_RADIATION_DAMAGE_MULTIPLIER;
                    }
                }

                if (damageSource == null || (damageSource != this && MyFactions.GetFactionsRelation(damageSource, this) == MyFactionRelationEnum.Enemy))
                {
                    healthDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                    shipDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                    empDamage *= MyGameplayConstants.GameplayDifficultyProfile.DamageToPlayerFromEnemyMultiplicator;
                }

                if (MySession.Static != null)
                {
                    if (!MySession.Static.Player.IsDead())
                    {
                        MySession.Static.Player.AddHealth(-healthDamage, damageSource);
                    }
                }

                if (damageType == MyDamageType.Radioactivity || damageType == MyDamageType.Sunwind)
                {
                    m_radiationLastDamage = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                    //PlayGeigerBeeping();
                    if (healthDamage >= MySmallShipConstants.WARNING_RADIATION_DAMAGE_PER_SECOND * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS)
                    {
                        m_radiationCriticalLastDamage = MyMinerGame.TotalGamePlayTimeInMilliseconds;
                        //PlayRadiationWarning();
                    }
                }
            }

            DisableByEMP(TimeSpan.FromSeconds(MySmallShipConstants.EMP_SMALLSHIP_DISABLE_DURATION_MULTIPLIER * empDamage));

            if (isPlayerShip)
            {
                if (damageSource != null)
                {
                    MyHud.SetDamageIndicator(damageSource, damageSource.GetPosition(), shipDamage);
                }
            }

            base.DoDamageInternal(healthDamage, shipDamage, empDamage, damageType, ammoType, damageSource, justDeactivate);

            UpdateDamageEffect();
        }
Пример #10
0
 public MyEntity CanSee(MyEntity target)
 {
     return MyEnemyTargeting.CanSee(this, target.GetPosition(), target);
 }
Пример #11
0
        bool MoveMotherShipForwardDest(MyEntity entity, Vector3 velocity, Vector3 destination)
        {
            if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10)
            {
                MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);

                return false;
            }
            return true;
        }
Пример #12
0
        /// <summary>
        /// Moves and Rotates entity
        /// </summary>
        /// <param name="newPosition"></param>
        /// <param name="newOrientation"></param>
        /// <param name="entity"></param>
        public static void MoveAndRotateObject(Vector3 newPosition, Matrix newOrientation, MyEntity entity)
        {
            BoundingSphere sphere = new BoundingSphere(newPosition + entity.LocalVolumeOffset, entity.WorldVolume.Radius);

            if (MyMwcSectorConstants.SECTOR_SIZE_FOR_PHYS_OBJECTS_BOUNDING_BOX.Contains(sphere) == MinerWarsMath.ContainmentType.Contains)
            {
                Matrix entityBeforeMoveOrientation = entity.GetWorldRotation();
                Vector3 entityBeforeMovePosition = entity.GetPosition();

                if (entityBeforeMovePosition != newPosition || entityBeforeMoveOrientation != newOrientation)
                {
                    // Move object
                    bool moveSuccesfull = entity.MoveAndRotate(newPosition, newOrientation);
                    Vector3 currentPosition = entity.GetPosition();
                    Matrix currentOrientation = entity.GetWorldRotation();

                    if (moveSuccesfull)
                    {
                        //entity.UpdateWorldMatrix();
                        //  Play movement or rotation sounds
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if (entityBeforeMovePosition != currentPosition)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveStep);
                            }

                            if (entityBeforeMoveOrientation != currentOrientation)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectRotateStep);
                            }

                            m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyEditorConstants.DELAY_OBJECT_MOVEMENT_SOUND_IN_MILLIS;
                        }

                        MyEditor.Static.RecheckAllColidingEntitesAndClearNonColiding();//check all coliding entites to see if any went out of collision state
                        
                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("CheckAllCollidingObjectsForEntity");

                        // This was taking up to 170ms for 800 prefabs, so its replaced by void CheckCollisions(IEnumerable<MyEntity> entities) in HandleInput().
                        //MyEditor.Static.CheckAllCollidingObjectsForEntity(entity);//check all colliding state of entity after move

                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); 
                    }
                    else
                    {
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if ((entityBeforeMovePosition != currentPosition) || (entityBeforeMoveOrientation != currentOrientation))
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveInvalid);
                                m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + 1000;
                            }
                        }
                    }

                }
            }
        }
Пример #13
0
        /// <summary>
        /// This method calculates new object position when its being rotated - in case only one object is selected and rotated
        /// only rotation is changed, but for multiple selected object, rotation is calculated based on the objects selected center
        /// </summary>
        static void GetRotationAndPosition(MyEntity entity, Matrix rotation, out Vector3 newPosition, out Matrix newRotation)
        {
            Matrix entityOrientation = entity.GetWorldRotation();
            Vector3 entityPosition = entity.GetPosition();
            Vector3 gizmoPosition = Position;

            if (ActivePivot == PivotType.OBJECT_CENTER)
            {
                //gizmoPosition = entityPosition;
            }

            Matrix localRot = Matrix.Identity;
            localRot.Forward = entityOrientation.Forward;
            localRot.Up = entityOrientation.Up;
            localRot.Right = entityOrientation.Right;
            m_localRight = MyMwcUtils.Normalize(m_localRight);
            localRot.Translation = entityPosition - gizmoPosition;

            Matrix rot = localRot * rotation;
            newPosition = rot.Translation + gizmoPosition;
            entityOrientation.Forward = rot.Forward;
            entityOrientation.Up = rot.Up;
            entityOrientation.Right = rot.Right;
            entityOrientation.Translation = Vector3.Zero;
            newRotation = entityOrientation;
        }
Пример #14
0
        /// <summary>
        /// Chceck if ship can see target
        /// </summary>
        /// <param name="position">Target position</param>
        /// <param name="target">Target entity.</param>
        /// <returns>True, if bot can see position.</returns>
        public static MyEntity CanSee(MyEntity source, Vector3 position, MyEntity ignoreEntity)
        {
            MyIntersectionResultLineTriangleEx? result = null;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MySmallShip CanSee");
            //There is 100 multiplier because Epsilon can get lost during transformation inside GetAllIntersectionWithLine
            //and normalization assert then appears
            if ((source.GetPosition() - position).Length() > MyMwcMathConstants.EPSILON * 100.0f)
            {
                var line = new MyLine(source.GetPosition(), position, true);
                result = MyEntities.GetIntersectionWithLine(ref line, source, ignoreEntity, ignoreChilds: true);
            }

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            return result.HasValue ? result.Value.Entity : null;
        }
 void MoveMotherShipForward(MyEntity entity, float speed)
 {
     Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction
     MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
 }
Пример #16
0
        public static bool IsRenderingInsideEntity(MyEntity entity)
        {
            if (entity == MySession.PlayerShip)
            {
                var isMainRenderInsidePlayerShip = Static.CameraAttachedTo ==
                                                   MyCameraAttachedToEnum.PlayerMinerShip &&
                                                   !MySecondaryCamera.Instance.IsCurrentlyRendering;

                var isSecondaryRenderInsidePlayerShip = MySecondaryCamera.Instance.IsInsidePlayerShip &&
                                                        MySecondaryCamera.Instance.IsCurrentlyRendering;

                return isMainRenderInsidePlayerShip || isSecondaryRenderInsidePlayerShip;
            }

            var squaredDistanceToCamera = Vector3.DistanceSquared(entity.GetPosition(), MyCamera.Position);

            var closeEnoughToCamera = squaredDistanceToCamera < 0.0001f;

            return closeEnoughToCamera;
        }
        private bool GetSafeRespawnPositionNearEntity(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyEntity entity, out Vector3 position)
        {
            float dist = entity.WorldVolume.Radius * 2;

            for (int c = 15; c-- != 0; )
            {
                Vector3 randomPointInSphere = MyMwcUtils.GetRandomVector3Normalized() * MyMwcUtils.GetRandomFloat(0, 1) * dist; // Random point in sphere
                Vector3 newTestPos = entity.GetPosition() + randomPointInSphere;

                var shipRadius = MinerWars.AppCode.Game.Models.MyModels.GetModelOnlyData(MyShipTypeConstants.GetShipTypeProperties(shipType).Visual.ModelLod0Enum).BoundingSphere.Radius;

                BoundingSphere bsphere = new BoundingSphere(newTestPos, shipRadius);
                MyEntity col = MyEntities.GetIntersectionWithSphere(ref bsphere);

                MyLine line = new MyLine(entity.GetPosition(), newTestPos);

                if (col == null && MyEntities.GetAnyIntersectionWithLine(ref line, entity, null, false, true, false, false) == null)
                {
                    position = newTestPos;
                    return true;
                }
            }
            position = default(Vector3);
            return false;
        }
 private static bool IsTargetVisible(MySmallShip smallShip, MyEntity otherEntity)
 {
     MyLine line = new MyLine(smallShip.WorldVolume.Center, otherEntity.GetPosition(), true);
     MyIntersectionResultLineTriangleEx? result = MyEntities.GetIntersectionWithLine(ref line, smallShip, null, ignoreChilds: true);
     return result != null && result.Value.Entity.GetBaseEntity() == otherEntity;
 }
 void MoveMotherShipForward(MyEntity entity, Vector3 velocity)
 {
     MyScriptWrapper.Move(entity, entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS);
 }
Пример #20
0
        public override void AtackedByEnemy(MyEntity damageSource)
        {
            // Leaders is far - ignore enemy attack
            if (IsLeaderFar() || (LeaderLostEnabled && Vector3.DistanceSquared(Leader.GetPosition(), damageSource.GetPosition()) > MyAIConstants.FAR_LEADER_DISTANCE_SQR))
            {
                return;
            }

            MyBotDesire desire = null;
            foreach (var item in m_desires)
            {
                if (item.DesireType == BotDesireType.ATACKED_BY_ENEMY && item.GetEnemy() == damageSource)
                {
                    desire = item;
                    break;
                }
            }

            if (desire == null)
            {
                desire = new MyAttackedByEnemyDesire(damageSource);
                AddDesire(desire);
            }
        }
Пример #21
0
        // Calculates squared distance from entity to closest player or player friend
        public float DistanceToPlayersSquared(MyEntity entity)
        {
            float dist = Vector3.DistanceSquared(MinerWars.AppCode.Game.GUI.MyGuiScreenGamePlay.Static.ControlledEntity.GetPosition(), entity.GetPosition());

            for (int i = 0; i < PlayerFriends.Count; i++)
            {
                var friend = PlayerFriends[i];
                float newdist = Vector3.DistanceSquared(friend.GetPosition(), entity.GetPosition());
                if (newdist < dist)
                {
                    dist = newdist;
                }
            }

            return dist;
        }
        MyEntity ChooseClosestPlayer(MyEntity bot)
        {
            if (MyMultiplayerGameplay.IsHosting)
            {
                var closestEntity = MySession.PlayerShip;
                var distSquared = Vector3.DistanceSquared(bot.GetPosition(), MySession.PlayerShip.GetPosition());

                foreach (var player in MyMultiplayerGameplay.Peers.Players)
                {
                    if (player.Ship != null && !player.Ship.IsDead() && !player.Ship.IsPilotDead())
                    {
                        var newDistSquared = Vector3.DistanceSquared(player.Ship.GetPosition(), closestEntity.GetPosition());
                        if (newDistSquared < distSquared)
                        {
                            distSquared = newDistSquared;
                            closestEntity = player.Ship;
                        }
                    }
                }

                return closestEntity;
            }
            else
            {
                return MySession.PlayerShip;
            }
        }
        bool MoveEntityForward(MyEntity entity, float speed, Vector3 destination, bool updateVelocity)
        {
            float SlowDownRadius = 200;
            float StopRadius = 10;

           // speed *= 10;

            Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction

            if (Vector3.DistanceSquared(destination, entity.GetPosition()) < SlowDownRadius * SlowDownRadius)
            {
                velocity = entity.Physics.LinearVelocity * 0.995f;
            }

            entity.Physics.Clear();

            if (Vector3.DistanceSquared(destination, entity.GetPosition()) > StopRadius * StopRadius)
            {
                Vector3 newPos = entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS;
                //entity.SetPosition(newPos); // recalculate position
                if (updateVelocity)
                {
                    MyScriptWrapper.MoveWithVelocity(entity, newPos, velocity);
                    // When at target set velocity to zero
                    if (Vector3.DistanceSquared(destination, entity.GetPosition()) > StopRadius * StopRadius)
                    {
                        MyScriptWrapper.MoveWithVelocity(entity, entity.GetPosition(), Vector3.Zero);
                    }
                }
                else
                {
                    MyScriptWrapper.Move(entity, newPos);
                }
                return false;
            }
            return true;
        }