コード例 #1
0
        private void SpawnCaravanAtDestinationTile()
        {
            PawnFlyersTraveling.tmpPawns.Clear();
            for (int i = 0; i < this.pods.Count; i++)
            {
                ThingOwner innerContainer = this.pods[i].innerContainer;
                for (int j = 0; j < innerContainer.Count; j++)
                {
                    Pawn      pawn      = innerContainer[j] as Pawn;
                    PawnFlyer pawnFlyer = innerContainer[j] as PawnFlyer;
                    if (pawn != null)
                    {
                        PawnFlyersTraveling.tmpPawns.Add(pawn);
                    }
                    else if (pawnFlyer != null)
                    {
                        PawnFlyersTraveling.tmpPawns.Add((Pawn)pawnFlyer);
                    }
                }
            }
            int startingTile;

            if (!GenWorldClosest.TryFindClosestPassableTile(this.destinationTile, out startingTile))
            {
                startingTile = this.destinationTile;
            }
            Caravan o = CaravanMaker.MakeCaravan(PawnFlyersTraveling.tmpPawns, Faction.OfPlayer, startingTile, true);

            o.AddPawn((Pawn)pawnFlyer, false);
            for (int k = 0; k < this.pods.Count; k++)
            {
                ThingOwner innerContainer2 = this.pods[k].innerContainer;
                for (int l = 0; l < innerContainer2.Count; l++)
                {
                    if (!(innerContainer2[l] is Pawn))
                    {
                        Pawn pawn2 = CaravanInventoryUtility.FindPawnToMoveInventoryTo(innerContainer2[l],
                                                                                       PawnFlyersTraveling.tmpPawns, null, null);
                        pawn2.inventory.innerContainer.TryAdd(innerContainer2[l], true);
                    }
                    else
                    {
                        Pawn pawn3 = innerContainer2[l] as Pawn;
                        if (!pawn3.IsPrisoner)
                        {
                            if (pawn3.Faction != pawnFlyer.Faction)
                            {
                                pawn3.SetFaction(pawnFlyer.Faction);
                            }
                        }
                    }
                }
            }
            this.RemoveAllPods();
            Find.WorldObjects.Remove(this);
            Messages.Message("MessageTransportPodsArrived".Translate(), o, MessageTypeDefOf.PositiveEvent);
        }
コード例 #2
0
 private void AddItemsFromTransferablesToRandomInventories(List <Pawn> pawns)
 {
     transferables.RemoveAll((TransferableOneWay x) => x.AnyThing is Pawn);
     if (ListPlayerPawnsInventorySeparately)
     {
         for (int i = 0; i < pawns.Count; i++)
         {
             if (CanListInventorySeparately(pawns[i]))
             {
                 ThingOwner <Thing> innerContainer = pawns[i].inventory.innerContainer;
                 for (int num = innerContainer.Count - 1; num >= 0; num--)
                 {
                     RemoveCarriedItemFromTransferablesOrDrop(innerContainer[num], pawns[i], transferables);
                 }
             }
         }
         for (int j = 0; j < transferables.Count; j++)
         {
             if (transferables[j].things.Any((Thing x) => !x.Spawned))
             {
                 transferables[j].things.SortBy((Thing x) => x.Spawned);
             }
         }
     }
     for (int k = 0; k < transferables.Count; k++)
     {
         if (!(transferables[k].AnyThing is Corpse))
         {
             TransferableUtility.Transfer(transferables[k].things, transferables[k].CountToTransfer, delegate(Thing splitPiece, IThingHolder originalHolder)
             {
                 Thing item2 = splitPiece.TryMakeMinified();
                 CaravanInventoryUtility.FindPawnToMoveInventoryTo(item2, pawns, null).inventory.innerContainer.TryAdd(item2);
             });
         }
     }
     for (int l = 0; l < transferables.Count; l++)
     {
         if (!(transferables[l].AnyThing is Corpse))
         {
             continue;
         }
         TransferableUtility.TransferNoSplit(transferables[l].things, transferables[l].CountToTransfer, delegate(Thing originalThing, int numToTake)
         {
             if (AutoStripSpawnedCorpses)
             {
                 Corpse corpse = originalThing as Corpse;
                 if (corpse != null && corpse.Spawned)
                 {
                     corpse.Strip();
                 }
             }
             Thing item = originalThing.SplitOff(numToTake);
             CaravanInventoryUtility.FindPawnToMoveInventoryTo(item, pawns, null).inventory.innerContainer.TryAdd(item);
         });
     }
 }
