Ejemplo n.º 1
0
        public void Hatch()
        {
            PawnGenerationRequest request = new PawnGenerationRequest(this.Props.hatcherPawn, this.hatcheeFaction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false, false, false, false, 0, null, 1, null, null, null, null, null);
            Pawn hatchling = PawnGenerator.GeneratePawn(request);

            hatchling.SetFactionDirect(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Horrors")));
            PawnUtility.TrySpawnHatchedOrBornPawn(hatchling, this.parent);
            PawnInventoryGenerator.GenerateInventoryFor(hatchling, request);
            PawnWeaponGenerator.TryGenerateWeaponFor(hatchling, request);
            Lord lord = CreateNewLord();

            lord.AddPawn(hatchling);
            this.parent.Destroy(DestroyMode.Vanish);
        }
Ejemplo n.º 2
0
 private static void GenerateGearFor(Pawn pawn, PawnGenerationRequest request)
 {
     ProfilerThreadCheck.BeginSample("GenerateGearFor");
     ProfilerThreadCheck.BeginSample("GenerateStartingApparelFor");
     PawnApparelGenerator.GenerateStartingApparelFor(pawn, request);
     ProfilerThreadCheck.EndSample();
     ProfilerThreadCheck.BeginSample("TryGenerateWeaponFor");
     PawnWeaponGenerator.TryGenerateWeaponFor(pawn);
     ProfilerThreadCheck.EndSample();
     ProfilerThreadCheck.BeginSample("GenerateInventoryFor");
     PawnInventoryGenerator.GenerateInventoryFor(pawn, request);
     ProfilerThreadCheck.EndSample();
     ProfilerThreadCheck.EndSample();
 }
Ejemplo n.º 3
0
        public void Hatch()
        {
            var request = new PawnGenerationRequest(Props.hatcherPawn, hatcheeFaction, PawnGenerationContext.NonPlayer,
                                                    -1, false, true, false, false, true, false, 1f, false, true, true, false);
            var hatchling = PawnGenerator.GeneratePawn(request);

            hatchling.SetFactionDirect(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("Horrors")));
            PawnUtility.TrySpawnHatchedOrBornPawn(hatchling, parent);
            PawnInventoryGenerator.GenerateInventoryFor(hatchling, request);
            PawnWeaponGenerator.TryGenerateWeaponFor(hatchling, request);
            var lord = CreateNewLord();

            lord.AddPawn(hatchling);
            parent.Destroy();
        }
Ejemplo n.º 4
0
        private static void GenerateInventoryFor_Coping(Pawn pawn, Pawn sourcePawn)
        {
            if ((sourcePawn != null) &&
                ((sourcePawn.RaceProps.Humanlike && pawn.RaceProps.Humanlike) ||
                 (sourcePawn.def == pawn.def)))
            {
                if (sourcePawn.inventory == null)
                {
                    return;
                }

                while (sourcePawn.inventory.container.Any())
                {
                    Thing thing = sourcePawn.inventory.container.First();
                    sourcePawn.inventory.container.TransferToContainer(thing, pawn.inventory.container, thing.stackCount);
                    //sourcePawn.inventory.container.TryDrop(sourcePawn.inventory.container.Contents.First<Thing>(), out thing);
                    //pawn.inventory.container.TryAdd(thing);
                }
            }
            else
            {
                PawnInventoryGenerator.GenerateInventoryFor(pawn);
            }
        }
