Exemple #1
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            // bail out if showing worksettings is nonsensical
            if (pawn.Dead || !pawn.workSettings.EverWork)
            {
                return;
            }

            var incapable = IncapableOfWholeWorkType(pawn);
            var worktype  = def.workType;

            // create rect in centre of cell
            var pos = rect.center - new Vector2(WorkTypeBoxSize, WorkTypeBoxSize) / 2f;
            var box = new Rect(pos.x, pos.y, WorkTypeBoxSize, WorkTypeBoxSize);

            // plop in the tooltip
            Func <string> tipGetter = delegate { return(WorkUtilities.TipForPawnWorker(pawn, worktype, incapable)); };

            TooltipHandler.TipRegion(box, tipGetter, pawn.thingIDNumber ^ worktype.GetHashCode());

            // bail out if worktype is disabled (or pawn has no background story).
            if (!ShouldDrawCell(pawn))
            {
                return;
            }

            // draw the workbox
            Text.Font = GameFont.Medium;
            DrawWorkTypeBoxFor(box, pawn, worktype, incapable);
            Text.Font = GameFont.Small;

            // handle interactions
            HandleInteractions(rect, pawn);
        }
        public void Recache(WorkGiverDef workgiver, bool bubble = true)
        {
            // recache workgiver stuff
            var priorities = pawn.GetPriorities(workgiver);

            _everScheduledWorkGiver[workgiver]    = priorities.Any(p => p > 0);
            _timeScheduledWorkGiver[workgiver]    = priorities.Distinct().Count() > 1;
            _timeScheduledWorkGiverTip[workgiver] = WorkUtilities.TimeScheduledTip(pawn, priorities, workgiver.label);

            // also recache worktype
            if (bubble)
            {
                Recache(workgiver.workType, false);
            }
        }
Exemple #3
0
        protected virtual void DrawWorkGiverBoxFor(Rect box, Pawn pawn, WorkGiverDef workgiver, bool incapable)
        {
            // draw background
            GUI.color = incapable ? new Color(1f, .3f, .3f) : Color.white;
            WorkUtilities.DrawWorkBoxBackground(box, pawn, workgiver.workType);
            GUI.color = Color.white;

            // draw extras
            var tracker = PriorityManager.Get[pawn];

            if (tracker.TimeScheduled(workgiver))
            {
                WorkUtilities.DrawTimeScheduled(box);
            }

            // draw priorities / checks
            WorkUtilities.DrawPriority(box, pawn.GetPriority(workgiver, VisibleHour), true);
        }
        public void Recache(WorkTypeDef worktype, bool bubble = true)
        {
            var workgivers = worktype.WorkGivers();
            var priorities = pawn.GetPriorities(worktype);

            // first update all the workgivers (if bubbling down, or not yet set)
            foreach (var workgiver in workgivers)
            {
                if (bubble || !_everScheduledWorkGiver.ContainsKey(workgiver)) // using _everScheduled as a proxy - assumes all these are cached at the same time!
                {
                    Recache(workgiver, false);
                }
            }

            // recache worktype stuff
            _everScheduledWorkType[worktype]    = workgivers.Any(wg => _everScheduledWorkGiver[wg]);
            _timeScheduledWorkType[worktype]    = workgivers.Any(wg => _timeScheduledWorkGiver[wg]);
            _timeScheduledWorkTypeTip[worktype] = WorkUtilities.TimeScheduledTip(pawn, priorities, worktype.gerundLabel);

            // is any workgiver different from the whole at any time during the day?
            _partScheduledWorkType[worktype] = TimeUtilities.WholeDay
                                               .Any(hour => worktype.WorkGivers().Any(wg => pawn.GetPriority(worktype, hour) != pawn.GetPriority(wg, hour)));
        }
Exemple #5
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            // bail out if showing worksettings is nonsensical
            if (pawn.Dead ||
                !pawn.workSettings.EverWork)
            {
                return;
            }

            var workgiver = WorkGiver;

            // create rect in centre of cell, slightly offsetting left to give the appearance of aligning to worktype.
            var pos = rect.center - new Vector2(WorkGiverBoxSize, WorkGiverBoxSize) / 2f;
            var box = new Rect(pos.x - 2f, pos.y, WorkGiverBoxSize, WorkGiverBoxSize);

            // is the pawn currently capable of doing this job?
            var incapable = !pawn.CapableOf(workgiver);

            // plop in the tooltip
            Func <string> tipGetter = delegate { return(WorkUtilities.TipForPawnWorker(pawn, workgiver, incapable)); };

            TooltipHandler.TipRegion(box, tipGetter, pawn.thingIDNumber ^ workgiver.workType.GetHashCode());

            // bail out if pawn can't actually do this work
            if (!ShouldDrawCell(pawn))
            {
                return;
            }

            // draw the workbox
            Text.Font = GameFont.Tiny;
            DrawWorkGiverBoxFor(box, pawn, workgiver, incapable);

            // handle interactions
            HandleInteractions(rect, pawn);
        }