コード例 #3
0
        private void SpawnCaravanAtDestinationTile()
        {
            tmpPawns.Clear();
            for (var i = 0; i < pods.Count; i++)
            {
                var innerContainer = pods[i].innerContainer;
                for (var j = 0; j < innerContainer.Count; j++)
                {
                    if (innerContainer[j] is Pawn pawn)
                    {
                        tmpPawns.Add(pawn);
                    }
                    else if (innerContainer[j] is PawnFlyer pawnFlyer)
                    {
                        tmpPawns.Add(pawnFlyer);
                    }
                }
            }

            if (!GenWorldClosest.TryFindClosestPassableTile(destinationTile, out var startingTile))
            {
                startingTile = destinationTile;
            }

            var o = CaravanMaker.MakeCaravan(tmpPawns, Faction.OfPlayer, startingTile, true);

            o.AddPawn(pawnFlyer, false);
            for (var k = 0; k < pods.Count; k++)
            {
                var innerContainer2 = pods[k].innerContainer;
                for (var l = 0; l < innerContainer2.Count; l++)
                {
                    if (!(innerContainer2[l] is Pawn))
                    {
                        var pawn2 = CaravanInventoryUtility.FindPawnToMoveInventoryTo(innerContainer2[l],
                                                                                      tmpPawns, null);
                        pawn2.inventory.innerContainer.TryAdd(innerContainer2[l]);
                    }
                    else
                    {
                        var pawn3 = innerContainer2[l] as Pawn;
                        if (!pawn3.IsPrisoner)
                        {
                            if (pawn3.Faction != pawnFlyer.Faction)
                            {
                                pawn3.SetFaction(pawnFlyer.Faction);
                            }
                        }
                    }
                }
            }

            RemoveAllPods();
            Find.WorldObjects.Remove(this);
            Messages.Message("MessageTransportPodsArrived".Translate(), o, MessageTypeDefOf.PositiveEvent);
        }
コード例 #4
0
        private static void DropToWorldObject(WorldObject place, List <ThingEntry> things, string from)
        {
            GlobalTargetInfo ti = new GlobalTargetInfo(place);

            if (place is FactionBase && ((FactionBase)place).Map != null)
            {
                var cell = GameUtils.GetTradeCell(((FactionBase)place).Map);
                ti = new GlobalTargetInfo(cell, ((FactionBase)place).Map);
                Thing thinXZ;
                foreach (var thing in things)
                {
                    var thin = thing.CreateThing(false);
                    var map  = ((FactionBase)place).Map;
                    if (thin is Pawn)
                    {
                        GenSpawn.Spawn((Pawn)thin, cell, map);
                    }
                    else
                    {
                        GenDrop.TryDropSpawn(thin, cell, map, ThingPlaceMode.Near, out thinXZ, null);
                    }
                }
            }
            else if (place is Caravan)
            {
                var pawns = (place as Caravan).PawnsListForReading;
                foreach (var thing in things)
                {
                    var thin = thing.CreateThing(false);
                    if (thin is Pawn)
                    {
                        (place as Caravan).AddPawn(thin as Pawn, true);
                        GameUtils.SpawnSetupOnCaravan(thin as Pawn);
                    }
                    else
                    {
                        var p = CaravanInventoryUtility.FindPawnToMoveInventoryTo(thin, pawns, null);
                        if (p != null)
                        {
                            p.inventory.innerContainer.TryAdd(thin, true);
                        }
                    }
                }
            }
            Find.LetterStack.ReceiveLetter("OCity_UpdateWorld_Trade".Translate()
                                           , string.Format("OCity_UpdateWorld_TradeDetails".Translate()
                                                           , from
                                                           , place.LabelCap
                                                           , things.Aggregate("", (r, i) => r + Environment.NewLine + i.Name + " x" + i.Count))
                                           , LetterDefOf.PositiveEvent
                                           , ti
                                           , null);
        }
コード例 #5
0
            internal void <> m__1(Thing originalThing, int numToTake)
            {
                if (this.$this.AutoStripSpawnedCorpses)
                {
                    Corpse corpse = originalThing as Corpse;
                    if (corpse != null && corpse.Spawned)
                    {
                        corpse.Strip();
                    }
                }
                Thing item = originalThing.SplitOff(numToTake);

                CaravanInventoryUtility.FindPawnToMoveInventoryTo(item, this.pawns, null, null).inventory.innerContainer.TryAdd(item, true);
            }
