示例#1
0
    private void SetUp()
    {
        var Data   = Entity.GetComponent <KnightData>();
        var Status = Entity.GetComponent <StatusManager_Knight>();

        Status.OffBalance  = false;
        Status.Interrupted = false;

        BackTime  = Data.OffBalanceBackTime;
        StayTime  = Data.OffBalanceStayTime;
        TimeCount = 0;

        Context.AttackCoolDownTimeCount = 0;

        AIUtility.RectifyDirection(Context.Player, Entity);

        if (Status.CurrentTakenAttack.Dir == Direction.Right)
        {
            Entity.GetComponent <SpeedManager>().SelfSpeed.x = Data.OffBalanceBackSpeed;
        }
        else if (Status.CurrentTakenAttack.Dir == Direction.Left)
        {
            Entity.GetComponent <SpeedManager>().SelfSpeed.x = -Data.OffBalanceBackSpeed;
        }
    }
        public override Job TryGiveJob(Pawn pawn)
        {
            if (!JoyUtility.EnjoyableOutsideNow(pawn.Map))
            {
                return(null);
            }

            IntVec3 position = AIUtility.FindRandomSpotOutsideColony(pawn, def.searchDistance, canReach: false, canReserve: false);

            if (!position.IsValid)
            {
                return(null);
            }

            IntVec3 standPosition = IntVec3.Invalid;

            if (!AIUtility.FindAroundSpotFromTarget(pawn, position, 4.0f, 3.0f, canSee: true, canReach: true, canReserve: true).TryRandomElement(out standPosition))
            {
                return(null);
            }

            return(new Job(IdleJobDefOf.IdleJob_ThrowingStone, position, standPosition)
            {
                locomotionUrgency = modSettings.wanderMovePolicy
            });
        }
示例#3
0
    public override void Update()
    {
        base.Update();

        var PatronData = Entity.GetComponent <PatronData>();

        if (CheckOffBalance())
        {
            TransitionTo <KnightOffBalance>();
            return;
        }

        if (CheckGetInterrupted())
        {
            TransitionTo <KnightKnockedBack>();
            return;
        }
        if (!AIUtility.PlayerInDetectRange(Entity, Context.Player, Context.DetectRightX, Context.DetectLeftX, PatronData.DetectHeight, PatronData.DetectLayer, false))
        {
            TransitionTo <KnightPatron>();
            return;
        }

        KeepDis();
        CheckAttackCoolDown();
    }
 protected override void Activate(Brain brain)
 {
     SetStatus(STATUS.ACTIVE);
     RemoveAllSubGoals(brain);
     if (!brain.targetCtrl.CanReviveOfTargetAlly())
     {
         SetStatus(STATUS.COMPLETED);
     }
     else
     {
         float num = 2f;
         if (brain.owner is Player)
         {
             num = (brain.owner as Player).playerParameter.revivalRange;
         }
         num *= 0.7f;
         brain.moveCtrl.ChangeStopRange(num);
         Character target = brain.targetCtrl.GetAllyTarget() as Character;
         float     lengthWithBetweenObject = AIUtility.GetLengthWithBetweenObject(brain.owner, target);
         if (lengthWithBetweenObject < num)
         {
             AddSubGoal <Goal_Prayer>().SetPrayer(target, num);
         }
         else
         {
             AddSubGoal <Goal_GoToAlly>();
         }
     }
 }
