/// <summary> /// Returns a list of magazines, clips, or speedloaders compatible with the firearm, and also within any of the optional criteria /// </summary> /// <param name="firearm">The FVRObject of the firearm</param> /// <param name="minCapacity">The minimum capacity for desired containers</param> /// <param name="maxCapacity">The maximum capacity for desired containers. If this values is zero or negative, it is interpreted as no capacity ceiling</param> /// <param name="smallestIfEmpty">If true, when the returned list would normally be empty, will instead return the smallest capacity magazine compatible with the firearm</param> /// <param name="blacklistedContainers">A list of ItemIDs for magazines, clips, or speedloaders that will be excluded</param> /// <returns> A list of ammo container FVRObjects that are compatible with the given firearm </returns> public static List <FVRObject> GetCompatibleAmmoContainers(FVRObject firearm, int minCapacity = 0, int maxCapacity = 9999, bool smallestIfEmpty = true, MagazineBlacklistEntry blacklist = null) { //Refresh the FVRObject to have data directly from object dictionary firearm = IM.OD[firearm.ItemID]; //If the max capacity is zero or negative, we iterpret that as no limit on max capacity if (maxCapacity <= 0) { maxCapacity = 9999; } //Create a list containing all compatible ammo containers List <FVRObject> compatibleContainers = new List <FVRObject>(); if (firearm.CompatibleSpeedLoaders is not null) { compatibleContainers.AddRange(firearm.CompatibleSpeedLoaders); } //Go through each magazine and add compatible ones foreach (FVRObject magazine in firearm.CompatibleMagazines) { if (blacklist is not null && (!blacklist.IsMagazineAllowed(magazine.ItemID))) { continue; }
private void RegisterItemIntoMetaTagSystem(ItemSpawnerEntry entry) { if (!IM.OD.ContainsKey(entry.MainObjectID)) { return; } FVRObject mainObject = IM.OD[entry.MainObjectID]; string pageString = entry.EntryPath.Split('/')[0]; string subCategoryString = entry.EntryPath.Split('/')[1]; ItemSpawnerV2.PageMode page = ItemSpawnerV2.PageMode.Firearms; if (Enum.IsDefined(typeof(ItemSpawnerV2.PageMode), pageString)) { page = (ItemSpawnerV2.PageMode)Enum.Parse(typeof(ItemSpawnerV2.PageMode), pageString); } ItemSpawnerID.ESubCategory subCategory = ItemSpawnerID.ESubCategory.None; if (Enum.IsDefined(typeof(ItemSpawnerID.ESubCategory), subCategoryString)) { subCategory = (ItemSpawnerID.ESubCategory)Enum.Parse(typeof(ItemSpawnerID.ESubCategory), subCategoryString); } IM.AddMetaTag(subCategoryString, TagType.SubCategory, entry.MainObjectID, page); entry.ModTags.ForEach(tag => IM.AddMetaTag(tag, TagType.ModTag, entry.MainObjectID, page)); RegisterItemIntoMetaTagSystem(mainObject, page); }
private GameObject UpdateCurrentGameObj(GameObject obj) { if (obj != null) { m_currentGameObj = obj; m_currentFVRObj = null; m_currentFVRPhysObj = null; m_currentItemSpawnerID = null; if (m_currentGameObj.GetComponentInChildren <FVRPhysicalObject>() != null) { m_currentFVRPhysObj = m_currentGameObj.GetComponentInChildren <FVRPhysicalObject>(); m_currentFVRObj = m_currentFVRPhysObj.ObjectWrapper; m_currentItemSpawnerID = m_currentFVRPhysObj.IDSpawnedFrom; #if !UNITY_EDITOR && !UNITY_STANDALONE if (m_currentFVRObj != null && IM.HasSpawnedID(m_currentFVRObj.SpawnedFromId)) { m_currentItemSpawnerID = IM.GetSpawnerID(m_currentFVRObj.SpawnedFromId); } #endif } SpawnerRefreshElements(); } return(m_currentGameObj); }
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(); }
//we want to spawn a flashbang infront of the player with little notice private void SpawnFlash() { // Get the object you want to spawn FVRObject obj = IM.OD["PinnedGrenadeXM84"]; // Instantiate (spawn) the object above the player head Logger.LogInfo("Spawned Object"); GameObject go = Instantiate(obj.GetGameObject(), new Vector3(0f, .25f, 0f) + GM.CurrentPlayerBody.Head.position, GM.CurrentPlayerBody.Head.rotation); //prime the flash object Logger.LogInfo("Getting Component"); PinnedGrenade grenade = go.GetComponentInChildren <PinnedGrenade>(); Logger.LogInfo("Releasing Lever"); grenade.ReleaseLever(); //add force Logger.LogInfo("Adding Force"); go.GetComponent <Rigidbody>().AddForce(GM.CurrentPlayerBody.Head.forward * 500); }
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(); } }
//TODO To choose spawn based on IFF, we need to basically generate spawn points on our own in this method! public static TNH_Manager.SosigPatrolSquad GeneratePatrol(TNH_Manager instance, Patrol patrol, List <Vector3> SpawnPoints, List <Vector3> ForwardVectors, List <Vector3> PatrolPoints, int patrolIndex) { TNH_Manager.SosigPatrolSquad squad = new TNH_Manager.SosigPatrolSquad(); squad.PatrolPoints = new List <Vector3>(PatrolPoints); for (int i = 0; i < patrol.PatrolSize && i < SpawnPoints.Count; i++) { SosigEnemyTemplate template; bool allowAllWeapons; //If this is a boss, then we can only spawn it once, so add it to the list of spawned bosses if (patrol.IsBoss) { TNHTweaker.SpawnedBossIndexes.Add(patrolIndex); } //Select a sosig template from the custom character patrol if (i == 0) { template = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.LeaderType]]; allowAllWeapons = true; } else { template = IM.Instance.odicSosigObjsByID[(SosigEnemyID)LoadedTemplateManager.SosigIDDict[patrol.EnemyType.GetRandom()]]; allowAllWeapons = false; } CustomCharacter character = LoadedTemplateManager.LoadedCharactersDict[instance.C]; SosigTemplate customTemplate = LoadedTemplateManager.LoadedSosigsDict[template]; FVRObject droppedObject = instance.Prefab_HealthPickupMinor; //If squad is set to swarm, the first point they path to should be the players current position Sosig sosig; if (patrol.SwarmPlayer) { squad.PatrolPoints[0] = GM.CurrentPlayerBody.transform.position; sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons); sosig.SetAssaultSpeed(patrol.AssualtSpeed); } else { sosig = SpawnEnemy(customTemplate, character, SpawnPoints[i], Quaternion.LookRotation(ForwardVectors[i], Vector3.up), instance.AI_Difficulty, patrol.IFFUsed, true, squad.PatrolPoints[0], allowAllWeapons); sosig.SetAssaultSpeed(patrol.AssualtSpeed); } //Handle patrols dropping health if (i == 0 && UnityEngine.Random.value < patrol.DropChance) { sosig.Links[1].RegisterSpawnOnDestroy(droppedObject); } squad.Squad.Add(sosig); } return(squad); }
/// <summary> /// Spawn the object this marker describes. /// You can call this from a trigger! /// </summary> public void Spawn() { Debug.Log("Loading Anvil Asset: " + ResourceDefs.AnvilAssetResources[prefab]); FVRObject obj = Resources.Load <FVRObject>(ResourceDefs.AnvilAssetResources[prefab]); GameObject go = Instantiate(obj.GetGameObject(), transform.position, transform.rotation, ObjectReferences.CustomScene.transform); go.SetActive(true); }
private GameObject UpdateCurrentGameObj(FVRObject fvrObj) { if (fvrObj != null && fvrObj.GetGameObject() != null) { return(UpdateCurrentGameObj(fvrObj.GetGameObject())); } return(null); }
private static bool ShouldIncludeMagazine(FVRObject item, Dictionary <TagType, List <string> > tagQuery) { if (tagQuery[TagType.MagazineType].Count > 0 && !tagQuery[TagType.MagazineType].Contains(item.MagazineType.ToString())) { return(false); } return(true); }
/// <summary> /// Returns a list of magazines, clips, or speedloaders compatible with the firearm, and also within any of the optional criteria /// </summary> /// <param name="firearm">The FVRObject of the firearm</param> /// <param name="minCapacity">The minimum capacity for desired containers</param> /// <param name="maxCapacity">The maximum capacity for desired containers. If this values is zero or negative, it is interpreted as no capacity ceiling</param> /// <param name="smallestIfEmpty">If true, when the returned list would normally be empty, will instead return the smallest capacity magazine compatible with the firearm</param> /// <param name="blacklistedContainers">A list of ItemIDs for magazines, clips, or speedloaders that will be excluded</param> /// <returns> A list of ammo container FVRObjects that are compatible with the given firearm </returns> public static IEnumerable <FVRObject> GetCompatibleAmmoContainers(this FVRObject firearm, int minCapacity = 0, int maxCapacity = 9999, bool smallestIfEmpty = true, IEnumerable <string>?blacklistedContainers = null) { //Refresh the FVRObject to have data directly from object dictionary firearm = IM.OD[firearm.ItemID]; //If the max capacity is zero or negative, we iterpret that as no limit on max capacity if (maxCapacity <= 0) { maxCapacity = 9999; } //Create a list containing all compatible ammo containers List <FVRObject> compatibleContainers = new List <FVRObject>(); if (firearm.CompatibleMagazines is not null) { compatibleContainers.AddRange(firearm.CompatibleMagazines); } if (firearm.CompatibleClips is not null) { compatibleContainers.AddRange(firearm.CompatibleClips); } if (firearm.CompatibleSpeedLoaders is not null) { compatibleContainers.AddRange(firearm.CompatibleSpeedLoaders); } //Go through these containers and remove any that don't fit given criteria for (int i = compatibleContainers.Count - 1; i >= 0; i--) { if (blacklistedContainers is not null && blacklistedContainers.Contains(compatibleContainers[i].ItemID)) { compatibleContainers.RemoveAt(i); } if (compatibleContainers[i].MagazineCapacity <minCapacity || compatibleContainers[i].MagazineCapacity> maxCapacity) { compatibleContainers.RemoveAt(i); } } //If the resulting list is empty, and smallestIfEmpty is true, add the smallest capacity magazine to the list if (compatibleContainers.Count != 0 || !smallestIfEmpty || firearm.CompatibleMagazines is null) { return(compatibleContainers); } FVRObject?magazine = GetSmallestCapacityMagazine(firearm.CompatibleMagazines); if (magazine is not null) { compatibleContainers.Add(magazine); } return(compatibleContainers); }
private static bool ShouldIncludeFirearm(FVRObject item, Dictionary <TagType, List <string> > tagQuery) { if (tagQuery[TagType.Size].Count > 0 && !tagQuery[TagType.Size].Contains(item.TagFirearmSize.ToString())) { return(false); } if (tagQuery[TagType.Action].Count > 0 && !tagQuery[TagType.Action].Contains(item.TagFirearmAction.ToString())) { return(false); } if (tagQuery[TagType.RoundClass].Count > 0 && !tagQuery[TagType.RoundClass].Contains(item.TagFirearmRoundPower.ToString())) { return(false); } if (tagQuery[TagType.CountryOfOrigin].Count > 0 && !tagQuery[TagType.CountryOfOrigin].Contains(item.TagFirearmCountryOfOrigin.ToString())) { return(false); } if (tagQuery[TagType.IntroductionYear].Count > 0 && !tagQuery[TagType.IntroductionYear].Contains(item.TagFirearmFirstYear.ToString())) { return(false); } if (tagQuery[TagType.MagazineType].Count > 0 && !tagQuery[TagType.MagazineType].Contains(item.MagazineType.ToString())) { return(false); } if (tagQuery[TagType.Caliber].Count > 0 && (!item.UsesRoundTypeFlag || !tagQuery[TagType.Caliber].Contains(item.RoundType.ToString()))) { return(false); } if (tagQuery[TagType.FiringMode].Count > 0 && !item.TagFirearmFiringModes.Any(o => tagQuery[TagType.FiringMode].Contains(o.ToString()))) { return(false); } if (tagQuery[TagType.FeedOption].Count > 0 && !item.TagFirearmFeedOption.Any(o => tagQuery[TagType.FeedOption].Contains(o.ToString()))) { return(false); } if (tagQuery[TagType.AttachmentMount].Count > 0 && !item.TagFirearmMounts.Any(o => tagQuery[TagType.AttachmentMount].Contains(o.ToString()))) { return(false); } return(true); }
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; } } }
private void SpawnPillow() { // Get the object you want to spawn FVRObject obj = IM.OD["BodyPillow"]; // Instantiate (spawn) the object above the player head GameObject go = Instantiate(obj.GetGameObject(), new Vector3(0f, .25f, 0f) + GM.CurrentPlayerBody.Head.position, GM.CurrentPlayerBody.Head.rotation); //add force go.GetComponent <Rigidbody>().AddForce(GM.CurrentPlayerBody.Head.forward * 10000); }
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); }
private static bool ShouldIncludeAttachment(FVRObject item, Dictionary <TagType, List <string> > tagQuery) { if (tagQuery[TagType.AttachmentFeature].Count > 0 && !tagQuery[TagType.AttachmentFeature].Contains(item.TagAttachmentFeature.ToString())) { return(false); } if (tagQuery[TagType.AttachmentMount].Count > 0 && !tagQuery[TagType.AttachmentMount].Contains(item.TagAttachmentMount.ToString())) { return(false); } return(true); }
private IEnumerator SpawnAsync() { #if !UNITY_EDITOR FVRObject obj = IM.OD[ObjectId]; var callback = obj.GetGameObjectAsync(); yield return(callback); GameObject go = Instantiate(callback.Result, transform.position, transform.rotation, ObjectReferences.CustomScene.transform); go.SetActive(true); #else yield return(null); #endif }
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; } } } }
private void FireArmReloadedEvent(FVRObject obj) { if (obj == null) { return; } if (Attachment != null && Attachment.GetRootObject() != null && Attachment.GetRootObject().ObjectWrapper == obj) { if (MeatTrak != null && TrackingMode == TrackingModes.Reloads) { MeatTrak.NumberTarget++; } } }
private void SpawnWonderfulToy() { // Get the object you want to spawn FVRObject obj = IM.OD["TippyToyAnton"]; // Instantiate (spawn) the object above the player's right hand GameObject go = Instantiate(obj.GetGameObject(), new Vector3(0f, .25f, 0f) + GM.CurrentPlayerBody.Head.position, GM.CurrentPlayerBody.Head.rotation); //add some speeeeen go.GetComponent <Rigidbody>().AddTorque(new Vector3(.25f, .25f, .25f)); //add force go.GetComponent <Rigidbody>().AddForce(GM.CurrentPlayerBody.Head.forward * 25); }
private void SpawnShuri() { //Set cartridge speed float howFast = 30.0f; //Set max angle float maxAngle = 4.0f; Transform PointingTransfrom = transform; //Get Random direction for bullet Vector2 randRot = Random.insideUnitCircle; // Get the object I want to spawnz FVRObject obj = IM.OD["Shuriken"]; //Set Object Position Vector3 shuriPosition0 = GM.CurrentPlayerBody.Head.position + (GM.CurrentPlayerBody.Head.forward * 0.02f); //Create Bullet //GameObject go0 = Instantiate(obj.GetGameObject(), bulletPosition0, Quaternion.LookRotation(-GM.CurrentPlayerBody.LeftHand.upxx)); //GameObject go1 = Instantiate(obj.GetGameObject(), bulletPosition0, Quaternion.LookRotation(-GM.CurrentPlayerBody.LeftHand.up)); //old spray GameObject go0 = Instantiate(obj.GetGameObject(), shuriPosition0, Quaternion.LookRotation(GM.CurrentPlayerBody.Head.forward)); //Set Object Direction go0.transform.Rotate(new Vector3(randRot.x * maxAngle, randRot.y * maxAngle, 0.0f), Space.Self); //Add Force //go0.GetComponent<Rigidbody>().velocity = GM.CurrentPlayerBody.LeftHand.forward * howFast; //go1.GetComponent<Rigidbody>().velocity = GM.CurrentPlayerBody.LeftHand.forward * howFast; //old spray go0.GetComponent <Rigidbody>().velocity = go0.transform.forward * howFast; }
private void PurchaseMagButton() { if (purchaseMag == null || original.M.GetNumTokens() < PurchaseCost) { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position); } else { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position); original.M.SubtractTokens(PurchaseCost); original.M.Increment(10, false); Instantiate(purchaseMag.GetGameObject(), original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation); purchaseMag = null; UpdateIcons(); } }
private void UpgradeMagButton() { if (upgradeMag == null || original.M.GetNumTokens() < UpgradeCost) { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Fail, transform.position); } else { SM.PlayCoreSound(FVRPooledAudioType.UIChirp, original.AudEvent_Spawn, transform.position); original.M.SubtractTokens(UpgradeCost); original.M.Increment(10, false); TNHTweaker.HoldActions[original.M.m_level].Add($"Upgraded {detectedMag.ObjectWrapper.DisplayName} To {upgradeMag.DisplayName}"); Destroy(detectedMag.GameObject); Instantiate(upgradeMag.GetGameObject(), original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation); upgradeMag = null; detectedMag = null; UpdateIcons(); } }
private void RegisterItemIntoMetaTagSystem(FVRObject mainObject, ItemSpawnerV2.PageMode page) { if (mainObject.Category == FVRObject.ObjectCategory.Firearm) { IM.AddMetaTag(mainObject.TagSet.ToString(), TagType.Set, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagEra.ToString(), TagType.Era, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagFirearmSize.ToString(), TagType.Size, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagFirearmAction.ToString(), TagType.Action, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagFirearmRoundPower.ToString(), TagType.RoundClass, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagFirearmCountryOfOrigin.ToString(), TagType.CountryOfOrigin, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagFirearmFirstYear.ToString(), TagType.IntroductionYear, mainObject.ItemID, page); IM.AddMetaTag(mainObject.MagazineType.ToString(), TagType.MagazineType, mainObject.ItemID, page); if (mainObject.UsesRoundTypeFlag) { IM.AddMetaTag(mainObject.RoundType.ToString(), TagType.Caliber, mainObject.ItemID, page); } mainObject.TagFirearmFiringModes.ForEach(tag => IM.AddMetaTag(tag.ToString(), TagType.FiringMode, mainObject.ItemID, page)); mainObject.TagFirearmFeedOption.ForEach(tag => IM.AddMetaTag(tag.ToString(), TagType.FeedOption, mainObject.ItemID, page)); mainObject.TagFirearmMounts.ForEach(mode => IM.AddMetaTag(mode.ToString(), TagType.AttachmentMount, mainObject.ItemID, page)); } else if (mainObject.Category == FVRObject.ObjectCategory.Attachment) { IM.AddMetaTag(mainObject.TagSet.ToString(), TagType.Set, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagEra.ToString(), TagType.Era, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagAttachmentFeature.ToString(), TagType.AttachmentFeature, mainObject.ItemID, page); IM.AddMetaTag(mainObject.TagAttachmentMount.ToString(), TagType.AttachmentMount, mainObject.ItemID, page); } }
private static bool ShouldIncludeGeneral(FVRObject item, ItemSpawnerEntry entry, Dictionary <TagType, List <string> > tagQuery) { if (tagQuery[TagType.SubCategory].Count > 0 && !tagQuery[TagType.SubCategory].Contains(entry.EntryPath.Split('/')[1])) { return(false); } if (tagQuery[TagType.Set].Count > 0 && !tagQuery[TagType.Set].Contains(item.TagSet.ToString())) { return(false); } if (tagQuery[TagType.Era].Count > 0 && !tagQuery[TagType.Era].Contains(item.TagEra.ToString())) { return(false); } if (tagQuery[TagType.ModTag].Count > 0 && !entry.ModTags.Any(o => tagQuery[TagType.ModTag].Contains(o.ToString()))) { return(false); } return(true); }
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); } }
protected override void Awake() { base.Awake(); //Create a primitive cube to get MeshRender from var prim = GameObject.CreatePrimitive(PrimitiveType.Cube); var primRend = prim.GetComponent <MeshRenderer>(); //Load object texture var imageAsset = File.ReadAllBytes("Mods/AudioMod/Model/Texture.jpg"); //Set collison sound for earlier null check DependantRBs = new Rigidbody[0]; //Add mesh filter component var meshFilter = gameObject.AddComponent <MeshFilter>(); meshFilter.name = "MusicControllerMesh"; //Load the .obj file, and scale it to a smaller max size var musicControllerMesh = FastObjImporter.Instance .ImportFile("Mods/AudioMod/Model/SonyWalkman.obj") .ScaleToMaxSize(.1f); meshFilter.mesh = musicControllerMesh; meshFilter.transform.localPosition = new Vector3(0, 0, 0); var meshRender = gameObject.AddComponent <MeshRenderer>(); //Create texture object and load textureImage var texture = new Texture2D(2, 2); texture.LoadImage(imageAsset); //Get the material from the primitive cube and assign its texture to the one we created meshRender.material.CopyPropertiesFromMaterial(primRend.sharedMaterial); meshRender.material.mainTexture = texture; Destroy(prim); //Create a RigidBody component and set its parameters var rigidBody = gameObject.AddComponent <Rigidbody>(); rigidBody.mass = 1f; rigidBody.useGravity = true; rigidBody.angularDrag = 0.05f; rigidBody.drag = 1f; rigidBody.detectCollisions = true; RootRigidbody = rigidBody; //Add a collider. Set its size to match the imported mesh and center to match its position var collider = gameObject.AddComponent <BoxCollider>(); collider.isTrigger = false; collider.size = new Vector3(meshFilter.mesh.bounds.size.x, meshFilter.mesh.bounds.size.y, meshFilter.mesh.bounds.size.z); collider.center = new Vector3(transform.position.x, transform.position.y, transform.position.z); var colid = m_colliders.ToList(); colid.Add(collider); m_colliders = colid.ToArray(); SetAllCollidersToLayer(false, "default"); //H3VR properties set here IsSimpleInteract = false; UseGripRotInterp = true; ControlType = FVRInteractionControlType.GrabToggle; //Makes it so releasing trigger wont drop object SpawnLockable = false; //Make non spawnlockable Harnessable = true; //Make harnessable (green tinted quick belt slot w/ auto return) Size = FVRPhysicalObjectSize.Small; //Set size to small so it fits in small quick belt slots UsesGravity = true; //Make use gravity PositionInterpSpeed = 4f; //IDK what this does RotationInterpSpeed = 4f; //IDK what this does enabled = true; //IDK what this does DistantGrabbable = true; //Makes it so the empty hand touchpad beam can pick up this item IsPickUpLocked = false; ObjectWrapper = new FVRObject() { Category = FVRObject.ObjectCategory.Tool, ItemID = nameof(MusicController), DisplayName = "Music Controller", Mass = 1 }; }
public IEnumerator SpawnRounds(FVRObject bullet, int count) { GameObject bulletObject = bullet.GetGameObject(); return(TNHTweakerUtils.InstantiateMultiple(bulletObject, original.Spawnpoint_Mag.position, count));; }