예제 #1
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();
                }
            }
        }
예제 #2
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;
                            }
                        }
                    }
                }
            }
        }