コード例 #6
0
 private void AddItemsFromTransferablesToRandomInventories(List <Pawn> pawns)
 {
     this.transferables.RemoveAll((TransferableOneWay x) => x.AnyThing is Pawn);
     for (int i = 0; i < this.transferables.Count; i++)
     {
         TransferableUtility.TransferNoSplit(this.transferables[i].things, this.transferables[i].CountToTransfer, delegate(Thing originalThing, int numToTake)
         {
             Corpse corpse = originalThing as Corpse;
             if (corpse != null && corpse.SpawnedOrAnyParentSpawned)
             {
                 corpse.Strip();
             }
             Thing thing = originalThing.SplitOff(numToTake);
             this.RemoveFromCorpseIfPossible(thing);
             CaravanInventoryUtility.FindPawnToMoveInventoryTo(thing, pawns, null, null).inventory.innerContainer.TryAdd(thing, true);
         }, true, true);
     }
 }
コード例 #7
0
        private void GivePodContentsToCaravan(Caravan caravan)
        {
            for (int i = 0; i < this.pods.Count; i++)
            {
                List <Thing> tmpContainedThings = new List <Thing>();
                //PawnFlyersTraveling.tmpContainedThing.Clear();

                tmpContainedThings.AddRange(this.pods[i].innerContainer);
                //this.pods[i].innerContainer.
                for (int j = 0; j < tmpContainedThings.Count; j++)
                {
                    this.pods[i].innerContainer.Remove(tmpContainedThings[j]);
                    tmpContainedThings[j].holdingOwner = null;
                    Pawn      pawn      = tmpContainedThings[j] as Pawn;
                    PawnFlyer pawnFlyer = tmpContainedThings[j] as PawnFlyer;
                    if (pawn != null)
                    {
                        caravan.AddPawn(pawn, true);
                    }
                    else if (pawnFlyer != null)
                    {
                        caravan.AddPawn(pawnFlyer, true);
                    }
                    else
                    {
                        Pawn pawn2 = CaravanInventoryUtility.FindPawnToMoveInventoryTo(tmpContainedThings[j],
                                                                                       caravan.PawnsListForReading, null, null);
                        bool flag = false;
                        if (pawn2 != null)
                        {
                            flag = pawn2.inventory.innerContainer.TryAdd(tmpContainedThings[j], true);
                        }
                        if (!flag)
                        {
                            tmpContainedThings[j].Destroy(DestroyMode.Vanish);
                        }
                    }
                }
            }
            this.RemoveAllPods();
            Find.WorldObjects.Remove(this);
            Messages.Message("MessageTransportPodsArrivedAndAddedToCaravan".Translate(), caravan,
                             MessageTypeDefOf.PositiveEvent);
        }
コード例 #8
0
        public static void SetupShipTrading(LandedShip landedShip)
        {
            List <Pawn> allPawns = new List <Pawn>();

            foreach (ShipBase current in landedShip.ships)
            {
                allPawns = DropShipUtility.AllPawnsInShip(current);
                for (int k = 0; k < allPawns.Count; k++)
                {
                    ThingContainer innerContainer2 = current.GetInnerContainer();
                    for (int l = 0; l < innerContainer2.Count; l++)
                    {
                        if (!(innerContainer2[l] is Pawn))
                        {
                            Pawn pawn2 = CaravanInventoryUtility.FindPawnToMoveInventoryTo(innerContainer2[l], allPawns, null, null);
                            pawn2.inventory.innerContainer.TryAdd(innerContainer2[l], true);
                        }
                    }
                }
            }
        }
