示例#1
0
        // Token: 0x0600567B RID: 22139 RVA: 0x001CE8D0 File Offset: 0x001CCAD0
        public static bool CanUseConsideringQueuedJobs(Pawn pawn, ThingWithComps gear, bool showMessage = true)
        {
            CompTurret compReloadable = gear.TryGetCompFast <CompTurret>();

            if (compReloadable == null)
            {
                return(true);
            }
            string text = null;

            if (!Event.current.shift)
            {
                if (!compReloadable.CanBeUsed)
                {
                    text = compReloadable.DisabledReason(compReloadable.MinAmmoNeeded(false), compReloadable.MaxAmmoNeeded(false));
                }
            }
            else if (CompTurretReloadableUtility.TotalChargesFromQueuedJobs(pawn, gear) + 1 > compReloadable.RemainingCharges)
            {
                text = compReloadable.DisabledReason(compReloadable.MaxAmmoAmount(), compReloadable.MaxAmmoAmount());
            }
            if (text != null)
            {
                if (showMessage)
                {
                    Messages.Message(text, pawn, MessageTypeDefOf.RejectInput, false);
                }
                return(false);
            }
            return(true);
        }
示例#2
0
        public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn)
        {
            string       text4 = "Reload".Translate(this.parent.Named("GEAR"), this.AmmoDef.Named("AMMO")) + " (" + this.LabelRemaining + ")";
            List <Thing> chosenAmmo;

            if (!selPawn.CanReach(Operator, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
            {
                yield return(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            else if (!this.NeedsReload(true))
            {
                yield return(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            else if ((chosenAmmo = CompTurretReloadableUtility.FindEnoughAmmo(selPawn, Operator.Position, this, true)) == null)
            {
                yield return(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            else
            {
                Action action4 = delegate()
                {
                    selPawn.jobs.TryTakeOrderedJob(JobGiver_ReloadCompTurret.MakeReloadJob(this, chosenAmmo), JobTag.Misc);
                };
                yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4, MenuOptionPriority.Default, null, null, 0f, null, null), selPawn, Operator, "ReservedBy"));
            }
            foreach (var item in base.CompFloatMenuOptions(selPawn))
            {
                yield return(item);
            }
        }
示例#3
0
 // Token: 0x0600313B RID: 12603 RVA: 0x00114110 File Offset: 0x00112310
 protected override Job TryGiveJob(Pawn pawn)
 {
     foreach (CompTurretGun compReloadable in CompTurretReloadableUtility.FindSomeReloadableComponents(pawn, false))
     {
         if (compReloadable == null)
         {
             continue;
         }
         List <Thing> list = CompTurretReloadableUtility.FindEnoughAmmo(pawn, pawn.Position, compReloadable, false);
         if (list == null)
         {
             continue;
         }
         return(JobGiver_ReloadCompTurret.MakeReloadJob(compReloadable, list));
     }
     return(null);
 }