示例#5
0
        private void Scout_Click(object sender, EventArgs e)
        {
            bool running = controller.Enabled;

            controller.Stop();
            string             report  = "When scouting the sorrounding area, you see the following:";
            List <WorldPlayer> objects = World.Instance.actors.Where(a => AIUtility.Distance(a.WorldPosition, player.WorldPosition) == 1).ToList();

            foreach (var obj in objects)
            {
                report += obj.Report() + "\n";
            }
            Scouting s = player.GetTree("Scouting") as Scouting;

            if (s is null)
            {
                Scouting item = new Scouting();
                player.trees.Add(item);
                item.Activate();
            }
            else
            {
                s.Xp += objects.Count;
            }
            MessageBox.Show(report);
            if (running)
            {
                controller.Start();
            }
        }
        public override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.equipment == null || pawn.equipment.Primary == null || !pawn.equipment.Primary.def.IsMeleeWeapon)
            {
                return(null);
            }

            IntVec3 position = IntVec3.Invalid;

            if (pawn.ownership != null)
            {
                Room room = pawn.ownership.OwnedRoom;
                if (room != null)
                {
                    if (!room.Cells.Where(x => x.Standable(pawn.Map) && !x.IsForbidden(pawn) && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.None)).TryRandomElement(out position))
                    {
                        position = AIUtility.FindRandomSpotOutsideColony(pawn, canReach: true, canReserve: true);
                    }
                }
            }

            if (position.IsValid)
            {
                return(new Job(IdleJobDefOf.IdleJob_PracticeMelee, pawn.equipment.Primary, position)
                {
                    locomotionUrgency = modSettings.wanderMovePolicy
                });
            }

            return(null);
        }
    public override TaskStatus OnUpdate()
    {
        bool MovingRight = m_SpeedManager.GetTruePos().x < Target.Value.transform.position.x;

        if (MovingRight)
        {
            transform.eulerAngles = Vector3.zero;
        }
        else
        {
            transform.eulerAngles = new Vector3(0f, 180f, 0f);
        }

        m_SpeedManager.SelfSpeed.x = (MovingRight ? 1f : -1f) * Speed.Value;
        if (Mathf.Abs(AIUtility.GetXDiff(Target.Value, Owner.gameObject)) <= ArrivalDistance.Value)
        {
            m_SpeedManager.SelfSpeed.x = 0f;
        }

        if (m_Timer < Time.timeSinceLevelLoad)
        {
            return(TaskStatus.Success);
        }

        return(TaskStatus.Running);
    }
示例#8
0
 public static bool IsFailCondition(Unit self, Unit target, EUnitCondition condition)
 {
   bool flag = SceneBattle.Instance.Battle.CheckEnemySide(self, target);
   if (AIUtility.IsFailCondition(condition))
     return flag;
   return !flag;
 }
示例#9
0
    public override void Update()
    {
        base.Update();

        if (CheckOffBalance())
        {
            TransitionTo <SoulWarriorOffBalance>();
            return;
        }

        if (CheckGetInterrupted())
        {
            SetKnockedBack(true, Entity.GetComponent <StatusManager_SoulWarrior>().CurrentTakenAttack);
            return;
        }

        if (InKnockedBack)
        {
            KnockedBackProcess();
        }


        var PatronData = Entity.GetComponent <PatronData>();
        var Data       = Entity.GetComponent <SoulWarriorData>();

        if (!AIUtility.PlayerInDetectRange(Entity, Context.Player, Context.DetectRightX + Data.MagicUseableDis, Context.DetectLeftX - Data.MagicUseableDis, PatronData.DetectHeight, PatronData.DetectLayer, false))
        {
            TransitionTo <SoulWarriorPatron>();
        }
        CheckTime();
    }
示例#10
0
文件: Npc.cs 项目: ede0m/GustoGame
 private void ResetRoam(bool useAStar)
 {
     if (npcInInterior != null)
     {
         randomRegionRoamTile = npcInInterior.RandomInteriorTile(); // interior tile roaming
     }
     else
     {
         randomRegionRoamTile = BoundingBoxLocations.RegionMap[regionKey].RegionLandTiles[RandomEvents.rand.Next(BoundingBoxLocations.RegionMap[regionKey].RegionLandTiles.Count)]; // region tile roaming
     }
     if (useAStar)
     {
         TilePiece rtp         = (TilePiece)randomRegionRoamTile;
         Point?    gridPointTo = rtp.mapCordPoint;
         if (mapCordPoint != Point.Zero && mapCordPoint != null)
         {
             roaming     = true;
             currentPath = AIUtility.Pathfind(mapCordPoint.Value, gridPointTo.Value, PathType.AllOutdoor); // NOTE: This freezes the game when hitting GustoMap region (because it is almost all the tiles at the moment)
         }
     }
     else
     {
         roaming = true;
     }
 }
