protected override void RunInt() { Slate slate = QuestGen.slate; Map target = QuestGen.slate.Get <Map>("map"); float points = QuestGen.slate.Get("points", 0f); QuestPart_Incident questPart_Incident = new QuestPart_Incident(); questPart_Incident.incident = incidentDef.GetValue(slate); IncidentParms incidentParms = new IncidentParms(); incidentParms.forced = true; incidentParms.target = target; incidentParms.points = points; if (!customLetterLabel.GetValue(slate).NullOrEmpty() || customLetterLabelRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { incidentParms.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules.GetValue(slate), customLetterLabel.GetValue(slate), "root")); } if (!customLetterText.GetValue(slate).NullOrEmpty() || customLetterTextRules.GetValue(slate) != null) { QuestGen.AddTextRequest("root", delegate(string x) { incidentParms.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules.GetValue(slate), customLetterText.GetValue(slate), "root")); } questPart_Incident.SetIncidentParmsAndRemoveTarget(incidentParms); questPart_Incident.inSignal = (QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal")); QuestGen.quest.AddPart(questPart_Incident); }
protected override void RunInt() { Slate slate = QuestGen.slate; float points = QuestGen.slate.Get("points", 0f); GameCondition gameCondition = GameConditionMaker.MakeCondition(this.gameCondition.GetValue(slate), duration.GetValue(slate)); QuestPart_GameCondition questPart_GameCondition = new QuestPart_GameCondition(); questPart_GameCondition.gameCondition = gameCondition; List <Rule> list = new List <Rule>(); Dictionary <string, string> dictionary = new Dictionary <string, string>(); if (targetWorld.GetValue(slate)) { questPart_GameCondition.targetWorld = true; gameCondition.RandomizeSettings(points, null, list, dictionary); } else { Map map = GetMap(QuestGen.slate); questPart_GameCondition.mapParent = map.Parent; gameCondition.RandomizeSettings(points, map, list, dictionary); } questPart_GameCondition.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal"); QuestGen.quest.AddPart(questPart_GameCondition); if (!storeGameConditionDescriptionFutureAs.GetValue(slate).NullOrEmpty()) { slate.Set(storeGameConditionDescriptionFutureAs.GetValue(slate), gameCondition.def.descriptionFuture); } QuestGen.AddQuestNameRules(list); QuestGen.AddQuestDescriptionRules(list); QuestGen.AddQuestDescriptionConstants(dictionary); }
protected override void RunInt() { Slate slate = QuestGen.slate; if (((outSignals.GetValue(slate) != null) ? outSignals.GetValue(slate).Count() : 0) + ((node != null) ? 1 : 0) != 0) { QuestPart_PassActivable questPart_PassActivable = new QuestPart_PassActivable(); QuestGen.quest.AddPart(questPart_PassActivable); questPart_PassActivable.inSignalEnable = (QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? slate.Get <string>("inSignal")); questPart_PassActivable.inSignalDisable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalDisable.GetValue(slate)); questPart_PassActivable.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal.GetValue(slate)); if (node != null) { QuestGenUtility.RunInnerNode(node, questPart_PassActivable.OutSignalCompleted); } IEnumerable <string> value = outSignals.GetValue(slate); if (value != null) { foreach (string item in value) { questPart_PassActivable.outSignalsCompleted.Add(QuestGenUtility.HardcodedSignalWithQuestID(item)); } } questPart_PassActivable.signalListenMode = (signalListenMode.GetValue(slate) ?? QuestPart.SignalListenMode.OngoingOnly); } }
protected override void RunInt() { Slate slate = QuestGen.slate; MapParent parent = slate.Get <Map>("map").Parent; string text = QuestGen.GenerateNewSignal("PawnOfRaceKilled"); QuestPart_PawnsKilled questPart_PawnsKilled = new QuestPart_PawnsKilled(); questPart_PawnsKilled.inSignalEnable = (QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal")); questPart_PawnsKilled.race = race.GetValue(slate); questPart_PawnsKilled.requiredInstigatorFaction = Faction.OfPlayer; questPart_PawnsKilled.count = count.GetValue(slate); questPart_PawnsKilled.mapParent = parent; questPart_PawnsKilled.outSignalPawnKilled = text; if (node != null) { QuestGenUtility.RunInnerNode(node, questPart_PawnsKilled); } if (!outSignalComplete.GetValue(slate).NullOrEmpty()) { questPart_PawnsKilled.outSignalsCompleted.Add(QuestGenUtility.HardcodedSignalWithQuestID(outSignalComplete.GetValue(slate))); } QuestGen.quest.AddPart(questPart_PawnsKilled); QuestPart_PawnsAvailable questPart_PawnsAvailable = new QuestPart_PawnsAvailable(); questPart_PawnsAvailable.inSignalEnable = (QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal")); if (!outSignalPawnsNotAvailable.GetValue(slate).NullOrEmpty()) { questPart_PawnsAvailable.outSignalPawnsNotAvailable = QuestGenUtility.HardcodedSignalWithQuestID(outSignalPawnsNotAvailable.GetValue(slate)); } questPart_PawnsAvailable.race = race.GetValue(slate); questPart_PawnsAvailable.requiredCount = count.GetValue(slate); questPart_PawnsAvailable.mapParent = parent; questPart_PawnsAvailable.inSignalDecrement = text; QuestGen.quest.AddPart(questPart_PawnsAvailable); }
protected override void RunInt() { Slate slate = QuestGen.slate; float randomInRange = GetRangeFromRating().RandomInRange; slate.Set(storeAs.GetValue(slate), roundRandom.GetValue(slate) ? ((float)GenMath.RoundRandom(randomInRange)) : randomInRange); }
private void DoWork(Slate slate) { if (mapOf.GetValue(slate) == null) { return; } Map mapHeld = mapOf.GetValue(slate).MapHeld; if (mapHeld != null && mapHeld.IsPlayerHome) { slate.Set(storeAs.GetValue(slate), mapHeld); return; } int tile = mapOf.GetValue(slate).Tile; if (tile == -1) { return; } Map map = null; List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { if (maps[i].IsPlayerHome && (map == null || Find.WorldGrid.ApproxDistanceInTiles(tile, maps[i].Tile) < Find.WorldGrid.ApproxDistanceInTiles(tile, map.Tile))) { map = maps[i]; } } if (map != null) { slate.Set(storeAs.GetValue(slate), map); } }
protected override void RunInt() { if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Shuttle is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 8811221); return; } Slate slate = QuestGen.slate; Thing thing = ThingMaker.MakeThing(ThingDefOf.Shuttle); if (owningFaction.GetValue(slate) != null) { thing.SetFaction(owningFaction.GetValue(slate)); } CompShuttle compShuttle = thing.TryGetComp <CompShuttle>(); if (requiredPawns.GetValue(slate) != null) { compShuttle.requiredPawns.AddRange(requiredPawns.GetValue(slate)); } if (requiredItems.GetValue(slate) != null) { compShuttle.requiredItems.AddRange(requiredItems.GetValue(slate)); } compShuttle.acceptColonists = acceptColonists.GetValue(slate); compShuttle.onlyAcceptColonists = onlyAcceptColonists.GetValue(slate); compShuttle.onlyAcceptHealthy = onlyAcceptHealthy.GetValue(slate); compShuttle.requiredColonistCount = requireColonistCount.GetValue(slate); compShuttle.dropEverythingIfUnsatisfied = dropEverythingIfUnsatisfied.GetValue(slate); compShuttle.leaveImmediatelyWhenSatisfied = leaveImmediatelyWhenSatisfied.GetValue(slate); compShuttle.dropEverythingOnArrival = dropEverythingOnArrival.GetValue(slate); compShuttle.permitShuttle = permitShuttle.GetValue(slate); compShuttle.hideControls = hideControls.GetValue(slate); QuestGen.slate.Set(storeAs.GetValue(slate), thing); }
protected override void RunInt() { Slate slate = QuestGen.slate; Map map = slate.Get <Map>("map"); QuestPart_ThreatsGenerator questPart_ThreatsGenerator = new QuestPart_ThreatsGenerator(); questPart_ThreatsGenerator.threatStartTicks = threatStartTicks.GetValue(slate); questPart_ThreatsGenerator.inSignalEnable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? slate.Get <string>("inSignal"); questPart_ThreatsGenerator.inSignalDisable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalDisable.GetValue(slate)); ThreatsGeneratorParams value = parms.GetValue(slate); value.faction = faction.GetValue(slate) ?? value.faction; questPart_ThreatsGenerator.parms = value; questPart_ThreatsGenerator.mapParent = map.Parent; QuestGen.quest.AddPart(questPart_ThreatsGenerator); if (!storeThreatExampleAs.GetValue(slate).NullOrEmpty()) { PawnGroupMakerParms pawnGroupMakerParms = new PawnGroupMakerParms(); pawnGroupMakerParms.groupKind = PawnGroupKindDefOf.Combat; pawnGroupMakerParms.raidStrategy = RaidStrategyDefOf.ImmediateAttack; pawnGroupMakerParms.faction = value.faction ?? (from x in Find.FactionManager.GetFactions_NewTemp(allowHidden: false, allowDefeated: false, allowNonHumanlike: true, TechLevel.Industrial) where x.HostileTo(Faction.OfPlayer) select x).RandomElement(); float num = value.threatPoints ?? (StorytellerUtility.DefaultThreatPointsNow(map) * value.currentThreatPointsFactor); if (value.minThreatPoints.HasValue) { num = Mathf.Max(num, value.minThreatPoints.Value); } pawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(num, PawnsArrivalModeDefOf.EdgeWalkIn, RaidStrategyDefOf.ImmediateAttack, pawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(pawnGroupMakerParms); slate.Set(storeThreatExampleAs.GetValue(slate), PawnUtility.PawnKindsToLineList(pawnKinds, " - ", ColoredText.ThreatColor)); } }
protected override void RunInt() { Slate slate = QuestGen.slate; QuestPart_ShuttleLeaveDelay questPart_ShuttleLeaveDelay = new QuestPart_ShuttleLeaveDelay(); questPart_ShuttleLeaveDelay.inSignalEnable = QuestGenUtility.HardcodedSignalWithQuestID(inSignalEnable.GetValue(slate)) ?? QuestGen.slate.Get <string>("inSignal"); questPart_ShuttleLeaveDelay.delayTicks = delayTicks.GetValue(slate); questPart_ShuttleLeaveDelay.shuttle = shuttle.GetValue(slate); questPart_ShuttleLeaveDelay.expiryInfoPart = "ShuttleDepartsIn".Translate(); questPart_ShuttleLeaveDelay.expiryInfoPartTip = "ShuttleDepartsOn".Translate(); if (inSignalsDisable.GetValue(slate) != null) { foreach (string item in inSignalsDisable.GetValue(slate)) { questPart_ShuttleLeaveDelay.inSignalsDisable.Add(QuestGenUtility.HardcodedSignalWithQuestID(item)); } } if (node != null) { QuestGenUtility.RunInnerNode(node, questPart_ShuttleLeaveDelay); } if (!outSignalComplete.GetValue(slate).NullOrEmpty()) { questPart_ShuttleLeaveDelay.outSignalsCompleted.Add(QuestGenUtility.HardcodedSignalWithQuestID(outSignalComplete.GetValue(slate))); } QuestGen.quest.AddPart(questPart_ShuttleLeaveDelay); }
private void SetVars(Slate slate) { if (pawn.GetValue(slate) == null || otherPawns.GetValue(slate) == null) { return; } tmpRelations.Clear(); int num = 0; foreach (Pawn item in otherPawns.GetValue(slate)) { PawnRelationDef mostImportantRelation = pawn.GetValue(slate).GetMostImportantRelation(item); if (mostImportantRelation != null) { tmpRelations.Add(mostImportantRelation.GetGenderSpecificLabel(item)); } else { num++; } } if (num == 1) { tmpRelations.Add(nonRelatedLabel.GetValue(slate)); } else if (num >= 2) { tmpRelations.Add(num + " " + nonRelatedLabelPlural.GetValue(slate)); } if (tmpRelations.Any()) { slate.Set(storeAs.GetValue(slate), tmpRelations.ToCommaList(useAnd: true)); tmpRelations.Clear(); } }
protected override void RunInt() { Slate slate = QuestGen.slate; PawnGenerationRequest request = new PawnGenerationRequest(kindDef.GetValue(slate), faction.GetValue(slate), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, allowAddictions: allowAddictions.GetValue(slate) ?? true, forcedTraits: forcedTraits.GetValue(slate), prohibitedTraits: prohibitedTraits.GetValue(slate), biocodeWeaponChance: biocodeWeaponChance.GetValue(slate), mustBeCapableOfViolence: mustBeCapableOfViolence.GetValue(slate), colonistRelationChanceFactor: 1f, forceAddFreeWarmLayerIfNeeded: false, allowGay: true, allowFood: true, inhabitant: false, certainlyBeenInCryptosleep: false, forceRedressWorldPawnIfFormerColonist: false, worldPawnFactionDoesntMatter: false, extraPawnForExtraRelationChance: extraPawnForExtraRelationChance.GetValue(slate), relationWithExtraPawnChanceFactor: relationWithExtraPawnChanceFactor.GetValue(slate)); request.BiocodeApparelChance = biocodeApparelChance.GetValue(slate); request.ForbidAnyTitle = forbidAnyTitle.GetValue(slate); Pawn pawn = PawnGenerator.GeneratePawn(request); if (ensureNonNumericName.GetValue(slate) && (pawn.Name == null || pawn.Name.Numerical)) { pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn); } if (storeAs.GetValue(slate) != null) { QuestGen.slate.Set(storeAs.GetValue(slate), pawn); } if (addToList.GetValue(slate) != null) { QuestGenUtility.AddToOrMakeList(QuestGen.slate, addToList.GetValue(slate), pawn); } if (addToLists.GetValue(slate) != null) { foreach (string item in addToLists.GetValue(slate)) { QuestGenUtility.AddToOrMakeList(QuestGen.slate, item, pawn); } } QuestGen.AddToGeneratedPawns(pawn); if (!pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } }
protected override void RunInt() { Slate slate = QuestGen.slate; if (targets.GetValue(slate) == null) { return; } string questTagToAdd = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag.GetValue(slate)); foreach (object item in targets.GetValue(slate)) { Thing thing = item as Thing; if (thing != null) { QuestUtility.AddQuestTag(ref thing.questTags, questTagToAdd); continue; } WorldObject worldObject = item as WorldObject; if (worldObject != null) { QuestUtility.AddQuestTag(ref worldObject.questTags, questTagToAdd); } } }
private bool SetVars(Slate slate) { Thing value = factionOf.GetValue(slate); if (value == null) { return(false); } Faction faction = value.Faction; if (faction == null) { return(false); } List <Choice> value2 = choices.GetValue(slate); for (int i = 0; i < value2.Count; i++) { if (((value2[i].factionDef != null && faction.def == value2[i].factionDef) || (!value2[i].categoryTag.NullOrEmpty() && value2[i].categoryTag == faction.def.categoryTag)) && value2[i].pawnKinds.TryRandomElement(out PawnKindDef result)) { slate.Set(storeAs.GetValue(slate), result); return(true); } } if (fallback.GetValue(slate) != null) { slate.Set(storeAs.GetValue(slate), fallback.GetValue(slate)); return(true); } return(false); }
private bool IsFactionLeader(Slate slate) { if (pawn.GetValue(slate) != null && pawn.GetValue(slate).Faction != null) { return(pawn.GetValue(slate).Faction.leader == pawn.GetValue(slate)); } return(false); }
protected override bool TestRunInt(Slate slate) { if (faction.GetValue(slate) == null) { return(false); } return(true); }
protected override void RunInt() { Slate slate = QuestGen.slate; Map map = slate.Get <Map>("map"); slate.Set(storeAs.GetValue(slate), RandomOfferDurationTicks(map.Tile, settlement.GetValue(slate).Tile, out int travelTicks)); slate.Set(storeEstimatedTravelTimeAs.GetValue(slate), travelTicks); }
protected override bool TestRunInt(Slate slate) { if (incidentDef.GetValue(slate) == null || points.GetValue(slate) < incidentDef.GetValue(slate).minThreatPoints) { return(false); } return(true); }
private bool IsOfRoyalFaction(Slate slate) { if (thing.GetValue(slate) != null && thing.GetValue(slate).Faction != null) { return(thing.GetValue(slate).Faction.def.HasRoyalTitles); } return(false); }
public static LookTargets ToLookTargets(SlateRef <IEnumerable <object> > objects, Slate slate) { if (objects.GetValue(slate) == null || !objects.GetValue(slate).Any()) { return(LookTargets.Invalid); } return(ToLookTargets(objects.GetValue(slate))); }
protected override bool TestRunInt(Slate slate) { if (!targetWorld.GetValue(slate) && GetMap(slate) == null) { return(false); } return(true); }
private bool IsOfFaction(Slate slate) { if (thing.GetValue(slate) != null) { return(thing.GetValue(slate).Faction == faction.GetValue(slate)); } return(false); }
protected override void RunInt() { if (rules.GetValue(QuestGen.slate) != null) { QuestGen.AddQuestDescriptionRules(rules.GetValue(QuestGen.slate)); } Resolve(); }
private ResearchProjectDef FindTargetProject(Slate slate) { if (fixedProject.GetValue(slate) != null) { return(fixedProject.GetValue(slate)); } return(DefDatabase <ResearchProjectDef> .AllDefsListForReading.Where((ResearchProjectDef p) => !p.IsFinished && !p.TechprintRequirementMet).RandomElement()); }
private bool IsFreeWorldPawn(Slate slate) { if (pawn.GetValue(slate) != null) { return(Find.WorldPawns.GetSituation(pawn.GetValue(slate)) == WorldPawnSituation.Free); } return(false); }
private bool DoWork(Slate slate) { float num = slate.Get("points", 0f); float value = pointsPerArea.GetValue(slate); float num2 = Mathf.Min(num / value, 2500f); float randomInRange = RandomAspectRatioRange.RandomInRange; float f = Mathf.Sqrt(randomInRange * num2); float f2 = Mathf.Sqrt(num2 / randomInRange); int num3 = GenMath.RoundRandom(f); int num4 = GenMath.RoundRandom(f2); if (Rand.Bool) { int num5 = num3; num3 = num4; num4 = num5; } int?value2 = maxSize.GetValue(slate); if (value2.HasValue) { num3 = Mathf.Min(num3, value2.Value); num4 = Mathf.Min(num4, value2.Value); } num3 = Mathf.Max(num3, 3); num4 = Mathf.Max(num4, 3); IntVec2 value3 = new IntVec2(num3, num4); ResolveParams parms = default(ResolveParams); parms.sketch = new Sketch(); parms.monumentSize = value3; parms.useOnlyStonesAvailableOnMap = useOnlyResourcesAvailableOnMap.GetValue(slate); parms.onlyBuildableByPlayer = true; if (useOnlyResourcesAvailableOnMap.GetValue(slate) != null) { parms.allowWood = (useOnlyResourcesAvailableOnMap.GetValue(slate).Biome.TreeDensity >= BiomeDefOf.BorealForest.TreeDensity); } parms.allowedMonumentThings = new ThingFilter(); parms.allowedMonumentThings.SetAllowAll(null, includeNonStorable: true); parms.allowedMonumentThings.SetAllow(ThingDefOf.Urn, allow: false); Sketch sketch = RimWorld.SketchGen.SketchGen.Generate(SketchResolverDefOf.Monument, parms); if (clearStuff.GetValue(slate) ?? true) { List <SketchThing> things = sketch.Things; for (int i = 0; i < things.Count; i++) { things[i].stuff = null; } List <SketchTerrain> terrain = sketch.Terrain; for (int j = 0; j < terrain.Count; j++) { terrain[j].treatSimilarAsSame = true; } } slate.Set(storeAs.GetValue(slate), sketch); return(true); }
protected override bool TestRunInt(Slate slate) { if (!TryFindTile(slate, out var tile)) { return(false); } slate.Set(storeAs.GetValue(slate), tile); return(true); }
protected override void RunInt() { string processedTag = GetProcessedTag(QuestGen.slate); QuestUtility.AddQuestTag(ref QuestGen.quest.tags, processedTag); if (storeProcessedTagAs.GetValue(QuestGen.slate) != null) { QuestGen.slate.Set(storeProcessedTagAs.GetValue(QuestGen.slate), processedTag); } }
protected override void RunInt() { Slate slate = QuestGen.slate; Site var = QuestGen_Sites.GenerateSite(sitePartsParams.GetValue(slate), tile.GetValue(slate), faction.GetValue(slate), hiddenSitePartsPossible.GetValue(slate), singleSitePartRules.GetValue(slate)); if (storeAs.GetValue(slate) != null) { QuestGen.slate.Set(storeAs.GetValue(slate), var); } }
private void SetVars(Slate slate) { Option option = options.GetValue(slate).RandomElementByWeight((Option x) => x.weight); slate.Set(storeHediffAs.GetValue(slate), option.def); if (storePartsToAffectAs.GetValue(slate) != null) { slate.Set(storePartsToAffectAs.GetValue(slate), option.partsToAffect); } }
protected override bool TestRunInt(Slate slate) { List <object> list = value.GetValue(slate); if (list != null) { QuestGenUtility.AddRangeToOrMakeList(slate, name.GetValue(slate), list); } return(true); }