Exemplo n.º 1
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            JobQueue jobQueue = pawn.jobs.jobQueue;
            bool     flag     = pawn.Downed || jobQueue.AnyCanBeginNow(pawn, this.inBedOnly);

            if (flag)
            {
                while (jobQueue.Count > 0 && !jobQueue.Peek().job.CanBeginNow(pawn, this.inBedOnly))
                {
                    QueuedJob queuedJob = jobQueue.Dequeue();
                    pawn.ClearReservationsForJob(queuedJob.job);
                    if (pawn.jobs.debugLog)
                    {
                        pawn.jobs.DebugLogEvent("   Throwing away queued job that I cannot begin now: " + queuedJob.job);
                    }
                }
            }
            ThinkResult result;

            if (jobQueue.Count > 0 && jobQueue.Peek().job.CanBeginNow(pawn, this.inBedOnly))
            {
                QueuedJob queuedJob2 = jobQueue.Dequeue();
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent("   Returning queued job: " + queuedJob2.job);
                }
                result = new ThinkResult(queuedJob2.job, this, queuedJob2.tag, true);
            }
            else
            {
                result = ThinkResult.NoJob;
            }
            return(result);
        }
Exemplo n.º 2
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            int count = this.subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                ThinkResult result = ThinkResult.NoJob;
                try
                {
                    result = this.subNodes[i].TryIssueJobPackage(pawn, jobParams);
                }
                catch (Exception ex)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Exception in ",
                        base.GetType(),
                        " TryIssueJobPackage: ",
                        ex.ToString()
                    }), false);
                }
                if (result.IsValid)
                {
                    return(result);
                }
            }
            return(ThinkResult.NoJob);
        }
Exemplo n.º 3
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            if (Find.TickManager.TicksGame < this.GetLastTryTick(pawn) + 2500)
            {
                return(ThinkResult.NoJob);
            }
            this.SetLastTryTick(pawn, Find.TickManager.TicksGame);
            float num = this.MtbHours(pawn);

            if (num <= 0f)
            {
                return(ThinkResult.NoJob);
            }
            Rand.PushState();
            int salt = Gen.HashCombineInt(base.UniqueSaveKey, 26504059);

            Rand.Seed = pawn.RandSeedForHour(salt);
            bool flag = Rand.MTBEventOccurs(num, 2500f, 2500f);

            Rand.PopState();
            if (flag)
            {
                return(base.TryIssueJobPackage(pawn, jobParams));
            }
            return(ThinkResult.NoJob);
        }
 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
 {
     if (this.matchedTrees == null)
     {
         this.matchedTrees = new List <ThinkTreeDef>();
         foreach (ThinkTreeDef thinkTreeDef in DefDatabase <ThinkTreeDef> .AllDefs)
         {
             if (thinkTreeDef.insertTag == this.insertTag)
             {
                 this.matchedTrees.Add(thinkTreeDef);
             }
         }
         this.matchedTrees = (from tDef in this.matchedTrees
                              orderby tDef.insertPriority descending
                              select tDef).ToList <ThinkTreeDef>();
     }
     for (int i = 0; i < this.matchedTrees.Count; i++)
     {
         ThinkResult result = this.matchedTrees[i].thinkRoot.TryIssueJobPackage(pawn, jobParams);
         if (result.IsValid)
         {
             return(result);
         }
     }
     return(ThinkResult.NoJob);
 }
Exemplo n.º 5
0
 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
 {
     if (this.Satisfied(pawn) == !this.invert)
     {
         return(base.TryIssueJobPackage(pawn, jobParams));
     }
     return(ThinkResult.NoJob);
 }
