예제 #1
0
        public void Recache(WorkGiverDef workgiver)
        {
            // recache workgiver stuff
            var priorities = pawn.GetPriorities(workgiver);

            _everScheduledWorkGiver[workgiver]    = priorities.Any(p => p > 0);
            _timeScheduledWorkGiver[workgiver]    = priorities.Distinct().Count() > 1;
            _timeScheduledWorkGiverTip[workgiver] = DrawUtilities.TimeScheduledTip(pawn, priorities, workgiver.label);
        }
예제 #2
0
        protected virtual void DrawWorkGiverBoxFor(Rect box, Pawn pawn, WorkGiverDef workgiver, bool incapable)
        {
            List <SkillDef> skillsNeeded = workgiver.workType.relevantSkills;
            float           averageSkill = pawn.skills.AverageOfRelevantSkillsFor(workgiver.workType);

            Passion passion = Passion.None;

            if (skillsNeeded.Count > 0)
            {
                passion = pawn.skills.GetSkill(workgiver.workType.relevantSkills[0]).passion;
            }

            Color red   = new Color(1f, 0f, 0f);
            Color green = new Color(0f, 1f, 0f);
            Color blue  = new Color(0f, 0f, 1f);
            Color black = new Color(0f, 0f, 0f);

            Color passionColor;

            if (passion == Passion.None)
            {
                passionColor = red;
            }
            else if (passion == Passion.Minor)
            {
                passionColor = blue;
            }
            else
            {
                passionColor = green;
            }

            GUI.color = Color.Lerp(black + (passionColor * 0.2f), passionColor, averageSkill / 20);
            // draw background
            //GUI.color = incapable ? new Color( 1f, .3f, .3f ) : Color.white;

            DrawUtilities.DrawWorkBoxBackground(box, pawn, workgiver.workType);
            GUI.color = Color.white;

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

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

            // draw priorities / checks
            DrawUtilities.DrawPriority(box, pawn.GetPriority(workgiver, VisibleHour), true);
        }
예제 #3
0
        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] = DrawUtilities.TimeScheduledTip(pawn, priorities, workgiver.label);

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

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

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

            // draw priorities / checks
            DrawUtilities.DrawPriority(box, pawn.GetPriority(workgiver, VisibleHour), true);
        }
예제 #5
0
        public void Recache(WorkTypeDef worktype)
        {
            var workgivers = worktype.WorkGivers();
            var priorities = pawn.GetPriorities(worktype);

            // first make sure all workgivers are cached
            foreach (var workgiver in workgivers)
            {
                if (!_everScheduledWorkGiver.ContainsKey(workgiver))
                {
                    Recache(workgiver);
                }
            }

            // recache worktype stuff
            _everScheduledWorkType[worktype]    = workgivers.Any(wg => _everScheduledWorkGiver[wg]);
            _timeScheduledWorkType[worktype]    = workgivers.Any(wg => _timeScheduledWorkGiver[wg]);
            _timeScheduledWorkTypeTip[worktype] = DrawUtilities.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)));
        }
예제 #6
0
        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] = DrawUtilities.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)));
        }
        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(DrawUtilities.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);
        }