Exemple #1
0
        static void Prefix(RimWorld.Faction other, ref int goodwillChange, bool canSendMessage, bool canSendHostilityLetter, ref string reason, RimWorld.Planet.GlobalTargetInfo?lookTarget)
        {
            var tradeCaravanCost = -LoadedModManager.GetMod <AdjustableTradeCosts>().GetSettings <TradeCostsSettings>().tradeCaravanCost;
            var militaryAidCost  = -LoadedModManager.GetMod <AdjustableTradeCosts>().GetSettings <TradeCostsSettings>().militaryAidCost;

            String translatedReqTrader = "GoodwillChangedReason_RequestedTrader".Translate();

            if (translatedReqTrader.Equals(reason))
            {
                goodwillChange = tradeCaravanCost;
            }

            String translatedMilitaAid = "GoodwillChangedReason_RequestedMilitaryAid".Translate();

            if (translatedMilitaAid.Equals(reason))
            {
                goodwillChange = militaryAidCost;
            }
        }
Exemple #2
0
 public static int GetCurrentTitleSeniorityIn(this Pawn p, Faction faction)
 {
     return(p.GetCurrentTitleIn(faction)?.seniority ?? 0);
 }
 public override float MinimumPoints(Faction fac, PawnGroupKindDef groupKind)
 {
     return(Mathf.Max(base.MinimumPoints(fac, groupKind), 350f));
 }
 public static IEnumerable <Thing> GetMeditationFociAffectedByBuilding(Map map, ThingDef def, Faction faction, IntVec3 pos, Rot4 rotation)
 {
     if (!CountsAsArtificialBuilding(def, faction))
     {
         yield break;
     }
     foreach (Thing item in map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.MeditationFocus)))
     {
         CompMeditationFocus compMeditationFocus = item.TryGetComp <CompMeditationFocus>();
         if (compMeditationFocus != null && compMeditationFocus.WillBeAffectedBy(def, faction, pos, rotation))
         {
             yield return(item);
         }
     }
 }
Exemple #5
0
 public LordJob_Siege(Faction faction, IntVec3 siegeSpot, float blueprintPoints)
 {
     this.faction         = faction;
     this.siegeSpot       = siegeSpot;
     this.blueprintPoints = blueprintPoints;
 }
 public static bool AllyOrNeutralTo(this Faction fac, Faction other)
 {
     return(!fac.HostileTo(other));
 }
Exemple #7
0
 public LordJob_StageThenAttack(Faction faction, IntVec3 stageLoc, int raidSeed)
 {
     this.faction  = faction;
     this.stageLoc = stageLoc;
     this.raidSeed = raidSeed;
 }
        private bool TrySpawnPowerTransmittingBuildingNear(IntVec3 position, Map map, Faction faction, ThingDef def, out Building newBuilding, Predicate <IntVec3> extraValidator = null)
        {
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassAllDestroyableThings, Danger.Deadly, false);
            IntVec3       loc;

            if (RCellFinder.TryFindRandomCellNearWith(position, delegate(IntVec3 x)
            {
                if (!x.Standable(map) || x.Roofed(map) || !this.EverPossibleToTransmitPowerAt(x, map))
                {
                    return(false);
                }
                if (!map.reachability.CanReach(position, x, PathEndMode.OnCell, traverseParams))
                {
                    return(false);
                }
                CellRect.CellRectIterator iterator = GenAdj.OccupiedRect(x, Rot4.North, def.size).GetIterator();
                while (!iterator.Done())
                {
                    IntVec3 current = iterator.Current;
                    if (!current.InBounds(map) || current.Roofed(map) || current.GetEdifice(map) != null || current.GetFirstItem(map) != null || current.GetTransmitter(map) != null)
                    {
                        return(false);
                    }
                    iterator.MoveNext();
                }
                return(extraValidator == null || extraValidator(x));
            }, map, out loc, 8, 2147483647))
            {
                newBuilding = (Building)GenSpawn.Spawn(ThingMaker.MakeThing(def, null), loc, map, Rot4.North, WipeMode.Vanish, false);
                newBuilding.SetFaction(faction, null);
                return(true);
            }
            newBuilding = null;
            return(false);
        }