コード例 #9
0
        private void exchangeOfGoods(Caravan caravan)
        {
            //Pawn bestNegotiator = CaravanVisitUtility.BestNegotiator(caravan);
            ThingOwner <Thing> сontainer = new ThingOwner <Thing>();
            Dialog_TradeOnline form      = null;

            if (сaravanOnline.OnlineWObject == null)
            {
                Log.Error("OCity_Caravan_LOGNoData".Translate());
                return;
            }

            var goods = GameUtils.GetAllThings(caravan);

            form = new Dialog_TradeOnline(goods
                                          , сaravanOnline.OnlinePlayerLogin
                                          , сaravanOnline.OnlineWObject.FreeWeight
                                          , () =>
            {
                if (!SessionClientController.Data.BackgroundSaveGameOff)
                {
                    var select            = form.GetSelect();
                    bool selectAllCaravan = caravan.PawnsListForReading.Count == select.Count(s => s.Key is Pawn);
                    if (selectAllCaravan)
                    {
                        Log.Message("OCity_Caravan_LOGSwap".Translate());
                        select = new Dictionary <Thing, int>();
                        foreach (var pawn in caravan.PawnsListForReading)
                        {
                            foreach (var item in pawn.inventory.innerContainer.ToDictionary(t => t, t => t.stackCount))
                            {
                                select.Add(item.Key, item.Value);
                            }
                            select.Add(pawn, 1);
                            pawn.inventory.innerContainer.Clear();
                        }
                    }
                    //передаем выбранные товары из caravan к другому игроку в сaravanOnline
                    var sendThings = new List <ThingEntry>();
                    foreach (var pair in select)
                    {
                        var thing     = pair.Key;
                        var numToTake = pair.Value;
                        if (thing is Pawn)
                        {
                            var pawn = thing as Pawn;
                            //если отдали пешку, то выкладываем все другим и удаляемся из каравана
                            var things = pawn.inventory.innerContainer.ToList();
                            pawn.inventory.innerContainer.Clear();
                            GameUtils.DeSpawnSetupOnCaravan(caravan, pawn);
                            foreach (var thin in things)
                            {
                                var p = CaravanInventoryUtility.FindPawnToMoveInventoryTo(thin, caravan.PawnsListForReading, null);
                                if (p != null)
                                {
                                    p.inventory.innerContainer.TryAdd(thin, true);
                                }
                            }
                        }
                        sendThings.Add(ThingEntry.CreateEntry(thing, numToTake));
                    }

                    if (selectAllCaravan)
                    {
                        //удаляем пешку из игры
                        foreach (var pawn in caravan.PawnsListForReading)
                        {
                            GameUtils.PawnDestroy(pawn);
                        }

                        Find.WorldObjects.Remove(caravan);
                    }
                    else
                    {
                        foreach (var pair in select)
                        {
                            var thing     = pair.Key;
                            var numToTake = pair.Value;
                            if (thing is Pawn)
                            {
                                var pawn = thing as Pawn;
                                //удаляем пешку из игры
                                GameUtils.PawnDestroy(pawn);
                            }
                            else
                            {
                                //если отдали вешь, то находим кто её тащит и убираем с него
                                Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                                ownerOf.inventory.innerContainer.TryTransferToContainer(thing, сontainer, numToTake);
                            }
                        }
                    }

                    //После передачи сохраняем, чтобы нельзя было обузить, после чего передаем вещи
                    SessionClientController.SaveGameNowSingleAndCommandSafely(
                        (connect) =>
                    {
                        return(connect.SendThings(sendThings
                                                  , SessionClientController.My.Login
                                                  , сaravanOnline.OnlinePlayerLogin
                                                  , сaravanOnline.OnlineWObject.ServerId
                                                  , сaravanOnline.Tile
                                                  ));
                    },
                        null,
                        null); //если не удалось отправить письмо, то жопа так как сейв уже прошел
                }
            });
            Find.WindowStack.Add(form);
        }
