public static Toil GoToPlatform(TargetIndex bedIndex)
        {
            Toil gotoBed = new Toil();

            gotoBed.initAction = delegate
            {
                Pawn         actor = gotoBed.actor;
                Building_Bed bed   = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing;
                IntVec3      bedSleepingSlotPosFor = RestUtility.GetBedSleepingSlotPosFor(actor, bed);
                if (actor.Position == bedSleepingSlotPosFor)
                {
                    actor.jobs.curDriver.ReadyForNextToil();
                }
                else
                {
                    actor.pather.StartPath(bedSleepingSlotPosFor, PathEndMode.OnCell);
                }
            };
            gotoBed.tickAction = delegate
            {
                Pawn         actor         = gotoBed.actor;
                Building_Bed building_Bed  = (Building_Bed)actor.CurJob.GetTarget(bedIndex).Thing;
                Pawn         curOccupantAt = building_Bed.GetCurOccupantAt(actor.pather.Destination.Cell);
                if (curOccupantAt != null && curOccupantAt != actor)
                {
                    actor.pather.StartPath(RestUtility.GetBedSleepingSlotPosFor(actor, building_Bed), PathEndMode.OnCell);
                }
            };
            gotoBed.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            gotoBed.FailOnPlatformNoLongerUsable(bedIndex);
            //gotoBed.FailOnBedNoLongerUsable(bedIndex);
            return(gotoBed);
        }