コード例 #1
0
ファイル: Dialog_DockBoat.cs プロジェクト: SmashPhil/Vehicles
        private bool DockBoatTransferPawns()
        {
            DockedBoat dockedBoat = (DockedBoat)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfVehicles.DockedBoat);

            dockedBoat.Tile = caravan.Tile;
            float randomInRange = Rand.Range(2f, 4f) + (50 * (1 - caravan.PawnsListForReading.Where(x => x.IsBoat()).Max(x => (x as VehiclePawn).VehicleDef.properties.visibility)));

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

            if (caravan.PawnsListForReading.Where(p => !p.IsBoat()).Count() <= 0)
            {
                return(false);
            }

            foreach (TransferableOneWay t in transferables)
            {
                TransferableUtility.TransferNoSplit(t.things, t.CountToTransfer, delegate(Thing thing, int numToTake)
                {
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(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 (p.IsBoat())
                {
                    dockedBoat.dockedBoats.TryAddOrTransfer(p, false);
                }
            }
            Find.WorldObjects.Add(dockedBoat);
            return(true);
        }
コード例 #2
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, DockedBoat dockedBoat)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanVisit(caravan, dockedBoat), () => new CaravanArrivalAction_DockedBoats(dockedBoat),
                                                            "CommandUndockShip".Translate(dockedBoat.Label), caravan, dockedBoat.Tile, dockedBoat));
 }
コード例 #3
0
 public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, DockedBoat dockedBoat)
 {
     return(dockedBoat != null && dockedBoat.Spawned);
 }
コード例 #4
0
 public CaravanArrivalAction_DockedBoats(DockedBoat dockedBoat)
 {
     this.dockedBoat = dockedBoat;
 }