예제 #1
0
        // Token: 0x0600001E RID: 30 RVA: 0x000027C4 File Offset: 0x000009C4
        public override void PreAbsorbStack(Thing otherStack, int count)
        {
            float t = (float)count / (float)(this.parent.stackCount + count);
            CompUniversalFermenter comp = ((ThingWithComps)otherStack).GetComp <CompUniversalFermenter>();

            this.ruinedPercent = Mathf.Lerp(this.ruinedPercent, comp.ruinedPercent, t);
        }
        // Token: 0x0600003C RID: 60 RVA: 0x00002F10 File Offset: 0x00001110
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompUniversalFermenter compUniversalFermenter = ThingCompUtility.TryGetComp <CompUniversalFermenter>(t);

            if (compUniversalFermenter == null || compUniversalFermenter.Fermented || compUniversalFermenter.SpaceLeftForIngredient <= 0)
            {
                return(false);
            }
            float ambientTemperature = compUniversalFermenter.parent.AmbientTemperature;

            if (ambientTemperature < compUniversalFermenter.Product.temperatureSafe.min + 2f || ambientTemperature > compUniversalFermenter.Product.temperatureSafe.max - 2f)
            {
                JobFailReason.Is(WorkGiver_FillUniversalFermenter.TemperatureTrans, null);
                return(false);
            }
            if (ForbidUtility.IsForbidden(t, pawn) || !ReservationUtility.CanReserveAndReach(pawn, t, (PathEndMode)2, DangerUtility.NormalMaxDanger(pawn), 1, -1, null, forced))
            {
                return(false);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
            {
                return(false);
            }
            if (this.FindIngredient(pawn, t) == null)
            {
                JobFailReason.Is(WorkGiver_FillUniversalFermenter.NoIngredientTrans, null);
                return(false);
            }
            return(!FireUtility.IsBurning(t));
        }
        // Token: 0x06000030 RID: 48 RVA: 0x00002C83 File Offset: 0x00000E83
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompUniversalFermenter comp = ThingCompUtility.TryGetComp <CompUniversalFermenter>(this.Fermenter);

            ToilFailConditions.FailOn <JobDriver_TakeProductOutOfUniversalFermenter>(this, () => !comp.Fermented);
            ToilFailConditions.FailOnDestroyedNullOrForbidden <JobDriver_TakeProductOutOfUniversalFermenter>(this, (TargetIndex)1);
            yield return(Toils_Reserve.Reserve((TargetIndex)1, 1, -1, null));

            yield return(Toils_Goto.GotoThing((TargetIndex)1, (PathEndMode)3));

            yield return(ToilEffects.WithProgressBarToilDelay(ToilFailConditions.FailOnDestroyedNullOrForbidden <Toil>(Toils_General.Wait(200, 0), (TargetIndex)1), (TargetIndex)1, false, -0.5f));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    Thing thing = comp.TakeOutProduct();
                    GenPlace.TryPlaceThing(thing, this.pawn.Position, this.Map, (ThingPlaceMode)1, null, null);
                    StoragePriority storagePriority = StoreUtility.CurrentStoragePriorityOf(thing);
                    IntVec3 intVec;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(thing, this.pawn, this.Map, storagePriority, this.pawn.Faction, out intVec, true))
                    {
                        this.job.SetTarget((TargetIndex)2, thing);
                        this.job.count = thing.stackCount;
                        this.job.SetTarget((TargetIndex)3, intVec);
                        return;
                    }
                    this.EndJobWith((JobCondition)3);
                },
                defaultCompleteMode = (ToilCompleteMode)1
            });

            yield return(Toils_Reserve.Reserve((TargetIndex)2, 1, -1, null));

            yield return(Toils_Reserve.Reserve((TargetIndex)3, 1, -1, null));

            yield return(Toils_Goto.GotoThing((TargetIndex)2, (PathEndMode)3));

            yield return(Toils_Haul.StartCarryThing((TargetIndex)2, false, false, false));

            Toil carry = Toils_Haul.CarryHauledThingToCell((TargetIndex)3);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell((TargetIndex)3, carry, true));

            yield break;
        }
        // Token: 0x0600002B RID: 43 RVA: 0x00002C03 File Offset: 0x00000E03
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompUniversalFermenter comp = ThingCompUtility.TryGetComp <CompUniversalFermenter>(this.Fermenter);

            ToilFailConditions.FailOn <JobDriver_FillUniversalFermenter>(this, () => comp.SpaceLeftForIngredient <= 0);
            ToilFailConditions.FailOnDestroyedNullOrForbidden <JobDriver_FillUniversalFermenter>(this, (TargetIndex)1);
            ToilFailConditions.FailOnDestroyedNullOrForbidden <JobDriver_FillUniversalFermenter>(this, (TargetIndex)2);
            Toil ingrToil = Toils_Reserve.Reserve((TargetIndex)2, 1, -1, null);

            yield return(ingrToil);

            yield return(Toils_Reserve.Reserve((TargetIndex)1, 1, -1, null));

            yield return(ToilFailConditions.FailOnDestroyedNullOrForbidden <Toil>(ToilFailConditions.FailOnSomeonePhysicallyInteracting <Toil>(Toils_Goto.GotoThing((TargetIndex)2, (PathEndMode)3), (TargetIndex)2), (TargetIndex)2));

            yield return(ToilFailConditions.FailOnDestroyedNullOrForbidden <Toil>(Toils_Haul.StartCarryThing((TargetIndex)2, false, true, false), (TargetIndex)2));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(ingrToil, (TargetIndex)2, 0, true, null));

            yield return(Toils_Haul.CarryHauledThingToCell((TargetIndex)1));

            yield return(ToilEffects.WithProgressBarToilDelay(ToilFailConditions.FailOnDestroyedNullOrForbidden <Toil>(Toils_General.Wait(200, 0), (TargetIndex)1), (TargetIndex)1, false, -0.5f));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    if (!comp.AddIngredient(this.Ingredient))
                    {
                        this.EndJobWith((JobCondition)3);
                        Log.Message("JobCondition.Incompletable", false);
                    }
                },
                defaultCompleteMode = (ToilCompleteMode)1
            });

            yield break;
        }
예제 #5
0
        // Token: 0x06000042 RID: 66 RVA: 0x000030B0 File Offset: 0x000012B0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompUniversalFermenter compUniversalFermenter = ThingCompUtility.TryGetComp <CompUniversalFermenter>(t);

            return(compUniversalFermenter != null && compUniversalFermenter.Fermented && !FireUtility.IsBurning(t) && !ForbidUtility.IsForbidden(t, pawn) && ReservationUtility.CanReserveAndReach(pawn, t, (PathEndMode)2, DangerUtility.NormalMaxDanger(pawn), 1, -1, null, forced));
        }
예제 #6
0
        // Token: 0x06000020 RID: 32 RVA: 0x00002830 File Offset: 0x00000A30
        public override void PostSplitOff(Thing piece)
        {
            CompUniversalFermenter comp = ((ThingWithComps)piece).GetComp <CompUniversalFermenter>();

            comp.ruinedPercent = this.ruinedPercent;
        }
예제 #7
0
        // Token: 0x0600001F RID: 31 RVA: 0x00002808 File Offset: 0x00000A08
        public override bool AllowStackWith(Thing other)
        {
            CompUniversalFermenter comp = ((ThingWithComps)other).GetComp <CompUniversalFermenter>();

            return(this.Ruined == comp.Ruined);
        }