コード例 #1
0
        public override void PostSplitOff(Thing piece)
        {
            CompUniversalFermenter comp = ((ThingWithComps)piece).GetComp <CompUniversalFermenter>();

            comp.ruinedPercent = ruinedPercent;
            //ruinedPercent = ruinedPercent;
        }
コード例 #2
0
        public override bool AllowStackWith(Thing other)
        {
            CompUniversalFermenter comp = ((ThingWithComps)other).GetComp <CompUniversalFermenter>();

            return(Ruined == comp.Ruined);
            //return Ruined == Ruined;
        }
コード例 #3
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompUniversalFermenter comp = t.TryGetComp <CompUniversalFermenter>();

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

            if (ambientTemperature < comp.Product.temperatureSafe.min + 2f || ambientTemperature > comp.Product.temperatureSafe.max - 2f)
            {
                JobFailReason.Is(TemperatureTrans);
                return(false);
            }
            if (t.IsForbidden(pawn) || !pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, forced))
            {
                return(false);
            }
            if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null)
            {
                return(false);
            }
            if (FindIngredient(pawn, t) == null)
            {
                JobFailReason.Is(NoIngredientTrans);
                return(false);
            }
            return(!t.IsBurning());
        }
コード例 #4
0
        public override void PreAbsorbStack(Thing otherStack, int count)
        {
            float t = (float)count / (float)(parent.stackCount + count);
            CompUniversalFermenter comp = ((ThingWithComps)otherStack).GetComp <CompUniversalFermenter>();

            ruinedPercent = Mathf.Lerp(ruinedPercent, comp.ruinedPercent, t);
            //ruinedPercent = Mathf.Lerp(ruinedPercent, ruinedPercent, t);
        }
コード例 #5
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>();

            // Verify fermenter and ingredient validity
            this.FailOn(() => comp.SpaceLeftForIngredient <= 0);
            this.FailOnDespawnedNullOrForbidden(FermenterInd);
            this.FailOnBurningImmobile(FermenterInd);
            this.FailOnDestroyedNullOrForbidden(IngredientInd);

            // Reserve resources
            // Creating the toil before yielding allows for CheckForGetOpportunityDuplicate
            Toil ingrToil = Toils_Reserve.Reserve(IngredientInd);

            yield return(ingrToil);

            // Reserve fermenter
            yield return(Toils_Reserve.Reserve(FermenterInd));

            // Go to the ingredient
            yield return(Toils_Goto.GotoThing(IngredientInd, PathEndMode.ClosestTouch)
                         .FailOnSomeonePhysicallyInteracting(IngredientInd)
                         .FailOnDestroyedNullOrForbidden(IngredientInd));

            // Haul the ingredients
            yield return(Toils_Haul.StartCarryThing(IngredientInd, false, true).FailOnDestroyedNullOrForbidden(IngredientInd));

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(ingrToil, IngredientInd, TargetIndex.None, true));

            // Carry ingredients to the fermenter
            yield return(Toils_Haul.CarryHauledThingToCell(FermenterInd));

            // Add delay for adding ingredients to the fermenter
            yield return(Toils_General.Wait(Duration).FailOnDestroyedNullOrForbidden(FermenterInd).WithProgressBarToilDelay(FermenterInd));

            // Use ingredients
            // The UniversalFermenter automatically destroys held ingredients
            Toil add = new Toil();

            add.initAction = () =>
            {
                if (!comp.AddIngredient(Ingredient))
                {
                    // The ingredient is not allowed, end the job
                    EndJobWith(JobCondition.Incompletable);
                    Log.Message("JobCondition.Incompletable");
                }
            };
            add.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(add);

            // End the current job
            yield break;
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>();

            // Verify fermenter validity
            this.FailOn(() => !comp.Fermented);
            this.FailOnDestroyedNullOrForbidden(FermenterInd);

            // Reserve fermenter
            yield return(Toils_Reserve.Reserve(FermenterInd));

            // Go to the fermenter
            yield return(Toils_Goto.GotoThing(FermenterInd, PathEndMode.ClosestTouch));

            // Add delay for collecting product from fermenter, if it is ready
            yield return(Toils_General.Wait(Duration).FailOnDestroyedNullOrForbidden(FermenterInd).WithProgressBarToilDelay(FermenterInd));

            // Collect product
            Toil collect = new Toil();

            collect.initAction = () =>
            {
                Thing product = comp.TakeOutProduct();
                GenPlace.TryPlaceThing(product, pawn.Position, Map, ThingPlaceMode.Near);
                StoragePriority storagePriority = StoreUtility.CurrentStoragePriorityOf(product);
                IntVec3         c;

                // Try to find a suitable storage spot for the product
                if (StoreUtility.TryFindBestBetterStoreCellFor(product, pawn, Map, storagePriority, pawn.Faction, out c))
                {
                    this.job.SetTarget(TargetIndex.B, product);
                    this.job.count = product.stackCount;
                    this.job.SetTarget(TargetIndex.C, c);
                }
                // If there is no spot to store the product, end this job
                else
                {
                    EndJobWith(JobCondition.Incompletable);
                }
            };
            collect.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(collect);

            // Reserve the product
            yield return(Toils_Reserve.Reserve(ProductToHaulInd));

            // Reserve the storage cell
            yield return(Toils_Reserve.Reserve(StorageCellInd));

            // Go to the product
            yield return(Toils_Goto.GotoThing(ProductToHaulInd, PathEndMode.ClosestTouch));

            // Pick up the product
            yield return(Toils_Haul.StartCarryThing(ProductToHaulInd));

            // Carry the product to the storage cell, then place it down
            Toil carry = Toils_Haul.CarryHauledThingToCell(StorageCellInd);

            yield return(carry);

            yield return(Toils_Haul.PlaceHauledThingInCell(StorageCellInd, carry, true));

            // End the current job
            yield break;
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            CompUniversalFermenter comp = t.TryGetComp <CompUniversalFermenter>();

            return(comp != null && comp.Fermented && !t.IsBurning() && !t.IsForbidden(pawn) && pawn.CanReserveAndReach(t, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, forced));
        }