public void PurchaseAmmoButton() { if (detectedFirearm == null || original.M.GetNumTokens() < PanelCost) { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position); return; } else { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position); original.M.SubtractTokens(PanelCost); original.M.Increment(10, false); FVRObject.OTagFirearmRoundPower roundPower = AM.GetRoundPower(detectedFirearm.RoundType); int numSpawned = GetRoundsToSpawn(roundPower); TNHTweakerLogger.Log("Compatible rounds count for " + detectedFirearm.ObjectWrapper.ItemID + ": " + IM.OD[detectedFirearm.ObjectWrapper.ItemID].CompatibleSingleRounds.Count, TNHTweakerLogger.LogType.General); CustomCharacter character = LoadedTemplateManager.LoadedCharactersDict[original.M.C]; MagazineBlacklistEntry blacklistEntry = null; if (character.GetMagazineBlacklist().ContainsKey(detectedFirearm.ObjectWrapper.ItemID)) { blacklistEntry = character.GetMagazineBlacklist()[detectedFirearm.ObjectWrapper.ItemID]; } FVRObject compatibleRound = FirearmUtils.GetCompatibleRounds(detectedFirearm.ObjectWrapper, character.ValidAmmoEras, character.ValidAmmoSets, character.GlobalAmmoBlacklist, blacklistEntry).GetRandom(); AnvilManager.Run(SpawnRounds(compatibleRound, numSpawned)); detectedFirearm = null; UpdateIcons(); } }
public void Start() { firearm = GetComponent <FVRFireArm>(); if (firearm == null) { Console.WriteLine("Cannot find firearm!"); UnityEngine.Object.Destroy(this); } }
private bool Better1911(FVRFireArm gun) { var obj = gun.ObjectWrapper; if (obj != null) { return(obj.ItemID == _tacID || obj.ItemID == "M1911Operator"); } return(false); }
public static bool FVRFireArmAttachment_UpdateSnappingBasedOnDistance(FVRFireArmAttachment __instance) { if (_easyAttachmentAttaching.Value && __instance.m_hand.OtherHand.CurrentInteractable != null && __instance.m_hand.OtherHand.CurrentInteractable is FVRFireArm) { FVRFireArm fvrfireArm = __instance.m_hand.OtherHand.CurrentInteractable as FVRFireArm; float handToMuzzle = Vector3.Distance(__instance.m_hand.OtherHand.transform.position, fvrfireArm.CurrentMuzzle.position) + 0.25f; float distance = Vector3.Distance(__instance.transform.position, fvrfireArm.transform.position); __instance.SetAllCollidersToLayer(false, distance <= handToMuzzle ? "NoCol" : "Default"); } return(true); }
static bool IsTwoHandStabilized_Patch(FVRFireArm __instance, ref bool __result) { __result = false; if (__instance.m_hand != null && __instance.m_hand.OtherHand != null) { float num = Vector3.Distance(__instance.m_hand.PalmTransform.position, __instance.m_hand.OtherHand.PalmTransform.position); if (num < 0.15f) { __result = true; } } return(false); }
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; } } } }
/// <summary> /// Returns a list of all attached objects on the given firearm. This includes attached magazines /// </summary> /// <param name="fireArm">The firearm that is being scanned for attachmnets</param> /// <param name="includeSelf">If true, includes the given firearm as the first item in the list of attached objects</param> /// <returns>A list containing every attached item on the given firearm</returns> public static IEnumerable <FVRPhysicalObject> GetAllAttachedObjects(this FVRFireArm fireArm, bool includeSelf = false) { List <FVRPhysicalObject> detectedObjects = new List <FVRPhysicalObject>(); if (includeSelf) { detectedObjects.Add(fireArm); } if (fireArm.Magazine is not null && !fireArm.Magazine.IsIntegrated && fireArm.Magazine.ObjectWrapper is not null) { detectedObjects.Add(fireArm.Magazine); } detectedObjects.AddRange(fireArm.Attachments.Where(attachment => attachment.ObjectWrapper is not null).Cast <FVRPhysicalObject>()); return(detectedObjects); }
private void ShotFiredEvent(FVRFireArm firearm) { if (firearm == null) { return; } if (Attachment != null && Attachment.GetRootObject() != null && Attachment.GetRootObject() == firearm) { if (MeatTrak != null && TrackingMode == TrackingModes.Shots) { MeatTrak.NumberTarget++; } else if (TrackingMode == TrackingModes.Bullets) { UpdateBulletMode(firearm); } } }
private void Scan() { int colliderCount = Physics.OverlapBoxNonAlloc(original.ScanningVolume.position, original.ScanningVolume.localScale * 0.5f, colBuffer, original.ScanningVolume.rotation, original.ScanningLM, QueryTriggerInteraction.Collide); detectedFirearm = null; for (int i = 0; i < colliderCount; i++) { if (colBuffer[i].attachedRigidbody != null) { FVRFireArm firearm = colBuffer[i].GetComponent <FVRFireArm>(); if (firearm != null && !firearm.IsHeld && firearm.QuickbeltSlot == null) { detectedFirearm = firearm; return; } } } }
public void OnDetach() { if (ChangesRecoil) { RecoilModifier(actionType.detach); } if (ChangesMagCapacity) { MagSizeModifier(actionType.detach); } if (ChangesBoltSpeed) { BoltSpeedModifier(actionType.detach); } //if (ChangesFireSelector) FireSelectorModifier(actionType.detach); if (ChangesGrabPos) { ChangeGrabPos(actionType.detach); } weapon = null; }
public void OnAttach() { weapon = attachment.curMount.Parent.GetComponent <FVRFireArm>(); if (ChangesRecoil) { RecoilModifier(actionType.attach); } if (ChangesMagCapacity) { MagSizeModifier(actionType.attach); } if (ChangesBoltSpeed) { BoltSpeedModifier(actionType.attach); } //if (ChangesFireSelector) FireSelectorModifier(actionType.attach); if (ChangesGrabPos) { ChangeGrabPos(actionType.attach); } }
static bool BreakActionPatch_FailureToExtract(BreakActionWeapon __instance, FVRFireArm chamber) { if (!Meatyceiver.enableFirearmFailures.Value) { return(true); } if (MCM.HasFlag(chamber, states.StuckRound)) { return(false); } float chance = Meatyceiver.breakActionFTE.Value * (Meatyceiver.generalMult.Value - 1) * Meatyceiver.breakActionFTEMultAffect.Value; if (Meatyceiver.CalcFail(chance, __instance)) { MCM.AddFlag(chamber, states.StuckRound); return(false); } return(true); }
static bool DefaultPatch_FailureToFeed(FVRFireArm __instance) { float failureinc = 0; if (!isFirearmFailEnabled) { return(true); } if (__instance.Magazine != null && Meatyceiver.enableMagUnreliability.Value) { if (!__instance.Magazine.IsBeltBox) { //if the box mag's cap is over the cap that would begin failures if (__instance.Magazine.m_capacity > Meatyceiver.minRoundCount.Value) { //diff between mag cap and min round cap and multuiply by failure inc per round float baseFailureInc = (__instance.Magazine.m_capacity - Meatyceiver.minRoundCount.Value) * Meatyceiver.failureIncPerRound.Value; //failure inc = the failure inc * general mult - 1 * mag unreliability (?) failureinc = baseFailureInc + (baseFailureInc * Meatyceiver.generalMult.Value - 1 * Meatyceiver.magUnreliabilityGenMultAffect.Value); } } } //then calculate the rate, + what we just got before float chance = Meatyceiver.HFRate.Value * Meatyceiver.generalMult.Value + failureinc; //throw that meat pile n calc if (Meatyceiver.CalcFail(chance, __instance)) { return(false); } return(true); }
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); }
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; } } } } } }
public void ApplyFirearmProperties(FVRFireArm firearm) { if (!OverrideFireRate && !OverrideFireSelectors) { return; } Handgun handgunComp = firearm.gameObject.GetComponent <Handgun>(); if (handgunComp != null) { if (OverrideFireSelectors) { List <Handgun.FireSelectorMode> modeList = new List <Handgun.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetHandgunMode()); } handgunComp.FireSelectorModes = modeList.ToArray(); } if (OverrideFireRate) { handgunComp.Slide.Speed_Forward = SpeedForward; handgunComp.Slide.Speed_Rearward = SpeedRearward; handgunComp.Slide.SpringStiffness = SpringStiffness; } return; } ClosedBoltWeapon closedBoltComp = firearm.gameObject.GetComponent <ClosedBoltWeapon>(); if (closedBoltComp != null) { if (OverrideFireSelectors) { List <ClosedBoltWeapon.FireSelectorMode> modeList = new List <ClosedBoltWeapon.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetClosedBoltMode()); } closedBoltComp.FireSelector_Modes = modeList.ToArray(); } if (OverrideFireRate) { closedBoltComp.Bolt.Speed_Forward = SpeedForward; closedBoltComp.Bolt.Speed_Rearward = SpeedRearward; closedBoltComp.Bolt.SpringStiffness = SpringStiffness; } return; } OpenBoltReceiver openBoltComp = firearm.gameObject.GetComponent <OpenBoltReceiver>(); if (openBoltComp != null) { if (OverrideFireSelectors) { List <OpenBoltReceiver.FireSelectorMode> modeList = new List <OpenBoltReceiver.FireSelectorMode>(); foreach (FireSelectorMode mode in FireSelectorModes) { modeList.Add(mode.GetOpenBoltMode()); } openBoltComp.FireSelector_Modes = modeList.ToArray(); } if (OverrideFireRate) { openBoltComp.Bolt.BoltSpeed_Forward = SpeedForward; openBoltComp.Bolt.BoltSpeed_Rearward = SpeedRearward; openBoltComp.Bolt.BoltSpringStiffness = SpringStiffness; } return; } }
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; }