Exemple #9
0
        public void SetGuestStatus(Faction newHost, bool prisoner = false)
        {
            if (newHost != null)
            {
                Released = false;
            }
            if (newHost == HostFaction && prisoner == IsPrisoner)
            {
                return;
            }
            if (!prisoner && pawn.Faction.HostileTo(newHost))
            {
                Log.Error(string.Concat("Tried to make ", pawn, " a guest of ", newHost, " but their faction ", pawn.Faction, " is hostile to ", newHost));
                return;
            }
            if (newHost != null && newHost == pawn.Faction && !prisoner)
            {
                Log.Error(string.Concat("Tried to make ", pawn, " a guest of their own faction ", pawn.Faction));
                return;
            }
            bool num = prisoner && (!IsPrisoner || HostFaction != newHost);

            isPrisonerInt = prisoner;
            Faction faction = hostFactionInt;

            hostFactionInt = newHost;
            Pawn obj = pawn;
            bool clearMentalState = prisoner;

            obj.ClearMind(newHost != null, clearInspiration: false, clearMentalState);
            if (num)
            {
                pawn.DropAndForbidEverything();
                pawn.GetLord()?.Notify_PawnLost(pawn, PawnLostCondition.MadePrisoner);
                if (pawn.Drafted)
                {
                    pawn.drafter.Drafted = false;
                }
                float x = pawn.RecruitDifficulty(Faction.OfPlayer);
                resistance  = StartingResistancePerRecruitDifficultyCurve.Evaluate(x);
                resistance *= StartingResistanceFactorFromPopulationIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntent);
                resistance *= StartingResistanceRandomFactorRange.RandomInRange;
                if (pawn.royalty != null)
                {
                    RoyalTitle mostSeniorTitle = pawn.royalty.MostSeniorTitle;
                    if (mostSeniorTitle != null)
                    {
                        resistance *= mostSeniorTitle.def.recruitmentResistanceFactor;
                        resistance += mostSeniorTitle.def.recruitmentResistanceOffset;
                    }
                }
                resistance = GenMath.RoundRandom(resistance);
            }
            PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn);
            pawn.health.surgeryBills.Clear();
            if (pawn.ownership != null)
            {
                pawn.ownership.Notify_ChangedGuestStatus();
            }
            ReachabilityUtility.ClearCacheFor(pawn);
            if (pawn.Spawned)
            {
                pawn.Map.mapPawns.UpdateRegistryForPawn(pawn);
                pawn.Map.attackTargetsCache.UpdateTarget(pawn);
            }
            AddictionUtility.CheckDrugAddictionTeachOpportunity(pawn);
            if (prisoner && pawn.playerSettings != null)
            {
                pawn.playerSettings.Notify_MadePrisoner();
            }
            if (faction != hostFactionInt)
            {
                QuestUtility.SendQuestTargetSignals(pawn.questTags, "ChangedHostFaction", pawn.Named("SUBJECT"), hostFactionInt.Named("FACTION"));
            }
        }
Exemple #10
0
        public void Spawn(Map map, IntVec3 pos, Faction faction, SpawnPosType posType = SpawnPosType.Unchanged, SpawnMode spawnMode = SpawnMode.Normal, bool wipeIfCollides = false, bool clearEdificeWhereFloor = false, List <Thing> spawnedThings = null, bool dormant = false, bool buildRoofsInstantly = false, Func <SketchEntity, IntVec3, bool> canSpawnThing = null, Action <IntVec3, SketchEntity> onFailedToSpawnThing = null)
        {
            IntVec3 offset = GetOffset(pos, posType);

            if (clearEdificeWhereFloor)
            {
                for (int i = 0; i < cachedTerrain.Count; i++)
                {
                    if (cachedTerrain[i].def.layerable)
                    {
                        (cachedTerrain[i].pos + offset).GetEdifice(map)?.Destroy();
                    }
                }
            }
            foreach (SketchEntity item in entities.OrderBy((SketchEntity x) => x.SpawnOrder))
            {
                IntVec3 intVec = item.pos + offset;
                if ((canSpawnThing != null && !canSpawnThing(item, intVec)) || !item.Spawn(intVec, map, faction, spawnMode, wipeIfCollides, spawnedThings, dormant))
                {
                    onFailedToSpawnThing?.Invoke(intVec, item);
                }
            }
            if (spawnedThings != null && spawnMode == SpawnMode.TransportPod && !wipeIfCollides)
            {
                bool flag = false;
                for (int j = 0; j < spawnedThings.Count; j++)
                {
                    for (int k = j + 1; k < spawnedThings.Count; k++)
                    {
                        CellRect cellRect = GenAdj.OccupiedRect(spawnedThings[j].Position, spawnedThings[j].Rotation, spawnedThings[j].def.size);
                        CellRect other    = GenAdj.OccupiedRect(spawnedThings[k].Position, spawnedThings[k].Rotation, spawnedThings[k].def.size);
                        if (cellRect.Overlaps(other) && (GenSpawn.SpawningWipes(spawnedThings[j].def, spawnedThings[k].def) || GenSpawn.SpawningWipes(spawnedThings[k].def, spawnedThings[j].def)))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        break;
                    }
                }
                if (flag)
                {
                    for (int l = 0; l < spawnedThings.Count; l++)
                    {
                        ActiveDropPodInfo activeDropPodInfo;
                        if ((activeDropPodInfo = spawnedThings[l].ParentHolder as ActiveDropPodInfo) != null)
                        {
                            activeDropPodInfo.spawnWipeMode = null;
                        }
                    }
                }
            }
            if (!buildRoofsInstantly || spawnMode != SpawnMode.Normal)
            {
                return;
            }
            foreach (IntVec3 suggestedRoofCell in GetSuggestedRoofCells())
            {
                IntVec3 c = suggestedRoofCell + offset;
                if (c.InBounds(map) && !c.Roofed(map))
                {
                    map.roofGrid.SetRoof(c, RoofDefOf.RoofConstructed);
                }
            }
        }
Exemple #11
0
 protected virtual bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(!f.IsPlayer && !f.defeated && (desperate || (f.def.allowedArrivalTemperatureRange.Includes(map.mapTemperature.OutdoorTemp) && f.def.allowedArrivalTemperatureRange.Includes(map.mapTemperature.SeasonalTemp))));
 }
