// Token: 0x06005678 RID: 22136 RVA: 0x001CE823 File Offset: 0x001CCA23
        public static IEnumerable <Pair <CompReloadableDual, Thing> > FindPotentiallyReloadableGear(Pawn pawn, List <Thing> potentialAmmo)
        {
            if (pawn.apparel == null)
            {
                yield break;
            }
            List <Apparel> worn = pawn.apparel.WornApparel;
            int            num;

            for (int i = 0; i < worn.Count; i = num + 1)
            {
                CompReloadableDual comp           = worn[i].TryGetComp <CompReloadableDual>();
                CompReloadableDual compReloadable = comp;
                if (((compReloadable != null) ? compReloadable.AmmoDefSecondry : null) != null)
                {
                    for (int j = 0; j < potentialAmmo.Count; j = num + 1)
                    {
                        Thing thing = potentialAmmo[j];
                        if (thing.def == comp.Props.ammoDefSecondry)
                        {
                            yield return(new Pair <CompReloadableDual, Thing>(comp, thing));
                        }
                        num = j;
                    }
                    comp = null;
                }
                num = i;
            }
            yield break;
        }
        // Token: 0x0600567B RID: 22139 RVA: 0x001CE8D0 File Offset: 0x001CCAD0
        public static bool CanUseConsideringQueuedJobs(Pawn pawn, ThingWithComps gear, bool showMessage = true)
        {
            CompReloadableDual compReloadable = gear.TryGetComp <CompReloadableDual>();

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

            if (!Event.current.shift)
            {
                if (!compReloadable.CanBeUsed)
                {
                    text = compReloadable.DisabledReason(compReloadable.MinAmmoNeededSecondry(false), compReloadable.MaxAmmoNeededSecondry(false));
                }
            }
            else if (ReloadableDualUtility.TotalChargesFromQueuedJobs(pawn, gear) + 1 > compReloadable.RemainingCharges)
            {
                text = compReloadable.DisabledReason(compReloadable.MaxAmmoAmountSecondry(), compReloadable.MaxAmmoAmountSecondry());
            }
            if (text != null)
            {
                if (showMessage)
                {
                    Messages.Message(text, pawn, MessageTypeDefOf.RejectInput, false);
                }
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
 public void EraseSuitsData()
 {
     this.assignedSuit = null;
     this.OgsOld_CompTurretGunFirst  = null;
     this.OgsOld_CompTurretGunSecond = null;
     this.compReloadableDual         = null;
 }
        // Token: 0x06005679 RID: 22137 RVA: 0x001CE83C File Offset: 0x001CCA3C
        public static Pawn WearerOf(CompReloadableDual comp)
        {
            Pawn_ApparelTracker pawn_ApparelTracker = comp.ParentHolder as Pawn_ApparelTracker;

            if (pawn_ApparelTracker != null)
            {
                return(pawn_ApparelTracker.pawn);
            }
            return(null);
        }
        // Token: 0x06005677 RID: 22135 RVA: 0x001CE7CC File Offset: 0x001CC9CC
        public static List <Thing> FindEnoughAmmo(Pawn pawn, IntVec3 rootCell, CompReloadableDual comp, bool forceReload)
        {
            if (comp == null)
            {
                return(null);
            }
            IntRange desiredQuantity = new IntRange(comp.MinAmmoNeededSecondry(forceReload), comp.MaxAmmoNeededSecondry(forceReload));

            return(RefuelWorkGiverUtility.FindEnoughReservableThings(pawn, rootCell, desiredQuantity, (Thing t) => t.def == comp.AmmoDefSecondry));
        }
Esempio n. 6
0
        protected override bool TryCastShot()
        {
            if (!ModLister.RoyaltyInstalled)
            {
                Log.ErrorOnce("Items with jump capability are a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 550187797);
                return(false);
            }
#pragma warning disable CS0436 // Type conflicts with imported type
            CompReloadable reloadableCompSource = base.ReloadableCompSource;
#pragma warning restore CS0436 // Type conflicts with imported type
            Pawn casterPawn = CasterPawn;
            if (casterPawn == null || reloadableCompSource == null || !reloadableCompSource.CanBeUsed)
            {
                return(false);
            }
            //	Log.Message("reloadableCompSource " + reloadableCompSource.Props.chargeNoun);
            IntVec3            cell           = currentTarget.Cell;
            Map                map            = casterPawn.Map;
            CompReloadableDual reloadableDual = reloadableCompSource as CompReloadableDual;
            if (reloadableDual != null)
            {
                if (this.verbProps.label == reloadableDual.Props.chargeNoun)
                {
                    reloadableDual.UsedOnce();
                    //	Log.Message("reloadableDual UsedOnce " + reloadableDual.RemainingCharges);
                }
                else
                if (this.verbProps.label == reloadableDual.Props.chargeNounSecondry)
                {
                    reloadableDual.UsedOnceSecondry();
                    //	Log.Message("reloadableDual UsedOnceSecondry " + reloadableDual.RemainingChargesSecondry);
                }
            }
            else
            {
                if (this.verbProps.label == reloadableCompSource.Props.chargeNoun)
                {
                    reloadableCompSource.UsedOnce();
                    //	Log.Message("reloadableCompSource UsedOnce " + reloadableCompSource.RemainingCharges);
                }
            }
            PawnFlyer pawnFlyer = PawnFlyer.MakeFlyer(verbProps.defaultProjectile ?? ThingDefOf.PawnJumper, casterPawn, cell);
            if (pawnFlyer != null)
            {
                GenSpawn.Spawn(pawnFlyer, cell, map);
                return(true);
            }
            return(false);
        }
Esempio n. 7
0
        public void InitSuitsData(MechSuit suit)
        {
            this.assignedSuit = suit;
            var turrets = assignedSuit.AllComps.Where(x => x is OgsOld_CompTurretGun);

            if (turrets.Count() > 0)
            {
                this.OgsOld_CompTurretGunFirst = turrets.ElementAt(0) as OgsOld_CompTurretGunDamagable;
            }
            if (turrets.Count() > 1)
            {
                this.OgsOld_CompTurretGunSecond = turrets.ElementAt(1) as OgsOld_CompTurretGunDamagable;
            }
            this.compReloadableDual = assignedSuit.GetComp <CompReloadableDual>();
        }
        // Token: 0x0600567A RID: 22138 RVA: 0x001CE860 File Offset: 0x001CCA60
        public static int TotalChargesFromQueuedJobs(Pawn pawn, ThingWithComps gear)
        {
            CompReloadableDual compReloadable = gear.TryGetComp <CompReloadableDual>();
            int num = 0;

            if (compReloadable != null && pawn != null)
            {
                foreach (Job job in pawn.jobs.AllJobs())
                {
                    Verb verbToUse = job.verbToUse;
                    if (verbToUse != null && compReloadable == verbToUse.ReloadableCompSource)
                    {
                        num++;
                    }
                }
            }
            return(num);
        }
        // Token: 0x06005676 RID: 22134 RVA: 0x001CE77C File Offset: 0x001CC97C
        public static CompReloadableDual FindSomeReloadableComponent(Pawn pawn, bool allowForcedReload)
        {
            if (pawn.apparel == null)
            {
                return(null);
            }
            List <Apparel> wornApparel = pawn.apparel.WornApparel;

            for (int i = 0; i < wornApparel.Count; i++)
            {
                CompReloadableDual compReloadable = wornApparel[i].TryGetComp <CompReloadableDual>();
                if (compReloadable != null && compReloadable.NeedsReload(allowForcedReload))
                {
                    return(compReloadable);
                }
            }
            return(null);
        }
Esempio n. 10
0
 // Token: 0x06005671 RID: 22129 RVA: 0x001CE6CF File Offset: 0x001CC8CF
 public Command_ReloadableDual(CompReloadableDual comp)
 {
     this.comp = comp;
 }