コード例 #10
0
        private static void DropToWorldObjectDo(WorldObject place, List <ThingEntry> things, string from, string text)
        {
            GlobalTargetInfo ti = new GlobalTargetInfo(place);
            var factionPirate   = SessionClientController.Data.FactionPirate;

            if (MainHelper.DebugMode)
            {
                Loger.Log("Mail================================================= {");
            }

            if (place is Settlement && ((Settlement)place).Map != null)
            {
                var map  = ((Settlement)place).Map;
                var cell = GameUtils.GetTradeCell(map);
                ti = new GlobalTargetInfo(cell, map);
                Thing thinXZ;
                foreach (var thing in things)
                {
                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Mail------------------------------------------------- {" + Environment.NewLine
                                  + thing.Data + Environment.NewLine
                                  + "Mail------------------------------------------------- }" + Environment.NewLine);
                    }
                    var thin = PrepareSpawnThingEntry(thing, factionPirate);

                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Spawn...");
                    }
                    if (thin is Pawn)
                    {
                        GenSpawn.Spawn((Pawn)thin, cell, map);
                    }
                    else
                    {
                        GenDrop.TryDropSpawn(thin, cell, map, ThingPlaceMode.Near, out thinXZ, null);
                    }
                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Spawn...OK");
                    }
                }
            }
            else if (place is Caravan)
            {
                var pawns = (place as Caravan).PawnsListForReading;
                foreach (var thing in things)
                {
                    /*
                     * thing.SetFaction(factionColonistLoadID, factionPirateLoadID);
                     * var thin = thing.CreateThing(false);
                     */
                    var thin = PrepareSpawnThingEntry(thing, factionPirate);

                    if (thin is Pawn)
                    {
                        (place as Caravan).AddPawn(thin as Pawn, true);
                        GameUtils.SpawnSetupOnCaravan(thin as Pawn);
                    }
                    else
                    {
                        var p = CaravanInventoryUtility.FindPawnToMoveInventoryTo(thin, pawns, null);
                        if (p != null)
                        {
                            p.inventory.innerContainer.TryAdd(thin, true);
                        }
                    }
                }
            }

            if (MainHelper.DebugMode)
            {
                Loger.Log("Mail================================================= }");
            }

            Find.LetterStack.ReceiveLetter("OCity_UpdateWorld_Trade".Translate()
                                           , text
                                           , LetterDefOf.PositiveEvent
                                           , ti
                                           , null);
        }
コード例 #11
0
        public override void Arrived(Caravan caravan)
        {
            if (mode == "exchangeOfGoods")
            {
                //Pawn bestNegotiator = CaravanVisitUtility.BestNegotiator(caravan);
                ThingOwner <Thing> сontainer = new ThingOwner <Thing>();
                Dialog_TradeOnline form      = null;
                if (сaravanOnline.OnlineWObject == null)
                {
                    Log.Error("OCity_Caravan_LOGNoData".Translate());
                    return;
                }

                var goods = CaravanInventoryUtility.AllInventoryItems(caravan).ToList().Concat(
                    caravan.PawnsListForReading
                    .Cast <Thing>()
                    ).ToList();

                form = new Dialog_TradeOnline(goods
                                              , сaravanOnline.OnlinePlayerLogin
                                              , сaravanOnline.OnlineWObject.FreeWeight
                                              , () =>
                {
                    var select            = form.GetSelect();
                    bool selectAllCaravan = caravan.PawnsListForReading.Count == select.Count(s => s.Key is Pawn);
                    if (selectAllCaravan)
                    {
                        Log.Message("OCity_Caravan_LOGSwap".Translate());
                        select = new Dictionary <Thing, int>();
                        foreach (var pawn in caravan.PawnsListForReading)
                        {
                            foreach (var item in pawn.inventory.innerContainer.ToDictionary(t => t, t => t.stackCount))
                            {
                                select.Add(item.Key, item.Value);
                            }
                            select.Add(pawn, 1);
                            pawn.inventory.innerContainer.Clear();
                        }
                    }
                    //передаем выбранные товары из caravan к другому игроку в сaravanOnline
                    var sendThings = new List <ThingEntry>();
                    foreach (var pair in select)
                    {
                        var thing     = pair.Key;
                        var numToTake = pair.Value;
                        if (thing is Pawn)
                        {
                            var pawn = thing as Pawn;
                            //если отдали пешку, то выкладываем все другим и удаляемся из каравана
                            var things = pawn.inventory.innerContainer.ToList();
                            pawn.inventory.innerContainer.Clear();
                            GameUtils.DeSpawnSetupOnCaravan(caravan, pawn);
                            foreach (var thin in things)
                            {
                                var p = CaravanInventoryUtility.FindPawnToMoveInventoryTo(thin, caravan.PawnsListForReading, null);
                                if (p != null)
                                {
                                    p.inventory.innerContainer.TryAdd(thin, true);
                                }
                            }
                        }
                        sendThings.Add(new ThingEntry(thing, numToTake));
                    }
                    SessionClientController.Command((connect) =>
                    {
                        connect.SendThings(sendThings
                                           , SessionClientController.My.Login
                                           , сaravanOnline.OnlinePlayerLogin
                                           , сaravanOnline.OnlineWObject.ServerId
                                           , сaravanOnline.Tile
                                           );
                    });

                    if (selectAllCaravan)
                    {
                        //удаляем пешку из игры
                        foreach (var pawn in caravan.PawnsListForReading)
                        {
                            pawn.Destroy(DestroyMode.Vanish);
                        }

                        Find.WorldObjects.Remove(caravan);
                    }
                    else
                    {
                        foreach (var pair in select)
                        {
                            var thing     = pair.Key;
                            var numToTake = pair.Value;
                            if (thing is Pawn)
                            {
                                var pawn = thing as Pawn;
                                //удаляем пешку из игры
                                pawn.Destroy(DestroyMode.Vanish);
                                //Find.WorldPawns.RemovePawn(pawn); не проверенное не полное удаление, если её вернут назад
                            }
                            else
                            {
                                //если отдали вешь, то находим кто её тащит и убираем с него
                                Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                                ownerOf.inventory.innerContainer.TryTransferToContainer(thing, сontainer, numToTake);
                            }
                        }
                    }
                });
                Find.WindowStack.Add(form);
            }
        }
