示例#1
0
        //
        // Methods
        //
        public override float GetPriority(Pawn pawn)
        {
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            float result;

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
            {
                result = 5.5f;
            }
            else
            {
                if (timeAssignmentDef == TimeAssignmentDefOf.Work)
                {
                    result = 9;
                }
                else
                {
                    if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
                    {
                        result = 2;
                    }
                    else
                    {
                        if (timeAssignmentDef != TimeAssignmentDefOf.Joy)
                        {
                            throw new NotImplementedException();
                        }
                        result = 2;
                    }
                }
            }
            return(result);
        }
        private void DoTimeAssignment(Rect rect, int hour)
        {
            rect = rect.ContractedBy(1f);
            TimeAssignmentDef assignment = this.timetable.GetAssignment(hour);

            GUI.DrawTexture(rect, assignment.ColorTexture);
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 2);
                bool flag = false;
                if (Input.GetMouseButton(0))
                {
                    if (assignment != this.selectedAssignment)
                    {
                        this.timetable.SetAssignment(hour, this.selectedAssignment);
                    }
                    foreach (Pawn current in this.pawns)
                    {
                        if (current.timetable.GetAssignment(hour) != assignment)
                        {
                            current.timetable.SetAssignment(hour, this.selectedAssignment);
                            flag = true;
                        }
                    }
                }
                if (flag)
                {
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
                }
            }
        }