Ejemplo n.º 5
0
        public static Pawn DoGeneratePawnFromSource(Pawn sourcePawn, bool isBerserk = true, bool oathOfHastur = false)
        {
            PawnKindDef pawnKindDef   = sourcePawn.kindDef;
            Faction     factionDirect = isBerserk ? Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile) : Faction.OfPlayer;
            Pawn        pawn          = (Pawn)ThingMaker.MakeThing(pawnKindDef.race);

            try
            {
                pawn.kindDef = pawnKindDef;
                pawn.SetFactionDirect(factionDirect);
                PawnComponentsUtility.CreateInitialComponents(pawn);
                pawn.gender = sourcePawn.gender;
                pawn.ageTracker.AgeBiologicalTicks    = sourcePawn.ageTracker.AgeBiologicalTicks;
                pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks;
                pawn.workSettings = new Pawn_WorkSettings(pawn);
                if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer)
                {
                    pawn.workSettings.EnableAndInitialize();
                }

                pawn.needs.SetInitialLevels();
                //Add hediffs?
                //Add relationships?
                if (pawn.RaceProps.Humanlike)
                {
                    pawn.story.melanin   = sourcePawn.story.melanin;
                    pawn.story.crownType = sourcePawn.story.crownType;
                    pawn.story.hairColor = sourcePawn.story.hairColor;
                    pawn.story.childhood = sourcePawn.story.childhood;
                    pawn.story.adulthood = sourcePawn.story.adulthood;
                    pawn.story.bodyType  = sourcePawn.story.bodyType;
                    pawn.story.hairDef   = sourcePawn.story.hairDef;
                    foreach (Trait current in sourcePawn.story.traits.allTraits)
                    {
                        pawn.story.traits.GainTrait(current);
                    }

                    SkillFixer(pawn, sourcePawn);
                    RelationshipFixer(pawn, sourcePawn);
                    AddedPartFixer(pawn, sourcePawn);
                    //pawn.story.GenerateSkillsFromBackstory();
                    NameTriple nameTriple = sourcePawn.Name as NameTriple;
                    //if (!oathOfHastur)
                    //{
                    //    pawn.Name = new NameTriple(nameTriple.First, string.Concat(new string[]
                    //        {
                    //        "* ",
                    //        Translator.Translate("Reanimated"),
                    //        " ",
                    //        nameTriple.Nick,
                    //        " *"
                    //        }), nameTriple.Last);
                    //}
                    pawn.Name = nameTriple;
                }
                string headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath);
                GenerateApparelFromSource(pawn, sourcePawn);
                PawnGenerationRequest con = new PawnGenerationRequest();
                PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
                if (isBerserk)
                {
                    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                }
                //Log.Message(pawn.NameStringShort);
                return(pawn);
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
                //Cthulhu.Utility.DebugReport(e.ToString());
            }
            return(null);
        }
Ejemplo n.º 6
0
        //public static bool Zombify(ReanimatedPawn pawn)
        //{
        //    if (pawn.Drawer == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics == null)
        //    {
        //        return false;
        //    }
        //    if (!pawn.Drawer.renderer.graphics.AllResolved)
        //    {
        //        pawn.Drawer.renderer.graphics.ResolveAllGraphics();
        //    }
        //    if (pawn.Drawer.renderer.graphics.headGraphic == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.nakedGraphic == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.headGraphic.path == null)
        //    {
        //        return false;
        //    }
        //    if (pawn.Drawer.renderer.graphics.nakedGraphic.path == null)
        //    {
        //        return false;
        //    }
        //    GiveZombieSkinEffect(pawn);
        //    return true;
        //}

        // Credit goes to Justin C for the Zombie Apocalypse code.
        // Taken from Verse.ZombieMod_Utility
        public static Pawn GenerateClonePawnFromSource(Pawn sourcePawn)
        {
            PawnKindDef pawnKindDef   = PawnKindDef.Named("ReanimatedCorpse");
            Faction     factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDefOf.SpacerHostile);
            Pawn        pawn          = (Pawn)ThingMaker.MakeThing(pawnKindDef.race);

            pawn.kindDef = pawnKindDef;
            pawn.SetFactionDirect(factionDirect);
            pawn.pather     = new Pawn_PathFollower(pawn);
            pawn.ageTracker = new Pawn_AgeTracker(pawn);
            pawn.health     = new Pawn_HealthTracker(pawn);
            pawn.jobs       = new Pawn_JobTracker(pawn);
            pawn.mindState  = new Pawn_MindState(pawn);
            pawn.filth      = new Pawn_FilthTracker(pawn);
            pawn.needs      = new Pawn_NeedsTracker(pawn);
            pawn.stances    = new Pawn_StanceTracker(pawn);
            pawn.natives    = new Pawn_NativeVerbs(pawn);
            PawnComponentsUtility.CreateInitialComponents(pawn);
            if (pawn.RaceProps.ToolUser)
            {
                pawn.equipment    = new Pawn_EquipmentTracker(pawn);
                pawn.carryTracker = new Pawn_CarryTracker(pawn);
                pawn.apparel      = new Pawn_ApparelTracker(pawn);
                pawn.inventory    = new Pawn_InventoryTracker(pawn);
            }
            if (pawn.RaceProps.Humanlike)
            {
                pawn.ownership    = new Pawn_Ownership(pawn);
                pawn.skills       = new Pawn_SkillTracker(pawn);
                pawn.relations    = new Pawn_RelationsTracker(pawn);
                pawn.story        = new Pawn_StoryTracker(pawn);
                pawn.workSettings = new Pawn_WorkSettings(pawn);
            }
            if (pawn.RaceProps.intelligence <= Intelligence.ToolUser)
            {
                pawn.caller = new Pawn_CallTracker(pawn);
            }
            //pawn.gender = Gender.None;
            pawn.gender = sourcePawn.gender;
            //Cthulhu.Utility.GenerateRandomAge(pawn, pawn.Map);
            pawn.ageTracker.AgeBiologicalTicks = sourcePawn.ageTracker.AgeBiologicalTicks;
            pawn.ageTracker.BirthAbsTicks      = sourcePawn.ageTracker.BirthAbsTicks;

            pawn.needs.SetInitialLevels();
            if (pawn.RaceProps.Humanlike)
            {
                string headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath);
                pawn.story.melanin   = sourcePawn.story.melanin;
                pawn.story.crownType = sourcePawn.story.crownType;
                pawn.story.hairColor = sourcePawn.story.hairColor;
                NameTriple name = sourcePawn.Name as NameTriple;
                pawn.Name            = name;
                pawn.story.childhood = sourcePawn.story.childhood;
                pawn.story.adulthood = sourcePawn.story.adulthood;
                pawn.story.hairDef   = sourcePawn.story.hairDef;
                foreach (Trait current in sourcePawn.story.traits.allTraits)
                {
                    pawn.story.traits.GainTrait(current);
                }
                //pawn.story.GenerateSkillsFromBackstory();
            }
            GenerateApparelFromSource(pawn, sourcePawn);
            PawnGenerationRequest con = new PawnGenerationRequest();

            PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
            Graphic nakedBodyGraphic = GraphicGetter_NakedHumanlike.GetNakedBodyGraphic(sourcePawn.story.bodyType, ShaderDatabase.CutoutSkin, sourcePawn.story.SkinColor);
            Graphic headGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.HeadGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, sourcePawn.story.SkinColor);
            Graphic hairGraphic      = GraphicDatabase.Get <Graphic_Multi>(sourcePawn.story.hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, sourcePawn.story.hairColor);

            pawn.Drawer.renderer.graphics.headGraphic  = headGraphic;
            pawn.Drawer.renderer.graphics.nakedGraphic = nakedBodyGraphic;
            pawn.Drawer.renderer.graphics.hairGraphic  = hairGraphic;
            return(pawn);
        }
