public void dropmag(FVRViveHand hand, bool _override = false)
        {
            if (DisallowEjection && !_override)
            {
                return;
            }
            FVRFireArmMagazine magazine = null;

            if (WepType == 1)
            {
                magazine = this.ClosedBoltReceiver.Magazine;
                this.ClosedBoltReceiver.ReleaseMag();
            }
            if (WepType == 2)
            {
                magazine = this.OpenBoltWeapon.Magazine;
                this.OpenBoltWeapon.ReleaseMag();
            }
            if (WepType == 3)
            {
                magazine = this.HandgunReceiver.Magazine;
                this.HandgunReceiver.ReleaseMag();
            }
            movemagtohand(hand, magazine);
        }
Пример #2
0
        private void DupeMagButton()
        {
            if ((detectedMag == null && detectedSpeedLoader == null) || original.M.GetNumTokens() < DupeCost)
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position);
            }

            else
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position);
                original.M.SubtractTokens(DupeCost);
                original.M.Increment(10, false);

                if (detectedMag != null)
                {
                    TNHTweaker.HoldActions[original.M.m_level].Add($"Duplicated {detectedMag.ObjectWrapper.DisplayName}");
                    FirearmUtils.SpawnDuplicateMagazine(detectedMag, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
                }

                else
                {
                    TNHTweaker.HoldActions[original.M.m_level].Add($"Duplicated {detectedSpeedLoader.ObjectWrapper.DisplayName}");
                    FirearmUtils.SpawnDuplicateSpeedloader(detectedSpeedLoader, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
                }

                detectedMag         = null;
                detectedSpeedLoader = null;
                UpdateIcons();
            }
        }
 public void movemagtohand(FVRViveHand hand, FVRFireArmMagazine magazine)
 {
     //puts mag in hand
     if (hand != null)
     {
         hand.ForceSetInteractable(magazine);
     }
     magazine.BeginInteraction(hand);
 }
        public override void UpdateInteraction(FVRViveHand hand)
        {
            base.UpdateInteraction(hand);

            bool flag = false;
            FVRFireArmMagazine prevmag = null;

            if (mag != null)
            {
                flag = true; prevmag = mag;
            }                                                            //check if mag was previously loaded

            if (WepType == 1)
            {
                mag = this.ClosedBoltReceiver.Magazine;
            }
            if (WepType == 2)
            {
                mag = this.OpenBoltWeapon.Magazine;
            }
            if (WepType == 3)
            {
                mag = this.HandgunReceiver.Magazine;
            }

            if (mag != null)
            {
                bool flag2 = false;
                if (Vector2.Angle(hand.Input.TouchpadAxes, dir) <= 45f && hand.Input.TouchpadDown && hand.Input.TouchpadAxes.magnitude > 0.2f)
                {
                    flag2 = true;
                }

                if (flag2 || !PressDownToRelease || hand.IsInStreamlinedMode && hand.Input.AXButtonPressed)
                {
                    if (TouchpadDir == TouchpadDirType.NoDirection)
                    {
                        return;
                    }
                    dropmag(hand);
                    this.EndInteraction(hand);
                }
            }
            else
            {
                if (flag)                 //if mag was previously loaded, but is now not
                {
                    movemagtohand(hand, prevmag);
                }
                this.EndInteraction(hand);
            }
        }
Пример #5
0
        private bool IsLowCapMag(FVRFireArmMagazine mag)
        {
            if (_configs.Magazine.FixMagPos.Value)
            {
                var obj = mag.ObjectWrapper;
                if (obj != null)
                {
                    return(mag.m_capacity <= 9);
                }
            }

            return(false);
        }
