public override void CompTick()
 {
     if (caravanIsWorking && Find.TickManager.TicksGame > workWillBeDoneAtTick)
     {
         CaravanVisitUtility.SettlementVisitedNow(caravan: (Caravan)parent)?.GetComponent <WorldObjectComp_SettlementBumperCropComp>().DoOutcome(caravan: (Caravan)parent);
     }
 }
Esempio n. 2
0
        public bool ShouldCancel()
        {
            if (!trader.CanTradeNow)
            {
                return(true);
            }

            if (trader is Pawn traderPawn)
            {
                if (!traderPawn.Spawned || !playerNegotiator.Spawned)
                {
                    return(true);
                }
                return(traderPawn.Position.DistanceToSquared(playerNegotiator.Position) > 2 * 2);
            }

            if (trader is Settlement traderBase)
            {
                var caravan = playerNegotiator.GetCaravan();
                if (caravan == null)
                {
                    return(true);
                }

                if (CaravanVisitUtility.SettlementVisitedNow(caravan) != traderBase)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 3
0
        public static Command TradeCommand(LandedShip caravan)
        {
            Pawn           bestNegotiator = CaravanVisitUtility.BestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = DropShipUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement factionBase = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (factionBase != null && factionBase.CanTradeNow)
                {
                    caravan.UnloadCargoForTrading();
                    //Find.WindowStack.Add(new Dialog_TradeFromShips(caravan, bestNegotiator, factionBase));
                    Find.WindowStack.Add(new Dialog_TradeFromShips(caravan, bestNegotiator, factionBase));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer(factionBase.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithFactionBase".Translate(), false);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.Good, factionBase, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            return(command_Action);
        }
 public override string CompInspectStringExtra()
 {
     if (CaravanVisitUtility.SettlementVisitedNow(caravan: (Caravan)parent)?.GetComponent <WorldObjectComp_SettlementBumperCropComp>()?.CaravanIsWorking ?? false)
     {
         return("MFI_CaravanWorking".Translate());
     }
     return(string.Empty);
 }
        private static void WorldReachUtility_PostFix(ref bool __result, Caravan c)
        {
            var settlement = CaravanVisitUtility.SettlementVisitedNow(caravan: c);
            WorldObjectComp_SettlementBumperCropComp bumperCropComponent = settlement?.GetComponent <WorldObjectComp_SettlementBumperCropComp>();

            if (bumperCropComponent != null)
            {
                __result = !bumperCropComponent.CaravanIsWorking;
            }
        }
Esempio n. 6
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            if (this.IsPlayerControlled)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandLaunchShip".Translate();
                command_Action.defaultDesc  = "CommandLaunchShipDesc".Translate();
                command_Action.icon         = DropShipUtility.LaunchSingleCommandTex;
                command_Action.action       = delegate
                {
                    SoundDef.Named("ShipTakeoff_SuborbitalLaunch").PlayOneShotOnCamera();
                    this.ships[0].StartChoosingDestination(this.ships[0], false);
                };
                yield return(command_Action);

                if (Find.WorldSelector.SingleSelectedObject == this)
                {
                    yield return(TravelingShipsUtility.ShipTouchdownCommand(this, true));

                    yield return(TravelingShipsUtility.ShipTouchdownCommand(this, false));
                }
                Settlement factionBase = CaravanVisitUtility.SettlementVisitedNow(this);
                if (factionBase != null && factionBase.CanTradeNow)
                {
                    yield return(TravelingShipsUtility.TradeCommand(this));
                }
                if (CaravanJourneyDestinationUtility.AnyJurneyDestinationAt(base.Tile))
                {
                    yield return(CaravanJourneyDestinationUtility.TakeOffCommand(base.Tile));
                }

                if (!this.ships.Any(x => x.ParkingMap == null))
                {
                    Command_Action command_Action4 = new Command_Action();
                    command_Action4.defaultLabel = "CommandTravelParkingPosition".Translate();
                    command_Action4.defaultDesc  = "CommandTravelParkingPositionDesc".Translate();
                    command_Action4.icon         = DropShipUtility.ReturnParkingFleet;
                    command_Action4.action       = delegate
                    {
                        foreach (ShipBase ship in this.ships)
                        {
                            ship.TryLaunch(new GlobalTargetInfo(ship.ParkingPosition, ship.ParkingMap), PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.EnterMapFriendly, false);
                        }
                    };
                    yield return(command_Action4);
                }
            }
        }
Esempio n. 7
0
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (this.Resting)
            {
                stringBuilder.Append("CaravanResting".Translate());
            }
            else if (this.AllOwnersDowned)
            {
                stringBuilder.Append("AllCaravanMembersDowned".Translate());
            }
            else if (this.pather.Moving)
            {
                if (this.pather.arrivalAction != null)
                {
                    stringBuilder.Append(this.pather.arrivalAction.ReportString);
                }
                else
                {
                    stringBuilder.Append("CaravanTraveling".Translate());
                }
            }
            else
            {
                Settlement factionBase = CaravanVisitUtility.SettlementVisitedNow(this);
                if (factionBase != null)
                {
                    stringBuilder.Append("CaravanVisiting".Translate(new object[]
                    {
                        factionBase.Label
                    }));
                }
                else
                {
                    stringBuilder.Append("CaravanWaiting".Translate());
                }
            }

            return(stringBuilder.ToString());
        }
Esempio n. 8
0
        static void ReopenTradingWindowLocally(Caravan caravan, Command __result)
        {
            var original = ((Command_Action)__result).action;

            ((Command_Action)__result).action = () =>
            {
                if (Multiplayer.Client != null && Multiplayer.WorldComp.trading.Any(t => t.trader == CaravanVisitUtility.SettlementVisitedNow(caravan)))
                {
                    Find.WindowStack.Add(new TradingWindow());
                    return;
                }

                original();
            };
        }