コード例 #1
0
        protected override void ScatterAt(IntVec3 loc, Map map, int count = 1)
        {
            DownedRefugeeComp component = ((WorldObject)map.info.parent).GetComponent <DownedRefugeeComp>();
            Pawn newThing = (component == null || !component.pawn.Any) ? DownedRefugeeQuestUtility.GenerateRefugee(map.Tile) : component.pawn.Take(component.pawn[0]);

            GenSpawn.Spawn(newThing, loc, map);
            MapGenerator.rootsToUnfog.Add(loc);
        }
コード例 #2
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int tile;

            if (!this.TryFindTile(out tile))
            {
                return(false);
            }
            Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.DownedRefugee, (!Rand.Chance(0.3f)) ? "DownedRefugeeQuestThreat" : null, tile, null, true, null, true, null);

            if (site == null)
            {
                return(false);
            }
            site.sitePartsKnown = true;
            Pawn pawn = DownedRefugeeQuestUtility.GenerateRefugee(tile);

            site.GetComponent <DownedRefugeeComp>().pawn.TryAdd(pawn, true);
            int randomInRange = SiteTuning.QuestSiteRefugeeTimeoutDaysRange.RandomInRange;

            site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000);
            Find.WorldObjects.Add(site);
            string text  = this.def.letterLabel;
            string text2 = string.Format(this.def.letterText.AdjustedFor(pawn, "PAWN"), new object[]
            {
                randomInRange,
                pawn.ageTracker.AgeBiologicalYears,
                pawn.story.Title,
                SitePartUtility.GetDescriptionDialogue(site, site.parts.FirstOrDefault <SitePart>())
            }).CapitalizeFirst();
            Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative != null)
            {
                PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn);
                if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0)
                {
                    pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative;
                    text2 = text2 + "\n\n" + "RelatedPawnInvolvedInQuest".Translate(new object[]
                    {
                        mostImportantColonyRelative.LabelShort,
                        mostImportantRelation.GetGenderSpecificLabel(pawn)
                    }).AdjustedFor(pawn, "PAWN");
                }
                else
                {
                    PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text2, pawn);
                }
                text = text + " " + "RelationshipAppendedLetterSuffix".Translate();
            }
            if (pawn.relations != null)
            {
                pawn.relations.everSeenByPlayer = true;
            }
            Find.LetterStack.ReceiveLetter(text, text2, this.def.letterDef, site, null, null);
            return(true);
        }
コード例 #3
0
        public static Pawn GenerateRefugee(int tile)
        {
            PawnKindDef           spaceRefugee            = PawnKindDefOf.SpaceRefugee;
            Faction               randomFactionForRefugee = DownedRefugeeQuestUtility.GetRandomFactionForRefugee();
            PawnGenerationRequest request = new PawnGenerationRequest(spaceRefugee, randomFactionForRefugee, PawnGenerationContext.NonPlayer, tile, false, false, false, false, true, false, 20f, true, true, true, false, false, false, false, null, null, new float?(0.2f), null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            HealthUtility.DamageUntilDowned(pawn, false);
            HealthUtility.DamageLegsUntilIncapableOfMoving(pawn, false);
            return(pawn);
        }
コード例 #4
0
        protected override void ScatterAt(IntVec3 loc, Map map, int count = 1)
        {
            DownedRefugeeComp component = map.Parent.GetComponent <DownedRefugeeComp>();
            Pawn pawn = (component == null || !component.pawn.Any) ? DownedRefugeeQuestUtility.GenerateRefugee(map.Tile) : component.pawn.Take(component.pawn[0]);

            HealthUtility.DamageUntilDowned(pawn, allowBleedingWounds: false);
            HealthUtility.DamageLegsUntilIncapableOfMoving(pawn, allowBleedingWounds: false);
            GenSpawn.Spawn(pawn, loc, map);
            pawn.mindState.WillJoinColonyIfRescued = true;
            MapGenerator.rootsToUnfog.Add(loc);
        }
コード例 #5
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            int tile;

            if (!this.TryFindTile(out tile))
            {
                return(false);
            }
            Site site = SiteMaker.TryMakeSite_SingleSitePart(SiteCoreDefOf.DownedRefugee, (!Rand.Chance(0.3f)) ? IncidentWorker_QuestDownedRefugee.DownedRefugeeQuestThreatTag : null, null, true, null);

            if (site == null)
            {
                return(false);
            }
            site.Tile = tile;
            Pawn pawn = DownedRefugeeQuestUtility.GenerateRefugee(tile);

            site.GetComponent <DownedRefugeeComp>().pawn.TryAdd(pawn, true);
            int randomInRange = IncidentWorker_QuestDownedRefugee.TimeoutDaysRange.RandomInRange;

            site.GetComponent <TimeoutComp>().StartTimeout(randomInRange * 60000);
            Find.WorldObjects.Add(site);
            string text = string.Format(this.def.letterText.AdjustedFor(pawn), pawn.Label, randomInRange).CapitalizeFirst();
            Pawn   mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn);

            if (mostImportantColonyRelative != null)
            {
                PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn);
                if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0)
                {
                    pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative;
                    text = text + "\n\n" + "RelatedPawnInvolvedInQuest".Translate(new object[]
                    {
                        mostImportantColonyRelative.LabelShort,
                        mostImportantRelation.GetGenderSpecificLabel(pawn)
                    }).AdjustedFor(pawn);
                }
                else
                {
                    PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, pawn);
                }
            }
            if (pawn.relations != null)
            {
                pawn.relations.everSeenByPlayer = true;
            }
            Find.LetterStack.ReceiveLetter(this.def.letterLabel, text, this.def.letterDef, site, null);
            return(true);
        }