示例#3
0
        // Token: 0x06000039 RID: 57 RVA: 0x00003F04 File Offset: 0x00002104
        private static void DrawTimeAssignmentSelectorFor(Rect rect, TimeAssignmentDef ta)
        {
            rect = rect.ContractedBy(2f);
            GUI.DrawTexture(rect, ta.ColorTexture);
            if (Widgets.ButtonInvisible(rect))
            {
                TimeAssignmentSelector.selectedAssignment = ta;
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }

            GUI.color = Color.white;
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.color   = Color.white;
            Widgets.Label(rect, ta.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            if (TimeAssignmentSelector.selectedAssignment == ta)
            {
                Widgets.DrawBox(rect, 2);
            }
        }
示例#4
0
        /// <summary>
        /// Gets a priority value of how important it is for a pawn to do pickup/drop activities.
        /// </summary>
        /// <param name="pawn">Pawn to fetch priority for</param>
        /// <returns>float indicating priority of pickup/drop job</returns>
        public override float GetPriority(Pawn pawn)
        {
            if (pawn.HasExcessThing())
            {
                return(9.2f);
            }
            ItemPriority priority;
            Thing        unused;
            int          i;
            Pawn         carriedBy;
            LoadoutSlot  slot = GetPrioritySlot(pawn, out priority, out unused, out i, out carriedBy);

            if (slot == null)
            {
                return(0f);
            }
            if (priority == ItemPriority.Low)
            {
                return(3f);
            }

            TimeAssignmentDef assignment = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            if (assignment == TimeAssignmentDefOf.Sleep)
            {
                return(3f);
            }

            return(9.2f);
        }
示例#5
0
        private void DoTimeAssignment(Rect rect, int hour)
        {
            rect = rect.ContractedBy(1f);
            bool mouseButton             = Input.GetMouseButton(0);
            TimeAssignmentDef assignment = this.colonistGroup.pawns.First().timetable.GetAssignment(hour);

            GUI.DrawTexture(rect, assignment.ColorTexture);
            if (!mouseButton)
            {
                MouseoverSounds.DoRegion(rect);
            }
            if (!Mouse.IsOver(rect))
            {
                return;
            }

            if (mouseButton && assignment != TimeAssignmentSelector.selectedAssignment && TimeAssignmentSelector.selectedAssignment != null)
            {
                SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                foreach (var p in this.colonistGroup.pawns)
                {
                    p.timetable.SetAssignment(hour, TimeAssignmentSelector.selectedAssignment);
                }
            }
        }
        public override float GetPriority(Pawn pawn)
        {
            //if (pawn.workSettings == null || !pawn.workSettings.EverWork)
            //{
            //    return 0f;
            //}
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
            {
                return(5.5f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Work)
            {
                return(9f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
            {
                return(3f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
            {
                return(2f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Meditate)
            {
                return(2f);
            }
            throw new NotImplementedException();
        }
示例#7
0
        public override float GetPriority(Pawn pawn)
        {
            if (pawn == null || pawn.needs == null)
            {
                return(0f);
            }

            Need_Rest needRest = pawn.needs.rest;

            if (needRest == null)
            {
                return(0f);
            }

            float             curLevel          = needRest.CurLevel;
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything);

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything || timeAssignmentDef == TimeAssignmentDefOf.Work)
            {
                if ((pawn as X2_AIRobot) == null || (pawn as X2_AIRobot).rechargeStation == null || (pawn as X2_AIRobot).rechargeStation.Position == null)
                {
                    return(0f);
                }

                // Own implementation: When level < 45% && dist > 25
                bool isOutsideMaxDistance = !AIRobot_Helper.IsInDistance(pawn.Position, (pawn as X2_AIRobot).rechargeStation.Position, 25f);
                if (curLevel < 0.45f && pawn as X2_AIRobot != null && isOutsideMaxDistance)
                {
                    return(8f);
                }

                if (curLevel < 0.25f)
                {
                    return(8f);
                }

                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
            {
                if (curLevel < 0.3f)
                {
                    return(8f);
                }

                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
            {
                if (curLevel < 0.75f)
                {
                    return(8f);
                }

                return(0f);
            }
            return(0f);
        }
示例#8
0
 public override void TransformValue(StatRequest req, ref float val)
 {
     if (MeMiMoSettings.workAssignmentMatters && req.Thing is Pawn pawn && pawn.timetable is Pawn_TimetableTracker timetable)
     {
         TimeAssignmentDef currentAssignment = timetable.CurrentAssignment;
         val *= (currentAssignment.GetModExtension <TimeAssignmentExtension>() is TimeAssignmentExtension tAE) ?
                tAE.globalWorkSpeedFactor : TimeAssignmentExtension.defaultValues.globalWorkSpeedFactor;
     }
 }
示例#9
0
 public static void UpdateNightOwl(Pawn pawn)
 {
     pawn.timetable.times = new List <TimeAssignmentDef>(24);
     for (int i = 0; i < 24; i++)
     {
         TimeAssignmentDef item = (i >= 10 && i <= 17) ? TimeAssignmentDefOf.Sleep : TimeAssignmentDefOf.Anything;
         pawn.timetable.times.Add(item);
     }
 }
示例#10
0
        //
        // Methods
        //
        public override float GetPriority(Pawn pawn)
        {
            //Need_Rest rest = pawn.needs.rest;
            Need_Battery battery = pawn.needs.TryGetNeed <Need_Battery> ();

            float result;

            if (battery == null)
            {
                result = 0;
            }
            else
            {
                float             curLevel          = battery.CurLevel;
                TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

                if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
                {
                    if ((curLevel < 0.5 && pawn is ArcBaseRobot) &
                        !BaseRobot_Helper.IsInDistance(pawn.Position, (pawn as ArcBaseRobot).rechargeStation.Position, 50))
                    {
                        result = 8;
                    }
                    else
                    {
                        result = (curLevel < 0.3) ? 8 : 0;
                    }
                }
                else
                {
                    if (timeAssignmentDef == TimeAssignmentDefOf.Work)
                    {
                        result = 0;
                    }
                    else
                    {
                        if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
                        {
                            result = (curLevel < 0.3) ? 8 : 0;
                        }
                        else
                        {
                            if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
                            {
                                result = (curLevel < 0.75) ? 8 : 0;
                            }
                            else
                            {
                                result = 0;
                            }
                        }
                    }
                }
            }
            return(result);
        }
示例#11
0
        static bool Prefix(Pawn pawn, JoyTickFullJoyAction fullJoyAction = JoyTickFullJoyAction.EndJob, float extraJoyGainFactor = 1f, Building joySource = null)
        {
            Job curJob = pawn.CurJob;

            if (curJob.def.joyKind == null)
            {
                Log.Warning("This method can only be called for jobs with joyKind.", false);
                return(false);;
            }
            if (joySource != null)
            {
                if (joySource.def.building.joyKind != null && pawn.CurJob.def.joyKind != joySource.def.building.joyKind)
                {
                    Log.ErrorOnce("Joy source joyKind and jobDef.joyKind are not the same. building=" + joySource.ToStringSafe <Building>() + ", jobDef=" + pawn.CurJob.def.ToStringSafe <JobDef>(), joySource.thingIDNumber ^ 876598732, false);
                }
                extraJoyGainFactor *= joySource.GetStatValue(StatDefOf.JoyGainFactor, true);
            }
            if (pawn.needs.joy == null)
            {
                pawn.jobs.curDriver.EndJobWith(JobCondition.InterruptForced);
                return(false);
            }

            TimeAssignmentDef timeAssignmentDef = (pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment;

            if (timeAssignmentDef != TimeAssignmentDefDinner.DinnerDef)
            {
                return(true);
            }

            pawn.needs.joy.GainJoy(extraJoyGainFactor * curJob.def.joyGainRate * 0.36f / 2500f, curJob.def.joyKind);
            if (curJob.def.joySkill != null)
            {
                pawn.skills.GetSkill(curJob.def.joySkill).Learn(curJob.def.joyXpPerTick, false);
            }
            if (pawn.needs.food.CurLevelPercentage < pawn.RaceProps.FoodLevelPercentageWantEat + ModSetting.eatThreshold && pawn.IsHashIntervalTick(60))//dinner饱腹值以下时结束娱乐
            {
                bool     desperate = pawn.needs.food.CurCategory == HungerCategory.Starving;
                Thing    thing;
                ThingDef thingDef;
                if (FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, desperate, out thing, out thingDef, true, true, false, true, false, pawn.IsWildMan(), false, false, FoodPreferability.Undefined))
                {
                    //Log.Message("joytickcheckend find {0}".Translate(thing.GetUniqueLoadID()));
                    if (fullJoyAction == JoyTickFullJoyAction.EndJob)
                    {
                        pawn.jobs.curDriver.EndJobWith(JobCondition.Succeeded);
                        return(false);
                    }
                    if (fullJoyAction == JoyTickFullJoyAction.GoToNextToil)
                    {
                        pawn.jobs.curDriver.ReadyForNextToil();
                    }
                }
            }
            return(false);
        }
示例#12
0
 public override string ExplanationPart(StatRequest req)
 {
     if (MeMiMoSettings.workAssignmentMatters && req.Thing is Pawn pawn && pawn.timetable is Pawn_TimetableTracker timetable)
     {
         TimeAssignmentDef currentAssignment = timetable.CurrentAssignment;
         float             workSpeedFactor   = (currentAssignment.GetModExtension <TimeAssignmentExtension>() is TimeAssignmentExtension tAE) ?
                                               tAE.globalWorkSpeedFactor : TimeAssignmentExtension.defaultValues.globalWorkSpeedFactor;
         return("M4_StatPart_TimeTable_ExplanationString".Translate(currentAssignment.label) + ": x" + workSpeedFactor.ToStringPercent());
     }
     return(null);
 }
示例#13
0
 public static bool Prefix(Pawn ___pawn, int hour, TimeAssignmentDef ta)
 {
     if (use_native)
     {
         return(true);
     }
     else
     {
         set_assignment(___pawn, hour, ta);
         return(false);
     }
 }
示例#14
0
 public static void set_assignment(Pawn p, int hour, TimeAssignmentDef ta)
 {
     use_native = true;
     try
     {
         p.timetable.SetAssignment(hour, ta);
     }
     finally
     {
         use_native = false;
     }
 }
示例#15
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!CultKnowledge.isExposed)
            {
                return(null);
            }
            if (CultKnowledge.selectedDeity == null)
            {
                return(null);
            }

            /*
             *  Get [CurrentAssignment] indirectly, because [pawn.timetable.CurrentAssignment] getter has harmony patch.
             *  Patch overrides result from [Cults_TimeAssignment_Worship] to [TimeAssignmentDefOf.Anything]
             *  Vanilla functions can't check custom timetable defs otherwise they throw [NotImplementedException]
             *  [JobGiver_Worship] happens before core colonist behavior
             *
             *  Classes that check a schedule:
             *      ThinkNode_Priority_GetJoy
             *      JobGiver_GetRest
             *      JobGiver_Work
             */
            // TimeAssignmentDef assignment = pawn.timetable.CurrentAssignment;
            TimeAssignmentDef assignment = pawn.timetable.times[GenLocalDate.HourOfDay(pawn)];

            // TODO: implement reservations

            IEnumerable <Building_BaseAltar> altars = pawn.Map.listerBuildings.AllBuildingsColonistOfClass <Building_BaseAltar>();
            TraverseParms parms = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false);
            Thing         altar = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, altars, PathEndMode.OnCell, parms);

            if (altar != null)
            {
                if (!WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, true, out IntVec3 spot, out Building chair))
                {
                    if (!WatchBuildingUtility.TryFindBestWatchCell(altar, pawn, false, out spot, out chair))
                    {
                        return(null);
                    }
                }
                ;

                Job job = JobMaker.MakeJob(CultsDefOf.Cults_Job_Worship, spot, altar);
                //if(pawn.CurJob != null)Log.Message("info " + pawn.HasReserved(pawn.CurJob.targetA).ToString() + " " + pawn.CurJobDef.defName.ToString());
                //if(pawn.CanReserve(spot, 1, -1)) pawn.Reserve(spot, job, 1, -1);
                if (assignment == Cults.CultsDefOf.Cults_TimeAssignment_Worship)
                {
                    return(job);
                }
            }
            ;
            return(null);
        }
        public override float GetPriority(Pawn pawn)
        {
            if ((!Controller.settings.AutoTakeAmmo && pawn.IsColonist) || !Controller.settings.EnableAmmoSystem)
            {
                return(0f);
            }

            if (pawn.Faction == null)
            {
                return(0f);
            }

            var priority = GetPriorityWork(pawn);

            if (priority == WorkPriority.Unloading)
            {
                return(9.2f);
            }
            else if (priority == WorkPriority.LowAmmo)
            {
                return(9f);
            }
            else if (priority == WorkPriority.Weapon)
            {
                return(8f);
            }
            else if (priority == WorkPriority.Ammo)
            {
                return(6f);
            }
            //else if (priority == WorkPriority.Apparel) return 5f;
            else if (priority == WorkPriority.None)
            {
                return(0f);
            }

            TimeAssignmentDef assignment = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            if (assignment == TimeAssignmentDefOf.Sleep)
            {
                return(0f);
            }

            if (pawn.health == null || pawn.Downed || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(0f);
            }
            else
            {
                return(0f);
            }
        }
示例#17
0
        static bool Prefix(ref ThoughtState __result, Pawn p)
        {
            if (p.needs.food == null)
            {
                __result = ThoughtState.Inactive;
                return(false);
            }
            if (p.RaceProps.Humanlike && p.timetable != null)
            {
                TimeAssignmentDef timeAssignmentDef = p.timetable.CurrentAssignment;
                if (timeAssignmentDef != TimeAssignmentDefDinner.DinnerDef)
                {
                    Need_Food food = p.needs.food;
                    if (p.timetable.GetAssignment((GenLocalDate.HourOfDay(p) + 1) % 24) == TimeAssignmentDefDinner.DinnerDef &&
                        food.CurLevelPercentage > p.RaceProps.FoodLevelPercentageWantEat * 0.45f && food.CurCategory >= HungerCategory.Hungry)
                    {//下一小时是dinner时间并且饥饿度百分比>0.45并且处于饥饿及以上类型状态
                        __result = ThoughtState.ActiveAtStage(7);
                        return(false);
                    }
                }
            }
            switch (p.needs.food.CurCategory)
            {
            case HungerCategory.Fed:
                __result = ThoughtState.Inactive;
                return(false);

            case HungerCategory.Hungry:
                __result = ThoughtState.ActiveAtStage(0);
                return(false);

            case HungerCategory.UrgentlyHungry:
                __result = ThoughtState.ActiveAtStage(1);
                return(false);

            case HungerCategory.Starving:
            {
                Hediff firstHediffOfDef = p.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Malnutrition, false);
                int    num = (firstHediffOfDef == null) ? 0 : firstHediffOfDef.CurStageIndex;
                if (num > 4)
                {
                    num = 4;
                }
                __result = ThoughtState.ActiveAtStage(2 + num);
                return(false);
            }

            default:
                throw new NotImplementedException();
            }
        }
示例#18
0
 private static void AutoNightOwl(Pawn pawn)
 {
     if (pawn?.story?.traits?.HasTrait(TraitDefOf.NightOwl) == true &&
         pawn.timetable != null &&
         !WorldComp.PawnsWithNightOwl.Contains(pawn))
     {
         pawn.timetable.times = new List <TimeAssignmentDef>(GenDate.HoursPerDay);
         for (int i = 0; i < GenDate.HoursPerDay; i++)
         {
             TimeAssignmentDef setNightOwlHours = i >= 11 && i <= 18 ? TimeAssignmentDefOf.Sleep : TimeAssignmentDefOf.Anything;
             pawn.timetable.times.Add(setNightOwlHours);
         }
         WorldComp.PawnsWithNightOwl.Add(pawn);
     }
 }
 private static void WriteItemToConsole(TimeAssignmentDef item)
 {
     CONS.WriteLine($"  {nameof(TimeAssignmentDef)}");
     CONS.WriteLine($"    defName: {item.DefName.ToStringOrDefault()}");
     CONS.WriteLine($"    label: {item.Label.ToStringOrDefault()}");
     CONS.WriteLine($"    color: {item.Color.ToStringOrDefault()}");
     if (item.AllowRest.HasValue)
     {
         CONS.WriteLine($"    allowRest: {item.AllowRest.Value}");
     }
     if (item.AllowJoy.HasValue)
     {
         CONS.WriteLine($"    allowJoy: {item.AllowJoy.Value}");
     }
 }
        private void DoTimeAssignment(Rect rect, Pawn p, int hour)
        {
            rect = rect.ContractedBy(1f);
            TimeAssignmentDef assignment = p.timetable.GetAssignment(hour);

            GUI.DrawTexture(rect, assignment.ColorTexture);
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 2);
                if (assignment != this.selectedAssignment && Input.GetMouseButton(0))
                {
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
                    p.timetable.SetAssignment(hour, this.selectedAssignment);
                }
            }
        }
        private static bool Prefix(ref WidgetRow row, ref Pawn pawn)
        {
            // override [InspectPanelFiller] UI current (schedule) assignment draw function
            TimeAssignmentDef realDef = pawn.timetable.times[GenLocalDate.HourOfDay(pawn)];

            if (realDef == CultsDefOf.Cults_TimeAssignment_Worship)
            {
                row.Gap(6f);
                row.FillableBar(93f, 16f, 1f, realDef.LabelCap, realDef.ColorTexture);
                return(false); // skip original method
            }
            else
            {
                return(true); // normal behavior
            }
        }
