protected override bool TryExecuteWorker(IncidentParms parms) { int tile; if (!this.TryFindTile(out tile)) { return(false); } Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.PrisonerWillingToJoin, "PrisonerRescueQuestThreat", tile, null, true, null, true, null); if (site == null) { return(false); } site.sitePartsKnown = true; Pawn pawn = PrisonerWillingToJoinQuestUtility.GeneratePrisoner(tile, site.Faction); site.GetComponent <PrisonerWillingToJoinComp>().pawn.TryAdd(pawn, true); int randomInRange = SiteTuning.QuestSiteTimeoutDaysRange.RandomInRange; site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000); Find.WorldObjects.Add(site); string text; string label; this.GetLetterText(pawn, site, site.parts.FirstOrDefault <SitePart>(), randomInRange, out text, out label); Find.LetterStack.ReceiveLetter(label, text, this.def.letterDef, site, site.Faction, null); return(true); }
protected override bool TryExecuteWorker(IncidentParms parms) { int tile = default(int); if (!this.TryFindTile(out tile)) { return(false); } Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.PrisonerWillingToJoin, IncidentWorker_QuestPrisonerWillingToJoin.PrisonerWillingToJoinQuestThreatTag, null, true, null); if (site == null) { return(false); } site.Tile = tile; Pawn pawn = PrisonerWillingToJoinQuestUtility.GeneratePrisoner(tile, site.Faction); ((WorldObject)site).GetComponent <PrisonerWillingToJoinComp>().pawn.TryAdd(pawn, true); int randomInRange = IncidentWorker_QuestPrisonerWillingToJoin.TimeoutDaysRange.RandomInRange; ((WorldObject)site).GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000); Find.WorldObjects.Add(site); Find.LetterStack.ReceiveLetter(base.def.letterLabel, this.GetLetterText(pawn, site.Faction, randomInRange), base.def.letterDef, site, null); return(true); }
protected override void ScatterAt(IntVec3 loc, Map map, int count = 1) { Faction faction; if (map.ParentFaction == null || map.ParentFaction == Faction.OfPlayer) { faction = Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined); } else { faction = map.ParentFaction; } CellRect cellRect = CellRect.CenteredOn(loc, 8, 8).ClipInsideMap(map); PrisonerWillingToJoinComp component = map.Parent.GetComponent <PrisonerWillingToJoinComp>(); Pawn singlePawnToSpawn; if (component != null && component.pawn.Any) { singlePawnToSpawn = component.pawn.Take(component.pawn[0]); } else { singlePawnToSpawn = PrisonerWillingToJoinQuestUtility.GeneratePrisoner(map.Tile, faction); } ResolveParams resolveParams = default(ResolveParams); resolveParams.rect = cellRect; resolveParams.faction = faction; BaseGen.globalSettings.map = map; BaseGen.symbolStack.Push("prisonCell", resolveParams); BaseGen.Generate(); ResolveParams resolveParams2 = default(ResolveParams); resolveParams2.rect = cellRect; resolveParams2.faction = faction; resolveParams2.singlePawnToSpawn = singlePawnToSpawn; resolveParams2.postThingSpawn = delegate(Thing x) { MapGenerator.rootsToUnfog.Add(x.Position); ((Pawn)x).mindState.WillJoinColonyIfRescued = true; }; BaseGen.globalSettings.map = map; BaseGen.symbolStack.Push("pawn", resolveParams2); BaseGen.Generate(); MapGenerator.SetVar <CellRect>("RectOfInterest", cellRect); }
protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1) { Faction faction = ((map.ParentFaction != null && map.ParentFaction != Faction.OfPlayer) ? map.ParentFaction : Find.FactionManager.RandomEnemyFaction()); CellRect cellRect = CellRect.CenteredOn(loc, 8, 8).ClipInsideMap(map); Pawn singlePawnToSpawn; if (parms.sitePart != null && parms.sitePart.things != null && parms.sitePart.things.Any) { singlePawnToSpawn = (Pawn)parms.sitePart.things.Take(parms.sitePart.things[0]); } else { PrisonerWillingToJoinComp component = map.Parent.GetComponent <PrisonerWillingToJoinComp>(); singlePawnToSpawn = ((component == null || !component.pawn.Any) ? PrisonerWillingToJoinQuestUtility.GeneratePrisoner(map.Tile, faction) : component.pawn.Take(component.pawn[0])); } ResolveParams resolveParams = default(ResolveParams); resolveParams.rect = cellRect; resolveParams.faction = faction; RimWorld.BaseGen.BaseGen.globalSettings.map = map; RimWorld.BaseGen.BaseGen.symbolStack.Push("prisonCell", resolveParams); RimWorld.BaseGen.BaseGen.Generate(); ResolveParams resolveParams2 = default(ResolveParams); resolveParams2.rect = cellRect; resolveParams2.faction = faction; resolveParams2.singlePawnToSpawn = singlePawnToSpawn; resolveParams2.singlePawnSpawnCellExtraPredicate = (IntVec3 x) => x.GetDoor(map) == null; resolveParams2.postThingSpawn = delegate(Thing x) { MapGenerator.rootsToUnfog.Add(x.Position); ((Pawn)x).mindState.WillJoinColonyIfRescued = true; }; RimWorld.BaseGen.BaseGen.globalSettings.map = map; RimWorld.BaseGen.BaseGen.symbolStack.Push("pawn", resolveParams2); RimWorld.BaseGen.BaseGen.Generate(); MapGenerator.SetVar("RectOfInterest", cellRect); }