Пример #1
0
        public static Building_BioReactor FindBioReactorFor(Pawn p, Pawn traveler, bool ignoreOtherReservations = false)
        {
            IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs
                                                where typeof(Building_BioReactor).IsAssignableFrom(def.thingClass)
                                                select def;

            foreach (ThingDef singleDef in enumerable)
            {
                Building_BioReactor building_BioReactor = (Building_BioReactor)GenClosest.ClosestThingReachable(p.Position, p.Map, ThingRequest.ForDef(singleDef), PathEndMode.InteractionCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, delegate(Thing x)
                {
                    bool result;
                    if (!((Building_BioReactor)x).HasAnyContents)
                    {
                        Pawn traveler2                = traveler;
                        LocalTargetInfo target        = x;
                        bool ignoreOtherReservations2 = ignoreOtherReservations;
                        result = traveler2.CanReserve(target, 1, -1, null, ignoreOtherReservations2);
                    }
                    else
                    {
                        result = false;
                    }
                    return(result);
                }, null, 0, -1, false, RegionType.Set_Passable, false);
                if (building_BioReactor != null && !building_BioReactor.forbiddable.Forbidden)
                {
                    if ((p.BodySize <= ((BioReactorDef)(building_BioReactor.def)).bodySizeMax) && (p.BodySize >= ((BioReactorDef)(building_BioReactor.def)).bodySizeMin))
                    {
                        return(building_BioReactor);
                    }
                }
            }
            return(null);
        }
Пример #2
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     flickComp = parent.GetComp <CompFlickable>();
     if (inputSettings == null)
     {
         inputSettings = new StorageSettings(this);
         if (parent.def.building.defaultStorageSettings != null)
         {
             inputSettings.CopyFrom(parent.def.building.defaultStorageSettings);
         }
     }
     bioReactor = (Building_BioReactor)parent;
 }
Пример #3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            Toil prepare = Toils_General.Wait(500, TargetIndex.None);

            prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell);
            prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(prepare);

            Toil enter = new Toil();

            enter.initAction = delegate()
            {
                Pawn actor = enter.actor;
                Building_BioReactor pod = (Building_BioReactor)actor.CurJob.targetA.Thing;
                Action action           = delegate()
                {
                    actor.DeSpawn(DestroyMode.Vanish);
                    pod.TryAcceptThing(actor, true);
                };
                if (!pod.def.building.isPlayerEjectable)
                {
                    int freeColonistsSpawnedOrInPlayerEjectablePodsCount = this.Map.mapPawns.FreeColonistsSpawnedOrInPlayerEjectablePodsCount;
                    if (freeColonistsSpawnedOrInPlayerEjectablePodsCount <= 1)
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CasketWarning".Translate(actor.Named("PAWN")).AdjustedFor(actor, "PAWN"), action, false, null));
                    }
                    else
                    {
                        action();
                    }
                }
                else
                {
                    action();
                }
            };
            enter.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(enter);

            yield break;
        }
Пример #4
0
 public static bool Prefix_AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
 {
     if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
     {
         foreach (LocalTargetInfo localTargetInfo3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
         {
             LocalTargetInfo localTargetInfo4 = localTargetInfo3;
             Pawn            victim           = (Pawn)localTargetInfo4.Thing;
             if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1, -1, null, true) && Building_BioReactor.FindBioReactorFor(victim, pawn, true) != null)
             {
                 string text4   = "CarryToBioReactor".Translate(localTargetInfo4.Thing.LabelCap, localTargetInfo4.Thing);
                 JobDef jDef    = Bio_JobDefOf.CarryToBioReactor;
                 Action action3 = delegate()
                 {
                     Building_BioReactor building_BioReactor = Building_BioReactor.FindBioReactorFor(victim, pawn, false);
                     if (building_BioReactor == null)
                     {
                         building_BioReactor = Building_BioReactor.FindBioReactorFor(victim, pawn, true);
                     }
                     if (building_BioReactor == null)
                     {
                         Messages.Message("CannotCarryToBioReactor".Translate() + ": " + "NoBioReactor".Translate(), victim, MessageTypeDefOf.RejectInput, false);
                         return;
                     }
                     Job job = new Job(jDef, victim, building_BioReactor);
                     job.count = 1;
                     pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                 };
                 string label   = text4;
                 Action action2 = action3;
                 Pawn   revalidateClickTarget = victim;
                 opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action2, MenuOptionPriority.Default, null, revalidateClickTarget, 0f, null, null), pawn, victim, "ReservedBy"));
             }
         }
     }
     return(true);
 }
Пример #5
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     building_BioReactor = (Building_BioReactor)parent;
     compRefuelable      = parent.GetComp <CompRefuelable>();
 }