예제 #1
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_HybridizationChamber building_hybridizationchamber = t as Building_HybridizationChamber;
            bool result;

            if (building_hybridizationchamber == null || !building_hybridizationchamber.hybridizationChamberFull)
            {
                result = false;
            }
            else if (t.IsBurning())
            {
                result = false;
            }
            else
            {
                if (!t.IsForbidden(pawn))
                {
                    LocalTargetInfo target = t;
                    if (pawn.CanReserve(target, 1, -1, null, forced))
                    {
                        result = true;
                        return(result);
                    }
                }
                result = false;
            }
            return(result);
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            this.FailOnBurningImmobile(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            yield return(Toils_General.Wait(240).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Building_HybridizationChamber buildingHybridizationChamber = (Building_HybridizationChamber)this.job.GetTarget(TargetIndex.A).Thing;
                    buildingHybridizationChamber.hybridizationChamberFull = false;
                    Thing newBee = ThingMaker.MakeThing(GetHybridBee());
                    GenSpawn.Spawn(newBee, buildingHybridizationChamber.Position - GenAdj.CardinalDirections[0], buildingHybridizationChamber.Map);
                    StoragePriority currentPriority = StoreUtility.CurrentStoragePriorityOf(newBee);
                    IntVec3 c;
                    if (StoreUtility.TryFindBestBetterStoreCellFor(newBee, this.pawn, this.Map, currentPriority, this.pawn.Faction, out c, true))
                    {
                        this.job.SetTarget(TargetIndex.C, c);
                        this.job.SetTarget(TargetIndex.B, newBee);
                        this.job.count = newBee.stackCount;

                        buildingHybridizationChamber.tickCounter = 0;
                    }
                    else
                    {
                        this.EndJobWith(JobCondition.Incompletable);
                        buildingHybridizationChamber.hybridizationChamberFull = false;
                        buildingHybridizationChamber.tickCounter = 0;
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

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

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

            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

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

            Toil carryToCell = Toils_Haul.CarryHauledThingToCell(TargetIndex.C);

            yield return(carryToCell);

            yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, carryToCell, true));
        }
예제 #3
0
        public override void PostDraw()
        {
            if (RimBees_Settings.RB_Ben_ShowProgress)
            {
                Building_HybridizationChamber hybridizationchamber = this.parent as Building_HybridizationChamber;
                var progress = hybridizationchamber.tickCounter / (hybridizationchamber.ticksToDays * 3f);
                if (hybridizationchamber.hybridizationChamberFull)
                {
                    progress = 1f;
                }

                GenDraw.DrawFillableBar(new GenDraw.FillableBarRequest
                {
                    center      = parent.DrawPos + CompBeeHouse.ProgressBarOffset,
                    size        = CompBeeHouse.ProgressBarSize,
                    fillPercent = progress,
                    margin      = 0.1f,
                    rotation    = Rot4.North,
                    filledMat   = CompBeeHouse.FilledMat,
                    unfilledMat = CompBeeHouse.UnfilledMat,
                });
            }
        }
예제 #4
0
        public ThingDef GetHybridBee()
        {
            Building_HybridizationChamber buildinghybridizationchamber = (Building_HybridizationChamber)this.job.GetTarget(TargetIndex.A).Thing;

            return(DefDatabase <ThingDef> .GetNamed("RB_Bee_" + buildinghybridizationchamber.hybridizedBee + "_Queen", true));
        }