예제 #1
0
        private static void DrawScrollBoxEntry(Rect inRect, Rect outRect, WorkPackageDef def, bool alternate)
        {
            try
            {
                if (inRect.Contains(Event.current.mousePosition) && outRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(inRect);
                    TooltipHandler.TipRegion(inRect, def.Tooltip);
                }
                else if (alternate)
                {
                    Widgets.DrawAltRect(inRect);
                }

                GUI.BeginGroup(inRect);
                Rect labelRect = new Rect(0f, 0f, inRect.width, inRect.height);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(labelRect, def.label);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
            }
        }
        private void DrawSelectedEntry(WorkPackageDef p, Rect entryRect, bool alternate)
        {
            try
            {
                if (entryRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(entryRect);
                }
                else if (alternate)
                {
                    Widgets.DrawAltRect(entryRect);
                }
                TooltipHandler.TipRegion(entryRect, p.Tooltip);

                GUI.BeginGroup(entryRect);

                Rect labelRect = new Rect(0f, 0f, entryRect.width - 25f, entryRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(labelRect, p.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;

                Rect buttonRect = new Rect(entryRect.width - 25f, entryRect.height / 2 - 12.5f, 25f, 25f);
                if (Widgets.ImageButton(buttonRect, Widget.ArrowLeftTex, Color.white))
                {
                    _bp.WorkPackages.Remove(p);
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
예제 #3
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);
        }
예제 #4
0
 public void AddWorkPackage(WorkPackageDef package)
 {
     if (!workPackages.Contains(package))
     {
         workTypesCache  = null;
         powerNeedsCache = null;
         RefreshWorkGiverCaches();
         workPackages.Add(package);
         if (package.specialistWorker != null)
         {
             SpecialistWorker worker = (SpecialistWorker)Activator.CreateInstance(package.specialistWorker, new object[] { parent });
             specialist.AddWorker(worker);
         }
     }
 }
        private void DrawSelectedEntry(WorkPackageDef p, Rect entryRect, bool alternate)
        {
            try
            {
                if (entryRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(entryRect);
                }
                else if (alternate)
                {
                    Widgets.DrawAltRect(entryRect);
                }
                TooltipHandler.TipRegion(entryRect, p.Tooltip);

                GUI.BeginGroup(entryRect);

                Rect labelRect = new Rect(0f, 0f, entryRect.width - 25f, entryRect.height);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(labelRect, p.LabelCap);
                Text.Anchor = TextAnchor.UpperLeft;

                Rect buttonRect = new Rect(entryRect.width - 25f, entryRect.height / 2 - 12.5f, 25f, 25f);
                if (Widgets.ImageButton(buttonRect, Widget.ArrowLeftTex, Color.white))
                {
                    _bp.WorkPackages.Remove(p);
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
예제 #6
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);
        }
예제 #7
0
 public bool Contains(WorkPackageDef def)
 {
     return(AllWorkPackages.Contains(def));
 }
예제 #8
0
 public bool Contains(WorkPackageDef def)
 {
     return AllWorkPackages.Contains(def);
 }
예제 #9
0
 public void AddWorkPackage(WorkPackageDef package)
 {
     if (!workPackages.Contains(package))
     {
         workTypesCache = null;
         powerNeedsCache = null;
         RefreshWorkGiverCaches();
         workPackages.Add(package);
         if (package.specialistWorker != null)
         {
             SpecialistWorker worker = (SpecialistWorker)Activator.CreateInstance(package.specialistWorker, new object[] { parent });
             specialist.AddWorker(worker);
         }
     }
 }
예제 #10
0
        private static void DrawScrollBoxEntry(Rect inRect, Rect outRect, WorkPackageDef def, bool alternate)
        {
            try
            {
                if (inRect.Contains(Event.current.mousePosition) && outRect.Contains(Event.current.mousePosition))
                {
                    Widgets.DrawHighlight(inRect);
                    TooltipHandler.TipRegion(inRect, def.Tooltip);
                }
                else if (alternate)
                    Widgets.DrawAltRect(inRect);

                GUI.BeginGroup(inRect);
                Rect labelRect = new Rect(0f, 0f, inRect.width, inRect.height);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(labelRect, def.label);
                Text.Anchor = TextAnchor.UpperLeft;
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
            }
        }