Ejemplo n.º 7
0
        public static ReanimatedPawn DoGenerateZombiePawnFromSource(Pawn sourcePawn, bool isBerserk = true,
                                                                    bool oathOfHastur = false)
        {
            var pawnKindDef   = PawnKindDef.Named("ReanimatedCorpse");
            var factionDirect = isBerserk
                ? Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile)
                : Faction.OfPlayer;
            var pawn = (ReanimatedPawn)ThingMaker.MakeThing(pawnKindDef.race);

            try
            {
                pawn.kindDef = pawnKindDef;
                pawn.SetFactionDirect(factionDirect);
                PawnComponentsUtility.CreateInitialComponents(pawn);
                pawn.gender = sourcePawn.gender;
                pawn.ageTracker.AgeBiologicalTicks    = sourcePawn.ageTracker.AgeBiologicalTicks;
                pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks;
                pawn.workSettings = new Pawn_WorkSettings(pawn);
                if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer)
                {
                    pawn.workSettings.EnableAndInitialize();
                }

                pawn.needs.SetInitialLevels();
                //Add hediffs?
                //Add relationships?
                if (pawn.RaceProps.Humanlike)
                {
                    pawn.story.melanin   = sourcePawn.story.melanin;
                    pawn.story.crownType = sourcePawn.story.crownType;
                    pawn.story.hairColor = sourcePawn.story.hairColor;
                    pawn.story.childhood = sourcePawn.story.childhood;
                    pawn.story.adulthood = sourcePawn.story.adulthood;
                    pawn.story.bodyType  = sourcePawn.story.bodyType;
                    pawn.story.hairDef   = sourcePawn.story.hairDef;
                    if (!oathOfHastur)
                    {
                        foreach (var current in sourcePawn.story.traits.allTraits)
                        {
                            pawn.story.traits.GainTrait(current);
                        }
                    }
                    else
                    {
                        pawn.story.traits.GainTrait(new Trait(TraitDef.Named("Cults_OathtakerHastur2"), 0, true));
                        pawn.story.traits.GainTrait(new Trait(TraitDefOf.Psychopath, 0, true));

                        SkillFixer(pawn, sourcePawn);
                        RelationshipFixer(pawn, sourcePawn);
                        AddedPartFixer(pawn, sourcePawn);
                    }

                    //pawn.story.GenerateSkillsFromBackstory();
                    var nameTriple = sourcePawn.Name as NameTriple;
                    if (!oathOfHastur)
                    {
                        pawn.Name = new NameTriple(nameTriple?.First,
                                                   string.Concat("* ", "Reanimated".Translate(), " ", nameTriple?.Nick, " *"),
                                                   nameTriple?.Last);
                    }
                    else
                    {
                        pawn.Name = nameTriple;
                    }
                }

                var headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic)
                ?.SetValue(pawn.story, headGraphicPath);
                GenerateZombieApparelFromSource(pawn, sourcePawn);
                var con = new PawnGenerationRequest();
                PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
                GiveZombieSkinEffect(pawn, sourcePawn as ReanimatedPawn, oathOfHastur);
                if (isBerserk)
                {
                    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                }

                //Log.Message(pawn.Name.ToStringShort);
                return(pawn);
            }
            catch (Exception e)
            {
                Utility.DebugReport(e.ToString());
            }

            return(null);
        }
