コード例 #1
0
        protected override Job TryGiveJobFromJoyGiverDefDirect(JoyGiverDef def, Pawn pawn)
        {
            Job result;

            if (pawn.mindState.duty == null)
            {
                result = null;
            }
            else if (pawn.needs.joy == null)
            {
                result = null;
            }
            else
            {
                float curLevelPercentage = pawn.needs.joy.CurLevelPercentage;
                if (curLevelPercentage > 0.92f)
                {
                    result = null;
                }
                else
                {
                    IntVec3 cell = pawn.mindState.duty.focus.Cell;
                    result = def.Worker.TryGiveJobInPartyArea(pawn, cell);
                }
            }
            return(result);
        }
コード例 #2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!this.CanDoDuringMedicalRest && pawn.InBed() && HealthAIUtility.ShouldSeekMedicalRest(pawn))
            {
                return(null);
            }
            List <JoyGiverDef> allDefsListForReading = DefDatabase <JoyGiverDef> .AllDefsListForReading;
            JoyToleranceSet    tolerances            = pawn.needs.joy.tolerances;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                JoyGiverDef joyGiverDef = allDefsListForReading[i];
                this.joyGiverChances[joyGiverDef] = 0f;
                if (this.JoyGiverAllowed(joyGiverDef))
                {
                    if (!pawn.needs.joy.tolerances.BoredOf(joyGiverDef.joyKind))
                    {
                        if (joyGiverDef.Worker.MissingRequiredCapacity(pawn) == null)
                        {
                            if (joyGiverDef.pctPawnsEverDo < 1f)
                            {
                                Rand.PushState(pawn.thingIDNumber ^ 63216713);
                                if (Rand.Value >= joyGiverDef.pctPawnsEverDo)
                                {
                                    Rand.PopState();
                                    goto IL_131;
                                }
                                Rand.PopState();
                            }
                            float num  = tolerances[joyGiverDef.joyKind];
                            float num2 = Mathf.Pow(1f - num, 5f);
                            num2 = Mathf.Max(0.001f, num2);
                            this.joyGiverChances[joyGiverDef] = joyGiverDef.Worker.GetChance(pawn) * num2;
                        }
                    }
                }
                IL_131 :;
            }
            for (int j = 0; j < this.joyGiverChances.Count; j++)
            {
                JoyGiverDef def;
                if (!allDefsListForReading.TryRandomElementByWeight((JoyGiverDef d) => this.joyGiverChances[d], out def))
                {
                    break;
                }
                Job job = this.TryGiveJobFromJoyGiverDefDirect(def, pawn);
                if (job != null)
                {
                    return(job);
                }
                this.joyGiverChances[def] = 0f;
            }
            return(null);
        }
コード例 #3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!CanDoDuringMedicalRest && pawn.InBed() && HealthAIUtility.ShouldSeekMedicalRest(pawn))
            {
                return(null);
            }
            List <JoyGiverDef> allDefsListForReading = DefDatabase <JoyGiverDef> .AllDefsListForReading;
            JoyToleranceSet    tolerances            = pawn.needs.joy.tolerances;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                JoyGiverDef joyGiverDef = allDefsListForReading[i];
                joyGiverChances[joyGiverDef] = 0f;
                if (!JoyGiverAllowed(joyGiverDef) || pawn.needs.joy.tolerances.BoredOf(joyGiverDef.joyKind) || !joyGiverDef.Worker.CanBeGivenTo(pawn))
                {
                    continue;
                }
                if (joyGiverDef.pctPawnsEverDo < 1f)
                {
                    Rand.PushState(pawn.thingIDNumber ^ 0x3C49C49);
                    if (Rand.Value >= joyGiverDef.pctPawnsEverDo)
                    {
                        Rand.PopState();
                        continue;
                    }
                    Rand.PopState();
                }
                float num = tolerances[joyGiverDef.joyKind];
                float b   = Mathf.Pow(1f - num, 5f);
                b = Mathf.Max(0.001f, b);
                joyGiverChances[joyGiverDef] = joyGiverDef.Worker.GetChance(pawn) * b;
            }
            for (int j = 0; j < joyGiverChances.Count; j++)
            {
                if (!allDefsListForReading.TryRandomElementByWeight((JoyGiverDef d) => joyGiverChances[d], out JoyGiverDef result))
                {
                    break;
                }
                Job job = TryGiveJobFromJoyGiverDefDirect(result, pawn);
                if (job != null)
                {
                    return(job);
                }
                joyGiverChances[result] = 0f;
            }
            return(null);
        }
