Esempio n. 1
0
        public void PalmRound(FVRFireArmRound round, bool insertAtFront, bool updateDisplay, int addAtIndex = 0)
        {
            SM.PlayHandlingGrabSound(this.HandlingGrabSound, base.transform.position, false);
            patch_FVRFireArmRound.ProxyRound proxyRound = new patch_FVRFireArmRound.ProxyRound();
            GameObject gameObject = new GameObject("Proxy");

            proxyRound.GO = gameObject;
            gameObject.transform.SetParent(base.transform);
            proxyRound.Filter        = gameObject.AddComponent <MeshFilter>();
            proxyRound.Renderer      = gameObject.AddComponent <MeshRenderer>();
            proxyRound.Class         = round.RoundClass;
            proxyRound.Type          = round.RoundType;
            proxyRound.ObjectWrapper = round.ObjectWrapper;
            if (insertAtFront)
            {
                for (int i = this.ProxyRounds.Count - 1; i >= 1; i--)
                {
                    this.ProxyRounds[i] = this.ProxyRounds[i - 1];
                }
                this.ProxyRounds[0] = proxyRound;
            }
            else
            {
                this.ProxyRounds.Add(proxyRound);
            }
            this.HoveredOverRound = null;
            UnityEngine.Object.Destroy(round.gameObject);
            if (updateDisplay)
            {
                this.UpdateProxyDisplay();
            }
        }
        public static bool FVRFireArmClip_LoadOneRoundFromClipToMag(FVRFireArmClip __instance)
        {
            if (__instance.FireArm == null || __instance.FireArm.Magazine == null || __instance.FireArm.Magazine.IsFull() || !__instance.HasARound())
            {
                return(false);
            }
            FVRFireArmRound rnd = __instance.RemoveRound(false).GetComponent <FVRFireArmRound>();

            SM.PlayGenericSound(__instance.LoadFromClipToMag, __instance.transform.position);
            __instance.FireArm.Magazine.AddRound(rnd, false, true);
            return(false);
        }
Esempio n. 3
0
 public void AddRound(FVRFireArmRound round, bool makeSound, bool updateDisplay, bool animate)
 {
     if (this.m_numRounds < this.m_capacity)
     {
         this.m_timeSinceRoundInserted = 0f;
         patch_FVRLoadedRound fvrloadedRound = new patch_FVRLoadedRound();
         fvrloadedRound.LR_Class             = round.RoundClass;
         fvrloadedRound.LR_Type              = round.RoundType;
         fvrloadedRound.LR_Mesh              = AM.GetRoundMesh(round.RoundType, round.RoundClass);
         fvrloadedRound.LR_Material          = AM.GetRoundMaterial(round.RoundType, round.RoundClass);
         fvrloadedRound.LR_ObjectWrapper     = AM.GetRoundSelfPrefab(round.RoundType, round.RoundClass);
         this.LoadedRounds[this.m_numRounds] = fvrloadedRound;
         this.m_numRounds++;
         if (makeSound)
         {
             if (this.FireArm != null)
             {
                 if (this.m_numRounds >= this.m_capacity)
                 {
                     this.FireArm.PlayAudioEvent(FirearmAudioEventType.MagazineInsertRound, 0.8f);
                 }
                 else
                 {
                     this.FireArm.PlayAudioEvent(FirearmAudioEventType.MagazineInsertRound, 1f);
                 }
             }
             else if (this.m_numRounds >= this.m_capacity)
             {
                 SM.PlayCoreSoundOverrides(FVRPooledAudioType.Generic, this.Profile.MagazineInsertRound, base.transform.position, this.Profile.MagazineInsertRound.VolumeRange * 1f, this.Profile.MagazineInsertRound.PitchRange * 0.8f);
             }
             else
             {
                 SM.PlayCoreSound(FVRPooledAudioType.Generic, this.Profile.MagazineInsertRound, base.transform.position);
             }
         }
     }
     if (updateDisplay)
     {
         this.UpdateBulletDisplay();
     }
     if (animate && this.m_canAnimate)
     {
         this.DisplayBullets[0].transform.position = round.transform.position;
         this.DisplayBullets[0].transform.rotation = round.transform.rotation;
         this.m_roundInsertionStartPos             = round.transform.position;
         this.m_roundInsertionStartRot             = round.transform.rotation;
         this.m_roundInsertionLerp = 0f;
     }
 }
 public static bool RoundPatch_InsertEmptyRound(FVRFireArmRound __instance, ref Collider collider)
 {
     if (__instance.isManuallyChamberable && __instance.HoveredOverChamber == null && __instance.m_hoverOverReloadTrigger == null && collider.gameObject.CompareTag("FVRFireArmChamber"))
     {
         FVRFireArmChamber component = collider.gameObject.GetComponent <FVRFireArmChamber>();
         if (component.RoundType == __instance.RoundType && component.IsManuallyChamberable && component.IsAccessible && !component.IsFull)
         {
             __instance.HoveredOverChamber = component;
         }
     }
     if (__instance.isMagazineLoadable && __instance.HoveredOverChamber == null && collider.gameObject.CompareTag("FVRFireArmMagazineReloadTrigger"))
     {
         FVRFireArmMagazineReloadTrigger component2 = collider.gameObject.GetComponent <FVRFireArmMagazineReloadTrigger>();
         if (component2.IsClipTrigger)
         {
             if (component2 != null && component2.Clip != null && component2.Clip.RoundType == __instance.RoundType && !component2.Clip.IsFull() && (component2.Clip.FireArm == null || component2.Clip.IsDropInLoadable))
             {
                 __instance.m_hoverOverReloadTrigger = component2;
             }
         }
         else if (component2.IsSpeedloaderTrigger)
         {
             if (!component2.SpeedloaderChamber.IsLoaded)
             {
                 __instance.m_hoverOverReloadTrigger = component2;
             }
         }
         else if (component2 != null && component2.Magazine != null && component2.Magazine.RoundType == __instance.RoundType && !component2.Magazine.IsFull() && (component2.Magazine.FireArm == null || component2.Magazine.IsDropInLoadable))
         {
             __instance.m_hoverOverReloadTrigger = component2;
         }
     }
     if (__instance.isPalmable && __instance.ProxyRounds.Count < __instance.MaxPalmedAmount && collider.gameObject.CompareTag("FVRFireArmRound"))
     {
         FVRFireArmRound component3 = collider.gameObject.GetComponent <FVRFireArmRound>();
         if (component3.RoundType == __instance.RoundType && component3.QuickbeltSlot == null)
         {
             __instance.HoveredOverRound = component3;
         }
     }
     return(false);
 }
