コード例 #1
0
 //Stop a hauling job if haulability gets toggled off
 static void Postfix(JobDriver __instance)
 {
     if (__instance is JobDriver_HaulToCell)
     {
         List <Toil> toils =
             (List <Toil>) typeof(JobDriver).InvokeMember("toils",
                                                          BindingFlags.GetField | BindingFlags.Instance | BindingFlags.NonPublic,
                                                          null, __instance, null);
         Toil toilGoto = toils[1];
         if (toilGoto.defaultCompleteMode != ToilCompleteMode.PatherArrival)
         {
             Log.Error("Trying to add fail condition on JobDriver_HaulToCell but "
                       + toilGoto.ToString()
                       + " doesn't appear to be a Goto Toil");
             return;
         }
         toilGoto.AddFailCondition(delegate
         {
             Thing t = __instance.job.targetA.Thing;
             return(!__instance.job.ignoreDesignations && !t.IsAHaulableSetToHaulable());
         });
     }
 }
コード例 #2
0
        private GizmoResult GizmoOnGUI_old(Vector2 topLeft, float maxWidth)
        {
            var gizmoRect   = new Rect(topLeft.x, topLeft.y, GetWidth(maxWidth), 75f);
            var contentRect = gizmoRect.ContractedBy(ContentPadding);

            Widgets.DrawWindowBackground(gizmoRect);

            string curJob = parent.CurJobDef == null ? "null" : parent.CurJobDef.defName;

            if (!curJobs.ContainsKey(parent))
            {
                curJobs[parent]  = curJob;
                lastJobs[parent] = "none yet";
            }
            else if (curJobs[parent] != curJob)
            {
                lastJobs[parent] = curJobs[parent];
                curJobs[parent]  = curJob;
            }
            string curJobDriverStr    = parent.jobs.curDriver == null ? "null" : parent.jobs.curDriver.ToString();
            string toilStr            = "null";
            string toilActiveSkillStr = "null";

            if (parent?.jobs?.curDriver != null)
            {
                Toil toil = Traverse.Create(parent.jobs.curDriver).Property("CurToil").GetValue() as Toil;
                if (toil != null)
                {
                    toilStr = toil.ToString();
                    if (toil.activeSkill != null)
                    {
                        toilActiveSkillStr = toil.activeSkill().ToString();
                    }
                }
            }


            if (Widgets.ButtonText(contentRect.RightPartPixels(15), "<>"))
            {
                var tickManager = Find.TickManager;
                if (!tickManager.Paused)
                {
                    tickManager.TogglePaused();
                }

                tickManager.DoSingleTick();
            }

            var font = Text.Font;

            Text.Font = GameFont.Tiny;

            float offset = 0;

            printBool("Idle:", parent.mindState.IsIdle, contentRect, 0);                        offset += 10f;
            printStringPair("Job:", curJobs[parent], Color.white, contentRect, offset);         offset += 10f;
            printStringPair("Last job:", lastJobs[parent], Color.white, contentRect, offset);   offset += 10f;
            printStringPair("JobDriver:", curJobDriverStr, Color.white, contentRect, offset);   offset += 10f;
            printStringPair("Toil:", toilStr, Color.white, contentRect, offset);                offset += 10f;
            printStringPair("T. actSk:", toilActiveSkillStr, Color.white, contentRect, offset); offset += 10f;

            Text.Font = font;

            return(new GizmoResult(GizmoState.Clear));
        }