using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Deli;
using Deli.Immediate;
using Deli.Setup;
using Deli.VFS;
using FistVR;
using HarmonyLib;
using MagazinePatcher;
using Microsoft.CodeAnalysis;
using OtherLoader;
using Stratum;
using Stratum.Extensions;
using TNHFramework.ObjectTemplates;
using TNHFramework.ObjectTemplates.V1;
using TNHFramework.Patches;
using TNHFramework.Utilities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using Valve.Newtonsoft.Json;
using Valve.Newtonsoft.Json.Converters;
using YamlDotNet.Serialization;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TakeAndHoldTweaker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TakeAndHoldTweaker")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("13103263-bab2-4450-ae68-23c78eb493b2")]
[assembly: AssemblyFileVersion("0.2.4.0")]
[assembly: AssemblyVersion("0.2.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TNHFramework
{
public static class AsyncLoadMonitor
{
public static List<AnvilCallback<AssetBundle>> CallbackList = new List<AnvilCallback<AssetBundle>>();
public static float GetProgress()
{
if (!CallbackList.Any())
{
return 1f;
}
float num = 0f;
for (int num2 = CallbackList.Count - 1; num2 >= 0; num2--)
{
if (((AnvilCallbackBase)CallbackList[num2]).IsCompleted)
{
CallbackList.RemoveAt(num2);
}
else
{
num += ((AnvilCallbackBase)CallbackList[num2]).Progress;
}
}
return num / (float)CallbackList.Count;
}
}
public class SosigLinkLootWrapper : MonoBehaviour
{
public TNH_Manager M;
public global::TNHFramework.ObjectTemplates.CustomCharacter character;
public global::TNHFramework.ObjectTemplates.EquipmentGroup group;
public bool dontDrop;
public bool shouldDropOnCleanup;
private void OnDestroy()
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
if (dontDrop)
{
return;
}
TNHFrameworkLogger.Log("Lootable link was destroyed!", TNHFrameworkLogger.LogType.TNH);
List<global::TNHFramework.ObjectTemplates.EquipmentGroup> spawnedEquipmentGroups = group.GetSpawnedEquipmentGroups();
string text = null;
int num = 0;
string text2 = default(string);
foreach (global::TNHFramework.ObjectTemplates.EquipmentGroup item in spawnedEquipmentGroups)
{
for (int i = 0; i < item.ItemsToSpawn; i++)
{
if (item.IsCompatibleMagazine)
{
FVRObject ammoContainerForEquipped = FirearmUtils.GetAmmoContainerForEquipped(item.MinAmmoCapacity, item.MaxAmmoCapacity, character.GlobalObjectBlacklist, character.GetMagazineBlacklist());
if ((Object)(object)ammoContainerForEquipped == (Object)null)
{
TNHFrameworkLogger.Log("Spawning nothing since group was compatible magazines, and could not find a compatible magazine for player", TNHFrameworkLogger.LogType.TNH);
}
else
{
text = ammoContainerForEquipped.ItemID;
}
}
else
{
List<string> objects = item.GetObjects();
if (!objects.Any())
{
TNHFrameworkLogger.Log("Spawning nothing since group was empty", TNHFrameworkLogger.LogType.TNH);
}
else
{
text = objects.GetRandom();
}
}
if (Utility.IsNullOrWhiteSpace(text))
{
continue;
}
if (LoadedTemplateManager.LoadedVaultFiles.ContainsKey(text))
{
TNHFrameworkLogger.Log("Spawning vault file " + text, TNHFrameworkLogger.LogType.TNH);
GameObject val = new GameObject("SosigDropMarker");
val.transform.position = ((Component)this).transform.position + Vector3.up * 0.1f * (float)(num + 1);
val.transform.rotation = Quaternion.identity;
val.transform.localScale = ((Component)this).transform.localScale;
VaultSystem.SpawnVaultFile(LoadedTemplateManager.LoadedVaultFiles[text], val.transform, true, false, false, ref text2, Vector3.zero, (ReturnObjectListDelegate)null, false);
Object.Destroy((Object)(object)val, 10f);
}
else if (LoadedTemplateManager.LoadedLegacyVaultFiles.ContainsKey(text) && LoadedTemplateManager.LoadedLegacyVaultFiles[text] != null)
{
TNHFrameworkLogger.Log("Spawning legacy vault file " + text, TNHFrameworkLogger.LogType.TNH);
AnvilManager.Run(TNHFrameworkUtils.SpawnLegacyVaultFile(LoadedTemplateManager.LoadedLegacyVaultFiles[text], ((Component)this).transform.position + Vector3.up * 0.1f * (float)(num + 1), Quaternion.identity, M, addForce: true));
}
else if ((Object)(object)IM.OD[text] != (Object)null)
{
TNHFrameworkLogger.Log("Spawning item " + text, TNHFrameworkLogger.LogType.TNH);
AnvilManager.Run(TNHFrameworkUtils.SpawnItemRoutine(M, ((Component)this).transform.position + Vector3.up * 0.1f * (float)(num + 1), Quaternion.identity, IM.OD[text], addForce: true));
}
num++;
if (TNHFramework.SosigItemDropVibrate.Value)
{
for (int j = 0; j < 2; j++)
{
FVRViveHand obj = GM.CurrentMovementManager.Hands[j];
obj.Buzz(obj.Buzzer.Buzz_GunShot);
}
}
}
}
}
private void OnApplicationQuit()
{
dontDrop = true;
}
}
public class DebugPatches
{
[HarmonyPatch(typeof(TNH_Manager), "Start")]
[HarmonyPrefix]
public static void AddPointDebugText(TNH_Manager __instance)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
foreach (TNH_HoldPoint holdPoint in __instance.HoldPoints)
{
TNHFrameworkLogger.Log("Adding text!", TNHFrameworkLogger.LogType.TNH);
GameObject val = new GameObject("Canvas");
val.transform.rotation = Quaternion.LookRotation(Vector3.right);
val.transform.position = holdPoint.SpawnPoint_SystemNode.position + Vector3.up * 0.2f;
Canvas obj = val.AddComponent<Canvas>();
RectTransform component = ((Component)obj).GetComponent<RectTransform>();
obj.renderMode = (RenderMode)2;
component.sizeDelta = new Vector2(1f, 1f);
GameObject val2 = new GameObject("Text");
val2.transform.SetParent(val.transform);
val2.transform.rotation = val.transform.rotation;
val2.transform.localPosition = Vector3.zero;
val2.AddComponent<CanvasRenderer>();
Text obj2 = val2.AddComponent<Text>();
Font font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
obj2.text = "Hold " + __instance.HoldPoints.IndexOf(holdPoint);
obj2.alignment = (TextAnchor)4;
obj2.fontSize = 32;
val2.transform.localScale = new Vector3(0.0015f, 0.0015f, 0.0015f);
obj2.font = font;
obj2.horizontalOverflow = (HorizontalWrapMode)1;
}
}
}
public class SosigLoaderDeli
{
public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
IFileHandle val = (IFileHandle)(object)((handle is IFileHandle) ? handle : null);
if (val == null)
{
throw new ArgumentException("Could not load sosig! Make sure you're pointing to a sosig template json file in the manifest");
}
try
{
string text = ((Stage)stage).ImmediateReaders.Get<string>().Invoke(val);
JsonSerializerSettings val2 = new JsonSerializerSettings
{
NullValueHandling = (NullValueHandling)1
};
SosigTemplate sosigTemplate = JsonConvert.DeserializeObject<SosigTemplate>(text, val2);
TNHFrameworkLogger.Log("Sosig loaded successfully : " + sosigTemplate.DisplayName, TNHFrameworkLogger.LogType.General);
LoadedTemplateManager.AddSosigTemplate(sosigTemplate);
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError("Failed to load setup assets for sosig file! Caused Error: " + ex.ToString());
}
}
}
public class CharacterLoaderDeli
{
public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
IDirectoryHandle val = (IDirectoryHandle)(object)((handle is IDirectoryHandle) ? handle : null);
if (val == null)
{
throw new ArgumentException("Could not load character! Character should point to a folder holding the character.json and thumb.png");
}
try
{
global::TNHFramework.ObjectTemplates.V1.CustomCharacter customCharacter = null;
Sprite val2 = null;
foreach (IFileHandle file in ExtIDirectoryHandle.GetFiles(val))
{
if (((IHandle)file).Path.EndsWith("character.json"))
{
string text = ((Stage)stage).ImmediateReaders.Get<string>().Invoke(file);
JsonSerializerSettings val3 = new JsonSerializerSettings
{
NullValueHandling = (NullValueHandling)1
};
customCharacter = JsonConvert.DeserializeObject<global::TNHFramework.ObjectTemplates.V1.CustomCharacter>(text, val3);
}
else if (((IHandle)file).Path.EndsWith("thumb.png"))
{
val2 = TNHFrameworkUtils.LoadSprite(file);
}
}
if (customCharacter == null)
{
TNHFrameworkLogger.LogError("Failed to load custom character! No character.json file found");
return;
}
if ((Object)(object)val2 == (Object)null)
{
TNHFrameworkLogger.LogError("Failed to load custom character! No thumb.png file found");
return;
}
foreach (IFileHandle file2 in ExtIDirectoryHandle.GetFiles(val))
{
foreach (global::TNHFramework.ObjectTemplates.V1.EquipmentPool equipmentPool in customCharacter.EquipmentPools)
{
if (((IHandle)file2).Path.Split(new char[1] { '/' }).Last() == equipmentPool.IconName)
{
equipmentPool.GetPoolEntry().TableDef.Icon = TNHFrameworkUtils.LoadSprite(file2);
}
}
}
TNHFrameworkLogger.Log("Character loaded successfully : " + customCharacter.DisplayName, TNHFrameworkLogger.LogType.General);
LoadedTemplateManager.AddCharacterTemplate(new global::TNHFramework.ObjectTemplates.CustomCharacter(customCharacter), val2);
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError("Failed to load setup assets for character! Caused Error: " + ex.ToString());
}
}
}
public class VaultFileLoaderDeli
{
public void LoadAsset(SetupStage stage, Mod mod, IHandle handle)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
IFileHandle val = (IFileHandle)(object)((handle is IFileHandle) ? handle : null);
if (val == null)
{
throw new ArgumentException("Could not load vault file! Make sure you're pointing to a vault json file in the manifest");
}
try
{
string text = ((Stage)stage).ImmediateReaders.Get<string>().Invoke(val);
JsonSerializerSettings val2 = new JsonSerializerSettings
{
NullValueHandling = (NullValueHandling)1
};
SavedGunSerializable savedGunSerializable = JsonConvert.DeserializeObject<SavedGunSerializable>(text, val2);
TNHFrameworkLogger.Log("Vault file loaded successfully : " + savedGunSerializable.FileName, TNHFrameworkLogger.LogType.General);
LoadedTemplateManager.AddVaultFile(savedGunSerializable);
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError("Failed to load setup assets for vault file! Caused Error: " + ex.ToString());
}
}
}
public static class TNHMenuInitializer
{
[CompilerGenerated]
private sealed class <InitializeTNHMenuAsync>d__6 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public SceneLoader hotdog;
public Text itemsText;
public Text progressText;
public TNH_CharacterDatabase CharDatabase;
public bool outputFiles;
public string path;
public TNH_UIManager instance;
public List<CharacterCategory> Categories;
private bool <isOtherLoaderLoaded>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitializeTNHMenuAsync>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
SceneLoader obj2 = hotdog;
if (obj2 != null)
{
((Component)obj2).gameObject.SetActive(false);
}
try
{
PokeOtherloader();
<isOtherLoaderLoaded>5__2 = true;
}
catch
{
<isOtherLoaderLoaded>5__2 = false;
TNHFrameworkLogger.LogWarning("OtherLoader not found. If you are using OtherLoader, please ensure you have version 0.1.6 or later!");
}
float num2 = 0f;
goto IL_0062;
}
case 1:
{
<>1__state = -1;
float num2 = AsyncLoadMonitor.GetProgress();
if (<isOtherLoaderLoaded>5__2)
{
num2 = Mathf.Min(num2, GetOtherLoaderProgress());
itemsText.text = GetLoadingItems();
}
progressText.text = $"LOADING ITEMS : {num2 * 100f:0.0}%";
if (num2 < 1f)
{
goto IL_0062;
}
bool flag;
try
{
PokeMagPatcher();
flag = true;
TNHFrameworkLogger.LogWarning("MagazinePatcher is detected.");
}
catch
{
flag = false;
TNHFrameworkLogger.LogWarning("MagazinePatcher not found.");
}
if (!flag)
{
if (TNHFramework.InternalMagPatcher.Value)
{
TNHFrameworkLogger.Log($"[{DateTime.Now:HH:mm:ss}] Internal Mag Patcher started!", TNHFrameworkLogger.LogType.General);
InternalMagPatcher();
TNHFrameworkLogger.Log($"[{DateTime.Now:HH:mm:ss}] Internal Mag Patcher finished!", TNHFrameworkLogger.LogType.General);
}
break;
}
goto IL_00f3;
}
case 2:
{
<>1__state = -1;
float num = PokeMagPatcher();
itemsText.text = GetMagPatcherCacheLog();
progressText.text = $"CACHING ITEMS : {num * 100f:0.0}%";
if (!(num < 1f))
{
break;
}
goto IL_00f3;
}
IL_0062:
<>2__current = null;
<>1__state = 1;
return true;
IL_00f3:
<>2__current = null;
<>1__state = 2;
return true;
}
if (TNHFramework.FixModAttachmentTags.Value)
{
TNHFrameworkUtils.FixModAttachmentTags();
}
LoadTNHTemplates(CharDatabase);
SavedCharacters = CharDatabase.Characters;
if (outputFiles)
{
CreateTNHFiles(path);
}
TNHInitialized = true;
UIManagerPatches.RefreshTNHUI(instance, Categories, CharDatabase);
itemsText.text = "";
progressText.text = "";
SceneLoader obj4 = hotdog;
if (obj4 != null)
{
((Component)obj4).gameObject.SetActive(true);
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static bool TNHInitialized = false;
public static bool MagazineCacheFailed = false;
public static List<TNH_CharacterDef> SavedCharacters;
private static readonly MethodInfo miGetCatFolderName = typeof(VaultSystem).GetMethod("GetCatFolderName", BindingFlags.Static | BindingFlags.NonPublic);
private static readonly MethodInfo miGetSubcatFolderName = typeof(VaultSystem).GetMethod("GetSubcatFolderName", BindingFlags.Static | BindingFlags.NonPublic);
private static readonly MethodInfo miGetSuffix = typeof(VaultSystem).GetMethod("GetSuffix", BindingFlags.Static | BindingFlags.NonPublic);
public static IEnumerator InitializeTNHMenuAsync(string path, Text progressText, Text itemsText, SceneLoader hotdog, List<CharacterCategory> Categories, TNH_CharacterDatabase CharDatabase, TNH_UIManager instance, bool outputFiles)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitializeTNHMenuAsync>d__6(0)
{
path = path,
progressText = progressText,
itemsText = itemsText,
hotdog = hotdog,
Categories = Categories,
CharDatabase = CharDatabase,
instance = instance,
outputFiles = outputFiles
};
}
public static void PokeOtherloader()
{
LoaderStatus.GetLoaderProgress();
_ = LoaderStatus.LoadingItems;
}
public static float GetOtherLoaderProgress()
{
return LoaderStatus.GetLoaderProgress();
}
public static string GetLoadingItems()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
List<string> loadingItems = LoaderStatus.LoadingItems;
for (int i = 0; i < loadingItems.Count; i++)
{
string text = ColorUtility.ToHtmlStringRGBA(new Color(0.5f, 0.5f, 0.5f, Mathf.Clamp(((float)loadingItems.Count - (float)i) / (float)loadingItems.Count, 0f, 1f)));
loadingItems[i] = "<color=#" + text + ">Loading Assets (" + loadingItems[i] + ")</color>";
}
loadingItems.Reverse();
return string.Join("\n", loadingItems.ToArray());
}
public static float PokeMagPatcher()
{
return PatcherStatus.PatcherProgress;
}
public static string GetMagPatcherCacheLog()
{
return PatcherStatus.CacheLog;
}
public static void InternalMagPatcher()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Invalid comparison between Unknown and I4
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Invalid comparison between Unknown and I4
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Invalid comparison between Unknown and I4
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Invalid comparison between Unknown and I4
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Invalid comparison between Unknown and I4
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_036f: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Invalid comparison between Unknown and I4
//IL_040a: Unknown result type (might be due to invalid IL or missing references)
//IL_0423: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0488: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
List<FVRObject> list = new List<FVRObject>();
foreach (KeyValuePair<string, FVRObject> item in IM.OD)
{
if ((int)item.Value.Category == 1)
{
list.Add(item.Value);
}
else if ((int)item.Value.Category == 4)
{
if (!TNHFramework.CartridgeDictionary.ContainsKey(item.Value.RoundType))
{
TNHFramework.CartridgeDictionary.Add(item.Value.RoundType, new List<FVRObject>());
}
TNHFramework.CartridgeDictionary[item.Value.RoundType].Add(item.Value);
}
else if ((int)item.Value.Category == 2)
{
if (!TNHFramework.MagazineDictionary.ContainsKey(item.Value.MagazineType))
{
TNHFramework.MagazineDictionary.Add(item.Value.MagazineType, new List<FVRObject>());
}
TNHFramework.MagazineDictionary[item.Value.MagazineType].Add(item.Value);
}
else if ((int)item.Value.Category == 3)
{
if (!TNHFramework.StripperDictionary.ContainsKey(item.Value.ClipType))
{
TNHFramework.StripperDictionary.Add(item.Value.ClipType, new List<FVRObject>());
}
TNHFramework.StripperDictionary[item.Value.ClipType].Add(item.Value);
}
else if ((int)item.Value.Category == 6)
{
if (!TNHFramework.SpeedloaderDictionary.ContainsKey(item.Value.RoundType))
{
TNHFramework.SpeedloaderDictionary.Add(item.Value.RoundType, new List<FVRObject>());
}
if (item.Value.ItemID == "Speedloader12gauge_5Shot")
{
item.Value.MagazineCapacity = 5;
}
TNHFramework.SpeedloaderDictionary[item.Value.RoundType].Add(item.Value);
}
}
foreach (FVRObject item2 in list)
{
FVRFireArm val = null;
FireArmClipType clipType = item2.ClipType;
FireArmRoundType roundType = item2.RoundType;
FireArmMagazineType magazineType = item2.MagazineType;
int num = item2.MagazineCapacity;
if (!ValidFireArm(roundType, clipType, magazineType, 0))
{
if (!item2.IsModContent && (int)item2.TagFirearmAction == 8 && item2.TagFirearmFeedOption.Contains((OTagFirearmFeedOption)1))
{
continue;
}
TNHFrameworkLogger.Log($"Loading firearm {item2.DisplayName} [Mod = {item2.IsModContent}]", TNHFrameworkLogger.LogType.General);
GameObject gameObject = ((AnvilAsset)item2).GetGameObject();
if ((Object)(object)gameObject != (Object)null)
{
val = gameObject.GetComponent<FVRFireArm>();
}
if ((Object)(object)val != (Object)null)
{
roundType = val.RoundType;
magazineType = val.MagazineType;
clipType = val.ClipType;
}
}
if (!ValidFireArm(roundType, clipType, magazineType, num))
{
TNHFrameworkLogger.Log("Firearm " + item2.DisplayName + " skipped!", TNHFrameworkLogger.LogType.General);
continue;
}
if ((item2.CompatibleSingleRounds == null || !item2.CompatibleSingleRounds.Any()) && TNHFramework.CartridgeDictionary.ContainsKey(roundType))
{
TNHFrameworkLogger.Log($"Giving firearm {item2.DisplayName} new rounds of type {roundType}", TNHFrameworkLogger.LogType.General);
item2.CompatibleSingleRounds = TNHFramework.CartridgeDictionary[roundType];
}
if ((item2.CompatibleMagazines == null || !item2.CompatibleMagazines.Any()) && TNHFramework.MagazineDictionary.ContainsKey(magazineType) && (int)magazineType != 0)
{
TNHFrameworkLogger.Log($"Giving firearm {item2.DisplayName} new magazines of type {magazineType}", TNHFrameworkLogger.LogType.General);
item2.CompatibleMagazines = TNHFramework.MagazineDictionary[magazineType];
}
if ((item2.CompatibleClips == null || !item2.CompatibleClips.Any()) && TNHFramework.StripperDictionary.ContainsKey(clipType) && (int)clipType != 0)
{
TNHFrameworkLogger.Log($"Giving firearm {item2.DisplayName} new clips of type {clipType}", TNHFrameworkLogger.LogType.General);
item2.CompatibleClips = TNHFramework.StripperDictionary[clipType];
}
if ((item2.CompatibleSpeedLoaders != null && item2.CompatibleSpeedLoaders.Any()) || (int)item2.TagFirearmAction != 3)
{
continue;
}
if ((Object)(object)val == (Object)null)
{
GameObject gameObject2 = ((AnvilAsset)item2).GetGameObject();
if ((Object)(object)gameObject2 != (Object)null)
{
val = gameObject2.GetComponent<FVRFireArm>();
}
}
if ((Object)(object)val != (Object)null)
{
roundType = val.RoundType;
Revolver component = ((Component)val).gameObject.GetComponent<Revolver>();
if ((Object)(object)component != (Object)null)
{
num = component.Chambers.Length;
}
}
if (!TNHFramework.SpeedloaderDictionary.ContainsKey(roundType))
{
continue;
}
foreach (FVRObject item3 in TNHFramework.SpeedloaderDictionary[roundType])
{
if (item3.MagazineCapacity == num)
{
TNHFrameworkLogger.Log($"Giving firearm {item2.DisplayName} new speedloader of type {roundType}", TNHFrameworkLogger.LogType.General);
item2.CompatibleSpeedLoaders.Add(item3);
}
}
}
}
public static bool ValidFireArm(FireArmRoundType roundType, FireArmClipType clipType, FireArmMagazineType magazineType, int magazineCapacity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
if ((int)roundType == 0 && (int)magazineType == 0 && magazineCapacity == 0)
{
return (int)clipType > 0;
}
return true;
}
public static void LoadTNHTemplates(TNH_CharacterDatabase CharDatabase)
{
TNHFrameworkLogger.Log("Performing TNH Initialization", TNHFrameworkLogger.LogType.General);
TNHFrameworkLogger.Log("Adding default sosigs to template dictionary", TNHFrameworkLogger.LogType.General);
LoadDefaultSosigs();
TNHFrameworkLogger.Log("Adding default characters to template dictionary", TNHFrameworkLogger.LogType.General);
LoadDefaultCharacters(CharDatabase.Characters);
LoadedTemplateManager.DefaultIconSprites = GetAllIcons(LoadedTemplateManager.DefaultCharacters);
TNHFrameworkLogger.Log("Delayed Init of default characters", TNHFrameworkLogger.LogType.General);
InitCharacters(LoadedTemplateManager.DefaultCharacters);
TNHFrameworkLogger.Log("Delayed Init of custom characters", TNHFrameworkLogger.LogType.General);
InitCharacters(LoadedTemplateManager.CustomCharacters);
TNHFrameworkLogger.Log("Delayed Init of custom sosigs", TNHFrameworkLogger.LogType.General);
InitSosigs(LoadedTemplateManager.CustomSosigs);
}
private static void LoadDefaultSosigs()
{
foreach (SosigEnemyTemplate value in ManagerSingleton<IM>.Instance.odicSosigObjsByID.Values)
{
LoadedTemplateManager.AddSosigTemplate(value);
}
}
private static void LoadDefaultCharacters(List<TNH_CharacterDef> characters)
{
foreach (TNH_CharacterDef character in characters)
{
LoadedTemplateManager.AddCharacterTemplate(character);
}
}
public static Dictionary<string, Sprite> GetAllIcons(List<global::TNHFramework.ObjectTemplates.CustomCharacter> characters)
{
Dictionary<string, Sprite> dictionary = new Dictionary<string, Sprite>();
foreach (global::TNHFramework.ObjectTemplates.CustomCharacter character in characters)
{
foreach (PoolEntry entry in character.GetCharacter().EquipmentPool.Entries)
{
if (!dictionary.ContainsKey(((Object)entry.TableDef.Icon).name))
{
TNHFrameworkLogger.Log("Icon found (" + ((Object)entry.TableDef.Icon).name + ")", TNHFrameworkLogger.LogType.Character);
dictionary.Add(((Object)entry.TableDef.Icon).name, entry.TableDef.Icon);
}
}
}
return dictionary;
}
private static void InitCharacters(List<global::TNHFramework.ObjectTemplates.CustomCharacter> characters)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
for (int num = characters.Count - 1; num >= 0; num--)
{
global::TNHFramework.ObjectTemplates.CustomCharacter character = characters[num];
try
{
character.DelayedInit();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError("Failed to load character: " + character.DisplayName + ". Error Output:\n" + ex.ToString());
characters.RemoveAt(num);
CharacterTemplate value = LoadedTemplateManager.LoadedCharacterDict.Single((KeyValuePair<TNH_Char, CharacterTemplate> o) => o.Value.Custom == character).Value;
LoadedTemplateManager.LoadedCharacterDict.Remove(value.Def.CharacterID);
}
}
}
private static void InitSosigs(List<SosigTemplate> sosigs)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < sosigs.Count; i++)
{
SosigTemplate sosig = sosigs[i];
try
{
sosig.DelayedInit();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError("Failed to load sosig: " + sosig.DisplayName + ". Error Output:\n" + ex.ToString());
KeyValuePair<TNH_Char, CharacterTemplate>[] array = LoadedTemplateManager.LoadedCharacterDict.Where((KeyValuePair<TNH_Char, CharacterTemplate> o) => o.Value.Custom.CharacterUsesSosig(sosig.SosigEnemyID)).ToArray();
for (int j = 0; j < array.Length; j++)
{
KeyValuePair<TNH_Char, CharacterTemplate> keyValuePair = array[j];
TNHFrameworkLogger.LogError("Removing character that used removed sosig: " + keyValuePair.Value.Custom.DisplayName);
LoadedTemplateManager.LoadedCharacterDict.Remove(keyValuePair.Key);
}
}
}
}
public static void CreateTNHFiles(string path)
{
TNHFrameworkLogger.Log("Creating character creation files", TNHFrameworkLogger.LogType.General);
CreateSosigTemplateFiles(LoadedTemplateManager.DefaultSosigs, path);
CreateSosigTemplateFiles(LoadedTemplateManager.CustomSosigs, path);
CreateCharacterFiles(LoadedTemplateManager.DefaultCharacters, path, isCustom: false);
CreateCharacterFiles(LoadedTemplateManager.CustomCharacters, path, isCustom: true);
CreateIconIDFile(path, LoadedTemplateManager.DefaultIconSprites.Keys.ToList());
CreateObjectIDFile(path);
CreateSosigIDFile(path);
CreateJsonVaultFiles(path);
CreateGeneratedTables(path);
CreatePopulatedCharacterTemplate(path);
}
public static string CleanFilename(string filename)
{
return Regex.Replace(filename, "(<|>|:|\"|/|\\\\|\\||\\?|\\*)", "");
}
public static void CreateSosigTemplateFiles(List<SosigEnemyTemplate> sosigs, string path)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
try
{
TNHFrameworkLogger.Log("Creating default sosig template files", TNHFrameworkLogger.LogType.File);
path += "/DefaultSosigTemplates";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
foreach (SosigEnemyTemplate sosig in sosigs)
{
string path2 = path + "/" + CleanFilename(((object)(SosigEnemyID)(ref sosig.SosigEnemyID)).ToString() + ".json");
if (File.Exists(path2))
{
File.Delete(path2);
}
using (StreamWriter streamWriter = File.CreateText(path2))
{
string value = JsonConvert.SerializeObject((object)new SosigTemplate(sosig), (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)new StringEnumConverter() });
streamWriter.WriteLine(value);
streamWriter.Close();
}
string path3 = path + "/" + CleanFilename(((object)(SosigEnemyID)(ref sosig.SosigEnemyID)).ToString() + ".yaml");
if (File.Exists(path3))
{
File.Delete(path3);
}
using StreamWriter streamWriter2 = File.CreateText(path3);
ISerializer obj = new SerializerBuilder().WithIndentedSequences().Build();
SosigTemplate sosigTemplate = new SosigTemplate(sosig);
string value2 = obj.Serialize((object)sosigTemplate);
streamWriter2.WriteLine(value2);
streamWriter2.Close();
}
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateSosigTemplateFiles(List<SosigTemplate> sosigs, string path)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
try
{
TNHFrameworkLogger.Log("Creating custom sosig template files", TNHFrameworkLogger.LogType.File);
path += "/CustomSosigTemplates";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
foreach (SosigTemplate sosig in sosigs)
{
string path2 = path + "/" + CleanFilename(sosig.SosigEnemyID + ".json");
if (File.Exists(path2))
{
File.Delete(path2);
}
using (StreamWriter streamWriter = File.CreateText(path2))
{
string value = JsonConvert.SerializeObject((object)sosig, (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)new StringEnumConverter() });
streamWriter.WriteLine(value);
streamWriter.Close();
}
string path3 = path + "/" + CleanFilename(sosig.SosigEnemyID + ".yaml");
if (File.Exists(path3))
{
File.Delete(path3);
}
using StreamWriter streamWriter2 = File.CreateText(path3);
string value2 = new SerializerBuilder().WithIndentedSequences().Build().Serialize((object)sosig);
streamWriter2.WriteLine(value2);
streamWriter2.Close();
}
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateCharacterFiles(List<global::TNHFramework.ObjectTemplates.CustomCharacter> characters, string path, bool isCustom)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
try
{
TNHFrameworkLogger.Log("Creating " + (isCustom ? "custom" : "default") + " character template files", TNHFrameworkLogger.LogType.File);
path += (isCustom ? "/CustomCharacters" : "/DefaultCharacters");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
foreach (global::TNHFramework.ObjectTemplates.CustomCharacter character in characters)
{
string path2 = path + "/" + CleanFilename(character.DisplayName + ".json");
if (File.Exists(path2))
{
File.Delete(path2);
}
using (StreamWriter streamWriter = File.CreateText(path2))
{
string value = JsonConvert.SerializeObject((object)character, (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)new StringEnumConverter() });
streamWriter.WriteLine(value);
streamWriter.Close();
}
string text = path + "/" + CleanFilename(character.DisplayName + ".yaml");
TNHFrameworkLogger.Log("Creating character template file: " + text, TNHFrameworkLogger.LogType.File);
if (File.Exists(text))
{
File.Delete(text);
}
using StreamWriter streamWriter2 = File.CreateText(text);
string value2 = new SerializerBuilder().WithIndentedSequences().Build().Serialize((object)character);
streamWriter2.WriteLine(value2);
streamWriter2.Close();
}
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateIconIDFile(string path, List<string> icons)
{
try
{
if (File.Exists(path + "/IconIDs.txt"))
{
File.Delete(path + "/IconIDs.txt");
}
using StreamWriter streamWriter = File.CreateText(path + "/IconIDs.txt");
streamWriter.WriteLine("#Available Icons for equipment pools");
foreach (string icon in icons)
{
streamWriter.WriteLine(icon);
}
streamWriter.Close();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateObjectIDFile(string path)
{
try
{
if (File.Exists(path + "/ObjectIDs.csv"))
{
File.Delete(path + "/ObjectIDs.csv");
}
using StreamWriter streamWriter = File.CreateText(path + "/ObjectIDs.csv");
streamWriter.WriteLine("DisplayName,ObjectID,Mod Content,Category,Era,Set,Country of Origin,Attachment Feature,Firearm Action,Firearm Feed Option,Firing Modes,Firearm Mounts,Attachment Mount,Round Power,Size,Melee Handedness,Melee Style,Powerup Type,Thrown Damage Type,Thrown Type");
foreach (FVRObject value in IM.OD.Values)
{
streamWriter.WriteLine(value.DisplayName.Replace(",", ".") + "," + value.ItemID.Replace(",", ".") + "," + value.IsModContent + "," + ((object)(ObjectCategory)(ref value.Category)).ToString() + "," + ((object)(OTagEra)(ref value.TagEra)).ToString() + "," + ((object)(OTagSet)(ref value.TagSet)).ToString() + "," + ((object)(OTagFirearmCountryOfOrigin)(ref value.TagFirearmCountryOfOrigin)).ToString() + "," + ((object)(OTagAttachmentFeature)(ref value.TagAttachmentFeature)).ToString() + "," + ((object)(OTagFirearmAction)(ref value.TagFirearmAction)).ToString() + "," + string.Join("+", value.TagFirearmFeedOption.Select((OTagFirearmFeedOption o) => ((object)(OTagFirearmFeedOption)(ref o)).ToString()).ToArray()) + "," + string.Join("+", value.TagFirearmFiringModes.Select((OTagFirearmFiringMode o) => ((object)(OTagFirearmFiringMode)(ref o)).ToString()).ToArray()) + "," + string.Join("+", value.TagFirearmMounts.Select((OTagFirearmMount o) => ((object)(OTagFirearmMount)(ref o)).ToString()).ToArray()) + "," + ((object)(OTagFirearmMount)(ref value.TagAttachmentMount)).ToString() + "," + ((object)(OTagFirearmRoundPower)(ref value.TagFirearmRoundPower)).ToString() + "," + ((object)(OTagFirearmSize)(ref value.TagFirearmSize)).ToString() + "," + ((object)(OTagMeleeHandedness)(ref value.TagMeleeHandedness)).ToString() + "," + ((object)(OTagMeleeStyle)(ref value.TagMeleeStyle)).ToString() + "," + ((object)(OTagPowerupType)(ref value.TagPowerupType)).ToString() + "," + ((object)(OTagThrownDamageType)(ref value.TagThrownDamageType)).ToString() + "," + ((object)(OTagThrownType)(ref value.TagThrownType)).ToString());
}
streamWriter.Close();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateSosigIDFile(string path)
{
try
{
if (File.Exists(path + "/SosigIDs.txt"))
{
File.Delete(path + "/SosigIDs.txt");
}
using StreamWriter streamWriter = File.CreateText(path + "/SosigIDs.txt");
streamWriter.WriteLine("#Available Sosig IDs for spawning");
List<string> list = LoadedTemplateManager.SosigIDDict.Keys.ToList();
list.Sort();
foreach (string item in list)
{
streamWriter.WriteLine(item);
}
streamWriter.Close();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateJsonVaultFiles(string path)
{
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Expected O, but got Unknown
try
{
TNHFrameworkLogger.Log("Creating JSON vault files", TNHFrameworkLogger.LogType.File);
path += "/VaultFiles";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string[] files = ES2.GetFiles(string.Empty, "*.txt");
List<SavedGunSerializable> list = new List<SavedGunSerializable>();
string[] array = files;
foreach (string text in array)
{
try
{
if (text.Contains("DONTREMOVETHISPARTOFFILENAMEV02a") && ES2.Exists(text))
{
ES2Reader val = ES2Reader.Create(text);
try
{
SavedGun gun = val.Read<SavedGun>("SavedGun");
list.Add(new SavedGunSerializable(gun));
}
finally
{
((IDisposable)val)?.Dispose();
}
}
}
catch
{
TNHFrameworkLogger.LogWarning("Vault File " + text + " could not be loaded");
}
}
foreach (SavedGunSerializable item in list)
{
string path2 = path + "/" + CleanFilename(item.FileName + ".json");
if (File.Exists(path2))
{
File.Delete(path2);
}
using StreamWriter streamWriter = File.CreateText(path2);
string value = JsonConvert.SerializeObject((object)item, (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)new StringEnumConverter() });
streamWriter.WriteLine(value);
streamWriter.Close();
}
TNHFrameworkLogger.Log("Copying V2 JSON vault files", TNHFrameworkLogger.LogType.File);
VaultFileDisplayMode val2 = (VaultFileDisplayMode)0;
string[] fileListForDisplayMode = VaultSystem.GetFileListForDisplayMode(val2, (CynJsonSortingMode)0);
string path3 = Path.Combine(CynJson.GetOrCreateH3VRDataPath(), VaultSystem.rootFolderName);
path3 = Path.Combine(path3, (string)miGetCatFolderName.Invoke(null, new object[1] { val2 }));
path3 = Path.Combine(path3, (string)miGetSubcatFolderName.Invoke(null, new object[1] { val2 }));
array = fileListForDisplayMode;
for (int i = 0; i < array.Length; i++)
{
string text2 = array[i] + (string)miGetSuffix.Invoke(null, new object[1] { val2 });
try
{
File.Copy(Path.Combine(path3, text2), Path.Combine(path, text2), overwrite: true);
}
catch (Exception arg)
{
TNHFrameworkLogger.LogError($"Vault File {text2} could not be copied: {arg}");
}
}
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
public static void CreateGeneratedTables(string path)
{
try
{
path += "/GeneratedEquipmentPools";
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
foreach (global::TNHFramework.ObjectTemplates.CustomCharacter item in LoadedTemplateManager.LoadedCharacterDict.Select((KeyValuePair<TNH_Char, CharacterTemplate> o) => o.Value.Custom))
{
using StreamWriter streamWriter = File.CreateText(path + "/" + CleanFilename(item.DisplayName + ".txt"));
streamWriter.WriteLine("Primary Starting Weapon");
if (item.PrimaryWeapon != null)
{
streamWriter.WriteLine(item.PrimaryWeapon.ToString());
}
streamWriter.WriteLine("\n\nSecondary Starting Weapon");
if (item.SecondaryWeapon != null)
{
streamWriter.WriteLine(item.SecondaryWeapon.ToString());
}
streamWriter.WriteLine("\n\nTertiary Starting Weapon");
if (item.TertiaryWeapon != null)
{
streamWriter.WriteLine(item.TertiaryWeapon.ToString());
}
streamWriter.WriteLine("\n\nPrimary Starting Item");
if (item.PrimaryItem != null)
{
streamWriter.WriteLine(item.PrimaryItem.ToString());
}
streamWriter.WriteLine("\n\nSecondary Starting Item");
if (item.SecondaryItem != null)
{
streamWriter.WriteLine(item.SecondaryItem.ToString());
}
streamWriter.WriteLine("\n\nTertiary Starting Item");
if (item.TertiaryItem != null)
{
streamWriter.WriteLine(item.TertiaryItem.ToString());
}
streamWriter.WriteLine("\n\nStarting Shield");
if (item.Shield != null)
{
streamWriter.WriteLine(item.Shield.ToString());
}
foreach (global::TNHFramework.ObjectTemplates.EquipmentPool equipmentPool in item.EquipmentPools)
{
streamWriter.WriteLine("\n\n" + equipmentPool.ToString());
}
streamWriter.Close();
}
}
catch
{
}
}
public static void CreatePopulatedCharacterTemplate(string path)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
try
{
TNHFrameworkLogger.Log("Creating populated character template file", TNHFrameworkLogger.LogType.File);
path += "/PopulatedCharacterTemplate.json";
if (!File.Exists(path))
{
File.Delete(path);
}
using StreamWriter streamWriter = File.CreateText(path);
string value = JsonConvert.SerializeObject((object)new global::TNHFramework.ObjectTemplates.CustomCharacter(), (Formatting)1, (JsonConverter[])(object)new JsonConverter[1] { (JsonConverter)new StringEnumConverter() });
streamWriter.WriteLine(value);
streamWriter.Close();
}
catch (Exception ex)
{
TNHFrameworkLogger.LogError(ex.ToString());
}
}
}
public class CharacterTemplate
{
public TNH_CharacterDef Def;
public global::TNHFramework.ObjectTemplates.CustomCharacter Custom;
public CharacterTemplate(TNH_CharacterDef def, global::TNHFramework.ObjectTemplates.CustomCharacter custom)
{
Def = def;
Custom = custom;
base..ctor();
}
}
public static class LoadedTemplateManager
{
public static global::TNHFramework.ObjectTemplates.CustomCharacter CurrentCharacter;
public static global::TNHFramework.ObjectTemplates.Level CurrentLevel;
public static Dictionary<TNH_Char, CharacterTemplate> LoadedCharacterDict = new Dictionary<TNH_Char, CharacterTemplate>();
public static Dictionary<SosigEnemyTemplate, SosigTemplate> LoadedSosigsDict = new Dictionary<SosigEnemyTemplate, SosigTemplate>();
public static Dictionary<PoolEntry, global::TNHFramework.ObjectTemplates.EquipmentPool> EquipmentPoolDictionary = new Dictionary<PoolEntry, global::TNHFramework.ObjectTemplates.EquipmentPool>();
public static Dictionary<string, VaultFile> LoadedVaultFiles = new Dictionary<string, VaultFile>();
public static Dictionary<string, SavedGunSerializable> LoadedLegacyVaultFiles = new Dictionary<string, SavedGunSerializable>();
public static List<global::TNHFramework.ObjectTemplates.CustomCharacter> CustomCharacters = new List<global::TNHFramework.ObjectTemplates.CustomCharacter>();
public static List<global::TNHFramework.ObjectTemplates.CustomCharacter> DefaultCharacters = new List<global::TNHFramework.ObjectTemplates.CustomCharacter>();
public static List<SosigTemplate> CustomSosigs = new List<SosigTemplate>();
public static List<SosigEnemyTemplate> DefaultSosigs = new List<SosigEnemyTemplate>();
public static Dictionary<string, int> SosigIDDict = new Dictionary<string, int>();
public static int NewSosigID = 30000;
public static int NewCharacterID = 1000;
public static Dictionary<string, Sprite> DefaultIconSprites = new Dictionary<string, Sprite>();
public static void AddSosigTemplate(SosigTemplate template)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
template.Validate();
SosigEnemyTemplate sosigEnemyTemplate = template.GetSosigEnemyTemplate();
if (!SosigIDDict.ContainsKey(template.SosigEnemyID))
{
SosigIDDict.Add(template.SosigEnemyID, NewSosigID);
NewSosigID++;
sosigEnemyTemplate.SosigEnemyID = (SosigEnemyID)SosigIDDict[template.SosigEnemyID];
CustomSosigs.Add(template);
LoadedSosigsDict.Add(sosigEnemyTemplate, template);
TNHFrameworkLogger.Log("Sosig added successfully : " + template.DisplayName, TNHFrameworkLogger.LogType.Character);
}
else
{
TNHFrameworkLogger.LogError("Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + template.SosigEnemyID);
}
}
public static void AddSosigTemplate(SosigEnemyTemplate realTemplate)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected I4, but got Unknown
SosigTemplate sosigTemplate = new SosigTemplate(realTemplate);
if (!SosigIDDict.ContainsKey(sosigTemplate.SosigEnemyID))
{
SosigIDDict.Add(sosigTemplate.SosigEnemyID, (int)realTemplate.SosigEnemyID);
DefaultSosigs.Add(realTemplate);
LoadedSosigsDict.Add(realTemplate, sosigTemplate);
TNHFrameworkLogger.Log("Sosig added successfully : " + sosigTemplate.DisplayName, TNHFrameworkLogger.LogType.Character);
}
else
{
TNHFrameworkLogger.LogError("Loaded sosig had same SosigEnemyID as another sosig -- SosigEnemyID : " + sosigTemplate.SosigEnemyID);
}
}
public static void AddCharacterTemplate(global::TNHFramework.ObjectTemplates.CustomCharacter template, Sprite thumbnail)
{
template.isCustom = true;
template.Validate();
CustomCharacters.Add(template);
LoadedCharacterDict.Add((TNH_Char)NewCharacterID, new CharacterTemplate(template.GetCharacter(NewCharacterID, thumbnail), template));
NewCharacterID++;
foreach (global::TNHFramework.ObjectTemplates.EquipmentPool equipmentPool in template.EquipmentPools)
{
EquipmentPoolDictionary.Add(equipmentPool.GetPoolEntry(), equipmentPool);
}
TNHFrameworkLogger.Log($"Character added successfully ({NewCharacterID - 1}) : " + template.DisplayName, TNHFrameworkLogger.LogType.Character);
}
public static void AddCharacterTemplate(TNH_CharacterDef realTemplate)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
global::TNHFramework.ObjectTemplates.CustomCharacter customCharacter = new global::TNHFramework.ObjectTemplates.CustomCharacter(realTemplate);
DefaultCharacters.Add(customCharacter);
LoadedCharacterDict.Add(realTemplate.CharacterID, new CharacterTemplate(realTemplate, customCharacter));
foreach (global::TNHFramework.ObjectTemplates.EquipmentPool equipmentPool in customCharacter.EquipmentPools)
{
if (!EquipmentPoolDictionary.ContainsKey(equipmentPool.GetPoolEntry()))
{
EquipmentPoolDictionary.Add(equipmentPool.GetPoolEntry(), equipmentPool);
}
}
TNHFrameworkLogger.Log($"Character added successfully ({realTemplate.CharacterID}) : " + realTemplate.DisplayName, TNHFrameworkLogger.LogType.Character);
}
public static void AddVaultFile(VaultFile template)
{
if (!LoadedVaultFiles.ContainsKey(template.FileName))
{
LoadedVaultFiles.Add(template.FileName, template);
}
}
public static void AddVaultFile(SavedGunSerializable template)
{
template.Validate();
if (!LoadedLegacyVaultFiles.ContainsKey(template.FileName))
{
LoadedLegacyVaultFiles.Add(template.FileName, template);
}
}
}
public enum PanelType
{
MagDuplicator,
Recycler,
AmmoReloader,
MagUpgrader,
AddFullAuto,
AmmoPurchase,
FireRateUp,
FireRateDown,
MagPurchase
}
public class MagazinePanel : MonoBehaviour
{
public TNH_MagDuplicator original;
public Dictionary<string, MagazineBlacklistEntry> blacklist;
public int DupeCost = 2;
public int UpgradeCost = 3;
public int PurchaseCost = 2;
private int numTokensSelected;
public static Sprite background;
private TNH_ObjectConstructorIcon DupeIcon;
private TNH_ObjectConstructorIcon UpgradeIcon;
private TNH_ObjectConstructorIcon PurchaseIcon;
private Text priceText_0;
private Text priceText_1;
private Text priceText_2;
private Text capacityText;
private FVRPhysicalObject selectedObject;
private FVRFireArmMagazine detectedMag;
private Speedloader detectedSpeedLoader;
private FVRObject purchaseMag;
private FVRObject upgradeMag;
private Collider[] colBuffer = (Collider[])(object)new Collider[50];
private readonly MethodInfo miUpdateIconDisplay = typeof(TNH_ObjectConstructorIcon).GetMethod("UpdateIconDisplay", BindingFlags.Instance | BindingFlags.NonPublic);
public void Awake()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
original = ((Component)this).gameObject.GetComponent<TNH_MagDuplicator>();
if ((Object)(object)original == (Object)null)
{
TNHFrameworkLogger.LogError("Mag Upgrader failed, original Mag Duplicator was null!");
}
((Behaviour)original).enabled = false;
blacklist = LoadedTemplateManager.CurrentCharacter.GetMagazineBlacklist();
InitPanel();
UpdateIcons();
original.M.TokenCountChangeEvent += new TokenCountChange(UpdateTokenDisplay);
}
private void OnDestroy()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
if ((Object)(object)original.M != (Object)null)
{
original.M.TokenCountChangeEvent -= new TokenCountChange(UpdateTokenDisplay);
}
}
private void InitPanel()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Expected O, but got Unknown
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Expected O, but got Unknown
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Expected O, but got Unknown
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Expected O, but got Unknown
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Expected O, but got Unknown
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/AmmoReloaderTitle (3)");
((Component)val).gameObject.GetComponent<Text>().text = "-- Mag Dupe / Upgrade / Buy --";
Transform val2 = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/Backing");
Transform val3 = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas");
Transform transform = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent).transform;
transform.localPosition = new Vector3(0f, -30f, 0f);
capacityText = ((Component)transform).gameObject.GetComponent<Text>();
Transform val4 = val3.Find("Icon_0");
val4.localPosition = new Vector3(-270f, -200f, 0f);
Transform val5 = val3.Find("Icon_1");
val5.localPosition = new Vector3(0f, -200f, 0f);
Transform transform2 = Object.Instantiate<GameObject>(((Component)val5).gameObject, val3).transform;
transform2.localPosition = new Vector3(275f, -200f, 0f);
Transform obj = ((Component)original).transform.Find("PointableButton_0");
obj.position = val4.position;
Transform val6 = ((Component)original).transform.Find("PointableButton_1");
val6.position = val5.position;
Transform transform3 = Object.Instantiate<GameObject>(((Component)val6).gameObject, val6.parent).transform;
transform3.position = transform2.position;
((Component)val2).gameObject.GetComponent<Image>().sprite = background;
DupeIcon = ((Component)val4).gameObject.GetComponent<TNH_ObjectConstructorIcon>();
UpgradeIcon = ((Component)val5).gameObject.GetComponent<TNH_ObjectConstructorIcon>();
PurchaseIcon = ((Component)transform2).gameObject.GetComponent<TNH_ObjectConstructorIcon>();
Button component = ((Component)obj).gameObject.GetComponent<Button>();
component.onClick = new ButtonClickedEvent();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
DupeMagButton();
});
Button component2 = ((Component)val6).gameObject.GetComponent<Button>();
component2.onClick = new ButtonClickedEvent();
((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
{
UpgradeMagButton();
});
Button component3 = ((Component)transform3).gameObject.GetComponent<Button>();
component3.onClick = new ButtonClickedEvent();
((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
{
PurchaseMagButton();
});
priceText_0 = AddPriceText(val4, new Vector3(-235f, 155f, 0f));
priceText_1 = AddPriceText(val5, new Vector3(40f, 155f, 0f));
priceText_2 = AddPriceText(transform2, new Vector3(355f, 150f, 0f));
priceText_2.alignment = (TextAnchor)3;
priceText_0.text = "x" + DupeCost;
priceText_1.text = "x" + UpgradeCost;
priceText_2.text = "x" + PurchaseCost;
capacityText.text = string.Empty;
}
private Text AddPriceText(Transform iconTransform, Vector3 localPosition)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("PriceCanvas");
val.transform.SetParent(iconTransform.parent);
val.transform.rotation = iconTransform.rotation;
val.transform.localPosition = localPosition;
Canvas obj = val.AddComponent<Canvas>();
RectTransform component = ((Component)obj).GetComponent<RectTransform>();
obj.renderMode = (RenderMode)2;
component.sizeDelta = new Vector2(1f, 1f);
GameObject val2 = new GameObject("Text");
val2.transform.SetParent(val.transform);
val2.transform.rotation = val.transform.rotation;
val2.transform.localPosition = Vector3.zero;
val2.AddComponent<CanvasRenderer>();
Text obj2 = val2.AddComponent<Text>();
Font font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
obj2.text = "x?";
obj2.alignment = (TextAnchor)4;
obj2.fontSize = 30;
obj2.fontStyle = (FontStyle)1;
val2.transform.localScale = new Vector3(0.0015f, 0.0015f, 0.0015f);
obj2.font = font;
obj2.horizontalOverflow = (HorizontalWrapMode)1;
return obj2;
}
private void DupeMagButton()
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
if (((Object)(object)detectedMag == (Object)null && (Object)(object)detectedSpeedLoader == (Object)null) || original.M.GetNumTokens() < DupeCost)
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Spawn, ((Component)this).transform.position);
original.M.SubtractTokens(DupeCost);
if ((Object)(object)detectedMag != (Object)null)
{
FirearmUtils.SpawnDuplicateMagazine(original.M, detectedMag, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
}
else
{
FirearmUtils.SpawnDuplicateSpeedloader(original.M, detectedSpeedLoader, original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
}
ClearSelection();
UpdateIcons();
}
private void UpgradeMagButton()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)upgradeMag == (Object)null || original.M.GetNumTokens() < UpgradeCost)
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Spawn, ((Component)this).transform.position);
original.M.SubtractTokens(UpgradeCost);
Object.Destroy((Object)(object)((FVRInteractiveObject)detectedMag).GameObject);
Object.Instantiate<GameObject>(((AnvilAsset)upgradeMag).GetGameObject(), original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
ClearSelection();
UpdateIcons();
}
private void PurchaseMagButton()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)purchaseMag == (Object)null || original.M.GetNumTokens() < PurchaseCost)
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Spawn, ((Component)this).transform.position);
original.M.SubtractTokens(PurchaseCost);
Object.Instantiate<GameObject>(((AnvilAsset)purchaseMag).GetGameObject(), original.Spawnpoint_Mag.position, original.Spawnpoint_Mag.rotation);
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Distance(original.ScanningVolume.position, ((Component)GM.CurrentPlayerBody.Head).transform.position) < 2f)
{
Scan();
UpdateIcons();
}
else
{
ClearSelection();
}
}
private void ClearSelection()
{
detectedMag = null;
detectedSpeedLoader = null;
purchaseMag = null;
upgradeMag = null;
selectedObject = null;
TG_Bounds placementBoundsRenderer = original.PlacementBoundsRenderer;
if (placementBoundsRenderer != null)
{
((Component)placementBoundsRenderer).gameObject.SetActive(false);
}
}
private void Scan()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
global::TNHFramework.ObjectTemplates.CustomCharacter currentCharacter = LoadedTemplateManager.CurrentCharacter;
if ((Object)(object)selectedObject != (Object)null)
{
Bounds val = default(Bounds);
((Bounds)(ref val))..ctor(((Component)selectedObject).transform.position, new Vector3(0.01f, 0.01f, 0.01f));
Collider[] componentsInChildren = ((Component)((Component)selectedObject).transform).GetComponentsInChildren<Collider>();
foreach (Collider val2 in componentsInChildren)
{
if ((Object)(object)val2 != (Object)null && val2.isTrigger)
{
((Bounds)(ref val)).Encapsulate(val2.bounds);
}
}
Vector3 position = selectedObject.RootRigidbody.position;
Vector3 val3 = ((Bounds)(ref val)).center - ((Component)selectedObject).transform.position;
if ((Object)(object)original.PlacementBoundsRenderer == (Object)null)
{
GameObject val4 = Object.Instantiate<GameObject>(original.PlacementBoundsPrefab, position, Quaternion.identity);
original.PlacementBoundsRenderer = val4.GetComponent<TG_Bounds>();
}
((Component)original.PlacementBoundsRenderer).gameObject.SetActive(true);
original.PlacementBoundsRenderer.PoseAndRescale(position + val3, ((Bounds)(ref val)).extents * 2f, original.EmitterPoint.position);
Bounds val5 = default(Bounds);
((Bounds)(ref val5))..ctor(original.ScanningVolume.position, new Vector3(0.001f, 0.001f, 0.001f));
((Bounds)(ref val5)).Encapsulate(original.ScanningVolume.TransformPoint(new Vector3(0.5f, 0.5f, 0.5f)));
((Bounds)(ref val5)).Encapsulate(original.ScanningVolume.TransformPoint(new Vector3(-0.5f, -0.5f, -0.5f)));
if (!((Bounds)(ref val)).Intersects(val5))
{
ClearSelection();
}
}
if (!((Object)(object)selectedObject == (Object)null))
{
return;
}
int num = Physics.OverlapBoxNonAlloc(original.ScanningVolume.position, original.ScanningVolume.localScale * 0.5f, colBuffer, original.ScanningVolume.rotation, LayerMask.op_Implicit(original.ScanningLM), (QueryTriggerInteraction)2);
detectedMag = null;
detectedSpeedLoader = null;
purchaseMag = null;
upgradeMag = null;
for (int j = 0; j < num; j++)
{
if (!((Object)(object)colBuffer[j].attachedRigidbody != (Object)null))
{
continue;
}
FVRFireArm component = ((Component)colBuffer[j]).GetComponent<FVRFireArm>();
if ((Object)(object)purchaseMag == (Object)null && (Object)(object)component != (Object)null && !((FVRInteractiveObject)component).IsHeld && (Object)(object)((FVRPhysicalObject)component).QuickbeltSlot == (Object)null)
{
MagazineBlacklistEntry magazineBlacklistEntry = (blacklist.ContainsKey(((FVRPhysicalObject)component).ObjectWrapper.ItemID) ? blacklist[((FVRPhysicalObject)component).ObjectWrapper.ItemID] : null);
List<FVRObject> compatibleMagazines = FirearmUtils.GetCompatibleMagazines(((FVRPhysicalObject)component).ObjectWrapper, -1, -1, smallestIfEmpty: false, currentCharacter.GlobalObjectBlacklist, magazineBlacklistEntry);
if (compatibleMagazines.Any())
{
purchaseMag = FirearmUtils.GetSmallestCapacityMagazine(compatibleMagazines, currentCharacter.GlobalObjectBlacklist, magazineBlacklistEntry);
selectedObject = (FVRPhysicalObject)(object)component;
}
}
FVRFireArmMagazine component2 = ((Component)colBuffer[j].attachedRigidbody).GetComponent<FVRFireArmMagazine>();
if ((Object)(object)component2 != (Object)null && (Object)(object)component2.FireArm == (Object)null && !((FVRInteractiveObject)component2).IsHeld && (Object)(object)((FVRPhysicalObject)component2).QuickbeltSlot == (Object)null && !component2.IsIntegrated)
{
detectedMag = component2;
selectedObject = (FVRPhysicalObject)(object)component2;
}
Speedloader component3 = ((Component)colBuffer[j].attachedRigidbody).GetComponent<Speedloader>();
if ((Object)(object)component3 != (Object)null && !((FVRInteractiveObject)component3).IsHeld && (Object)(object)((FVRPhysicalObject)component3).QuickbeltSlot == (Object)null && component3.IsPretendingToBeAMagazine)
{
detectedSpeedLoader = component3;
selectedObject = (FVRPhysicalObject)(object)component3;
}
if ((Object)(object)purchaseMag != (Object)null && ((Object)(object)detectedMag != (Object)null || (Object)(object)detectedSpeedLoader != (Object)null))
{
break;
}
}
}
private void UpdateIcons()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
global::TNHFramework.ObjectTemplates.CustomCharacter currentCharacter = LoadedTemplateManager.CurrentCharacter;
DupeIcon.State = (IconState)2;
UpgradeIcon.State = (IconState)2;
PurchaseIcon.State = (IconState)2;
int numTokens = original.M.GetNumTokens();
numTokensSelected = 0;
capacityText.text = string.Empty;
if ((Object)(object)detectedMag != (Object)null || (Object)(object)detectedSpeedLoader != (Object)null)
{
DupeIcon.State = (IconState)1;
if (numTokens >= DupeCost)
{
numTokensSelected = DupeCost;
}
}
if ((Object)(object)purchaseMag != (Object)null)
{
PurchaseIcon.State = (IconState)1;
if (numTokens >= PurchaseCost)
{
numTokensSelected = PurchaseCost;
}
}
if ((Object)(object)detectedMag != (Object)null)
{
upgradeMag = FirearmUtils.GetNextHighestCapacityMagazine(((FVRPhysicalObject)detectedMag).ObjectWrapper, currentCharacter.GlobalObjectBlacklist);
if ((Object)(object)upgradeMag != (Object)null)
{
UpgradeIcon.State = (IconState)1;
if (numTokens >= UpgradeCost)
{
numTokensSelected = UpgradeCost;
}
capacityText.text = $"{detectedMag.m_capacity} -> {upgradeMag.MagazineCapacity}";
}
}
miUpdateIconDisplay.Invoke(DupeIcon, new object[0]);
miUpdateIconDisplay.Invoke(UpgradeIcon, new object[0]);
miUpdateIconDisplay.Invoke(PurchaseIcon, new object[0]);
UpdateTokenDisplay(numTokens);
}
private void UpdateTokenDisplay(int numTokens)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < original.TokenList.Count; i++)
{
if (i < numTokens)
{
if (i < numTokens - numTokensSelected)
{
((Graphic)original.TokenList[i]).color = original.Token_Unselected;
}
else
{
((Graphic)original.TokenList[i]).color = original.Token_Selected;
}
}
else
{
((Graphic)original.TokenList[i]).color = original.Token_Empty;
}
}
}
}
public class AmmoPurchasePanel : MonoBehaviour
{
public TNH_MagDuplicator original;
public Dictionary<string, MagazineBlacklistEntry> blacklist;
public int PanelCost = 1;
private int numTokensSelected;
public static Sprite background;
private TNH_ObjectConstructorIcon PurchaseIcon;
private FVRPhysicalObject selectedObject;
private FVRFireArm detectedFirearm;
private Collider[] colBuffer = (Collider[])(object)new Collider[50];
private readonly MethodInfo miUpdateIconDisplay = typeof(TNH_ObjectConstructorIcon).GetMethod("UpdateIconDisplay", BindingFlags.Instance | BindingFlags.NonPublic);
public void Awake()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
original = ((Component)this).gameObject.GetComponent<TNH_MagDuplicator>();
if ((Object)(object)original == (Object)null)
{
TNHFrameworkLogger.LogError("Ammo Purchaser failed, original mag duplicator was null!");
}
((Behaviour)original).enabled = false;
InitPanel();
UpdateIcons();
original.M.TokenCountChangeEvent += new TokenCountChange(UpdateTokenDisplay);
}
private void OnDestroy()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
if ((Object)(object)original.M != (Object)null)
{
original.M.TokenCountChangeEvent -= new TokenCountChange(UpdateTokenDisplay);
}
}
private void InitPanel()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
((Component)((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/AmmoReloaderTitle (3)")).gameObject.GetComponent<Text>().text = "-- Ammo Purchaser --";
Transform val = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/Backing");
Transform obj = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas");
Transform val2 = obj.Find("Icon_0");
val2.localPosition = new Vector3(0f, -290f, 0f);
Object.Destroy((Object)(object)((Component)obj.Find("Icon_1")).gameObject);
Transform obj2 = ((Component)original).transform.Find("PointableButton_0");
obj2.position = val2.position;
Object.Destroy((Object)(object)((Component)((Component)original).transform.Find("PointableButton_1")).gameObject);
((Component)val).gameObject.GetComponent<Image>().sprite = background;
PurchaseIcon = ((Component)val2).gameObject.GetComponent<TNH_ObjectConstructorIcon>();
Button component = ((Component)obj2).gameObject.GetComponent<Button>();
component.onClick = new ButtonClickedEvent();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
PurchaseAmmoButton();
});
}
public void PurchaseAmmoButton()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)detectedFirearm == (Object)null || original.M.GetNumTokens() < PanelCost)
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
OTagFirearmRoundPower roundPower = AM.GetRoundPower(detectedFirearm.RoundType);
int roundsToSpawn = GetRoundsToSpawn(roundPower);
TNHFrameworkLogger.Log("Compatible rounds count for " + ((FVRPhysicalObject)detectedFirearm).ObjectWrapper.ItemID + ": " + IM.OD[((FVRPhysicalObject)detectedFirearm).ObjectWrapper.ItemID].CompatibleSingleRounds.Count, TNHFrameworkLogger.LogType.General);
global::TNHFramework.ObjectTemplates.CustomCharacter currentCharacter = LoadedTemplateManager.CurrentCharacter;
MagazineBlacklistEntry magazineBlacklistEntry = null;
if (currentCharacter.GetMagazineBlacklist().ContainsKey(((FVRPhysicalObject)detectedFirearm).ObjectWrapper.ItemID))
{
magazineBlacklistEntry = currentCharacter.GetMagazineBlacklist()[((FVRPhysicalObject)detectedFirearm).ObjectWrapper.ItemID];
}
FVRObject random = FirearmUtils.GetCompatibleRounds(((FVRPhysicalObject)detectedFirearm).ObjectWrapper, currentCharacter.ValidAmmoEras, currentCharacter.ValidAmmoSets, currentCharacter.GlobalAmmoBlacklist, currentCharacter.GlobalObjectBlacklist, magazineBlacklistEntry).GetRandom();
if ((Object)(object)random == (Object)null)
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Spawn, ((Component)this).transform.position);
original.M.SubtractTokens(PanelCost);
AnvilManager.Run(SpawnRounds(original.M, random, roundsToSpawn));
ClearSelection();
UpdateIcons();
}
public IEnumerator SpawnRounds(TNH_Manager M, FVRObject bullet, int count)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((AnvilAsset)bullet).GetGameObject();
return TNHFrameworkUtils.InstantiateMultiple(M, gameObject, original.Spawnpoint_Mag.position, count);
}
public int GetRoundsToSpawn(OTagFirearmRoundPower roundPower)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected I4, but got Unknown
return (int)roundPower switch
{
0 => 10,
1 => 30,
2 => 30,
3 => 18,
4 => 20,
5 => 16,
6 => 6,
7 => 3,
8 => 16,
9 => 10,
_ => 10,
};
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (Vector3.Distance(original.ScanningVolume.position, ((Component)GM.CurrentPlayerBody.Head).transform.position) < 2f)
{
Scan();
UpdateIcons();
}
else
{
ClearSelection();
}
}
private void ClearSelection()
{
detectedFirearm = null;
selectedObject = null;
TG_Bounds placementBoundsRenderer = original.PlacementBoundsRenderer;
if (placementBoundsRenderer != null)
{
((Component)placementBoundsRenderer).gameObject.SetActive(false);
}
}
private void Scan()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)selectedObject != (Object)null)
{
Bounds val = default(Bounds);
((Bounds)(ref val))..ctor(((Component)selectedObject).transform.position, new Vector3(0.01f, 0.01f, 0.01f));
Collider[] componentsInChildren = ((Component)((Component)selectedObject).transform).GetComponentsInChildren<Collider>();
foreach (Collider val2 in componentsInChildren)
{
if ((Object)(object)val2 != (Object)null && val2.isTrigger)
{
((Bounds)(ref val)).Encapsulate(val2.bounds);
}
}
Vector3 position = selectedObject.RootRigidbody.position;
Vector3 val3 = ((Bounds)(ref val)).center - ((Component)selectedObject).transform.position;
if ((Object)(object)original.PlacementBoundsRenderer == (Object)null)
{
GameObject val4 = Object.Instantiate<GameObject>(original.PlacementBoundsPrefab, position, Quaternion.identity);
original.PlacementBoundsRenderer = val4.GetComponent<TG_Bounds>();
}
((Component)original.PlacementBoundsRenderer).gameObject.SetActive(true);
original.PlacementBoundsRenderer.PoseAndRescale(position + val3, ((Bounds)(ref val)).extents * 2f, original.EmitterPoint.position);
Bounds val5 = default(Bounds);
((Bounds)(ref val5))..ctor(original.ScanningVolume.position, new Vector3(0.001f, 0.001f, 0.001f));
((Bounds)(ref val5)).Encapsulate(original.ScanningVolume.TransformPoint(new Vector3(0.5f, 0.5f, 0.5f)));
((Bounds)(ref val5)).Encapsulate(original.ScanningVolume.TransformPoint(new Vector3(-0.5f, -0.5f, -0.5f)));
if (!((Bounds)(ref val)).Intersects(val5))
{
ClearSelection();
}
}
if (!((Object)(object)selectedObject == (Object)null))
{
return;
}
int num = Physics.OverlapBoxNonAlloc(original.ScanningVolume.position, original.ScanningVolume.localScale * 0.5f, colBuffer, original.ScanningVolume.rotation, LayerMask.op_Implicit(original.ScanningLM), (QueryTriggerInteraction)2);
detectedFirearm = null;
for (int j = 0; j < num; j++)
{
if ((Object)(object)colBuffer[j].attachedRigidbody != (Object)null)
{
FVRFireArm component = ((Component)colBuffer[j].attachedRigidbody).GetComponent<FVRFireArm>();
if ((Object)(object)component != (Object)null && !((FVRInteractiveObject)component).IsHeld && (Object)(object)((FVRPhysicalObject)component).QuickbeltSlot == (Object)null)
{
detectedFirearm = component;
selectedObject = (FVRPhysicalObject)(object)component;
break;
}
}
}
}
private void UpdateIcons()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
PurchaseIcon.State = (IconState)2;
int numTokens = original.M.GetNumTokens();
numTokensSelected = 0;
if ((Object)(object)detectedFirearm != (Object)null)
{
PurchaseIcon.State = (IconState)1;
if (numTokens >= PanelCost)
{
numTokensSelected = PanelCost;
}
}
miUpdateIconDisplay.Invoke(PurchaseIcon, new object[0]);
UpdateTokenDisplay(numTokens);
}
private void UpdateTokenDisplay(int numTokens)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < original.TokenList.Count; i++)
{
if (i < numTokens)
{
if (i < numTokens - numTokensSelected)
{
((Graphic)original.TokenList[i]).color = original.Token_Unselected;
}
else
{
((Graphic)original.TokenList[i]).color = original.Token_Selected;
}
}
else
{
((Graphic)original.TokenList[i]).color = original.Token_Empty;
}
}
}
}
public class FullAutoPanel : MonoBehaviour
{
public TNH_MagDuplicator original;
public int PanelCost = 4;
private int numTokensSelected;
public static Sprite background;
private TNH_ObjectConstructorIcon PurchaseIcon;
private FVRPhysicalObject selectedObject;
public Handgun detectedHandgun;
public ClosedBoltWeapon detectedClosedBolt;
public OpenBoltReceiver detectedOpenBolt;
private Collider[] colBuffer = (Collider[])(object)new Collider[50];
private readonly MethodInfo miUpdateIconDisplay = typeof(TNH_ObjectConstructorIcon).GetMethod("UpdateIconDisplay", BindingFlags.Instance | BindingFlags.NonPublic);
public void Awake()
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
original = ((Component)this).gameObject.GetComponent<TNH_MagDuplicator>();
if ((Object)(object)original == (Object)null)
{
TNHFrameworkLogger.LogError("Full Auto Enabler failed, original Mag Duplicator was null!");
}
((Behaviour)original).enabled = false;
InitPanel();
UpdateIcons();
original.M.TokenCountChangeEvent += new TokenCountChange(UpdateTokenDisplay);
}
private void OnDestroy()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
if ((Object)(object)original.M != (Object)null)
{
original.M.TokenCountChangeEvent -= new TokenCountChange(UpdateTokenDisplay);
}
}
private void InitPanel()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
((Component)((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/AmmoReloaderTitle (3)")).gameObject.GetComponent<Text>().text = "-- Full Auto Upgrader --";
Transform val = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas/Backing");
Transform obj = ((Component)original).transform.Find("_CanvasHolder/_UITest_Canvas");
Transform val2 = obj.Find("Icon_0");
val2.localPosition = new Vector3(0f, -290f, 0f);
Object.Destroy((Object)(object)((Component)obj.Find("Icon_1")).gameObject);
Transform obj2 = ((Component)original).transform.Find("PointableButton_0");
obj2.position = val2.position;
Object.Destroy((Object)(object)((Component)((Component)original).transform.Find("PointableButton_1")).gameObject);
((Component)val).gameObject.GetComponent<Image>().sprite = background;
PurchaseIcon = ((Component)val2).gameObject.GetComponent<TNH_ObjectConstructorIcon>();
Button component = ((Component)obj2).gameObject.GetComponent<Button>();
component.onClick = new ButtonClickedEvent();
((UnityEvent)component.onClick).AddListener((UnityAction)delegate
{
AddFullAutoButton();
});
}
public void AddFullAutoButton()
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (((Object)(object)detectedHandgun == (Object)null && (Object)(object)detectedClosedBolt == (Object)null && (Object)(object)detectedOpenBolt == (Object)null) || PanelCost > original.M.GetNumTokens())
{
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Fail, ((Component)this).transform.position);
return;
}
SM.PlayCoreSound((FVRPooledAudioType)20, original.AudEvent_Spawn, ((Component)this).transform.position);
original.M.SubtractTokens(PanelCost);
if ((Object)(object)detectedHandgun != (Object)null)
{
AddFullAutoToHandgun(detectedHandgun);
ClearSelection();
}
else if ((Object)(object)detectedClosedBolt != (Object)null)
{
AddFullAutoToClosedBolt(detectedClosedBolt);
ClearSelection();
}
else if ((Object)(object)detectedOpenBolt != (Object)null)
{
AddFullAutoToOpenBolt(detectedOpenBolt);
ClearSelection();
}
}
private void AddFullAutoToHandgun(Handgun gun)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Expected O, but got Unknown
FireSelectorMode val = new FireSelectorMode
{
SelectorPosition = 0f,
ModeType = (FireSelectorModeType)2
};
if (gun.FireSelectorModes != null)
{
FireSelectorMode[] fireSelectorModes = gun.FireSelectorModes;
for (int i = 0; i < fireSelectorModes.Length; i++)
{
Debug.Log((object)fireSelectorModes[i].ModeType);
}
}
if (gun.FireSelectorModes == null || gun.FireSelectorModes.Length == 0)
{
FireSelectorMode val2 = new FireSelectorMode
{
SelectorPosition = 0f,
ModeType = (FireSelectorModeType)1
};
gun.FireSelectorModes = (FireSelectorMode[])(object)new FireSelectorMode[2] { val2, val };
}
else
{
List<FireSelectorMode> list = new List<FireSelectorMode>(gun.FireSelectorModes) { val };
gun.FireSelectorModes = list.ToArray();
}
if (!gun.HasFireSelector)
{
gun.HasFireSelector = true;
if (gun.HasSafety)
{
gun.FireSelectorAxis = gun.SafetyAxis;
gun.FireSelectorInterpStyle = gun.Safety_Interp;
gun.FireSelector = gun.Safety;
}
else if ((Object)(object)gun.FireSelector == (Object)null)
{
gun.FireSelector = Object.Instantiate<GameObject>(new GameObject(), ((FVRInteractiveObject)gun).GameObject.transform).transform;
}
}
if (gun.HasSafety)
{
((FVRFireArm)gun).AudioClipSet.FireSelector = ((FVRFireArm)gun).AudioClipSet.Safety;
gun.HasSafety = false;
}
}
private void AddFullAutoToClosedBolt(ClosedBoltWeapon gun)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
FireSelectorMode val = new FireSelectorMode
{
ModeType = (FireSelectorModeType)3,
SelectorPosition = 0f
};
if (gun.FireSelector_Modes == null || gun.FireSelector_Modes.Length == 0)
{
FireSelectorMode val2 = new FireSelectorMode
{
ModeType = (FireSelectorModeType)1,
SelectorPosition = 0f
};
gun.FireSelector_Modes = (FireSelectorMode[])(object)new FireSelectorMode[2] { val2, val };
}
else
{
List<FireSelectorMode> list = new List<FireSelectorMode>(gun.FireSelector_Modes) { val };
gun.FireSelector_Modes = list.ToArray();
}
}
private void AddFullAutoToOpenBolt(OpenBoltReceiver gun)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
FireSelectorMode val = new FireSelectorMode
{
ModeType = (FireSelectorModeType)2,
SelectorPosition = 0f
};
if (gun.FireSelector_Modes == null || gun.FireSelector_Modes.Length == 0)
{
FireSelectorMode val2 = new FireSelectorMode
{
ModeType = (FireSelectorModeType)1,
SelectorPosition = 0f
};
gun.FireSelector_Modes = (FireSelectorMode[])(object)new FireSelectorMode[2] { val2, val };
}
else
{
List<