Esempio n. 5
0
 public void AddRound(FVRFireArmRound round, bool makeSound, bool updateDisplay)
 {
     if (this.m_numRounds < this.m_capacity)
     {
         this.m_timeSinceRoundInserted = 0f;
         FVRLoadedRound fvrloadedRound = new FVRLoadedRound();
         fvrloadedRound.LR_Class             = round.RoundClass;
         fvrloadedRound.LR_Type              = round.RoundType;
         fvrloadedRound.LR_Mesh              = AM.GetRoundMesh(round.RoundType, round.RoundClass);
         fvrloadedRound.LR_Material          = AM.GetRoundMaterial(round.RoundType, round.RoundClass);
         fvrloadedRound.LR_ObjectWrapper     = AM.GetRoundSelfPrefab(round.RoundType, round.RoundClass);
         this.LoadedRounds[this.m_numRounds] = fvrloadedRound;
         this.m_numRounds++;
         if (makeSound)
         {
             SM.PlayGenericSound(this.InsertOntoClip, base.transform.position);
         }
     }
     if (updateDisplay)
     {
         this.UpdateBulletDisplay();
     }
 }
Esempio n. 6
0
        public void ChangeSpread()
        {
            FVRFireArmRound rnd = null;

            if (weapon is OpenBoltReceiver)
            {
                var wep = weapon as OpenBoltReceiver;
                rnd = wep.Chamber.GetRound();
            }
            else if (weapon is ClosedBoltWeapon)
            {
                var wep = weapon as ClosedBoltWeapon;
                rnd = wep.Chamber.GetRound();
            }
            else if (weapon is Handgun)
            {
                var wep = weapon as Handgun;
                rnd = wep.Chamber.GetRound();
            }
            else if (weapon is TubeFedShotgun)
            {
                var wep = weapon as TubeFedShotgun;
                rnd = wep.Chamber.GetRound();
            }

            if (rnd == null)
            {
                return;
            }

            if (rnd.ThrowAngMultiplier != 1.1)
            {
                rnd.ThrowAngMultiplier = 1.1f;
                rnd.ProjectileSpread  *= spreadmult;
            }
        }
 public static bool AddChamberableToRound(FVRFireArmRound __instance)
 {
     __instance.isManuallyChamberable = true;
     return(true);
 }
Esempio n. 8
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();
                }
            }
        }
Esempio n. 9
0
 static bool DefaultPatch_LightPrimerStrike(ref bool __result, FVRFireArmChamber __instance, FVRFireArmRound ___m_round)
 {
     if (__instance.Firearm is Revolver || __instance.Firearm is RevolvingShotgun)
     {
         return(true);
     }
     if (CalcLightPrimerStrikeFail(__instance.Firearm))
     {
         return(true);
     }
     __result = false;
     return(false);
 }