示例#11
0
    public override void Update()
    {
        base.Update();

        var PatronData = Entity.GetComponent <PatronData>();
        var Data       = Entity.GetComponent <SoulWarriorData>();

        if (CheckOffBalance())
        {
            TransitionTo <SoulWarriorOffBalance>();
            return;
        }

        if (CheckGetInterrupted())
        {
            TransitionTo <SoulWarriorKnockedBack>();
            return;
        }

        if (AIUtility.PlayerInDetectRange(Entity, Context.Player, Context.DetectRightX + Data.MagicUseableDis, Context.DetectLeftX - Data.MagicUseableDis, PatronData.DetectHeight, PatronData.DetectLayer, true))
        {
            TransitionTo <SoulWarriorEngage>();
            return;
        }
        Patron();
    }
    public bool CanSeekToOpponent(Vector3 target_pos, float move_len)
    {
        //IL_0007: Unknown result type (might be due to invalid IL or missing references)
        int obstacleMask = AIUtility.GetObstacleMask();

        return(CanSeekToPosition(target_pos, move_len, obstacleMask));
    }
    public bool CanSeekToAlly(Vector3 target_pos, float move_len)
    {
        //IL_0018: Unknown result type (might be due to invalid IL or missing references)
        int mask = AIUtility.GetObstacleMask() | AIUtility.GetOpponentMask(brain.owner);

        return(CanSeekToPosition(target_pos, move_len, mask));
    }
示例#14
0
    public void PerformRotation(Vector2 alignAngle, Vector2 requestDir)
    {
        float angle = Vector2.SignedAngle(alignAngle, requestDir);

        int[] powerChange = AIUtility.CalcPowerChangeForRotation(angle);
        Hull.PerformPowerChange(powerChange[0], powerChange[1]);
    }
示例#15
0
    public override void Update()
    {
        base.Update();

        var PatronData = Entity.GetComponent <PatronData>();

        if (CheckOffBalance())
        {
            TransitionTo <KnightOffBalance>();
            return;
        }

        if (CheckGetInterrupted())
        {
            TransitionTo <KnightKnockedBack>();
            return;
        }
        if (AIUtility.PlayerInDetectRange(Entity, Context.Player, Context.DetectRightX, Context.DetectLeftX, PatronData.DetectHeight, PatronData.DetectLayer, true))
        {
            TransitionTo <KnightEngage>();
            return;
        }

        CheckDisEngageTime();

        Patron();
    }
    public static FieldDropObject CreateTreasureBox(Coop_Model_EnemyDefeat model, List <InGameManager.DropDeliveryInfo> deliveryList, List <InGameManager.DropItemInfo> itemList, UIDropAnnounce.COLOR color)
    {
        //IL_004a: Unknown result type (might be due to invalid IL or missing references)
        //IL_004f: Unknown result type (might be due to invalid IL or missing references)
        //IL_0138: Unknown result type (might be due to invalid IL or missing references)
        //IL_013a: Unknown result type (might be due to invalid IL or missing references)
        //IL_013b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0140: Unknown result type (might be due to invalid IL or missing references)
        //IL_014b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0151: Unknown result type (might be due to invalid IL or missing references)
        //IL_0153: Unknown result type (might be due to invalid IL or missing references)
        //IL_016b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0170: Unknown result type (might be due to invalid IL or missing references)
        //IL_0182: Unknown result type (might be due to invalid IL or missing references)
        //IL_0187: Unknown result type (might be due to invalid IL or missing references)
        //IL_0196: Unknown result type (might be due to invalid IL or missing references)
        //IL_0198: Unknown result type (might be due to invalid IL or missing references)
        GameObject val = MonoBehaviourSingleton <InGameManager> .I.CreateTreasureBox(color);

        FieldDropObject fieldDropObject = val.GetComponent <FieldDropObject>();

        if (fieldDropObject == null)
        {
            fieldDropObject = val.AddComponent <FieldDropObject>();
        }
        fieldDropObject.itemInfo     = itemList;
        fieldDropObject.deliveryInfo = deliveryList;
        fieldDropObject.rewardId     = model.rewardId;
        fieldDropObject.isRare       = (color == UIDropAnnounce.COLOR.RARE);
        Vector3 zero = Vector3.get_zero();

        if (MonoBehaviourSingleton <InGameSettingsManager> .IsValid())
        {
            InGameSettingsManager.FieldDropItem fieldDrop = MonoBehaviourSingleton <InGameSettingsManager> .I.fieldDrop;
            float value  = Random.get_value();
            float value2 = Random.get_value();
            float value3 = Random.get_value();
            float num    = (!(Random.get_value() > 0.5f)) ? 1f : (-1f);
            float num2   = (!(Random.get_value() > 0.5f)) ? 1f : (-1f);
            zero._002Ector(Mathf.Lerp(fieldDrop.offsetMin.x, fieldDrop.offsetMax.x, value) * num, Mathf.Lerp(fieldDrop.offsetMin.y, fieldDrop.offsetMax.y, value2), Mathf.Lerp(fieldDrop.offsetMin.z, fieldDrop.offsetMax.z, value3) * num2);
        }
        Vector3 val2 = default(Vector3);

        val2._002Ector((float)model.x, 0f, (float)model.z);
        Vector3    target       = val2 + zero;
        int        obstacleMask = AIUtility.GetObstacleMask();
        RaycastHit hit          = default(RaycastHit);

        if (AIUtility.RaycastForTargetPos(val2, target, obstacleMask, out hit))
        {
            Vector3 point  = hit.get_point();
            float   x      = point.x;
            float   y      = target.y;
            Vector3 point2 = hit.get_point();
            target._002Ector(x, y, point2.z);
        }
        fieldDropObject.Drop(val2, target);
        return(fieldDropObject);
    }