Ejemplo n.º 8
0
 private static void GenerateGearFor(Pawn pawn, PawnGenerationRequest request)
 {
     PawnApparelGenerator.GenerateStartingApparelFor(pawn, request);
     PawnWeaponGenerator.TryGenerateWeaponFor(pawn);
     PawnInventoryGenerator.GenerateInventoryFor(pawn, request);
 }
Ejemplo n.º 9
0
        public static Zombie DoGenerateZombiePawnFromSource(Pawn sourcePawn, string pawnKind, string factionName)
        {
            PawnKindDef pawnKindDef   = PawnKindDef.Named(pawnKind);
            Faction     factionDirect = Find.FactionManager.FirstFactionOfDef(FactionDef.Named(factionName));
            Zombie      pawn          = (Zombie)ThingMaker.MakeThing(pawnKindDef.race, null);

            try
            {
                pawn.kindDef = pawnKindDef;
                pawn.SetFactionDirect(factionDirect);
                PawnComponentsUtility.CreateInitialComponents(pawn);
                pawn.gender = sourcePawn.gender;
                pawn.ageTracker.AgeBiologicalTicks    = sourcePawn.ageTracker.AgeBiologicalTicks;
                pawn.ageTracker.AgeChronologicalTicks = sourcePawn.ageTracker.AgeChronologicalTicks;
                pawn.workSettings = new Pawn_WorkSettings(pawn);
                if (pawn.workSettings != null && sourcePawn.Faction.IsPlayer)
                {
                    pawn.workSettings.EnableAndInitialize();
                }

                pawn.needs.SetInitialLevels();
                //Add hediffs?
                //Add relationships?
                if (pawn.RaceProps.Humanlike)
                {
                    pawn.story.melanin   = sourcePawn.story.melanin;
                    pawn.story.crownType = sourcePawn.story.crownType;
                    pawn.story.hairColor = sourcePawn.story.hairColor;
                    pawn.story.childhood = sourcePawn.story.childhood;
                    pawn.story.adulthood = sourcePawn.story.adulthood;
                    pawn.story.bodyType  = sourcePawn.story.bodyType;
                    pawn.story.hairDef   = sourcePawn.story.hairDef;

                    SkillFixer(pawn, sourcePawn);
                    RelationshipFixer(pawn, sourcePawn);
                    AddedPartFixer(pawn, sourcePawn);
                    //pawn.story.GenerateSkillsFromBackstory();
                    NameTriple nameTriple = sourcePawn.Name as NameTriple;
                    pawn.Name = new NameTriple(nameTriple.First, string.Concat(new string[]
                    {
                        "* ",
                        Translator.Translate("RE_Zombie"),
                        " ",
                        nameTriple.Nick,
                        " *"
                    }), nameTriple.Last);
                }
                string headGraphicPath = sourcePawn.story.HeadGraphicPath;
                typeof(Pawn_StoryTracker).GetField("headGraphicPath", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(pawn.story, headGraphicPath);
                GenerateZombieApparelFromSource(pawn, sourcePawn);
                PawnGenerationRequest con = new PawnGenerationRequest();
                PawnInventoryGenerator.GenerateInventoryFor(pawn, con);
                GiveZombieSkinEffect(pawn, sourcePawn as Zombie);
                //if (isBerserk)
                //{
                //    pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.Berserk);
                //}
                //Log.Message(pawn.Name.ToStringShort);
                return(pawn);
            }
            catch (Exception e)
            {
                //Cthulhu.Utility.DebugReport(e.ToString());
            }
            return(null);
        }