예제 #1
0
        public void AddProxy(FireArmRoundClass roundClass, FVRObject prefabWrapper)
        {
            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         = roundClass;
            proxyRound.Type          = prefabWrapper.GetGameObject().GetComponent <FVRFireArmRound>().RoundType;
            proxyRound.ObjectWrapper = prefabWrapper;
            this.ProxyRounds.Add(proxyRound);
        }
예제 #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(FireArmRoundClass rClass, bool makeSound, bool updateDisplay)
 {
     if (this.m_numRounds < this.m_capacity)
     {
         this.m_timeSinceRoundInserted = 0f;
         FVRLoadedRound fvrloadedRound = new 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)
         {
             SM.PlayGenericSound(this.InsertOntoClip, base.transform.position);
         }
     }
     if (updateDisplay)
     {
         this.UpdateBulletDisplay();
     }
 }
 public static bool AM_getRoundSelfPrefab(FireArmRoundType rType, FireArmRoundClass rClass, Dictionary <FireArmRoundType, Dictionary <FireArmRoundClass, FVRFireArmRoundDisplayData.DisplayDataClass> > ___TypeDic, ref FVRObject __result)
 {
     try { __result = ___TypeDic[rType][rClass].ObjectID; return(false); }
     catch { __result = ___TypeDic[FireArmRoundType.a45_ACP][FireArmRoundClass.FMJ].ObjectID; return(false); }
 }
 public static bool AM_getRoundMaterial(FireArmRoundType rType, FireArmRoundClass rClass, Dictionary <FireArmRoundType, Dictionary <FireArmRoundClass, FVRFireArmRoundDisplayData.DisplayDataClass> > ___TypeDic, ref Material __result)
 {
     try { __result = ___TypeDic[rType][rClass].Material; return(false); }
     catch { __result = ___TypeDic[FireArmRoundType.a45_ACP][FireArmRoundClass.FMJ].Material; return(false); }
 }
        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);
        }