Exemple #12
0
        public override void DoWindowContents(Rect inRect)
        {
            if (this.playerIsCaravan)
            {
                CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.MassUsage, this.MassCapacity, this.cachedMassCapacityExplanation, this.TilesPerDay, this.cachedTilesPerDayExplanation, this.DaysWorthOfFood, this.ForagedFoodPerDay, this.cachedForagedFoodPerDayExplanation, this.Visibility, this.cachedVisibilityExplanation, -1f, -1f, null), null, this.Tile, null, -9999f, new Rect(12f, 0f, inRect.width - 24f, 40f), true, null, false);
                inRect.yMin += 52f;
            }
            TradeSession.deal.UpdateCurrencyCount();
            GUI.BeginGroup(inRect);
            inRect = inRect.AtZero();
            TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x)
            {
                this.sorter1 = x;
                this.CacheTradeables();
            }, delegate(TransferableSorterDef x)
            {
                this.sorter2 = x;
                this.CacheTradeables();
            });
            float num      = inRect.width - 590f;
            Rect  position = new Rect(num, 0f, inRect.width - num, 58f);

            GUI.BeginGroup(position);
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect, Faction.OfPlayer.Name);
            Rect rect2 = new Rect(position.width / 2f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperRight;
            string text = TradeSession.trader.TraderName;

            if (Text.CalcSize(text).x > rect2.width)
            {
                Text.Font = GameFont.Small;
                text      = text.Truncate(rect2.width, null);
            }
            Widgets.Label(rect2, text);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Rect rect3 = new Rect(0f, 27f, position.width / 2f, position.height / 2f);

            Widgets.Label(rect3, "Negotiator".Translate() + ": " + TradeSession.playerNegotiator.LabelShort);
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect4 = new Rect(position.width / 2f, 27f, position.width / 2f, position.height / 2f);

            Widgets.Label(rect4, TradeSession.trader.TraderKind.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            if (!TradeSession.giftMode)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
                Text.Font = GameFont.Tiny;
                Rect rect5 = new Rect(position.width / 2f - 100f - 30f, 0f, 200f, position.height);
                Text.Anchor = TextAnchor.LowerCenter;
                Widgets.Label(rect5, "PositiveBuysNegativeSells".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.EndGroup();
            float num2 = 0f;

            if (this.cachedCurrencyTradeable != null)
            {
                float num3  = inRect.width - 16f;
                Rect  rect6 = new Rect(0f, 58f, num3, 30f);
                TradeUI.DrawTradeableRow(rect6, this.cachedCurrencyTradeable, 1);
                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, 87f, num3);
                GUI.color = Color.white;
                num2      = 30f;
            }
            Rect mainRect = new Rect(0f, 58f + num2, inRect.width, inRect.height - 58f - 38f - num2 - 20f);

            this.FillMainRect(mainRect);
            Rect rect7 = new Rect(inRect.width / 2f - Dialog_Trade.AcceptButtonSize.x / 2f, inRect.height - 55f, Dialog_Trade.AcceptButtonSize.x, Dialog_Trade.AcceptButtonSize.y);

            if (Widgets.ButtonText(rect7, (!TradeSession.giftMode) ? "AcceptButton".Translate() : ("OfferGifts".Translate() + " (" + FactionGiftUtility.GetGoodwillChange(TradeSession.deal.AllTradeables, TradeSession.trader.Faction).ToStringWithSign() + ")"), true, false, true))
            {
                Action action = delegate()
                {
                    bool flag;
                    if (TradeSession.deal.TryExecute(out flag))
                    {
                        if (flag)
                        {
                            SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null);
                            this.Close(false);
                        }
                        else
                        {
                            this.Close(true);
                        }
                    }
                };
                if (TradeSession.deal.DoesTraderHaveEnoughSilver())
                {
                    action();
                }
                else
                {
                    this.FlashSilver();
                    SoundDefOf.ClickReject.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null));
                }
                Event.current.Use();
            }
            Rect rect8 = new Rect(rect7.x - 10f - Dialog_Trade.OtherBottomButtonSize.x, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect8, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                TradeSession.deal.Reset();
                this.CacheTradeables();
                this.CountToTransferChanged();
            }
            Rect rect9 = new Rect(rect7.xMax + 10f, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect9, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
                Event.current.Use();
            }
            float y      = Dialog_Trade.OtherBottomButtonSize.y;
            Rect  rect10 = new Rect(inRect.width - y, rect7.y, y, y);

            if (Widgets.ButtonImageWithBG(rect10, Dialog_Trade.ShowSellableItemsIcon, new Vector2?(new Vector2(32f, 32f))))
            {
                Find.WindowStack.Add(new Dialog_SellableItems(TradeSession.trader.TraderKind));
            }
            TooltipHandler.TipRegion(rect10, "CommandShowSellableItemsDesc".Translate());
            Faction faction = TradeSession.trader.Faction;

            if (faction != null && !this.giftsOnly && !faction.def.permanentEnemy)
            {
                Rect rect11 = new Rect(rect10.x - y - 4f, rect7.y, y, y);
                if (TradeSession.giftMode)
                {
                    if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.TradeModeIcon, new Vector2?(new Vector2(32f, 32f))))
                    {
                        TradeSession.giftMode = false;
                        TradeSession.deal.Reset();
                        this.CacheTradeables();
                        this.CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegion(rect11, "TradeModeTip".Translate());
                }
                else
                {
                    if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.GiftModeIcon, new Vector2?(new Vector2(32f, 32f))))
                    {
                        TradeSession.giftMode = true;
                        TradeSession.deal.Reset();
                        this.CacheTradeables();
                        this.CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegion(rect11, "GiftModeTip".Translate(new object[]
                    {
                        faction.Name
                    }));
                }
            }
            GUI.EndGroup();
        }