コード例 #12
0
            internal void <> m__0(Thing splitPiece, IThingHolder originalHolder)
            {
                Thing item = splitPiece.TryMakeMinified();

                CaravanInventoryUtility.FindPawnToMoveInventoryTo(item, this.pawns, null, null).inventory.innerContainer.TryAdd(item, true);
            }
コード例 #13
0
        private static void DropToWorldObjectDo(WorldObject place, List <ThingEntry> things, string from, string text)
        {
            GlobalTargetInfo ti       = new GlobalTargetInfo(place);
            var factionColonistLoadID = Find.FactionManager.OfPlayer.GetUniqueLoadID();
            var factionPirate         = Find.FactionManager.AllFactions.FirstOrDefault(f => f.def.defName == "Pirate")
                                        ?? Find.FactionManager.OfAncientsHostile;
            var factionPirateLoadID = factionPirate.GetUniqueLoadID();

            if (MainHelper.DebugMode)
            {
                Loger.Log("Mail================================================= {");
            }

            if (place is Settlement && ((Settlement)place).Map != null)
            {
                var cell = GameUtils.GetTradeCell(((Settlement)place).Map);
                ti = new GlobalTargetInfo(cell, ((Settlement)place).Map);
                Thing thinXZ;
                foreach (var thing in things)
                {
                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Mail------------------------------------------------- {" + Environment.NewLine
                                  + thing.Data + Environment.NewLine
                                  + "Mail------------------------------------------------- }" + Environment.NewLine);
                    }

                    var   prisoner = thing.SetFaction(factionColonistLoadID, factionPirateLoadID);
                    Thing thin;
                    thin = thing.CreateThing(false);
                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("SetFaction...");
                    }
                    if (thin.def.CanHaveFaction)
                    {
                        if (prisoner && thin is Pawn)
                        {
                            thin.SetFaction(factionPirate);
                            var p = thin as Pawn;
                            p.guest.SetGuestStatus(factionPirate, true);
                        }
                        else
                        {
                            thin.SetFaction(Find.FactionManager.OfPlayer);
                        }
                    }


                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Spawn...");
                    }
                    var map = ((Settlement)place).Map;
                    if (thin is Pawn)
                    {
                        GenSpawn.Spawn((Pawn)thin, cell, map);
                    }
                    else
                    {
                        GenDrop.TryDropSpawn(thin, cell, map, ThingPlaceMode.Near, out thinXZ, null);
                    }
                    if (MainHelper.DebugMode)
                    {
                        Loger.Log("Spawn...OK");
                    }
                }
            }
            else if (place is Caravan)
            {
                var pawns = (place as Caravan).PawnsListForReading;
                foreach (var thing in things)
                {
                    thing.SetFaction(factionColonistLoadID, factionPirateLoadID);
                    var thin = thing.CreateThing(false);
                    if (thin is Pawn)
                    {
                        (place as Caravan).AddPawn(thin as Pawn, true);
                        GameUtils.SpawnSetupOnCaravan(thin as Pawn);
                    }
                    else
                    {
                        var p = CaravanInventoryUtility.FindPawnToMoveInventoryTo(thin, pawns, null);
                        if (p != null)
                        {
                            p.inventory.innerContainer.TryAdd(thin, true);
                        }
                    }
                }
            }

            if (MainHelper.DebugMode)
            {
                Loger.Log("Mail================================================= }");
            }

            Find.LetterStack.ReceiveLetter("OCity_UpdateWorld_Trade".Translate()
                                           , text
                                           , LetterDefOf.PositiveEvent
                                           , ti
                                           , null);
        }