Exemplo n.º 6
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Job job = this.TryGiveJob(pawn);

            if (job == null)
            {
                return(ThinkResult.NoJob);
            }
            return(new ThinkResult(job, this, null, false));
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkResult result = base.TryIssueJobPackage(pawn, jobParams);

            if (result.IsValid && result.Tag == null)
            {
                result = new ThinkResult(result.Job, result.SourceNode, new JobTag?(this.tagToGive), false);
            }
            return(result);
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkNode_PrioritySorter.workingNodes.Clear();
            int count = base.subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                ThinkNode_PrioritySorter.workingNodes.Insert(Rand.Range(0, ThinkNode_PrioritySorter.workingNodes.Count - 1), base.subNodes[i]);
            }
            while (ThinkNode_PrioritySorter.workingNodes.Count > 0)
            {
                float num  = 0f;
                int   num2 = -1;
                for (int j = 0; j < ThinkNode_PrioritySorter.workingNodes.Count; j++)
                {
                    float num3 = 0f;
                    try
                    {
                        num3 = ThinkNode_PrioritySorter.workingNodes[j].GetPriority(pawn);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Exception in " + base.GetType() + " GetPriority: " + ex.ToString());
                    }
                    if (!(num3 <= 0.0) && !(num3 < this.minPriority) && num3 > num)
                    {
                        num  = num3;
                        num2 = j;
                    }
                }
                if (num2 != -1)
                {
                    ThinkResult result = ThinkResult.NoJob;
                    try
                    {
                        result = ThinkNode_PrioritySorter.workingNodes[num2].TryIssueJobPackage(pawn, jobParams);
                    }
                    catch (Exception ex2)
                    {
                        Log.Error("Exception in " + base.GetType() + " TryIssueJobPackage: " + ex2.ToString());
                    }
                    if (result.IsValid)
                    {
                        return(result);
                    }
                    ThinkNode_PrioritySorter.workingNodes.RemoveAt(num2);
                    continue;
                }
                break;
            }
            return(ThinkResult.NoJob);
        }
Exemplo n.º 9
0
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            workingNodes.Clear();
            int count = subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                workingNodes.Insert(Rand.Range(0, workingNodes.Count - 1), subNodes[i]);
            }
            while (workingNodes.Count > 0)
            {
                float num  = 0f;
                int   num2 = -1;
                for (int j = 0; j < workingNodes.Count; j++)
                {
                    float num3 = 0f;
                    try
                    {
                        num3 = workingNodes[j].GetPriority(pawn);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Concat("Exception in ", GetType(), " GetPriority: ", ex.ToString()));
                    }
                    if (!(num3 <= 0f) && !(num3 < minPriority) && num3 > num)
                    {
                        num  = num3;
                        num2 = j;
                    }
                }
                if (num2 == -1)
                {
                    break;
                }
                ThinkResult result = ThinkResult.NoJob;
                try
                {
                    result = workingNodes[num2].TryIssueJobPackage(pawn, jobParams);
                }
                catch (Exception ex2)
                {
                    Log.Error(string.Concat("Exception in ", GetType(), " TryIssueJobPackage: ", ex2.ToString()));
                }
                if (result.IsValid)
                {
                    return(result);
                }
                workingNodes.RemoveAt(num2);
            }
            return(ThinkResult.NoJob);
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkResult result;

            if (this.Satisfied(pawn) == !this.invert)
            {
                result = base.TryIssueJobPackage(pawn, jobParams);
            }
            else
            {
                result = ThinkResult.NoJob;
            }
            return(result);
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            Job         job = this.TryGiveJob(pawn);
            ThinkResult result;

            if (job == null)
            {
                result = ThinkResult.NoJob;
            }
            else
            {
                result = new ThinkResult(job, this, null, false);
            }
            return(result);
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            int count = this.subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                if (this.subNodes[i].GetPriority(pawn) > this.minPriority)
                {
                    ThinkResult result = this.subNodes[i].TryIssueJobPackage(pawn, jobParams);
                    if (result.IsValid)
                    {
                        return(result);
                    }
                }
            }
            return(ThinkResult.NoJob);
        }
Exemplo n.º 13
0
 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
 {
     ThinkNode_Random.tempList.Clear();
     for (int i = 0; i < base.subNodes.Count; i++)
     {
         ThinkNode_Random.tempList.Add(base.subNodes[i]);
     }
     ThinkNode_Random.tempList.Shuffle();
     for (int j = 0; j < ThinkNode_Random.tempList.Count; j++)
     {
         ThinkResult result = ThinkNode_Random.tempList[j].TryIssueJobPackage(pawn, jobParams);
         if (result.IsValid)
         {
             return(result);
         }
     }
     return(ThinkResult.NoJob);
 }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            int count = base.subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                ThinkResult result = ThinkResult.NoJob;
                try
                {
                    result = base.subNodes[i].TryIssueJobPackage(pawn, jobParams);
                }
                catch (Exception ex)
                {
                    Log.Error("Exception in " + base.GetType() + " TryIssueJobPackage: " + ex.ToString());
                }
                if (result.IsValid)
                {
                    return(result);
                }
            }
            return(ThinkResult.NoJob);
        }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkResult result;

            try
            {
                if (this.maxDistToSquadFlag > 0f)
                {
                    if (pawn.mindState.maxDistToSquadFlag > 0f)
                    {
                        Log.Error("Squad flag was not reset properly; raiders may behave strangely");
                    }
                    pawn.mindState.maxDistToSquadFlag = this.maxDistToSquadFlag;
                }
                result = base.TryIssueJobPackage(pawn, jobParams);
            }
            finally
            {
                pawn.mindState.maxDistToSquadFlag = -1f;
            }
            return(result);
        }
