public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(
     Caravan caravan,
     WorldSettlementFC settlement)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(
                () => settlement.Spawned && settlement.settlement.isUnderAttack,
                () => new WorldSettlementDefendAction(settlement),
                "DefendColony".Translate(), caravan,
                settlement.Tile, settlement));
 }
        public override void OnAcceptKeyPressed()
        {
            base.OnAcceptKeyPressed();
            //faction.title = title;
            settlement.name = name;
            WorldSettlementFC settlementFc =
                Find.WorldObjects.WorldObjectAt <WorldSettlementFC>(settlement.mapLocation);

            if (settlementFc != null)
            {
                settlementFc.Name = name;
            }
        }
Example #3
0
        public static void changeDefendingMilitaryForce(FCEvent evt, SettlementFC settlementOfMilitaryForce)
        {
            FactionFC     factionfc        = Find.World.GetComponent <FactionFC>();
            militaryForce tmpMilitaryForce = null;
            SettlementFC  homeSettlement   = factionfc.returnSettlementByLocation(evt.location, evt.planetName);

            if (settlementOfMilitaryForce == evt.militaryForceDefending.homeSettlement)
            {
                Messages.Message("militaryAlreadyDefendingSettlement".Translate(), MessageTypeDefOf.RejectInput);
                return;
            }

            WorldSettlementFC target = Find.World.worldObjects.WorldObjectAt <WorldSettlementFC>(evt.location);

            if (evt.militaryForceDefending.homeSettlement !=
                factionfc.returnSettlementByLocation(evt.location, evt.planetName))
            {
                //if the forces defending aren't the forces belonging to the settlement
                evt.militaryForceDefending.homeSettlement.returnMilitary(false);
            }

            if (settlementOfMilitaryForce != homeSettlement)
            {
                tmpMilitaryForce =
                    militaryForce.createMilitaryForceFromSettlement(
                        factionfc.returnSettlementByLocation(evt.location, evt.planetName), true);
            }

            factionfc.militaryTargets.Remove(evt.location);
            evt.militaryForceDefending =
                militaryForce.createMilitaryForceFromSettlement(settlementOfMilitaryForce,
                                                                homeDefendingForce: tmpMilitaryForce);

            target.defenderForce = evt.militaryForceDefending;

            if (settlementOfMilitaryForce == homeSettlement)
            {
                //if home settlement is reseting to defense
                Messages.Message("defendingMilitaryReset".Translate(), MessageTypeDefOf.NeutralEvent);
            }
            else
            {
                //if settlement is foreign
                settlementOfMilitaryForce.SendMilitary(evt.settlementFCDefending.mapLocation, evt.planetName,
                                                       util.MilitaryJob.DefendFriendlySettlement, -1, evt.militaryForceAttackingFaction);
                Find.LetterStack.ReceiveLetter("Military Action", "ForeignMilitarySwitch"
                                               .Translate(settlementOfMilitaryForce.name,
                                                          factionfc.returnSettlementByLocation(evt.location, evt.planetName).name,
                                                          evt.militaryForceDefending.militaryLevel), LetterDefOf.NeutralEvent);
            }
        }
 public WorldSettlementTradeAction(WorldSettlementFC settlement) => this.settlement = settlement;
 public WorldSettlementTransportPodDefendAction(WorldSettlementFC mapParent, IntVec3 cell, bool landInShuttle)
 {
     this.mapParent     = mapParent;
     this.cell          = cell;
     this.landInShuttle = landInShuttle;
 }
 public WorldSettlementDefendAction(WorldSettlementFC settlement)
 {
     this.settlement = settlement;
 }
Example #7
0
        public static void Postfix(ref Pawn __instance, ref IEnumerable <Gizmo> __result)
        {
            List <Gizmo> output = __result.ToList();

            if (__result == null || __instance?.Faction == null || !output.Any() ||
                !(__instance.Map.Parent is WorldSettlementFC))
            {
                return;
            }

            Pawn found = __instance;
            Pawn_DraftController pawnDraftController = __instance.drafter ?? new Pawn_DraftController(__instance);

            WorldSettlementFC settlementFc = (WorldSettlementFC)__instance.Map.Parent;

            if (__instance.Faction.Equals(FactionColonies.getPlayerColonyFaction()))
            {
                Command_Toggle draftColonists = new Command_Toggle
                {
                    hotKey       = KeyBindingDefOf.Command_ColonistDraft,
                    isActive     = () => false,
                    toggleAction = () =>
                    {
                        if (pawnDraftController.pawn.Faction.Equals(Faction.OfPlayer))
                        {
                            return;
                        }
                        pawnDraftController.pawn.SetFaction(Faction.OfPlayer);
                        pawnDraftController.Drafted = true;
                    },
                    defaultDesc  = "CommandToggleDraftDesc".Translate(),
                    icon         = TexCommand.Draft,
                    turnOnSound  = SoundDefOf.DraftOn,
                    groupKey     = 81729172,
                    defaultLabel = "CommandDraftLabel".Translate()
                };
                if (pawnDraftController.pawn.Downed)
                {
                    draftColonists.Disable("IsIncapped".Translate(pawnDraftController.pawn.LabelShort, pawnDraftController.pawn));
                }
                draftColonists.tutorTag = "Draft";
                output.Add(draftColonists);
            }
            else if (__instance.Faction.Equals(Faction.OfPlayer) && __instance.Drafted &&
                     !settlementFc.supporting.Any(caravan => caravan.pawns.Any(pawn => pawn.Equals(found))))
            {
                foreach (Command_Toggle action in output.Where(gizmo => gizmo is Command_Toggle))
                {
                    if (action.hotKey != KeyBindingDefOf.Command_ColonistDraft)
                    {
                        continue;
                    }

                    int index = output.IndexOf(action);
                    action.toggleAction = () =>
                    {
                        found.SetFaction(FactionColonies.getPlayerColonyFaction());
                        //settlementFc.worldSettlement.defenderLord.AddPawn(__instance);
                    };
                    output[index] = action;
                    break;
                }
            }

            __result = output;
        }
Example #8
0
 public WorldSettlementTraderTracker(WorldSettlementFC settlement) => this.settlement = settlement;