Example #1
0
        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();
            }
        }
Example #2
0
        private void UpdateIcons()
        {
            DupeIcon.State     = TNH_ObjectConstructorIcon.IconState.Cancel;
            UpgradeIcon.State  = TNH_ObjectConstructorIcon.IconState.Cancel;
            PurchaseIcon.State = TNH_ObjectConstructorIcon.IconState.Cancel;

            if (detectedMag != null || detectedSpeedLoader != null)
            {
                DupeIcon.State = TNH_ObjectConstructorIcon.IconState.Accept;
            }

            if (purchaseMag != null)
            {
                PurchaseIcon.State = TNH_ObjectConstructorIcon.IconState.Accept;
            }

            if (detectedMag != null)
            {
                upgradeMag = FirearmUtils.GetNextHighestCapacityMagazine(detectedMag.ObjectWrapper);
                if (upgradeMag != null)
                {
                    UpgradeIcon.State = TNH_ObjectConstructorIcon.IconState.Accept;
                }
            }

            DupeIcon.UpdateIconDisplay();
            UpgradeIcon.UpdateIconDisplay();
            PurchaseIcon.UpdateIconDisplay();
        }
Example #3
0
        private void DupeMagButton()
        {
            if ((detectedMag == null && detectedSpeedLoader == null) || original.M.GetNumTokens() < DupeCost)
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position);
            }

            else
            {
                SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position);
                original.M.SubtractTokens(DupeCost);
                original.M.Increment(10, false);

                if (detectedMag != null)
                {
                    TNHTweaker.HoldActions[original.M.m_level].Add($"Duplicated {detectedMag.ObjectWrapper.DisplayName}");
                    FirearmUtils.SpawnDuplicateMagazine(detectedMag, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
                }

                else
                {
                    TNHTweaker.HoldActions[original.M.m_level].Add($"Duplicated {detectedSpeedLoader.ObjectWrapper.DisplayName}");
                    FirearmUtils.SpawnDuplicateSpeedloader(detectedSpeedLoader, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
                }

                detectedMag         = null;
                detectedSpeedLoader = null;
                UpdateIcons();
            }
        }
Example #4
0
        void OnDestroy()
        {
            if (dontDrop)
            {
                return;
            }

            TNHTweakerLogger.Log("TNHTweaker -- Lootable link was destroyed!", TNHTweakerLogger.LogType.TNH);

            List <EquipmentGroup> selectedGroups = group.GetSpawnedEquipmentGroups();
            string selectedItem;
            int    spawnedItems = 0;

            foreach (EquipmentGroup selectedGroup in selectedGroups)
            {
                for (int itemIndex = 0; itemIndex < selectedGroup.ItemsToSpawn; itemIndex++)
                {
                    if (selectedGroup.IsCompatibleMagazine)
                    {
                        FVRObject mag = FirearmUtils.GetAmmoContainerForEquipped(selectedGroup.MinAmmoCapacity, selectedGroup.MaxAmmoCapacity);
                        if (mag != null)
                        {
                            selectedItem = mag.ItemID;
                        }
                        else
                        {
                            TNHTweakerLogger.Log(
                                "TNHTweaker -- Spawning nothing, since group was compatible magazines, and could not find a compatible magazine for player",
                                TNHTweakerLogger.LogType.TNH);
                            return;
                        }
                    }

                    else
                    {
                        selectedItem = selectedGroup.GetObjects().GetRandom();
                    }

                    if (LoadedTemplateManager.LoadedVaultFiles.ContainsKey(selectedItem))
                    {
                        AnvilManager.Run(TNHTweakerUtils.SpawnFirearm(LoadedTemplateManager.LoadedVaultFiles[selectedItem],
                                                                      transform.position + (Vector3.up * 0.1f * spawnedItems), transform.rotation));
                    }
                    else
                    {
                        Instantiate(IM.OD[selectedItem].GetGameObject(), transform.position + (Vector3.up * 0.1f * spawnedItems), transform.rotation);
                    }

                    spawnedItems += 1;
                }
            }
        }
Example #5
0
        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;
                    }
                }
            }
        }