示例#17
0
	public PLACE GetSafetySide()
	{
		if (firstRecord == null)
		{
			return PLACE.LEFT;
		}
		return AIUtility.GetSideOfAngle360(firstRecord.angle).Reverse();
	}
示例#18
0
 private void CheckHitPlayer()
 {
     if (!AttackHit && AIUtility.HitPlayer(Entity.transform.position, Attack, Context.PlayerLayer))
     {
         AttackHit = true;
         Entity.GetComponent <SpeedManager>().SelfSpeed.x = 0;
     }
 }
    //might put this method in a player class to reduce repeated code.
    private bool canSeePlayer()
    {
        float distToPlayer   = AIUtility.findWalkableDistance(aiTransform.position, playerTransform.position);
        bool  inFOV          = AIUtility.objectInFieldOfView(playerTransform.position, aiTransform, halfFOVRad);
        bool  hasLineOfSight = AIUtility.objectVisibleFromPosition(playerTransform.gameObject, aiTransform.position);

        return(distToPlayer <= 50f && inFOV && hasLineOfSight);
    }
示例#20
0
	public PLACE GetSafetyPlace()
	{
		if (firstRecord == null)
		{
			return PLACE.BACK;
		}
		return AIUtility.GetPlaceOfAngle360(firstRecord.angle).Reverse();
	}
示例#21
0
    public override void UpdateInsistence()
    {
        Insistence = 0;
        weaponsThatCanHit.Clear();

        if (controller.PrevManeuverBehaviour == ManeuverGoal.Behaviour.GoingforIt)
        {
            Tank aiTank = controller.SelfTank;

            Tank targetTank = controller.TargetTank;

            foreach (WeaponPart weapon in aiTank.Hull.GetAllWeapons())
            {
                if (weapon.CalcTimeToReloaded() > 0)
                {
                    continue;
                }

                if (weapon.Schematic.BulletType != Bullet.BulletTypes.MissileCluster)
                {
                    Vector2 targetPos     = AIUtility.CalculateTargetPosWithWeapon(weapon.Schematic.ShootImpulse, weapon.CalculateFirePos(), aiTank.transform.position, targetTank.transform.position, targetTank.Body.velocity);
                    Vector2 curFireVec    = weapon.CalculateFireVec();
                    Ray     ray           = new Ray(weapon.CalculateFirePos(), curFireVec);
                    float   shortestDist  = Vector3.Cross(ray.direction, (Vector3)(targetPos) - ray.origin).magnitude;
                    bool    canHitIfFired = shortestDist < targetTank.Hull.Schematic.Size.x / 2f;

                    Vector2 targetVec = targetPos - weapon.CalculateFirePos();

                    bool fireVecFacingTarget = Vector2.Angle(curFireVec, targetVec) < 90f;
                    bool inRange             = targetVec.magnitude < weapon.Schematic.Range;
                    if (inRange && canHitIfFired && fireVecFacingTarget)
                    {
                        weaponsThatCanHit.Add(weapon);
                    }
                }
                else
                {
                    float distFromTarget = (targetTank.transform.position - aiTank.transform.position).magnitude;

                    float     checkDist = (float)weapon.Schematic.BulletInfos["shoot_impulse"] * (float)weapon.Schematic.BulletInfos["missile_shoot_time"];
                    const int WallBit   = 8;
                    const int LayerMask = 1 << WallBit;

                    RaycastHit2D hit = Physics2D.Raycast(aiTank.transform.position, weapon.CalculateFireVec(), checkDist, LayerMask);

                    if (hit.collider == null && distFromTarget <= weapon.Schematic.Range)
                    {
                        weaponsThatCanHit.Add(weapon);
                    }
                }
            }

            if (weaponsThatCanHit.Count > 0)
            {
                Insistence = 100;
            }
        }
    }