Exemple #13
0
 public bool IsViolatingRulesOf(Faction faction, int violationSourceLevel = -1)
 {
     return(ThingRequiringRoyalPermissionUtility.IsViolatingRulesOf(base.Def, parent.pawn, faction, (violationSourceLevel == -1) ? GetImplantLevel(parent) : violationSourceLevel));
 }
        // Token: 0x06000795 RID: 1941 RVA: 0x00042F44 File Offset: 0x00041344
        public override StateGraph CreateGraph()
        {
            StateGraph stateGraph = new StateGraph();
            LordToil_DefendAndExpandHiveLike lordToil_DefendAndExpandHive = new LordToil_DefendAndExpandHiveLike();

            lordToil_DefendAndExpandHive.distToHiveToAttack = 10f;
            stateGraph.StartingToil = lordToil_DefendAndExpandHive;
            LordToil_DefendHiveAggressively lordToil_DefendHiveAggressively = new LordToil_DefendHiveAggressively();

            lordToil_DefendHiveAggressively.distToHiveToAttack = 40f;
            stateGraph.AddToil(lordToil_DefendHiveAggressively);
            LordToil_AssaultColony lordToil_AssaultColony = new LordToil_AssaultColony(false);

            stateGraph.AddToil(lordToil_AssaultColony);

            Transition transition = new Transition(lordToil_DefendAndExpandHive, (!aggressive) ? (LordToil)lordToil_DefendHiveAggressively : (LordToil)lordToil_AssaultColony, false, true);

            transition.AddTrigger(new Trigger_PawnHarmed(0.5f, true, null));
            transition.AddTrigger(new Trigger_PawnLostViolently(false));
            transition.AddTrigger(new Trigger_Memo(HiveLike.MemoAttackedByEnemy));
            transition.AddTrigger(new Trigger_Memo(HiveLike.MemoBurnedBadly));
            transition.AddTrigger(new Trigger_Memo(HiveLike.MemoDestroyedNonRoofCollapse));
            transition.AddTrigger(new Trigger_Memo(HediffGiver_Heat.MemoPawnBurnedByAir));
            transition.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition, false);

            Transition transition2   = new Transition(lordToil_DefendAndExpandHive, lordToil_AssaultColony, false, true);
            Transition transition3   = transition2;
            float      chance        = 0.5f;
            Faction    parentFaction = base.Map.ParentFaction;

            transition3.AddTrigger(new Trigger_PawnHarmed(chance, false, parentFaction));
            transition2.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition2, false);
            Transition transition4 = new Transition(lordToil_DefendHiveAggressively, lordToil_AssaultColony, false, true);
            Transition transition5 = transition4;

            chance        = 0.5f;
            parentFaction = base.Map.ParentFaction;
            transition5.AddTrigger(new Trigger_PawnHarmed(chance, false, parentFaction));
            transition4.AddPostAction(new TransitionAction_EndAllJobs());
            stateGraph.AddTransition(transition4, false);
            Transition transition6 = new Transition(lordToil_DefendAndExpandHive, lordToil_DefendAndExpandHive, true, true);

            transition6.AddTrigger(new Trigger_Memo(HiveLike.MemoDeSpawned));
            stateGraph.AddTransition(transition6, false);
            Transition transition7 = new Transition(lordToil_DefendHiveAggressively, lordToil_DefendHiveAggressively, true, true);

            transition7.AddTrigger(new Trigger_Memo(HiveLike.MemoDeSpawned));
            stateGraph.AddTransition(transition7, false);
            Transition transition8 = new Transition(lordToil_AssaultColony, lordToil_DefendAndExpandHive, false, true);

            transition8.AddSource(lordToil_DefendHiveAggressively);
            transition8.AddTrigger(new Trigger_TicksPassedWithoutHarmOrMemos(1200, new string[]
            {
                HiveLike.MemoAttackedByEnemy,
                HiveLike.MemoBurnedBadly,
                HiveLike.MemoDestroyedNonRoofCollapse,
                HiveLike.MemoDeSpawned,
                HediffGiver_Heat.MemoPawnBurnedByAir
            }));
            transition8.AddPostAction(new TransitionAction_EndAttackBuildingJobs());
            stateGraph.AddTransition(transition8, false);
            return(stateGraph);
        }