示例#22
0
        public override float GetPriority(Pawn pawn)
        {
            Need_Pray prayNeed = pawn.GetReligionComponent().PrayTracker.PrayNeed;

            if (prayNeed != null)
            {
                float             curLevel          = prayNeed.CurLevel;
                TimeAssignmentDef timeAssignmentDef = pawn.timetable != null ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;
                if (timeAssignmentDef.allowJoy && curLevel <= 0.05f)
                {
                    return(1f);
                }
            }
            return(0.0f);
            //return pawn.GetReligionComponent().PietyTracker.PietyNeed.CurCategoryIntWithoutZero * 19f;
        }
示例#23
0
 public static void InsomniacPriority(ref float __result, Pawn pawn)
 {
     if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.Insomniac))
     {
         TimeAssignmentDef timeAssignmentDef = ((pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything);
         float             curLevel          = pawn.needs.rest.CurLevel;
         if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
         {
             if (curLevel < 0.1f)
             {
                 __result = 1f;
                 return;
             }
             __result = 0f;
             return;
         }
         else if (timeAssignmentDef == TimeAssignmentDefOf.Work)
         {
             __result = 0f;
             return;
         }
         else if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
         {
             if (curLevel < 0.1f)
             {
                 __result = 3f;
                 return;
             }
             __result = 0f;
             return;
         }
         else if (timeAssignmentDef == TimeAssignmentDefOf.Sleep)
         {
             if (curLevel < RestUtility.FallAsleepMaxLevel(pawn) / 2f)
             {
                 __result = 3f;
                 return;
             }
             __result = 0f;
             return;
         }
         else
         {
             throw new NotImplementedException();
         }
     }
 }
