using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.SosigIntegrityConfigs")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace NGA
{
[BepInPlugin("NGA.SosigIntegrityConfigs", "SosigIntegrityConfigs", "0.1.0")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
[BepInProcess("h3vr.exe")]
public class SosigIntegrityConfigs : BaseUnityPlugin
{
[HarmonyPatch(typeof(Sosig))]
[HarmonyPatch("Start")]
private class SosigStartHook
{
private static void Postfix(Sosig __instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected I4, but got Unknown
for (int i = 0; i < __instance.Links.Count; i++)
{
if ((Object)(object)__instance.Links[i] != (Object)null)
{
SosigBodyPart bodyPart = __instance.Links[i].BodyPart;
SosigBodyPart val = bodyPart;
switch ((int)val)
{
case 0:
__instance.Links[i].SetIntegrity(config_link_head_starting_integrity.Value);
__instance.Links[i].m_fullintegrity = config_link_head_starting_integrity.Value;
break;
case 1:
__instance.Links[i].SetIntegrity(config_link_torso_starting_integrity.Value);
__instance.Links[i].m_fullintegrity = config_link_torso_starting_integrity.Value;
break;
case 2:
__instance.Links[i].SetIntegrity(config_link_upper_starting_integrity.Value);
__instance.Links[i].m_fullintegrity = config_link_upper_starting_integrity.Value;
break;
case 3:
__instance.Links[i].SetIntegrity(config_link_lower_starting_integrity.Value);
__instance.Links[i].m_fullintegrity = config_link_lower_starting_integrity.Value;
break;
default:
__instance.Links[i].SetIntegrity(config_link_head_starting_integrity.Value);
__instance.Links[i].m_fullintegrity = config_link_head_starting_integrity.Value;
break;
}
}
else
{
Logger.LogMessage((object)"Sosig links null?");
}
}
}
}
[HarmonyPatch(typeof(Sosig))]
[HarmonyPatch("DestroyLink")]
private class SosigDestroyLinkHook
{
public static Sosig nga_static_instance;
private static bool Prefix(Sosig __instance, SosigLink link, DamageClass damClass)
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected I4, but got Unknown
//IL_0145: 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_015d: 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_01ce: 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_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Invalid comparison between Unknown and I4
//IL_0256: 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_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: 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_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)link.J != (Object)null)
{
Object.Destroy((Object)(object)link.J);
}
for (int num = __instance.Links.Count - 1; num >= 0; num--)
{
if ((Object)(object)__instance.Links[num] != (Object)null && (Object)(object)__instance.Links[num].J != (Object)null && (Object)(object)((Joint)__instance.Links[num].J).connectedBody == (Object)(object)link.R)
{
((Component)__instance.Links[num]).transform.SetParent((Transform)null);
Object.Destroy((Object)(object)__instance.Links[num].J);
}
}
__instance.m_linksDestroyed[link.BodyPart] = true;
__instance.Mustard *= 0.75f;
SosigBodyPart bodyPart = link.BodyPart;
SosigBodyPart val = bodyPart;
switch ((int)val)
{
case 0:
__instance.KillSpeech();
if (__instance.m_doesExplodeKill_Head)
{
__instance.SosigDies(damClass, (SosigDeathType)3);
}
else
{
__instance.Shudder(3f);
}
break;
case 1:
__instance.SosigDies(damClass, (SosigDeathType)3);
break;
case 2:
if (__instance.m_doesExplodeKill_Upper)
{
__instance.SosigDies(damClass, (SosigDeathType)3);
break;
}
__instance.BreakBack(false);
__instance.Shudder(2f);
break;
case 3:
if (__instance.m_doesExplodeKill_Lower)
{
__instance.SosigDies(damClass, (SosigDeathType)3);
break;
}
__instance.Hobble(false);
__instance.Shudder(2f);
break;
}
if (config_allow_sosig_explosion_fx.Value)
{
Object.Instantiate<GameObject>(__instance.DamageFX_Explosion, ((Component)link).transform.position, Random.rotation);
}
if (link.HasSpawnOnDestroy && config_allow_sosig_gibs_spawn.Value)
{
Object.Instantiate<GameObject>(((AnvilAsset)link.SpawnOnDestroy).GetGameObject(), ((Component)link).transform.position, Quaternion.identity);
}
if (config_allow_sosig_gibs_spawn.Value && __instance.UsesGibs && (int)GM.Options.SimulationOptions.SosigChunksMode == 0)
{
Vector3 position = ((Component)link).transform.position;
Quaternion rotation = ((Component)link).transform.rotation;
for (int i = 0; i < __instance.GibLocalPoses.Length; i++)
{
Vector3 val2 = ((Component)link).transform.position + ((Component)link).transform.right * __instance.GibLocalPoses[i].x + ((Component)link).transform.up * __instance.GibLocalPoses[i].y + ((Component)link).transform.forward * __instance.GibLocalPoses[i].z;
if (!config_allow_gibs_flying.Value)
{
}
GameObject val3 = Object.Instantiate<GameObject>(__instance.GibPrefabs[i], val2, rotation);
Rigidbody component = val3.GetComponent<Rigidbody>();
if (config_allow_gibs_flying.Value)
{
component.AddForceAtPosition(-link.R.velocity * Random.Range(0.3f, 1f), ((Component)link).transform.position, (ForceMode)2);
continue;
}
nga_static_instance = __instance;
component.drag = 20f;
((MonoBehaviour)nga_static_instance).StartCoroutine(EnableColliderAfterDelay(component, 0.05f));
}
}
Object.Destroy((Object)(object)((Component)link).gameObject);
__instance.CleanUpDecals();
__instance.UpdateRenderers();
return false;
}
private static IEnumerator EnableColliderAfterDelay(Rigidbody rg, float delay)
{
yield return (object)new WaitForSeconds(delay);
rg.drag = 1f;
}
}
[HarmonyPatch(typeof(Sosig))]
[HarmonyPatch("TickDownToClear")]
private class SosigTickDownToClearHook
{
private static void Postfix(Sosig __instance, float f)
{
if (config_clearsosig_force_tickdown.Value)
{
Logger.LogMessage((object)("Using new tickdown val " + config_tickdown_override_clear.Value));
__instance.m_tickDownToClear = config_tickdown_override_clear.Value;
}
else
{
Logger.LogMessage((object)"No tickdown forced");
}
}
}
[HarmonyPatch(typeof(Sosig))]
[HarmonyPatch("ClearSosig")]
private class SosigClearSosigHook
{
private static bool Prefix(Sosig __instance)
{
if (config_clearsosig_force_tickdown.Value && !__instance.m_isTickingDownToClear)
{
__instance.KillSosig();
__instance.TickDownToClear(config_tickdown_override_clear.Value);
return false;
}
if (config_clearsosig_explode.Value)
{
return true;
}
if ((Object)(object)__instance.DeParentOnSpawn != (Object)null)
{
Object.Destroy((Object)(object)((Component)__instance.DeParentOnSpawn).gameObject);
}
for (int i = 0; i < __instance.Links.Count; i++)
{
if ((Object)(object)__instance.Links[i] != (Object)null)
{
Object.Destroy((Object)(object)((Component)__instance.Links[i]).gameObject);
}
}
for (int j = 0; j < __instance.Hands.Count; j++)
{
__instance.Hands[j].DropHeldObject();
}
__instance.Inventory.DropAllObjects();
__instance.ClearCoverPoint();
Object.Destroy((Object)(object)((Component)__instance).gameObject);
return false;
}
}
[HarmonyPatch(typeof(SosigLink))]
[HarmonyPatch("GetDamageStateIndex")]
private class SosigLinkGetDamageStateIndexHook
{
private static bool Prefix(SosigLink __instance, ref int __result)
{
if (__instance.m_integrity > __instance.m_fullintegrity * (config_link_integrity_damaged_threshold.Value / 100f))
{
__result = 0;
return false;
}
if (__instance.m_integrity > __instance.m_fullintegrity * (config_link_integrity_damaged_threshold.Value / 200f))
{
__result = 1;
return false;
}
__result = 2;
return false;
}
}
[HarmonyPatch(typeof(SosigLink))]
[HarmonyPatch("LinkExplodes")]
private class SosigLinkLinkExplodesHook
{
private static bool Prefix(SosigLink __instance, DamageClass damClass)
{
if (config_link_allow_destroy.Value)
{
return true;
}
return false;
}
}
[HarmonyPatch(typeof(Sosig))]
[HarmonyPatch("BleedingUpdate")]
private class SosigBleedingUpdateHook
{
private static void Prefix(Sosig __instance)
{
//IL_00fc: 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)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
string value = config_mustard_colour.Value;
List<GameObject> list = new List<GameObject> { __instance.DamageFX_LargeMustardBurst, __instance.DamageFX_SmallMustardBurst, __instance.DamageFX_LargeMustardBurst, __instance.DamageFX_MustardSpoutSmall, __instance.DamageFX_MustardSpoutLarge, __instance.DamageFX_Explosion };
if (!config_enable_ketchup.Value)
{
return;
}
foreach (GameObject item in list)
{
if ((Object)(object)item == (Object)null)
{
Logger.LogWarning((object)"Null mustard fx");
continue;
}
ParticleSystem component = item.GetComponent<ParticleSystem>();
if ((Object)(object)component == (Object)null)
{
Logger.LogWarning((object)("No particle sys for " + ((Object)item).name));
continue;
}
ParticleSystemRenderer component2 = ((Component)component).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component2 != (Object)null)
{
Color colorFromString = GetColorFromString(value);
((Renderer)component2).material.SetColor("_Tint", colorFromString);
((Renderer)component2).material.SetColor("_Color", colorFromString);
}
else
{
Logger.LogWarning((object)("No particle renderer for " + ((Object)item).name));
}
}
}
}
private static ConfigEntry<float> config_link_integrity_damaged_threshold;
private static ConfigEntry<bool> config_link_allow_destroy;
private static ConfigEntry<float> config_link_head_starting_integrity;
private static ConfigEntry<float> config_link_torso_starting_integrity;
private static ConfigEntry<float> config_link_upper_starting_integrity;
private static ConfigEntry<float> config_link_lower_starting_integrity;
private static ConfigEntry<bool> config_allow_sosig_explosion_fx;
private static ConfigEntry<bool> config_allow_sosig_gibs_spawn;
private static ConfigEntry<bool> config_allow_gibs_flying;
private static ConfigEntry<float> config_tickdown_override_clear;
private static ConfigEntry<bool> config_enable_ketchup;
private static ConfigEntry<string> config_mustard_colour;
private static ConfigEntry<bool> config_clearsosig_explode;
private static ConfigEntry<bool> config_clearsosig_force_tickdown;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("NGA.SosigIntegrityConfigs");
SetUpConfigFields();
val.PatchAll();
Logger.LogMessage((object)"Hello, world! Sent from NGA.SosigIntegrityConfigs 0.0.1");
}
private void SetUpConfigFields()
{
config_clearsosig_force_tickdown = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Clean Up", "Use Tickdown on ClearSosig", false, "Forces all gamemodes like TnH and SupplyRun to use Tickdown Override below.");
config_tickdown_override_clear = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Clean Up", "Tickdown Time before Sosig cleared Override", 15f, "Requires Tickdown on ClearSosig: True. Time before game cleans up dead sosigs. Attempts to override All gamemodes.");
config_clearsosig_explode = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Clean Up", "Explode on ClearSosig", true, "Default: true. Disallows link explosions on Sosig cleanup in TnH, SupplyRun, etc. Independent of integrity settings below.");
config_link_head_starting_integrity = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Integrity", "Sosig Head Link Integrity", 100f, "Sosig part link integrity, decreased on damage, explodes on 0 killing sosig");
config_link_torso_starting_integrity = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Integrity", "Sosig Torso Link Integrity", 100f, "Sosig part link integrity, decreased on damage, explodes on 0 killing sosig");
config_link_upper_starting_integrity = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Integrity", "Sosig Upper Link Integrity", 100f, "Sosig part link integrity, decreased on damage, explodes on 0 killing sosig.");
config_link_lower_starting_integrity = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Integrity", "Sosig Lower Link Integrity", 100f, "Sosig part link integrity, decreased on damage, explodes on 0 killing sosig.");
config_link_integrity_damaged_threshold = ((BaseUnityPlugin)this).Config.Bind<float>("Sosig Body.Integrity", "Integrity threshold Damaged Percent %", 70f, "If Link integrity falls below threshold %, displays damaged sosig link mesh.");
config_link_allow_destroy = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Explode", "Allow link explode", true, "Default: 'true'. Whether the sosig link will explode/despawn when its integrity reaches 0.");
config_allow_sosig_explosion_fx = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Explode", "Sosig Explosion Sound", true, "Default: 'true'. Starting value of sosig link integrity, gets decreased upon damage.");
config_allow_sosig_gibs_spawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Explode", "Sosig Spawns Gibs on Explosion", true, "Default: 'true'. Whether little bits of sosigs (gibs) are spawned once a link explodes.");
config_allow_gibs_flying = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Explode", "Sosig Gibs go Flying on Explosion", true, "Default: 'true'. If Gibs spawning are enabled, this determines whether they go flying or simply fall on the ground.");
config_enable_ketchup = ((BaseUnityPlugin)this).Config.Bind<bool>("Sosig Body.Colour", "Ketchup", false, "Some people like ketchup. WARNING: Requires restarting game, try changing 'Mustard Colour' instead.");
config_mustard_colour = ((BaseUnityPlugin)this).Config.Bind<string>("Sosig Body.Colour", "Mustard Colour", "#E3C834FF", "Default: #E3C834FF (mustard). Requires hex code for color, red is #ff0000.");
}
private static Color GetColorFromString(string colorString)
{
//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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Color result = default(Color);
if (ColorUtility.TryParseHtmlString(colorString, ref result))
{
return result;
}
Logger.LogMessage((object)("Failed to parse color from string: " + colorString));
return Color.white;
}
}
}