Пример #6
0
        private void Scan()
        {
            int colliderCount = Physics.OverlapBoxNonAlloc(original.ScanningVolume.position, original.ScanningVolume.localScale * 0.5f, colBuffer, original.ScanningVolume.rotation, original.ScanningLM, QueryTriggerInteraction.Collide);

            detectedMag         = null;
            detectedSpeedLoader = null;
            purchaseMag         = null;
            upgradeMag          = null;

            for (int i = 0; i < colliderCount; i++)
            {
                if (colBuffer[i].attachedRigidbody != null)
                {
                    FVRFireArm firearm = colBuffer[i].GetComponent <FVRFireArm>();
                    if (purchaseMag == null && firearm != null && !firearm.IsHeld && firearm.QuickbeltSlot == null)
                    {
                        MagazineBlacklistEntry entry = null;
                        if (blacklist.ContainsKey(firearm.ObjectWrapper.ItemID))
                        {
                            entry = blacklist[firearm.ObjectWrapper.ItemID];
                        }
                        List <FVRObject> spawnableMags = FirearmUtils.GetCompatibleMagazines(firearm.ObjectWrapper, -1, -1, false, entry);

                        if (spawnableMags.Count > 0)
                        {
                            purchaseMag = FirearmUtils.GetSmallestCapacityMagazine(spawnableMags);
                        }
                    }

                    FVRFireArmMagazine mag = colBuffer[i].GetComponent <FVRFireArmMagazine>();
                    if (mag != null && mag.FireArm == null && (!mag.IsHeld) && mag.QuickbeltSlot == null && (!mag.IsIntegrated))
                    {
                        detectedMag = mag;
                    }

                    Speedloader speedloader = colBuffer[i].GetComponent <Speedloader>();
                    if (speedloader != null && (!speedloader.IsHeld) && speedloader.QuickbeltSlot == null && speedloader.IsPretendingToBeAMagazine)
                    {
                        detectedSpeedLoader = speedloader;
                    }

                    //If at this point we have a valid ammo container and firearm, we can stop looping
                    if (purchaseMag != null && (detectedMag != null || detectedSpeedLoader != null))
                    {
                        break;
                    }
                }
            }
        }