示例#24
0
        public override float GetPriority(Pawn pawn)
        {
            var priority = GetPriorityWork(pawn);

            if (priority == WorkPriority.Unloading)
            {
                return(9.2f);
            }
            else if (priority == WorkPriority.LowAmmo)
            {
                return(9f);
            }
            else if (priority == WorkPriority.Weapon)
            {
                return(8f);
            }
            else if (priority == WorkPriority.Ammo)
            {
                return(6f);
            }
            else if (priority == WorkPriority.Apparel)
            {
                return(5f);
            }
            else if (priority == WorkPriority.None)
            {
                return(0f);
            }

            TimeAssignmentDef assignment = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            if (assignment == TimeAssignmentDefOf.Sleep)
            {
                return(0f);
            }

            if (pawn.health == null || pawn.Downed || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                return(0f);
            }
            else
            {
                return(0f);
            }
        }
        // Token: 0x06000002 RID: 2 RVA: 0x0000207C File Offset: 0x0000027C
        public override float GetPriority(Pawn pawn)
        {
            bool  flag = pawn.workSettings == null || !pawn.workSettings.EverWork;
            float result;

            if (flag)
            {
                result = 9f;
            }
            else
            {
                TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;
                bool flag2 = timeAssignmentDef == TimeAssignmentDefOf.Anything;
                if (flag2)
                {
                    result = 5.5f;
                }
                else
                {
                    bool flag3 = timeAssignmentDef == TimeAssignmentDefOf.Work;
                    if (flag3)
                    {
                        result = 9f;
                    }
                    else
                    {
                        bool flag4 = timeAssignmentDef == TimeAssignmentDefOf.Sleep;
                        if (flag4)
                        {
                            result = 3f;
                        }
                        else
                        {
                            bool flag5 = timeAssignmentDef == TimeAssignmentDefOf.Joy;
                            if (!flag5)
                            {
                                throw new NotImplementedException();
                            }
                            result = 2f;
                        }
                    }
                }
            }
            return(result);
        }