Exemple #15
0
        public static string BuildDifferenceExplanationText(RoyalTitleDef currentTitle, RoyalTitleDef newTitle, Faction faction, Pawn pawn)
        {
            StringBuilder   stringBuilder = new StringBuilder();
            bool            flag          = ShouldBecomeConceitedOnNewTitle(pawn);
            List <WorkTags> list          = pawn.story.DisabledWorkTagsBackstoryAndTraits.GetAllSelectedItems <WorkTags>().ToList();
            List <WorkTags> obj           = (newTitle == null) ? new List <WorkTags>() : newTitle.disabledWorkTags.GetAllSelectedItems <WorkTags>().ToList();
            List <WorkTags> list2         = new List <WorkTags>();

            foreach (WorkTags item in obj)
            {
                if (!list.Contains(item))
                {
                    list2.Add(item);
                }
            }
            int num = (newTitle != null) ? faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(newTitle) : (-1);

            if (newTitle != null && flag)
            {
                stringBuilder.AppendLine("LetterRoyalTitleConceitedTrait".Translate(pawn.Named("PAWN"), (from t in GetConceitedTraits(pawn)
                                                                                                         select t.CurrentData.label).ToCommaList(useAnd: true)));
                stringBuilder.AppendLine();
                if (newTitle.minExpectation != null)
                {
                    stringBuilder.AppendLine("LetterRoyalTitleExpectation".Translate(pawn.Named("PAWN"), newTitle.minExpectation.label).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
            }
            if (newTitle != null)
            {
                if (newTitle.canBeInherited)
                {
                    Pawn         heir         = pawn.royalty.GetHeir(faction);
                    TaggedString taggedString = (heir != null) ? "LetterRoyalTitleHeir".Translate(pawn.Named("PAWN"), heir.Named("HEIR")) : "LetterRoyalTitleNoHeir".Translate(pawn.Named("PAWN"));
                    stringBuilder.Append(taggedString);
                    if (heir != null && heir.Faction != Faction.OfPlayer)
                    {
                        stringBuilder.Append(" " + "LetterRoyalTitleHeirFactionWarning".Translate(heir.Named("PAWN"), faction.Named("FACTION")));
                    }
                    stringBuilder.AppendLine(" " + "LetterRoyalTitleChangingHeir".Translate(faction.Named("FACTION")));
                }
                else
                {
                    stringBuilder.Append("LetterRoyalTitleCantBeInherited".Translate(newTitle.Named("TITLE")).CapitalizeFirst());
                    stringBuilder.Append(" " + "LetterRoyalTitleNoHeir".Translate(pawn.Named("PAWN")));
                    stringBuilder.AppendLine();
                }
                stringBuilder.AppendLine();
            }
            if (flag && list2.Count > 0)
            {
                stringBuilder.AppendLine("LetterRoyalTitleDisabledWorkTag".Translate(pawn.Named("PAWN"), (from t in list2
                                                                                                          orderby FirstTitleDisablingWorkTags(t).seniority
                                                                                                          select $"{t.LabelTranslated()} ({FirstTitleDisablingWorkTags(t).GetLabelFor(pawn)})").ToLineList("- ")).CapitalizeFirst());
                stringBuilder.AppendLine();
            }
            if (newTitle != null)
            {
                if ((int)newTitle.requiredMinimumApparelQuality > 0)
                {
                    stringBuilder.AppendLine("LetterRoyalTitleApparelQualityRequirement".Translate(pawn.Named("PAWN"), newTitle.requiredMinimumApparelQuality.GetLabel().ToLower()).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
                if (newTitle.requiredApparel != null && newTitle.requiredApparel.Count > 0)
                {
                    stringBuilder.AppendLine("LetterRoyalTitleApparelRequirement".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                    foreach (RoyalTitleDef.ApparelRequirement item2 in newTitle.requiredApparel)
                    {
                        int j = 0;
                        stringBuilder.Append("- ");
                        stringBuilder.AppendLine(string.Join(", ", item2.AllRequiredApparelForPawn(pawn, ignoreGender : false, includeWorn : true).Select(delegate(ThingDef a)
                        {
                            string result = (j == 0) ? a.LabelCap.Resolve() : a.label;
                            j++;
                            return(result);
                        }).ToArray()));
                    }
                    stringBuilder.AppendLine("- " + "ApparelRequirementAnyPrestigeArmor".Translate());
                    stringBuilder.AppendLine("- " + "ApparelRequirementAnyPsycasterApparel".Translate());
                    stringBuilder.AppendLine();
                }
                if (!newTitle.throneRoomRequirements.NullOrEmpty())
                {
                    stringBuilder.AppendLine("LetterRoyalTitleThroneroomRequirements".Translate(pawn.Named("PAWN"), "\n" + newTitle.throneRoomRequirements.Select((RoomRequirement r) => r.LabelCap()).ToLineList("- ")).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
                if (!newTitle.GetBedroomRequirements(pawn).EnumerableNullOrEmpty())
                {
                    stringBuilder.AppendLine("LetterRoyalTitleBedroomRequirements".Translate(pawn.Named("PAWN"), "\n" + (from r in newTitle.GetBedroomRequirements(pawn)
                                                                                                                         select r.LabelCap()).ToLineList("- ")).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
                if (flag && newTitle.foodRequirement.Defined && newTitle.SatisfyingMeals().Any() && (pawn.story == null || !pawn.story.traits.HasTrait(TraitDefOf.Ascetic)))
                {
                    stringBuilder.AppendLine("LetterRoyalTitleFoodRequirements".Translate(pawn.Named("PAWN"), "\n" + (from m in newTitle.SatisfyingMeals(includeDrugs: false)
                                                                                                                      select m.LabelCap.Resolve()).ToLineList("- ")).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
            }
            FindLostAndGainedPermits(currentTitle, newTitle, out List <RoyalTitlePermitDef> _, out List <RoyalTitlePermitDef> lostPermits);
            if (newTitle != null && newTitle.permits != null)
            {
                stringBuilder.AppendLine("LetterRoyalTitlePermits".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                foreach (RoyalTitlePermitDef item3 in newTitle.permits.OrderBy((RoyalTitlePermitDef p) => FirstTitleWithPermit(p)?.seniority))
                {
                    RoyalTitleDef royalTitleDef = FirstTitleWithPermit(item3);
                    if (royalTitleDef != null)
                    {
                        stringBuilder.AppendLine("- " + item3.LabelCap + " (" + royalTitleDef.GetLabelFor(pawn) + ")");
                    }
                }
                stringBuilder.AppendLine();
            }
            if (lostPermits.Count > 0)
            {
                stringBuilder.AppendLine("LetterRoyalTitleLostPermits".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                foreach (RoyalTitlePermitDef item4 in lostPermits)
                {
                    stringBuilder.AppendLine("- " + item4.LabelCap);
                }
                stringBuilder.AppendLine();
            }
            if (newTitle != null)
            {
                if (newTitle.grantedAbilities.Contains(AbilityDefOf.Speech) && (currentTitle == null || !currentTitle.grantedAbilities.Contains(AbilityDefOf.Speech)))
                {
                    stringBuilder.AppendLine("LetterRoyalTitleSpeechAbilityGained".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
                List <JoyKindDef> list3 = DefDatabase <JoyKindDef> .AllDefsListForReading.Where((JoyKindDef def) => def.titleRequiredAny != null && def.titleRequiredAny.Contains(newTitle)).ToList();

                if (list3.Count > 0)
                {
                    stringBuilder.AppendLine("LetterRoyalTitleEnabledJoyKind".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                    foreach (JoyKindDef item5 in list3)
                    {
                        stringBuilder.AppendLine("- " + item5.LabelCap);
                    }
                    stringBuilder.AppendLine();
                }
                if (flag && !newTitle.disabledJoyKinds.NullOrEmpty())
                {
                    stringBuilder.AppendLine("LetterRoyalTitleDisabledJoyKind".Translate(pawn.Named("PAWN")).CapitalizeFirst());
                    foreach (JoyKindDef disabledJoyKind in newTitle.disabledJoyKinds)
                    {
                        stringBuilder.AppendLine("- " + disabledJoyKind.LabelCap);
                    }
                    stringBuilder.AppendLine();
                }
                if (faction.def.royalImplantRules != null)
                {
                    List <RoyalImplantRule> list4 = new List <RoyalImplantRule>();
                    foreach (RoyalImplantRule royalImplantRule in faction.def.royalImplantRules)
                    {
                        RoyalTitleDef minTitleForImplant = faction.GetMinTitleForImplant(royalImplantRule.implantHediff);
                        int           num2 = faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(minTitleForImplant);
                        if (num >= num2)
                        {
                            if (royalImplantRule.maxLevel == 0)
                            {
                                list4.Add(royalImplantRule);
                            }
                            else
                            {
                                list4.AddDistinct(faction.GetMaxAllowedImplantLevel(royalImplantRule.implantHediff, newTitle));
                            }
                        }
                    }
                    if (list4.Count > 0)
                    {
                        stringBuilder.AppendLine("LetterRoyalTitleAllowedImplants".Translate(pawn.Named("PAWN"), "\n" + list4.Select((RoyalImplantRule i) => (i.maxLevel == 0) ? $"{i.implantHediff.LabelCap} ({faction.GetMinTitleForImplant(i.implantHediff).GetLabelFor(pawn)})" : $"{i.implantHediff.LabelCap}({i.maxLevel}x) ({i.minTitle.GetLabelFor(pawn)})").ToLineList("- ")).CapitalizeFirst());
                        stringBuilder.AppendLine();
                    }
                }
                if (currentTitle != null && newTitle.seniority < currentTitle.seniority)
                {
                    List <Hediff> list5 = new List <Hediff>();
                    if (pawn.health != null && pawn.health.hediffSet != null)
                    {
                        foreach (Hediff hediff in pawn.health.hediffSet.hediffs)
                        {
                            if (hediff.def.HasComp(typeof(HediffComp_RoyalImplant)))
                            {
                                RoyalTitleDef minTitleForImplant2 = faction.GetMinTitleForImplant(hediff.def, HediffComp_RoyalImplant.GetImplantLevel(hediff));
                                if (faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.IndexOf(minTitleForImplant2) > num)
                                {
                                    list5.Add(hediff);
                                }
                            }
                        }
                    }
                    if (list5.Count > 0)
                    {
                        stringBuilder.AppendLine("LetterRoyalTitleImplantsMustBeRemoved".Translate(pawn.Named("PAWN"), "\n" + list5.Select((Hediff i) => i.LabelCap).ToLineList("- ")).Resolve());
                        stringBuilder.AppendLine("LetterRoyalTitleImplantGracePeriod".Translate());
                        stringBuilder.AppendLine();
                    }
                }
                if (pawn.royalty.NewHighestTitle(faction, newTitle) && !newTitle.rewards.NullOrEmpty())
                {
                    stringBuilder.AppendLine("LetterRoyalTitleRewardGranted".Translate(pawn.Named("PAWN"), "\n" + newTitle.rewards.Select((ThingDefCountClass r) => r.Label).ToLineList("- ")).CapitalizeFirst());
                    stringBuilder.AppendLine();
                }
            }
            return(stringBuilder.ToString().TrimEndNewlines());

            RoyalTitleDef FirstTitleDisablingWorkTags(WorkTags t)
            {
                return(faction.def.RoyalTitlesAllInSeniorityOrderForReading.FirstOrDefault((RoyalTitleDef title) => (t & title.disabledWorkTags) != 0));
            }

            RoyalTitleDef FirstTitleWithPermit(RoyalTitlePermitDef permitDef)
            {
                return(faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.FirstOrDefault((RoyalTitleDef t) => t.permits != null && t.permits.Contains(permitDef)));
            }
        }
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(base.FactionCanBeGroupSource(f, map, desperate) && !f.def.hidden && !f.HostileTo(Faction.OfPlayer));
 }
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(base.FactionCanBeGroupSource(f, map, desperate) && f.def.caravanTraderKinds.Any());
 }
Exemple #18
0
 public override bool ClaimableBy(Faction by)
 {
     return(base.ClaimableBy(by) && (this.mannableComp == null || this.mannableComp.ManningPawn == null) && (this.powerComp == null || !this.powerComp.PowerOn));
 }
Exemple #19
0
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(base.FactionCanBeGroupSource(f, map, desperate) && f.HostileTo(Faction.OfPlayer) && (desperate || (float)GenDate.DaysPassed >= f.def.earliestRaidDays));
 }
 private string GenerateMessageText(Faction enemyFaction, int attackerCount, List <ThingCount> demands, Caravan caravan)
 {
     return("CaravanDemand".Translate(caravan.Name, enemyFaction.Name, attackerCount, GenLabel.ThingsLabel(demands, "  - "), enemyFaction.def.pawnsPlural).CapitalizeFirst());
 }
Exemple #21
0
 public LordJob_AssistColony(Faction faction, IntVec3 fallbackLocation)
 {
     this.faction          = faction;
     this.fallbackLocation = fallbackLocation;
 }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            parms.points *= IncidentWorker_CaravanDemand.IncidentPointsFactorRange.RandomInRange;
            Caravan caravan = (Caravan)parms.target;

            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction, null, false, false, false, true))
            {
                return(false);
            }
            List <ThingCount> demands = this.GenerateDemands(caravan);

            if (demands.NullOrEmpty <ThingCount>())
            {
                return(false);
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms, false);

            defaultPawnGroupMakerParms.generateFightersOnly            = true;
            defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
            List <Pawn> attackers = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>();

            if (attackers.Count == 0)
            {
                Log.Error(string.Concat(new object[]
                {
                    "Caravan demand incident couldn't generate any enemies even though min points have been checked. faction=",
                    defaultPawnGroupMakerParms.faction,
                    "(",
                    (defaultPawnGroupMakerParms.faction == null) ? "null" : defaultPawnGroupMakerParms.faction.def.ToString(),
                    ") parms=",
                    parms
                }), false);
                return(false);
            }
            CameraJumper.TryJumpAndSelect(caravan);
            DiaNode   diaNode   = new DiaNode(this.GenerateMessageText(parms.faction, attackers.Count, demands, caravan));
            DiaOption diaOption = new DiaOption("CaravanDemand_Give".Translate());

            diaOption.action = delegate
            {
                this.ActionGive(caravan, demands, attackers);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            DiaOption diaOption2 = new DiaOption("CaravanDemand_Fight".Translate());

            diaOption2.action = delegate
            {
                this.ActionFight(caravan, attackers);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            string      text               = "CaravanDemandTitle".Translate(parms.faction.Name);
            WindowStack arg_202_0          = Find.WindowStack;
            DiaNode     nodeRoot           = diaNode;
            Faction     faction            = parms.faction;
            bool        delayInteractivity = true;
            string      title              = text;

            arg_202_0.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction, delayInteractivity, false, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, text, parms.faction));
            return(true);
        }
 public static bool CanTradeWith(this Pawn p, Faction faction, TraderKindDef traderKind = null)
 {
     return(p.CanTradeWith_NewTemp(faction, traderKind).Accepted);
 }
 public LordJob_EscortPawn(Pawn escortee, Thing shuttle = null)
 {
     this.escortee   = escortee;
     this.shuttle    = shuttle;
     escorteeFaction = escortee.Faction;
 }
 public LordJob_VisitColony(Faction faction, IntVec3 chillSpot)
 {
     this.faction   = faction;
     this.chillSpot = chillSpot;
 }
Exemple #26
0
        private static bool IsSafeDropSpot(IntVec3 cell, Map map, Faction faction, IntVec2?size = null, int distToEdge = 25, int distToHostiles = 35, int distToFires = 15)
        {
            Faction factionBaseFaction = map.ParentFaction ?? Faction.OfPlayer;

            if (size.HasValue)
            {
                foreach (IntVec3 item in GenAdj.OccupiedRect(cell, Rot4.North, size.Value))
                {
                    if (!IsGoodDropSpot(item, map, allowFogged: false, canRoofPunch: false, allowIndoors: false))
                    {
                        return(false);
                    }
                }
            }
            else if (!IsGoodDropSpot(cell, map, allowFogged: false, canRoofPunch: false, allowIndoors: false))
            {
                return(false);
            }
            if (distToEdge > 0 && cell.CloseToEdge(map, distToEdge))
            {
                return(false);
            }
            if (faction != null)
            {
                foreach (IAttackTarget item2 in map.attackTargetsCache.TargetsHostileToFaction(faction))
                {
                    if (!item2.ThreatDisabled(null) && item2.Thing.Position.InHorDistOf(cell, distToHostiles))
                    {
                        return(false);
                    }
                }
            }
            if (!map.reachability.CanReachFactionBase(cell, factionBaseFaction))
            {
                return(false);
            }
            if (size.HasValue)
            {
                foreach (IntVec3 cell2 in CellRect.CenteredOn(cell, size.Value.x, size.Value.z).Cells)
                {
                    if (CellHasCrops(cell2))
                    {
                        return(false);
                    }
                }
            }
            else if (CellHasCrops(cell))
            {
                return(false);
            }
            float minDistToFiresSq = distToFires * distToFires;
            float closestDistSq    = float.MaxValue;
            int   firesCount       = 0;

            RegionTraverser.BreadthFirstTraverse(cell, map, (Region from, Region to) => true, delegate(Region x)
            {
                List <Thing> list = x.ListerThings.ThingsInGroup(ThingRequestGroup.Fire);
                for (int i = 0; i < list.Count; i++)
                {
                    float num = cell.DistanceToSquared(list[i].Position);
                    if (!(num > minDistToFiresSq))
                    {
                        if (num < closestDistSq)
                        {
                            closestDistSq = num;
                        }
                        firesCount++;
                    }
                }
                return(closestDistSq <= minDistToFiresSq && firesCount >= 5);
            }, 15);
            if (closestDistSq <= minDistToFiresSq && firesCount >= 5)
            {
                return(false);
            }
            return(true);

            bool CellHasCrops(IntVec3 c)
            {
                Plant plant = c.GetPlant(map);

                if (plant != null && plant.sown)
                {
                    return(map.zoneManager.ZoneAt(c) is Zone_Growing);
                }
                return(false);
            }
        }
        public static void DrawMeditationFociAffectedByBuildingOverlay(Map map, ThingDef def, Faction faction, IntVec3 pos, Rot4 rotation)
        {
            int num = 0;

            foreach (Thing item in GetMeditationFociAffectedByBuilding(map, def, faction, pos, rotation))
            {
                if (num++ > 10)
                {
                    break;
                }
                CompToggleDrawAffectedMeditationFoci compToggleDrawAffectedMeditationFoci = item.TryGetComp <CompToggleDrawAffectedMeditationFoci>();
                if (compToggleDrawAffectedMeditationFoci == null || compToggleDrawAffectedMeditationFoci.Enabled)
                {
                    GenAdj.OccupiedRect(pos, rotation, def.size);
                    GenDraw.DrawLineBetween(GenThing.TrueCenter(pos, rotation, def.size, def.Altitude), item.TrueCenter(), SimpleColor.Red);
                }
            }
        }
Exemple #28
0
        public static IntVec3 TryFindSafeLandingSpotCloseToColony(Map map, IntVec2 size, Faction faction = null, int borderWidth = 2)
        {
            size.x += borderWidth;
            size.z += borderWidth;
            tmpColonyBuildings.Clear();
            tmpColonyBuildings.AddRange(map.listerBuildings.allBuildingsColonist);
            if (!tmpColonyBuildings.Any())
            {
                return(CellFinderLoose.RandomCellWith(SpotValidator, map));
            }
            tmpColonyBuildings.Shuffle();
            for (int i = 0; i < tmpColonyBuildings.Count; i++)
            {
                if (TryFindDropSpotNear(tmpColonyBuildings[i].Position, map, out IntVec3 result, allowFogged: false, canRoofPunch: false, allowIndoors: false, size) && SkyfallerCanLandAt(result, map, size, faction))
                {
                    tmpColonyBuildings.Clear();
                    return(result);
                }
            }
            tmpColonyBuildings.Clear();
            return(CellFinderLoose.RandomCellWith(SpotValidator, map));

            bool SpotValidator(IntVec3 c)
            {
                if (!SkyfallerCanLandAt(c, map, size, faction))
                {
                    return(false);
                }
                if (ModsConfig.RoyaltyActive)
                {
                    List <Thing> list = map.listerThings.ThingsOfDef(ThingDefOf.ActivatorProximity);
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (list[j].Faction != null && list[j].Faction.HostileTo(faction))
                        {
                            CompSendSignalOnPawnProximity compSendSignalOnPawnProximity = list[j].TryGetComp <CompSendSignalOnPawnProximity>();
                            if (compSendSignalOnPawnProximity != null && c.InHorDistOf(list[j].Position, compSendSignalOnPawnProximity.Props.radius + 10f))
                            {
                                return(false);
                            }
                        }
                    }
                }
                return(true);
            }
        }
 protected override bool FactionCanBeGroupSource(Faction f, Map map, bool desperate = false)
 {
     return(base.FactionCanBeGroupSource(f, map, desperate) && !f.def.hidden && !f.HostileTo(Faction.OfPlayer) && !NeutralGroupIncidentUtility.AnyBlockingHostileLord(map, f));
 }
Exemple #30
0
 internal bool <> m__0(Faction f)
 {
     return(this.$this.FactionCanBeGroupSource(f, this.map, this.desperate));
 }