Beispiel #1
0
        private bool DockBoatTransferPawns()
        {
            DockedBoat dockedBoat = (DockedBoat)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfShips.DockedBoat);

            dockedBoat.Tile = caravan.Tile;
            float randomInRange = Rand.Range(2f, 4f) + (50 * (1 - caravan.PawnsListForReading.Where(x => HelperMethods.IsShip(x)).Max(x => x.GetComp <CompShips>().Props.visibility)));

            dockedBoat.GetComponent <TimeoutComp>().StartTimeout(Mathf.CeilToInt(randomInRange * 60000));
            List <Pawn> boats = caravan.PawnsListForReading.Where(x => HelperMethods.IsShip(x)).ToList();
            List <Pawn> pawns = caravan.PawnsListForReading.Where(x => !HelperMethods.IsShip(x)).ToList();

            if (caravan.PawnsListForReading.Where(x => !HelperMethods.IsShip(x)).Count() <= 0)
            {
                return(false);
            }

            foreach (TransferableOneWay t in this.transferables)
            {
                TransferableUtility.TransferNoSplit(t.things, t.CountToTransfer, delegate(Thing thing, int numToTake)
                {
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(this.caravan, thing);
                    if (ownerOf is null)
                    {
                        return;
                    }
                    CaravanInventoryUtility.MoveInventoryToSomeoneElse(ownerOf, thing, pawns, boats, numToTake);
                }, true, true);
            }

            for (int i = caravan.pawns.Count - 1; i >= 0; i--)
            {
                Pawn p = caravan.PawnsListForReading[i];
                if (HelperMethods.IsShip(p))
                {
                    dockedBoat.dockedBoats.TryAddOrTransfer(p, false);
                }
            }
            Find.WorldObjects.Add(dockedBoat);
            return(true);
        }