示例#22
0
 private void CheckHitPlayer()
 {
     if (!AttackHit)
     {
         if (AIUtility.HitPlayer(Magic.transform.position, MagicAttack, Context.PlayerLayer))
         {
             AttackHit = true;
         }
     }
 }
示例#23
0
 public CaravanRoute(City start, City end, CaravanMarket caravanMarket, List <string> itemTypes, int money, List <InventoryItem> items = null)
 {
     this.start     = start;
     this.end       = end;
     this.itemTypes = itemTypes;
     this.money     = money;
     this.items     = items;
     days           = AIUtility.Distance(start.position, end.position) / 10;
     BuyItems();
     this.caravanMarket = caravanMarket;
 }
    //might put this method in a player class to reduce repeated code.
    private bool canHearPlayer()
    {
        bool heard = false;

        if (heardPlayer && (AIUtility.findWalkableDistance(aiTransform.position, playerTransform.position) <= 20f))
        {
            heard = true;
            Debug.Log("Heard player");
        }
        heardPlayer = false;
        return(heard);
    }
示例#25
0
    protected override STATUS Process(Brain brain)
    {
        //IL_000b: Unknown result type (might be due to invalid IL or missing references)
        //IL_0011: Unknown result type (might be due to invalid IL or missing references)
        double num = (double)AIUtility.GetLengthWithBetweenPosition(brain.owner._transform.get_position(), stopPos);

        if (num > giveupLen)
        {
            SetStatus(STATUS.COMPLETED);
        }
        return(status);
    }
示例#26
0
    public override AIAction[] CalcActionsToPerform()
    {
        Tank selfTank   = controller.SelfTank;
        Tank targetTank = controller.TargetTank;
        Map  map        = controller.Map;

        List <TreeSearchMoveInfo> possibleMoves = new List <TreeSearchMoveInfo>();

        possibleMoves.Add(new TreeSearchMoveInfo(new Vector2(0, 1), true));
        possibleMoves.Add(new TreeSearchMoveInfo(new Vector2(0, -1), true));
        possibleMoves.Add(new TreeSearchMoveInfo(new Vector2(0, 1).Rotate(90f), true));
        possibleMoves.Add(new TreeSearchMoveInfo(new Vector2(0, 1).Rotate(-90f), true));

        LookaheadTree tree = new LookaheadTree();

        tree.PopulateTree(selfTank, map, LookaheadTime, LookaheadTimeStep, possibleMoves);

        List <LookaheadNode> possibleNodes = tree.FindAllNodesAtSearchTime(LookaheadTime);

        possibleNodes = AIUtility.FilterByPathNotObstructed(possibleNodes);

        possibleNodes = AIUtility.FilterByDestNotObstructed(possibleNodes, map);

        possibleNodes = AIUtility.FilterByPassingBullet(possibleNodes, map);

        possibleNodes = AIUtility.FilterByAwayFromWall(possibleNodes, selfTank.StateInfo);

        LookaheadNode bestNode = null;
        float         bestCost = 0;

        foreach (LookaheadNode node in possibleNodes)
        {
            WeaponPart notUsed;
            int        targetTime = AIUtility.CalcMinTimeForAimerToHitAimee(targetTank.StateInfo, node.TankInfo, targetTank.Hull.GetAllWeapons(), out notUsed);
            int        selfTime   = AIUtility.CalcMinTimeForAimerToHitAimee(node.TankInfo, targetTank.StateInfo, selfTank.Hull.GetAllWeapons(), out notUsed);

            float cost = targetTime - selfTime;

            if (bestNode == null || bestCost < cost)
            {
                bestNode = node;
                bestCost = cost;
            }
        }

        timeSinceLastJet = Time.time;

        List <AIAction> actions = new List <AIAction>();

        actions.Add(new JetInDirAction(bestNode.IncomingDir, controller));

        return(actions.ToArray());
    }
    public float GetLengthWithAttackPos(StageObject obj, Vector3 check_pos)
    {
        //IL_001a: Unknown result type (might be due to invalid IL or missing references)
        //IL_001f: Unknown result type (might be due to invalid IL or missing references)
        OpponentRecord opponentRecord = Find(obj);

        if (opponentRecord == null)
        {
            return(0f);
        }
        return(AIUtility.GetLengthWithBetweenPosition(opponentRecord.record.attackPos, check_pos));
    }
