Any way to get at the worker pawn on a worktablen

Started by skullywag, May 15, 2015, 07:44:03 AM

Previous topic - Next topic

skullywag

Trying to do stuff to the pawn currently working on a worktable in its tick method but having problem referencing them, I dont want to to just check the interaction square as I forsee problems with doing it that way, anyone know of a way to get it in anyway, through the billstack or something?
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

I do check via job driver with my clutter cloth locker, so i dont need to check interaction square all the time.
Maybe it will help

Jobdriver
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse;
using Verse.Sound;
using RimWorld;
using Verse.AI;

namespace ClutterModule
{
    public class JobDriver_LockerBasic : JobDriver
    {

        private const TargetIndex Locker = TargetIndex.A;
        private const TargetIndex CellInd = TargetIndex.B;
        private const TargetIndex WaitDuration = TargetIndex.C;

       
        protected override IEnumerable<Toil> MakeNewToils()
        {

            ToilFailConditions.FailOnDestroyed<JobDriver_LockerBasic>(this, TargetIndex.A);
            ToilFailConditions.FailOnDespawnedOrForbidden<JobDriver_LockerBasic>(this, TargetIndex.A);


            yield return Toils_Reserve.Reserve(TargetIndex.A, 1);
            yield return Toils_Goto.GotoCell(TargetIndex.B, PathMode.OnCell);
            yield return Toils_WaitWithSoundAndEffect(TimeCouter(), "Recipe_Tailor", "ConstructMetal", TargetIndex.B);
           
            yield break;
        }

        private Toil Toils_WaitWithSoundAndEffect(int duration, string soundDefName, string effecterDefName, TargetIndex targetIndex)
        {
            Toil toil = new Toil();
           
            toil.initAction = delegate
            {
                toil.actor.pather.StopDead();
                ClothLocker locker = this.TargetA.Thing as ClothLocker;
                locker.Interaction = true;
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration = duration;
            ToilEffects.WithSustainer(toil, () => SoundDef.Named(soundDefName));
            return toil;
        }
        private int TimeCouter()
        {
            int WornMulti = pawn.apparel.WornApparel.Count;
            if(WornMulti>0)
            {
                return (WornMulti*30);
            }
            else
            {
                return 200;
            }
        }

       }
}

All i do is clutter all around.

skullywag

Hmm problem is its the normal dobill so cant really mess with it. I have to get at the pawn from the worktable itself.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

1000101

I was looking at this myself a few weeks ago and couldn't find anything on the table itself nor attached bills to help so, I ended up doing exactly what you don't want to do - check the interaction cell for a pawn and then see if that pawn has a job and if it does, is it at the table we want.

If you can make your checks fast enough and short-circuit your code, the impact of checking the interaction cell isn't too bad.  The ThingComp CompPowerLowIdleDraw in CommunityCoreLibrary tries to be fairly efficient in it's scanning method.  For worktables, I set the ticker to rare as a pawn will always be at a table for more than a single rare tick to complete a bill (unless the player is micro-managing.)  So I can do the check reasonably fast and minimize how often I am doing it.
(2*b)||!(2*b) - That is the question.
There are 10 kinds of people in this world - those that understand binary and those that don't.

Powered By

soltysek

ther is a way easy way if you can inject method :P 1000101 i thing we need to find a way to do it :P