コード例 #4
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (!this.CanDoDuringMedicalRest && pawn.InBed() && HealthAIUtility.ShouldSeekMedicalRest(pawn))
            {
                return(null);
            }
            List <JoyGiverDef> allDefsListForReading = DefDatabase <JoyGiverDef> .AllDefsListForReading;
            JoyToleranceSet    tolerances            = pawn.needs.joy.tolerances;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                JoyGiverDef joyGiverDef = allDefsListForReading[i];
                this.joyGiverChances[joyGiverDef] = 0f;
                if (this.JoyGiverAllowed(joyGiverDef) && joyGiverDef.Worker.MissingRequiredCapacity(pawn) == null)
                {
                    if (joyGiverDef.pctPawnsEverDo < 1.0)
                    {
                        Rand.PushState(pawn.thingIDNumber ^ 63216713);
                        if (Rand.Value >= joyGiverDef.pctPawnsEverDo)
                        {
                            Rand.PopState();
                            continue;
                        }
                        Rand.PopState();
                    }
                    float chance = joyGiverDef.Worker.GetChance(pawn);
                    float num    = (float)(1.0 - tolerances[joyGiverDef.joyKind]);
                    chance *= num * num;
                    this.joyGiverChances[joyGiverDef] = chance;
                }
            }
            int         num2 = 0;
            JoyGiverDef def  = default(JoyGiverDef);

            while (num2 < this.joyGiverChances.Count && ((IEnumerable <JoyGiverDef>)allDefsListForReading).TryRandomElementByWeight <JoyGiverDef>((Func <JoyGiverDef, float>)((JoyGiverDef d) => this.joyGiverChances[d]), out def))
            {
                Job job = this.TryGiveJobFromJoyGiverDefDirect(def, pawn);
                if (job != null)
                {
                    return(job);
                }
                this.joyGiverChances[def] = 0f;
                num2++;
            }
            return(null);
        }
コード例 #5
0
        protected override Job TryGiveJobFromJoyGiverDefDirect(JoyGiverDef def, Pawn pawn)
        {
            if (pawn.mindState.duty == null)
            {
                return(null);
            }
            if (pawn.needs.joy == null)
            {
                return(null);
            }
            if (pawn.needs.joy.CurLevelPercentage > 0.92f)
            {
                return(null);
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

            return(def.Worker.TryGiveJobInGatheringArea(pawn, cell));
        }
コード例 #6
0
        protected override Job TryGiveJobFromJoyGiverDefDirect(JoyGiverDef def, Pawn pawn)
        {
            if (pawn.mindState.duty == null)
            {
                return(null);
            }
            if (pawn.needs.joy == null)
            {
                return(null);
            }
            float curLevelPercentage = pawn.needs.joy.CurLevelPercentage;

            if (curLevelPercentage > 0.92000001668930054)
            {
                return(null);
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

            return(def.Worker.TryGiveJobInPartyArea(pawn, cell));
        }
コード例 #7
0
 protected virtual Job TryGiveJobFromJoyGiverDefDirect(JoyGiverDef def, Pawn pawn)
 {
     return(def.Worker.TryGiveJob(pawn));
 }
コード例 #8
0
 protected virtual bool JoyGiverAllowed(JoyGiverDef def)
 {
     return(true);
 }
コード例 #9
0
 protected override Job TryGiveJobFromJoyGiverDefDirect(JoyGiverDef def, Pawn pawn)
 {
     return(def.Worker.TryGiveJobWhileInBed(pawn));
 }
コード例 #10
0
 protected override bool JoyGiverAllowed(JoyGiverDef def)
 {
     return(def.canDoWhileInBed);
 }
コード例 #11
0
 private float <TryGiveJob> m__0(JoyGiverDef d)
 {
     return(this.joyGiverChances[d]);
 }