示例#28
0
 public override void Notice()
 {
     // find all enemy units on field.
     foreach (Unit u in UnitManager.Instance.GetUnitsByTeam(team))
     {
         if (u.isBoss & !includingBosses)
         {
             continue;
         }
         AIUtility.AITypeChanger(u, changeTo);
     }
 }
示例#29
0
    private LookaheadNode runawayBehaviour(List <LookaheadNode> possibleNodes)
    {
        Tank targetTank = controller.TargetTank;
        Tank selfTank   = controller.SelfTank;

        float dist = (targetTank.transform.position - selfTank.transform.position).magnitude;

        float maxRange            = selfTank.Hull.GetMaxRange() * 1.5f;
        bool  onlyCloser          = maxRange < dist;
        bool  allWeaponsReloading = selfTank.Hull.IsAllWeaponsReloading();

        List <CostInfo> nodeCosts  = new List <CostInfo>();
        bool            withFilter = true;

        while (nodeCosts.Count == 0)
        {
            foreach (LookaheadNode node in possibleNodes)
            {
                WeaponPart notUsed;
                int        targetTime = AIUtility.CalcMinTimeForAimerToHitAimee(targetTank.StateInfo, node.TankInfo, targetTank.Hull.GetAllWeapons(), out notUsed);

                Vector2 incomingDir = node.GetNodeOneStepAfterRoot().IncomingDir;

                int   cost       = targetTime;
                float futureDist = ((Vector2)targetTank.transform.position - node.TankInfo.Pos).magnitude;
                if (!withFilter || ((onlyCloser && dist > futureDist) || (!onlyCloser && futureDist < maxRange) || allWeaponsReloading))
                {
                    nodeCosts.Add(new CostInfo(node, cost));
                }
            }

            withFilter = false;
        }

        CombatDebugHandler.Instance.RegisterObject("maneuver_runaway_cost_infos", nodeCosts);

        CostInfo bestInfo = null;

        foreach (CostInfo info in nodeCosts)
        {
            if (bestInfo == null || bestInfo.Cost < info.Cost)
            {
                bestInfo = info;
            }
        }

        bestInfo = handleSameCostCostInfos(bestInfo, nodeCosts);

        CombatDebugHandler.Instance.RegisterObject("maneuver_best_node", bestInfo.Node);

        return(bestInfo.Node.GetNodeOneStepAfterRoot());
    }
示例#30
0
    public override void Notice()
    {
        Character c = null;

        if (rosterCharacter != "")
        {
            c = UnitRoster.Instance.GetCharacter(rosterCharacter);
        }
        else
        {
            c = CharacterDB.Instance.GetCharacter(databaseCharacter);
        }
        if (level > 0)
        {
            c.Level = level;
        }

        Unit iSpawned = Unit.Create(c);

        iSpawned.name = (rosterCharacter != null) ? databaseCharacter : rosterCharacter;

        Tile targetTile = TileGrid.Instance.GetTileAt(transform.position);

        if (!iSpawned.MoveTo(targetTile))
        {
            if (targetTile.North == null || !iSpawned.MoveTo(targetTile.North))
            {
                if (targetTile.South == null || !iSpawned.MoveTo(targetTile.South))
                {
                    if (targetTile.East == null || !iSpawned.MoveTo(targetTile.East))
                    {
                        if (targetTile.West == null || !iSpawned.MoveTo(targetTile.West))
                        {
                            Debug.LogWarning("Unable to Spawn unit!");                             // TODO make sure this cannot happen!
                        }
                    }
                }
            }
        }

        iSpawned.team = team;
        if (changeAI)
        {
            try{
                AIUtility.AITypeChanger(iSpawned, ai);
                //UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(iSpawned.gameObject, "Assets/Event/EventTargets/SpawnUnit.cs (32,5)", ai.ToString());
            }catch (UnityException e) {
                Debug.LogException(e);
            }
        }
    }