Пример #7
0
        private void UpgradeMagButton()
        {
            if (upgradeMag == null || original.M.GetNumTokens() < UpgradeCost)
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position);
            }

            else
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position);
                original.M.SubtractTokens(UpgradeCost);
                original.M.Increment(10, false);

                Destroy(detectedMag.GameObject);
                Instantiate(upgradeMag.GetGameObject(), original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);

                upgradeMag  = null;
                detectedMag = null;
                UpdateIcons();
            }
        }
        public static bool AmmoSpawnerV2_CheckFillButton(AmmoSpawnerV2 __instance, FireArmRoundType ___m_curAmmoType, ref bool ___m_hasHeldType, ref FireArmRoundType ___heldType)
        {
            bool showFill = false;

            for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
            {
                if (GM.CurrentMovementManager.Hands[i].CurrentInteractable != null && GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRPhysicalObject)
                {
                    FireArmRoundType curAmmoType = ___m_curAmmoType;
                    if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmMagazine)
                    {
                        FVRFireArmMagazine fvrfireArmMagazine = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArmMagazine;
                        ___m_hasHeldType = true;
                        ___heldType      = fvrfireArmMagazine.RoundType;
                        if (TypeCheck(fvrfireArmMagazine.RoundType == curAmmoType))
                        {
                            showFill = true;
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmClip)
                    {
                        FVRFireArmClip fvrfireArmClip = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArmClip;
                        ___m_hasHeldType = true;
                        ___heldType      = fvrfireArmClip.RoundType;
                        if (TypeCheck(fvrfireArmClip.RoundType == curAmmoType))
                        {
                            showFill = true;
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is Speedloader)
                    {
                        Speedloader speedloader = GM.CurrentMovementManager.Hands[i].CurrentInteractable as Speedloader;
                        ___m_hasHeldType = true;
                        ___heldType      = speedloader.Chambers[0].Type;
                        if (TypeCheck(speedloader.Chambers[0].Type == curAmmoType))
                        {
                            showFill = true;
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArm)
                    {
                        FVRFireArm fvrfireArm = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArm;
                        ___m_hasHeldType = true;
                        ___heldType      = fvrfireArm.RoundType;
                        if (TypeCheck(fvrfireArm.RoundType == curAmmoType) || (fvrfireArm.Magazine != null || fvrfireArm.Clip != null))
                        {
                            showFill = true;
                        }
                    }
                }
            }
            if (showFill && !__instance.BTNGO_Fill.activeSelf)
            {
                __instance.BTNGO_Fill.SetActive(true);
            }
            else if (!showFill && __instance.BTNGO_Fill.activeSelf)
            {
                __instance.BTNGO_Fill.SetActive(false);
            }
            if (___m_hasHeldType && !__instance.BTNGO_Select.activeSelf)
            {
                __instance.BTNGO_Select.SetActive(true);
            }
            else if (!___m_hasHeldType && __instance.BTNGO_Select.activeSelf)
            {
                __instance.BTNGO_Select.SetActive(false);
            }
            return(false);
        }
        public static bool AmmoSpawnerV2_LoadIntoHeldObjects(FireArmRoundType ___m_curAmmoType, FireArmRoundClass ___m_curAmmoClass)
        {
            FireArmRoundType  curAmmoType  = ___m_curAmmoType;
            FireArmRoundClass curAmmoClass = ___m_curAmmoClass;

            for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
            {
                if (GM.CurrentMovementManager.Hands[i].CurrentInteractable != null && GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRPhysicalObject)
                {
                    if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmMagazine)
                    {
                        FVRFireArmMagazine fvrfireArmMagazine = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArmMagazine;
                        if (TypeCheck(fvrfireArmMagazine.RoundType == curAmmoType))
                        {
                            fvrfireArmMagazine.m_numRounds = 0;
                            for (int j = 0; j < fvrfireArmMagazine.LoadedRounds.Length; j++)
                            {
                                fvrfireArmMagazine.AddRound(AM.GetRoundSelfPrefab(curAmmoType, curAmmoClass).GetGameObject().GetComponent <FVRFireArmRound>(), false, true);
                            }
                            fvrfireArmMagazine.UpdateBulletDisplay();
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArmClip)
                    {
                        FVRFireArmClip fvrfireArmClip = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArmClip;
                        if (TypeCheck(fvrfireArmClip.RoundType == curAmmoType))
                        {
                            fvrfireArmClip.m_numRounds = 0;
                            for (int j = 0; j < fvrfireArmClip.LoadedRounds.Length; j++)
                            {
                                fvrfireArmClip.AddRound(AM.GetRoundSelfPrefab(curAmmoType, curAmmoClass).GetGameObject().GetComponent <FVRFireArmRound>(), false, true);
                            }
                            fvrfireArmClip.UpdateBulletDisplay();
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is Speedloader)
                    {
                        Speedloader speedloader = GM.CurrentMovementManager.Hands[i].CurrentInteractable as Speedloader;
                        if (TypeCheck(speedloader.Chambers[0].Type == curAmmoType))
                        {
                            for (int j = 0; j < speedloader.Chambers.Count; j++)
                            {
                                speedloader.Chambers[j].Type = curAmmoType;
                                speedloader.Chambers[j].Load(curAmmoClass);
                            }
                        }
                    }
                    else if (GM.CurrentMovementManager.Hands[i].CurrentInteractable is FVRFireArm)
                    {
                        FVRFireArm fvrfireArm = GM.CurrentMovementManager.Hands[i].CurrentInteractable as FVRFireArm;
                        if (TypeCheck(fvrfireArm.RoundType == curAmmoType))
                        {
                            for (int j = 0; j < fvrfireArm.FChambers.Count; j++)
                            {
                                fvrfireArm.FChambers[j].SetRound(AM.GetRoundSelfPrefab(curAmmoType, curAmmoClass).GetGameObject().GetComponent <FVRFireArmRound>());
                            }
                        }

                        if (TypeCheck(fvrfireArm.RoundType == curAmmoType) && fvrfireArm.Magazine != null)
                        {
                            fvrfireArm.Magazine.m_numRounds = 0;
                            for (int j = 0; j < fvrfireArm.Magazine.LoadedRounds.Length; j++)
                            {
                                fvrfireArm.Magazine.AddRound(AM.GetRoundSelfPrefab(curAmmoType, curAmmoClass).GetGameObject().GetComponent <FVRFireArmRound>(), false, true);
                            }
                            fvrfireArm.Magazine.UpdateBulletDisplay();
                        }
                        if (TypeCheck(fvrfireArm.RoundType == curAmmoType) && fvrfireArm.Clip != null)
                        {
                            fvrfireArm.Clip.m_numRounds = 0;
                            for (int j = 0; j < fvrfireArm.Clip.LoadedRounds.Length; j++)
                            {
                                fvrfireArm.Clip.AddRound(AM.GetRoundSelfPrefab(curAmmoType, curAmmoClass).GetGameObject().GetComponent <FVRFireArmRound>(), false, true);
                            }
                            fvrfireArm.Clip.UpdateBulletDisplay();
                        }
                    }
                }
            }
            return(false);
        }
Пример #10
0
        public static IEnumerator SpawnFirearm(SavedGunSerializable savedGun, Vector3 position, Quaternion rotation)
        {
            List <GameObject>  toDealWith    = new List <GameObject>();
            List <GameObject>  toMoveToTrays = new List <GameObject>();
            FVRFireArm         myGun         = null;
            FVRFireArmMagazine myMagazine    = null;
            List <int>         validIndexes  = new List <int>();
            Dictionary <GameObject, SavedGunComponent> dicGO = new Dictionary <GameObject, SavedGunComponent>();
            Dictionary <int, GameObject>       dicByIndex    = new Dictionary <int, GameObject>();
            List <AnvilCallback <GameObject> > callbackList  = new List <AnvilCallback <GameObject> >();

            SavedGun gun = savedGun.GetSavedGun();

            for (int i = 0; i < gun.Components.Count; i++)
            {
                callbackList.Add(IM.OD[gun.Components[i].ObjectID].GetGameObjectAsync());
            }
            yield return(callbackList);

            for (int j = 0; j < gun.Components.Count; j++)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(callbackList[j].Result);

                dicGO.Add(gameObject, gun.Components[j]);
                dicByIndex.Add(gun.Components[j].Index, gameObject);
                if (gun.Components[j].isFirearm)
                {
                    myGun = gameObject.GetComponent <FVRFireArm>();
                    savedGun.ApplyFirearmProperties(myGun);

                    validIndexes.Add(j);
                    gameObject.transform.position = position;
                    gameObject.transform.rotation = Quaternion.identity;
                }
                else if (gun.Components[j].isMagazine)
                {
                    myMagazine = gameObject.GetComponent <FVRFireArmMagazine>();
                    validIndexes.Add(j);
                    if (myMagazine != null)
                    {
                        gameObject.transform.position = myGun.GetMagMountPos(myMagazine.IsBeltBox).position;
                        gameObject.transform.rotation = myGun.GetMagMountPos(myMagazine.IsBeltBox).rotation;
                        myMagazine.Load(myGun);
                        myMagazine.IsInfinite = false;
                    }
                }
                else if (gun.Components[j].isAttachment)
                {
                    toDealWith.Add(gameObject);
                }
                else
                {
                    toMoveToTrays.Add(gameObject);
                    if (gameObject.GetComponent <Speedloader>() != null && gun.LoadedRoundsInMag.Count > 0)
                    {
                        Speedloader component = gameObject.GetComponent <Speedloader>();
                        component.ReloadSpeedLoaderWithList(gun.LoadedRoundsInMag);
                    }
                    else if (gameObject.GetComponent <FVRFireArmClip>() != null && gun.LoadedRoundsInMag.Count > 0)
                    {
                        FVRFireArmClip component2 = gameObject.GetComponent <FVRFireArmClip>();
                        component2.ReloadClipWithList(gun.LoadedRoundsInMag);
                    }
                }
                gameObject.GetComponent <FVRPhysicalObject>().ConfigureFromFlagDic(gun.Components[j].Flags);
            }
            if (myGun.Magazine != null && gun.LoadedRoundsInMag.Count > 0)
            {
                myGun.Magazine.ReloadMagWithList(gun.LoadedRoundsInMag);
                myGun.Magazine.IsInfinite = false;
            }
            int BreakIterator = 200;

            while (toDealWith.Count > 0 && BreakIterator > 0)
            {
                BreakIterator--;
                for (int k = toDealWith.Count - 1; k >= 0; k--)
                {
                    SavedGunComponent savedGunComponent = dicGO[toDealWith[k]];
                    if (validIndexes.Contains(savedGunComponent.ObjectAttachedTo))
                    {
                        GameObject                gameObject2 = toDealWith[k];
                        FVRFireArmAttachment      component3  = gameObject2.GetComponent <FVRFireArmAttachment>();
                        FVRFireArmAttachmentMount mount       = GetMount(dicByIndex[savedGunComponent.ObjectAttachedTo], savedGunComponent.MountAttachedTo);
                        gameObject2.transform.rotation = Quaternion.LookRotation(savedGunComponent.OrientationForward, savedGunComponent.OrientationUp);
                        gameObject2.transform.position = GetPositionRelativeToGun(savedGunComponent, myGun.transform);
                        if (component3.CanScaleToMount && mount.CanThisRescale())
                        {
                            component3.ScaleToMount(mount);
                        }
                        component3.AttachToMount(mount, false);
                        if (component3 is Suppressor)
                        {
                            (component3 as Suppressor).AutoMountWell();
                        }
                        validIndexes.Add(savedGunComponent.Index);
                        toDealWith.RemoveAt(k);
                    }
                }
            }
            int trayIndex = 0;
            int itemIndex = 0;

            for (int l = 0; l < toMoveToTrays.Count; l++)
            {
                toMoveToTrays[l].transform.position = position + (float)itemIndex * 0.1f * Vector3.up;
                toMoveToTrays[l].transform.rotation = rotation;
                itemIndex++;
                trayIndex++;
                if (trayIndex > 2)
                {
                    trayIndex = 0;
                }
            }
            myGun.SetLoadedChambers(gun.LoadedRoundsInChambers);
            myGun.SetFromFlagList(gun.SavedFlags);
            myGun.transform.rotation = rotation;
            yield break;
        }
Пример #11
0
        private void FVRFireArmMagazine_Release(On.FistVR.FVRFireArmMagazine.orig_Release orig, FVRFireArmMagazine self, bool PhysicalRelease)
        {
            if (Better1911(self.FireArm) && IsLowCapMag(self))
            {
                self.transform.localScale = new Vector3(1f, 1f, 1f);
            }

            orig(self, PhysicalRelease);
        }
Пример #12
0
        public static void FVRFireArmRound_DuplicateFromSpawnLock(FVRFireArmRound __instance, ref GameObject __result, FVRViveHand hand)
        {
            FVRFireArmRound round = __result.GetComponent <FVRFireArmRound>();

            if (_enableSmartPalming.Value && round != null && hand.OtherHand.CurrentInteractable != null)
            {
                int roundsNeeded = 0;

                FVRFireArmMagazine mag = hand.OtherHand.CurrentInteractable.GetComponentInChildren <FVRFireArmMagazine>();
                if (mag != null)
                {
                    roundsNeeded = mag.m_capacity - mag.m_numRounds;
                }

                FVRFireArmClip clip = hand.OtherHand.CurrentInteractable.GetComponentInChildren <FVRFireArmClip>();
                if (clip != null)
                {
                    roundsNeeded = clip.m_capacity - clip.m_numRounds;
                }

                if (hand.OtherHand.CurrentInteractable is FVRFireArm)
                {
                    if (hand.OtherHand.CurrentInteractable is BreakActionWeapon)
                    {
                        BreakActionWeapon baw = hand.OtherHand.CurrentInteractable as BreakActionWeapon;
                        for (int j = 0; j < baw.Barrels.Length; j++)
                        {
                            if (!baw.Barrels[j].Chamber.IsFull)
                            {
                                roundsNeeded += 1;
                            }
                        }
                    }
                    else if (hand.OtherHand.CurrentInteractable is Derringer)
                    {
                        Derringer derringer = hand.OtherHand.CurrentInteractable as Derringer;
                        for (int j = 0; j < derringer.Barrels.Count; j++)
                        {
                            if (!derringer.Barrels[j].Chamber.IsFull)
                            {
                                roundsNeeded += 1;
                            }
                        }
                    }
                    else if (hand.OtherHand.CurrentInteractable is SingleActionRevolver)
                    {
                        SingleActionRevolver saRevolver = hand.OtherHand.CurrentInteractable as SingleActionRevolver;
                        for (int j = 0; j < saRevolver.Cylinder.Chambers.Length; j++)
                        {
                            if (!saRevolver.Cylinder.Chambers[j].IsFull)
                            {
                                roundsNeeded += 1;
                            }
                        }
                    }

                    if (hand.OtherHand.CurrentInteractable.GetType().GetField("Chamber") != null)                     //handles most guns
                    {
                        FVRFireArmChamber Chamber = (FVRFireArmChamber)hand.OtherHand.CurrentInteractable.GetType().GetField("Chamber").GetValue(hand.OtherHand.CurrentInteractable);
                        if (!Chamber.IsFull)
                        {
                            roundsNeeded += 1;
                        }
                    }
                    if (hand.OtherHand.CurrentInteractable.GetType().GetField("Chambers") != null)                     //handles Revolver, LAPD2019, RevolvingShotgun
                    {
                        FVRFireArmChamber[] Chambers = (FVRFireArmChamber[])hand.OtherHand.CurrentInteractable.GetType().GetField("Chambers").GetValue(hand.OtherHand.CurrentInteractable);
                        for (int j = 0; j < Chambers.Length; j++)
                        {
                            if (!Chambers[j].IsFull)
                            {
                                roundsNeeded += 1;
                            }
                        }
                    }
                }

                //if rounds are needed, and if rounds needed is less than the proxy rounds + the real round (1)
                if (roundsNeeded > 0 && roundsNeeded < round.ProxyRounds.Count + 1)
                {
                    for (int i = roundsNeeded - 1; i < round.ProxyRounds.Count; i++)
                    {
                        Destroy(round.ProxyRounds[i].GO);
                    }
                    round.ProxyRounds.RemoveRange(roundsNeeded - 1, (round.ProxyRounds.Count + 1) - roundsNeeded);
                    round.UpdateProxyDisplay();
                }
            }
        }
Пример #13
0
        private void UpdateBulletMode(FVRFireArm firearm)
        {
            if (Attachment != null && Attachment.GetRootObject() != null && Attachment.GetRootObject() == firearm)
            {
                MeatTrak.NumberTarget = 0;

                FVRFireArmMagazine mag = firearm.GetComponentInChildren <FVRFireArmMagazine>();
                if (mag != null)
                {
                    MeatTrak.NumberTarget = mag.m_numRounds;
                }

                FVRFireArmClip clip = firearm.GetComponentInChildren <FVRFireArmClip>();
                if (clip != null)
                {
                    MeatTrak.NumberTarget = clip.m_numRounds;
                }

                if (firearm is FVRFireArm)
                {
                    if (firearm is BreakActionWeapon)
                    {
                        BreakActionWeapon baw = firearm as BreakActionWeapon;
                        for (int j = 0; j < baw.Barrels.Length; j++)
                        {
                            if (baw.Barrels[j].Chamber.IsFull && !baw.Barrels[j].Chamber.IsSpent)
                            {
                                MeatTrak.NumberTarget += 1;
                            }
                        }
                    }
                    else if (firearm is Derringer)
                    {
                        Derringer derringer = firearm as Derringer;
                        for (int j = 0; j < derringer.Barrels.Count; j++)
                        {
                            if (derringer.Barrels[j].Chamber.IsFull && !derringer.Barrels[j].Chamber.IsSpent)
                            {
                                MeatTrak.NumberTarget += 1;
                            }
                        }
                    }
                    else if (firearm is SingleActionRevolver)
                    {
                        SingleActionRevolver saRevolver = firearm as SingleActionRevolver;
                        for (int j = 0; j < saRevolver.Cylinder.Chambers.Length; j++)
                        {
                            if (saRevolver.Cylinder.Chambers[j].IsFull && !saRevolver.Cylinder.Chambers[j].IsSpent)
                            {
                                MeatTrak.NumberTarget += 1;
                            }
                        }
                    }

                    if (firearm.GetType().GetField("Chamber") != null)                     //handles most guns
                    {
                        FVRFireArmChamber Chamber = (FVRFireArmChamber)firearm.GetType().GetField("Chamber").GetValue(firearm);
                        if (Chamber.IsFull && !Chamber.IsSpent)
                        {
                            MeatTrak.NumberTarget += 1;
                        }
                    }
                    if (firearm.GetType().GetField("Chambers") != null)                     //handles Revolver, LAPD2019, RevolvingShotgun
                    {
                        FVRFireArmChamber[] Chambers = (FVRFireArmChamber[])firearm.GetType().GetField("Chambers").GetValue(firearm);
                        for (int j = 0; j < Chambers.Length; j++)
                        {
                            if (Chambers[j].IsFull && !Chambers[j].IsSpent)
                            {
                                MeatTrak.NumberTarget += 1;
                            }
                        }
                    }
                }
            }
        }
Пример #14
0
 static bool GeneralPatch_FailureToExtract(FVRFireArmMagazine __instance)
 {
     MCM.IncRoundsUsed(__instance);
     return(true);
 }