コード例 #6
0
        protected override void ScatterAt(IntVec3 loc, Map map, int count = 1)
        {
            DownedRefugeeComp component = map.info.parent.GetComponent <DownedRefugeeComp>();
            Pawn newThing;

            if (component != null && component.pawn.Any)
            {
                newThing = component.pawn.Take(component.pawn[0]);
            }
            else
            {
                newThing = DownedRefugeeQuestUtility.GenerateRefugee(map.Tile);
            }
            GenSpawn.Spawn(newThing, loc, map);
            MapGenerator.rootsToUnfog.Add(loc);
        }
コード例 #7
0
        protected override void ScatterAt(IntVec3 loc, Map map, int count = 1)
        {
            DownedRefugeeComp component = map.Parent.GetComponent <DownedRefugeeComp>();
            Pawn pawn;

            if (component != null && component.pawn.Any)
            {
                pawn = component.pawn.Take(component.pawn[0]);
            }
            else
            {
                pawn = DownedRefugeeQuestUtility.GenerateRefugee(map.Tile);
            }
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            pawn.mindState.willJoinColonyIfRescued = true;
            MapGenerator.rootsToUnfog.Add(loc);
        }
コード例 #8
0
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int count = 1)
        {
            Pawn pawn;

            if (parms.sitePart != null && parms.sitePart.things != null && parms.sitePart.things.Any)
            {
                pawn = (Pawn)parms.sitePart.things.Take(parms.sitePart.things[0]);
            }
            else
            {
                DownedRefugeeComp component = map.Parent.GetComponent <DownedRefugeeComp>();
                pawn = ((component == null || !component.pawn.Any) ? DownedRefugeeQuestUtility.GenerateRefugee(map.Tile) : component.pawn.Take(component.pawn[0]));
            }
            HealthUtility.DamageUntilDowned(pawn, allowBleedingWounds: false);
            HealthUtility.DamageLegsUntilIncapableOfMoving(pawn, allowBleedingWounds: false);
            GenSpawn.Spawn(pawn, loc, map);
            pawn.mindState.WillJoinColonyIfRescued = true;
            MapGenerator.rootsToUnfog.Add(loc);
            MapGenerator.SetVar("RectOfInterest", CellRect.CenteredOn(loc, 1, 1));
        }
コード例 #9
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, DownedRefugeeQuestUtility.GetRandomFactionForRefugee(), PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            outThings.Add(pawn);
            HealthUtility.DamageUntilDowned(pawn);
        }
コード例 #10
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, DownedRefugeeQuestUtility.GetRandomFactionForRefugee(), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: false, 20f));

            outThings.Add(pawn);
            HealthUtility.DamageUntilDowned(pawn);
        }