Exemplo n.º 16
0
        // Token: 0x06000025 RID: 37 RVA: 0x000036D4 File Offset: 0x000018D4
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            bool        flag = Find.TickManager.TicksGame < this.GetLastTryTick(pawn) + 10;
            ThinkResult result;

            if (flag)
            {
                result = ThinkResult.NoJob;
            }
            else
            {
                this.SetLastTryTick(pawn, Find.TickManager.TicksGame);
                float num   = this.MtbHours(pawn);
                bool  flag2 = num <= 0f;
                if (flag2)
                {
                    result = ThinkResult.NoJob;
                }
                else
                {
                    Rand.PushState();
                    int salt = Gen.HashCombineInt(base.UniqueSaveKey, 26504059);
                    Rand.Seed = pawn.RandSeedForHour(salt);
                    bool flag3 = Rand.MTBEventOccurs(num, 250f, 250f);
                    Rand.PopState();
                    bool flag4 = flag3;
                    if (flag4)
                    {
                        result = base.TryIssueJobPackage(pawn, jobParams);
                    }
                    else
                    {
                        result = ThinkResult.NoJob;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 17
0
 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
 {
     if (matchedTrees == null)
     {
         matchedTrees = new List <ThinkTreeDef>();
         foreach (ThinkTreeDef allDef in DefDatabase <ThinkTreeDef> .AllDefs)
         {
             if (allDef.insertTag == insertTag)
             {
                 matchedTrees.Add(allDef);
             }
         }
         matchedTrees = matchedTrees.OrderByDescending((ThinkTreeDef tDef) => tDef.insertPriority).ToList();
     }
     for (int i = 0; i < matchedTrees.Count; i++)
     {
         ThinkResult result = matchedTrees[i].thinkRoot.TryIssueJobPackage(pawn, jobParams);
         if (result.IsValid)
         {
             return(result);
         }
     }
     return(ThinkResult.NoJob);
 }
Exemplo n.º 18
0
 public abstract ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams);
Exemplo n.º 19
0
 public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
 {
     return(this.subtreeNode.TryIssueJobPackage(pawn, jobParams));
 }
        public override ThinkResult TryIssueJobPackage(Pawn pawn, JobIssueParams jobParams)
        {
            ThinkNode_PrioritySorter.workingNodes.Clear();
            int count = this.subNodes.Count;

            for (int i = 0; i < count; i++)
            {
                ThinkNode_PrioritySorter.workingNodes.Insert(Rand.Range(0, ThinkNode_PrioritySorter.workingNodes.Count - 1), this.subNodes[i]);
            }
            while (ThinkNode_PrioritySorter.workingNodes.Count > 0)
            {
                float num  = 0f;
                int   num2 = -1;
                for (int j = 0; j < ThinkNode_PrioritySorter.workingNodes.Count; j++)
                {
                    float num3 = 0f;
                    try
                    {
                        num3 = ThinkNode_PrioritySorter.workingNodes[j].GetPriority(pawn);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Exception in ",
                            base.GetType(),
                            " GetPriority: ",
                            ex.ToString()
                        }), false);
                    }
                    if (num3 > 0f && num3 >= this.minPriority)
                    {
                        if (num3 > num)
                        {
                            num  = num3;
                            num2 = j;
                        }
                    }
                }
                if (num2 == -1)
                {
                    break;
                }
                ThinkResult result = ThinkResult.NoJob;
                try
                {
                    result = ThinkNode_PrioritySorter.workingNodes[num2].TryIssueJobPackage(pawn, jobParams);
                }
                catch (Exception ex2)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Exception in ",
                        base.GetType(),
                        " TryIssueJobPackage: ",
                        ex2.ToString()
                    }), false);
                }
                if (result.IsValid)
                {
                    return(result);
                }
                ThinkNode_PrioritySorter.workingNodes.RemoveAt(num2);
            }
            return(ThinkResult.NoJob);
        }