示例#1
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            building_genepod = t as Building_NewGenePod;
            bool result;

            if (building_genepod == null || !building_genepod.SignalInsertGenes1)
            {
                result = false;
            }
            else if (t.IsBurning())
            {
                result = false;
            }
            else
            {
                if (!t.IsForbidden(pawn))
                {
                    LocalTargetInfo target  = t;
                    LocalTargetInfo target2 = building_genepod.typeOfGenesToInsert1;

                    if (pawn.CanReserve(target, 1, -1, null, forced))
                    {
                        if (pawn.CanReserve(target2, 1, -1, null, forced))
                        {
                            result = true;
                            return(result);
                        }
                    }
                }
                result = false;
            }
            return(result);
        }
示例#2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil reserveGenes = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null);

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

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

            yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveGenes, TargetIndex.B, TargetIndex.None, true, null));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

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

            yield return(new Toil
            {
                initAction = delegate
                {
                    Building_NewGenePod building_genepod = (Building_NewGenePod)this.job.GetTarget(TargetIndex.A).Thing;
                    building_genepod.TryAcceptThing2(this.job.targetB.Thing, true);
                    building_genepod.PodHasGenes2 = true;
                    building_genepod.SignalInsertGenes2 = false;
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });
        }
示例#3
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed("GR_BearGenetic", true)).Count > 0)
            {
                list.Add(new FloatMenuOption("Bear Genes", delegate
                {
                    gene = map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed("GR_BearGenetic", true)).RandomElement();
                    Building_NewGenePod pod  = (Building_NewGenePod)buildingpod;
                    pod.typeOfGenesToInsert1 = gene;
                    Log.Message("Gene is: " + gene.ToString(), false);
                    if (pod.typeOfGenesToInsert2 != null)
                    {
                        Log.Message("pod.typeOfGenesToInsert2 is: " + pod.typeOfGenesToInsert2.ToString(), false);
                    }
                    else
                    {
                        Log.Message("pod.typeOfGenesToInsert2 is null", false);
                    }


                    if (pod.typeOfGenesToInsert1 == pod.typeOfGenesToInsert2)
                    {
                        pod.typeOfGenesToInsert1 = null;
                        pod.SignalInsertGenes1   = false;
                    }
                    else
                    {
                        pod.SignalInsertGenes1 = true;
                    }
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }



            if (list.Count > 0)
            {
            }
            else
            {
                list.Add(new FloatMenuOption("GR_NoGenes".Translate(), delegate
                {
                }, MenuOptionPriority.Default, null, null, 29f, null, null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }