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 int GetRoundsToSpawn(FVRObject.OTagFirearmRoundPower roundPower) { if (roundPower == FVRObject.OTagFirearmRoundPower.Shotgun) { return(18); } if (roundPower == FVRObject.OTagFirearmRoundPower.Pistol) { return(30); } if (roundPower == FVRObject.OTagFirearmRoundPower.Tiny) { return(30); } if (roundPower == FVRObject.OTagFirearmRoundPower.Intermediate) { return(20); } if (roundPower == FVRObject.OTagFirearmRoundPower.FullPower) { return(16); } if (roundPower == FVRObject.OTagFirearmRoundPower.Exotic) { return(16); } if (roundPower == FVRObject.OTagFirearmRoundPower.AntiMaterial) { return(6); } if (roundPower == FVRObject.OTagFirearmRoundPower.Ordnance) { return(3); } return(10); }