Beispiel #1
0
        public override bool ShouldSkip(Pawn pawn)
        {
            Droid droid = pawn as Droid;
            bool  flag  = droid != null && droid.work.Contains(WorkPackageDef.Named("MD2CremationPackage")) && droid.work.specialist.GetWorker <CremationWorker>() != null;

            return(!flag);
        }
Beispiel #2
0
        public static Droid GenerateDroid(Blueprint bp, Faction faction)
        {
            Droid droid = (Droid)ThingMaker.MakeThing(bp.KindDef.race);

            droid.SetFactionDirect(faction);
            droid.kindDef             = bp.KindDef;
            droid.RaceProps.corpseDef = ThingDef.Named("MD2DroidCorpse");

            #region Trackers
            droid.thinker          = new Pawn_Thinker(droid);
            droid.playerController = new Pawn_PlayerController(droid);
            droid.inventory        = new Pawn_InventoryTracker(droid);
            droid.pather           = new Pawn_PathFollower(droid);
            droid.jobs             = new Pawn_JobTracker(droid);
            droid.health           = new Pawn_HealthTracker(droid);
            droid.ageTracker       = new Pawn_AgeTracker(droid);
            droid.filth            = new Pawn_FilthTracker(droid);
            droid.mindState        = new Pawn_MindState(droid);
            droid.equipment        = new Pawn_EquipmentTracker(droid);
            droid.apparel          = new Pawn_ApparelTracker(droid);
            droid.natives          = new Pawn_NativeVerbs(droid);
            droid.meleeVerbs       = new Pawn_MeleeVerbs(droid);
            droid.carryHands       = new Pawn_CarryHands(droid);
            droid.ownership        = new Pawn_Ownership(droid);
            droid.skills           = new Pawn_SkillTracker(droid);
            droid.story            = new Pawn_StoryTracker(droid);
            droid.workSettings     = new Pawn_WorkSettings(droid);
            droid.guest            = new Pawn_GuestTracker(droid);
            droid.needs            = new Pawn_NeedsTracker(droid);
            droid.stances          = new Pawn_StanceTracker(droid);

            typeof(Pawn_NeedsTracker).GetMethod("AddNeed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(droid.needs, new object[] { DefDatabase <NeedDef> .GetNamed("Mood") });
            #endregion

            droid.gender = droid.RaceProps.hasGenders ? Gender.Male : Gender.None;

            droid.ageTracker.SetChronologicalBirthDate(GenDate.CurrentYear, GenDate.DayOfMonth);
            droid.story.skinColor       = PawnSkinColors.PaleWhiteSkin;
            droid.story.crownType       = CrownType.Narrow;
            droid.story.headGraphicPath = GraphicDatabaseHeadRecords.GetHeadRandom(Gender.Male, droid.story.skinColor, droid.story.crownType).GraphicPath;
            droid.story.hairColor       = PawnHairColors.RandomHairColor(droid.story.skinColor, droid.ageTracker.AgeBiologicalYears);
            droid.story.name            = new PawnName()
            {
                first = "Droid",
                last  = "Droid",
                nick  = bp.Name
            };

            #region Managers

            droid.meta      = new MetaDataManager(droid, bp);
            droid.utilities = new UtilityManager(droid);

            WorkPackageDef        maintenance  = WorkPackageDef.Named("MD2MaintenancePackage");
            WorkPackageDef        firefighting = WorkPackageDef.Named("MD2FirefighterPackage");
            List <WorkPackageDef> list         = bp.WorkPackages;
            if (!list.Contains(maintenance))
            {
                list.Add(maintenance);
            }
            if (!list.Contains(firefighting))
            {
                list.Add(firefighting);
            }
            droid.work = new WorkManager(list, droid);

            droid.backstory = new BackstoryManager(droid);
            droid.backstory.SpawnSetup();

            droid.drawManager = new DrawManager(bp.BodyGraphicDef, bp.HeadGraphicDef, droid);
            droid.drawManager.SpawnSetup();

            droid.parts = new PartsManager(droid);
            #endregion

            foreach (SkillRecord sk in droid.skills.skills)
            {
                sk.level   = (bp.StartingSkillLevel > 20) ? 20 : (bp.StartingSkillLevel <= 0) ? 1 : bp.StartingSkillLevel;
                sk.passion = bp.SkillPassion;
            }
            droid.workSettings.EnableAndInitialize();

            foreach (var def in DefDatabase <WorkTypeDef> .AllDefs)
            {
                if (droid.work.Contains(def))
                {
                    droid.workSettings.SetPriority(def, 4);
                }
                else
                {
                    droid.workSettings.SetPriority(def, 0);
                    droid.workSettings.Disable(def);
                }
            }

            return(droid);
        }