Пример #1
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;
     }
 }
Пример #2
0
 public void AddRound(FireArmRoundClass rClass, bool makeSound, bool updateDisplay)
 {
     if (this.m_numRounds < this.m_capacity)
     {
         this.m_timeSinceRoundInserted = 0f;
         patch_FVRLoadedRound fvrloadedRound = new patch_FVRLoadedRound();
         fvrloadedRound.LR_Class             = rClass;
         fvrloadedRound.LR_Type              = this.RoundType;
         fvrloadedRound.LR_Mesh              = AM.GetRoundMesh(this.RoundType, rClass);
         fvrloadedRound.LR_Material          = AM.GetRoundMaterial(this.RoundType, rClass);
         fvrloadedRound.LR_ObjectWrapper     = AM.GetRoundSelfPrefab(this.RoundType, rClass);
         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.UsesOverrideInOut)
             {
                 SM.PlayGenericSound(this.ProfileOverride.MagazineInsertRound, base.transform.position);
             }
             else
             {
                 SM.PlayGenericSound(this.Profile.MagazineInsertRound, base.transform.position);
             }
         }
     }
     if (updateDisplay)
     {
         this.UpdateBulletDisplay();
     }
 }
Пример #3
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();
     }
 }
        public static bool SpeedloaderChamber_LoadEmpty(SpeedloaderChamber __instance, FireArmRoundClass rclass, bool playSound = false)
        {
            __instance.IsLoaded    = true;
            __instance.IsSpent     = true;
            __instance.LoadedClass = rclass;

            if (AM.GetRoundSelfPrefab(__instance.Type, __instance.LoadedClass).GetGameObject().GetComponent <FVRFireArmRound>().FiredRenderer != null)
            {
                __instance.Filter.mesh             = AM.GetRoundSelfPrefab(__instance.Type, __instance.LoadedClass).GetGameObject().GetComponent <FVRFireArmRound>().FiredRenderer.gameObject.GetComponent <MeshFilter>().sharedMesh;
                __instance.LoadedRenderer.material = AM.GetRoundMaterial(__instance.Type, __instance.LoadedClass);
                __instance.LoadedRenderer.enabled  = true;
                if (playSound && __instance.SpeedLoader.ProfileOverride != null)
                {
                    SM.PlayGenericSound(__instance.SpeedLoader.ProfileOverride.MagazineInsertRound, __instance.transform.position);
                }
            }
            else
            {
                __instance.IsLoaded = false;
                __instance.LoadedRenderer.enabled = 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);
        }