示例#26
0
        static bool Prefix(ref float __result, Pawn pawn)
        {
            if (pawn.workSettings == null || !pawn.workSettings.EverWork)
            {
                __result = 0f;
                return(false);
            }
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment;

            if (timeAssignmentDef != TimeAssignmentDefDinner.DinnerDef)
            {
                return(true);
            }

            __result = 2f;
            //Log.Message("{0} work priority = {1}".Translate(pawn.Label, __result));
            return(false);
        }
示例#27
0
        public override float GetPriority(Pawn pawn)
        {
            Need_Rest needRest = pawn.needs.rest;

            if (needRest == null)
            {
                return(0f);
            }
            float             curLevel          = needRest.CurLevel;
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable != null ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything);

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
            {
                if (curLevel < 0.3f)
                {
                    return(8f);
                }
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Work)
            {
                return(0f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
            {
                if (curLevel < 0.3f)
                {
                    return(8f);
                }
                return(0f);
            }
            if (timeAssignmentDef != TimeAssignmentDefOf.Sleep)
            {
                throw new NotImplementedException();
            }
            if (curLevel < 0.75f)
            {
                return(8f);
            }
            return(0f);
        }
        public override float GetPriority(Pawn pawn)
        {
            //if (pawn.GetLord() != null)
            //    return 0f;

            if (pawn.workSettings == null || !pawn.workSettings.EverWork)
            {
                return(0f);
            }
            TimeAssignmentDef timeAssignmentDef = (pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment;

            if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
            {
                return(5.5f);
            }
            if (timeAssignmentDef == TimeAssignmentDefOf.Work)
            {
                return(9f);
            }

            return(0f);
        }
        public MainTabWindow_Slaves()
        {
            this.workColumnSpacing = -1f;
            this.selectedAssignment = TimeAssignmentDefOf.Work;

            var originalFont = Text.Font;
            Text.Font = GameFont.Tiny;

            labelGetsFood = Data.Strings.GetsFood.Translate();
            widthGetsFood = Text.CalcSize( labelGetsFood ).x;

            labelRestrainCuff = Data.Strings.RestrainCuff.Translate();
            widthRestrainCuff = Text.CalcSize( labelRestrainCuff ).x;

            labelRestrainShackle = Data.Strings.RestrainShackle.Translate();
            widthRestrainShackle = Text.CalcSize( labelRestrainShackle ).x;

            labelMedicalCare = Data.Strings.MedicalCare.Translate();
            widthMedicalCare = Text.CalcSize( labelMedicalCare ).x;

            Text.Font = originalFont;
        }
示例#30
0
        /// <summary>
        /// Gets a priority value of how important it is for a pawn to do pickup/drop activities.
        /// </summary>
        /// <param name="pawn">Pawn to fetch priority for</param>
        /// <returns>float indicating priority of pickup/drop job</returns>
        public override float GetPriority(Pawn pawn)
        {
            CompInventory comp = pawn.TryGetComp <CompInventory>();

            if (comp == null)
            {
                return(0f);
            }
            else if (comp.ForcedLoadoutUpdate)
            {
                return(35f);
            }
            else if (comp.SkipUpdateLoadout)
            {
                return(0f);
            }
            if (pawn.HasExcessThing())
            {
                return(9.2f);
            }
            LoadoutSlot slot = GetPrioritySlot(pawn, out ItemPriority priority, out _, out _, out _);

            if (slot == null)
            {
                return(0f);
            }
            if (priority == ItemPriority.Low)
            {
                return(1f);
            }
            TimeAssignmentDef assignment = (pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything;

            if (assignment == TimeAssignmentDefOf.Sleep)
            {
                return(1f);
            }
            return(2.8f);
        }
示例#31
0
        private void DoTimeAssignmentEdited(Rect rect, Pawn p, int hour)
        {
            rect = rect.ContractedBy(1f);
            TimeAssignmentDef assignment = p.timetable.GetAssignment(hour);

            GUI.DrawTexture(rect, assignment.ColorTexture);
            if (Mouse.IsOver(rect))
            {
                Widgets.DrawBox(rect, 2);
                if (assignment != TimeAssignmentDefOf.Work && Input.GetMouseButton(0))
                {
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera(null);
                    p.timetable.SetAssignment(hour, TimeAssignmentDefOf.Work);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeAssignments, KnowledgeAmount.SmallInteraction);
                }
                if (assignment != TimeAssignmentDefOf.Sleep && Input.GetMouseButton(1))
                {
                    SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera(null);
                    p.timetable.SetAssignment(hour, TimeAssignmentDefOf.Sleep);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeAssignments, KnowledgeAmount.SmallInteraction);
                }
            }
        }
        private void DrawTimeAssignmentSelectorFor( Rect rect, TimeAssignmentDef ta )
        {
            rect = rect.ContractedBy( 2f );

            GUI.DrawTexture( rect, (Texture) ta.ColorTexture );
            if( Widgets.ButtonInvisible( rect ) )
            {
                this.selectedAssignment = ta;
                SoundStarter.PlayOneShotOnCamera( SoundDefOf.TickHigh );
            }

            GUI.color = Color.white;
            if( Mouse.IsOver( rect ) )
            {
                Widgets.DrawHighlight( rect );
            }

            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.color = Color.white;
            Widgets.Label( rect, ta.LabelCap );

            Text.Anchor = TextAnchor.UpperLeft;

            if( this.selectedAssignment != ta )
            {
                return;
            }
            Widgets.DrawBox( rect, 2 );
        }