Decompiled source of Toxic Gas Framework v1.2.1

Toxic_Gas_Framework.dll

Decompiled a year ago
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using OtherLoader;
using Sodalite.Api;
using UnityEngine;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[RequireComponent(typeof(ParticleSystem))]
public class CFX_AutoDestructShuriken : MonoBehaviour
{
	public bool OnlyDeactivate;

	private void OnEnable()
	{
		((MonoBehaviour)this).StartCoroutine("CheckIfAlive");
	}

	private IEnumerator CheckIfAlive()
	{
		do
		{
			yield return (object)new WaitForSeconds(0.5f);
		}
		while (((Component)this).GetComponent<ParticleSystem>().IsAlive(true));
		if (OnlyDeactivate)
		{
			((Component)this).gameObject.SetActive(false);
		}
		else
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
[RequireComponent(typeof(Light))]
public class CFX_LightIntensityFade : MonoBehaviour
{
	public float duration = 1f;

	public float delay = 0f;

	public float finalIntensity = 0f;

	private float baseIntensity;

	public bool autodestruct;

	private float p_lifetime = 0f;

	private float p_delay;

	private void Start()
	{
		baseIntensity = ((Component)this).GetComponent<Light>().intensity;
	}

	private void OnEnable()
	{
		p_lifetime = 0f;
		p_delay = delay;
		if (delay > 0f)
		{
			((Behaviour)((Component)this).GetComponent<Light>()).enabled = false;
		}
	}

	private void Update()
	{
		if (p_delay > 0f)
		{
			p_delay -= Time.deltaTime;
			if (p_delay <= 0f)
			{
				((Behaviour)((Component)this).GetComponent<Light>()).enabled = true;
			}
		}
		else if (p_lifetime / duration < 1f)
		{
			((Component)this).GetComponent<Light>().intensity = Mathf.Lerp(baseIntensity, finalIntensity, p_lifetime / duration);
			p_lifetime += Time.deltaTime;
		}
		else if (autodestruct)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
[RequireComponent(typeof(MeshFilter))]
public class WFX_BulletHoleDecal : MonoBehaviour
{
	private static Vector2[] quadUVs = (Vector2[])(object)new Vector2[4]
	{
		new Vector2(0f, 0f),
		new Vector2(0f, 1f),
		new Vector2(1f, 0f),
		new Vector2(1f, 1f)
	};

	public float lifetime = 10f;

	public float fadeoutpercent = 80f;

	public Vector2 frames;

	public bool randomRotation = false;

	public bool deactivate = false;

	private float life;

	private float fadeout;

	private Color color;

	private float orgAlpha;

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		color = ((Component)this).GetComponent<Renderer>().material.GetColor("_TintColor");
		orgAlpha = color.a;
	}

	private void OnEnable()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		int num = Random.Range(0, (int)(frames.x * frames.y));
		int num2 = (int)((float)num % frames.x);
		int num3 = (int)((float)num / frames.y);
		Vector2[] array = (Vector2[])(object)new Vector2[4];
		for (int i = 0; i < 4; i++)
		{
			array[i].x = (quadUVs[i].x + (float)num2) * (1f / frames.x);
			array[i].y = (quadUVs[i].y + (float)num3) * (1f / frames.y);
		}
		((Component)this).GetComponent<MeshFilter>().mesh.uv = array;
		if (randomRotation)
		{
			((Component)this).transform.Rotate(0f, 0f, Random.Range(0f, 360f), (Space)1);
		}
		life = lifetime;
		fadeout = life * (fadeoutpercent / 100f);
		color.a = orgAlpha;
		((Component)this).GetComponent<Renderer>().material.SetColor("_TintColor", color);
		((MonoBehaviour)this).StopAllCoroutines();
		((MonoBehaviour)this).StartCoroutine("holeUpdate");
	}

	private IEnumerator holeUpdate()
	{
		while (life > 0f)
		{
			life -= Time.deltaTime;
			if (life <= fadeout)
			{
				color.a = Mathf.Lerp(0f, orgAlpha, life / fadeout);
				((Component)this).GetComponent<Renderer>().material.SetColor("_TintColor", color);
			}
			yield return null;
		}
	}
}
[RequireComponent(typeof(Light))]
public class WFX_LightFlicker : MonoBehaviour
{
	public float time = 0.05f;

	private float timer;

	private void Start()
	{
		timer = time;
		((MonoBehaviour)this).StartCoroutine("Flicker");
	}

	private IEnumerator Flicker()
	{
		while (true)
		{
			((Behaviour)((Component)this).GetComponent<Light>()).enabled = !((Behaviour)((Component)this).GetComponent<Light>()).enabled;
			do
			{
				timer -= Time.deltaTime;
				yield return null;
			}
			while (timer > 0f);
			timer = time;
		}
	}
}
namespace Andrew_FTW.Toxic_Gas_Framework;

[BepInPlugin("Andrew_FTW.Toxic_Gas_Framework", "Toxic_Gas_Framework", "1.2.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
[BepInDependency("h3vr.cityrobo.prefab_replacer", "1.0.0")]
[BepInDependency("nrgill28.Sodalite", "1.2.0")]
public class Toxic_Gas_FrameworkPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Andrew_FTW.Toxic_Gas_Framework");
		OtherLoader.RegisterDirectLoad(BasePath, "Andrew_FTW.Toxic_Gas_Framework", "", "", "", "tgfreplace");
		GameAPI.PreloadAllAssets(Path.Combine(BasePath, "pr_toxic_gas_framework"));
	}
}
[ExecuteInEditMode]
public class NightVisionPostEffect : MonoBehaviour
{
	public Material nightVisionMat;

	public Material bloom;

	public bool renderNightVision = true;

	public bool renderBloom = true;

	[Range(1f, 16f)]
	public int iterations = 1;

	private const int BoxDownPrefilterPass = 0;

	private const int BoxDownPass = 1;

	private const int BoxUpPass = 2;

	private const int ApplyBloomPass = 3;

	private RenderTexture[] textures = (RenderTexture[])(object)new RenderTexture[16];

	private void OnRenderImage(RenderTexture src, RenderTexture dest)
	{
		//IL_0014: 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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		int num = ((Texture)src).width / 2;
		int num2 = ((Texture)src).height / 2;
		RenderTextureFormat format = src.format;
		RenderTexture val = RenderTexture.GetTemporary(num, num2, 0, format);
		if (renderNightVision)
		{
			Graphics.Blit((Texture)(object)src, val, nightVisionMat);
		}
		else
		{
			val = src;
		}
		if (!renderBloom)
		{
			Graphics.Blit((Texture)(object)val, dest);
			RenderTexture.ReleaseTemporary(val);
			return;
		}
		RenderTexture val2 = (textures[0] = RenderTexture.GetTemporary(num, num2, 0, format));
		Graphics.Blit((Texture)(object)val, val2, bloom, 0);
		RenderTexture val3 = val2;
		for (int i = 1; i < iterations; i++)
		{
			num /= 2;
			num2 /= 2;
			if (num2 < 2)
			{
				break;
			}
			val2 = (textures[i] = RenderTexture.GetTemporary(num, num2, 0, format));
			Graphics.Blit((Texture)(object)val3, val2, bloom, 1);
			val3 = val2;
		}
		for (int num3 = iterations - 2; num3 >= 0; num3--)
		{
			val2 = textures[num3];
			textures[num3] = null;
			Graphics.Blit((Texture)(object)val3, val2, bloom, 2);
			RenderTexture.ReleaseTemporary(val3);
			val3 = val2;
		}
		bloom.SetTexture("_SourceTex", (Texture)(object)val);
		Graphics.Blit((Texture)(object)val3, dest, bloom, 3);
		RenderTexture.ReleaseTemporary(val3);
		RenderTexture.ReleaseTemporary(val);
	}
}

ToxicGasFramework.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using FistVR;
using OpenScripts2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ToxicGasFramework")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ToxicGasFramework")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f937247f-2fab-4acb-a23a-56597cf4c08c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ToxicGasFramework;

public class RadioactiveObject : MonoBehaviour
{
	public float StrengthAt1m = 10f;

	public float MinEffectDist = 0.2f;

	public float MaxEffectDist = 20f;

	public float BaseDmgProbability = 0.001f;

	public float MaxProximityProbability = 0.8f;

	private float StrengthAtSource;

	public static List<RadioactiveObject> radioactiveObjects = new List<RadioactiveObject>();

	private Transform TorsoPt;

	private FVRPlayerBody playerBody;

	public void Awake()
	{
		StrengthAtSource = 12.56f * StrengthAt1m;
		playerBody = GM.CurrentPlayerBody;
		radioactiveObjects.Add(this);
		TorsoPt = ((Component)playerBody).transform.Find("Torso");
	}

	public void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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)
		if (!Physics.Linecast(((Component)this).transform.position, TorsoPt.position, 19))
		{
			float num = Vector3.Distance(TorsoPt.position, ((Component)this).transform.position);
			float num2 = StrengthAtSource / (12.56f * num);
			float num3 = Mathf.Clamp01((MaxEffectDist - num) / (MaxEffectDist - MinEffectDist));
			float num4 = Mathf.Lerp(BaseDmgProbability, MaxProximityProbability, num3);
			if (Random.value <= num4 && num2 > 1f)
			{
				Debug.Log((object)num2);
				FVRPlayerBody obj = playerBody;
				obj.Health -= num2;
				playerBody.HarmPercent(0f);
			}
		}
	}
}
public class PlayerBlindness : MonoBehaviour
{
	public static float BlindnessPercent = 0f;

	public Vector3 HeadOffsetPosition = new Vector3(0f, 0.015f, -0.05f);

	public float BlindLerpOn = 0.5f;

	public float BlindDegradationPerSecond = 2f;

	public AnimationCurve AnimationCurve;

	[HideInInspector]
	public static bool _isAMaskEquipped;

	[HideInInspector]
	public static Vector2 _DamBlindVals = new Vector2(0f, 0f);

	private Color BlindColor;

	private MaterialPropertyBlock PropertyBlock = new MaterialPropertyBlock();

	public static GameObject prefab;

	public List<Renderer> Renderers = new List<Renderer>();

	public void Start()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		prefab.transform.SetParent(GM.CurrentPlayerBody.Head, false);
		prefab.transform.localPosition = new Vector3(0f, 0f, 0f);
		Transform transform = prefab.transform;
		transform.localPosition += HeadOffsetPosition;
		BlindColor = new Color(0f, 0f, 0f, 0f);
	}

	public void Update()
	{
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: 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)
		if (GasMask.gasMasks.Count != 0)
		{
			bool flag = false;
			foreach (GasMask gasMask in GasMask.gasMasks)
			{
				if ((Object)(object)gasMask.Mask.QuickbeltSlot != (Object)null && (Object)(object)((Component)gasMask.Mask.QuickbeltSlot).GetComponent<HeadQBSlot>() != (Object)null)
				{
					flag = true;
					_DamBlindVals = new Vector2(gasMask.MaskDamageMultiplier, gasMask.MaskBlindnessMultiplier);
				}
			}
			if (flag)
			{
				_isAMaskEquipped = true;
			}
			else
			{
				_isAMaskEquipped = false;
			}
		}
		else
		{
			GasMask.gasMasks.Clear();
			_isAMaskEquipped = false;
		}
		if (BlindnessPercent > 0f)
		{
			BlindnessPercent -= BlindDegradationPerSecond * Time.deltaTime;
			if (BlindnessPercent > 1f)
			{
				BlindnessPercent = 1f;
			}
			BlindColor.a = AnimationCurve.Evaluate(BlindnessPercent);
			PropertyBlock.SetColor("_Color", BlindColor);
			{
				foreach (Renderer renderer in Renderers)
				{
					renderer.SetPropertyBlock(PropertyBlock);
				}
				return;
			}
		}
		if (!(BlindnessPercent <= 0f) || BlindColor.a == 0f)
		{
			return;
		}
		BlindColor.a = 0f;
		PropertyBlock.SetColor("_Color", BlindColor);
		BlindnessPercent = 0f;
		foreach (Renderer renderer2 in Renderers)
		{
			renderer2.SetPropertyBlock(PropertyBlock);
		}
	}
}
[Serializable]
public class GasData
{
	public float Damage;

	public float SosigBlindness;

	public float SosigStun;

	public float PlayerBlindness;

	public float PlayerMaxBlindness = 1f;

	[Tooltip("Tick is in seconds")]
	public float EffectTick;
}
[RequireComponent(typeof(Collider))]
public class GasVolume : MonoBehaviour
{
	public GasData VolumeGasData;

	private Dictionary<GameObject, Coroutine> coroutines = new Dictionary<GameObject, Coroutine>();

	private string[] sosigMaskList = new string[12]
	{
		"SosigAccessory_Tactical_GasMask1(Clone)", "SosigAccessory_Tactical_GasMask2(Clone)", "SosigAccessory_Tactical_GasMask3(Clone)", "Sosigaccesory_MF2_Red_PY_mask(Clone)", "Sosigaccesory_MF2_Blue_PY_mask(Clone)", "MG_Ninja_Helmet(Clone)", "MG_Telekine_Head(Clone)", "Sosig_HL_UncivilErection_Helmet(Clone)", "Sosig_HalfLife_OverwatchElite_Helmet(Clone)", "Sosig_HalfLife_OverwatchSoldier_Helmet(Clone)",
		"MG_Chemwar_Head(Clone)", "Operator_Gasmask_Black(Clone)"
	};

	public bool ignoresMasks;

	private List<GameObject> parentsBeingDamaged = new List<GameObject>();

	public List<GameObject> debug_DamagedEntities;

	private void Update()
	{
		debug_DamagedEntities = parentsBeingDamaged;
	}

	private void OnTriggerEnter(Collider collider)
	{
		if (((Component)collider).gameObject.layer == LayerMask.NameToLayer("PlayerHead") || (Object)(object)((Component)collider).GetComponent<SosigLink>() != (Object)null)
		{
			GameObject sosigOrPlayer = GetSosigOrPlayer(collider);
			if ((Object)(object)sosigOrPlayer != (Object)null && !parentsBeingDamaged.Contains(sosigOrPlayer))
			{
				bool isPlayer = (((Object)(object)sosigOrPlayer.GetComponent<FVRPlayerBody>() != (Object)null) ? true : false);
				parentsBeingDamaged.Add(sosigOrPlayer);
				Coroutine value = ((MonoBehaviour)this).StartCoroutine(DamageTick(collider, isPlayer));
				coroutines.Add(sosigOrPlayer, value);
			}
		}
	}

	private void OnTriggerExit(Collider collider)
	{
		GameObject sosigOrPlayer = GetSosigOrPlayer(collider);
		if (parentsBeingDamaged.Contains(sosigOrPlayer) && coroutines.TryGetValue(sosigOrPlayer, out var value))
		{
			parentsBeingDamaged.Remove(sosigOrPlayer);
			((MonoBehaviour)this).StopCoroutine(value);
			coroutines.Remove(sosigOrPlayer);
		}
	}

	private IEnumerator DamageTick(Collider collider, bool _isPlayer)
	{
		while (true)
		{
			if (_isPlayer)
			{
				if ((Object)(object)((Component)collider).GetComponent<FVRPlayerHitbox>() != (Object)null)
				{
					FVRPlayerHitbox component = ((Component)collider).GetComponent<FVRPlayerHitbox>();
					if (!PlayerBlindness._isAMaskEquipped || ignoresMasks)
					{
						component.Damage((float)(int)(VolumeGasData.Damage + 1f));
						if (PlayerBlindness.BlindnessPercent < VolumeGasData.PlayerMaxBlindness)
						{
							PlayerBlindness.BlindnessPercent += VolumeGasData.PlayerBlindness;
						}
					}
					else
					{
						component.Damage((float)(int)((VolumeGasData.Damage + 1f) * PlayerBlindness._DamBlindVals.x));
						if (PlayerBlindness.BlindnessPercent < VolumeGasData.PlayerMaxBlindness)
						{
							PlayerBlindness.BlindnessPercent += VolumeGasData.PlayerBlindness * PlayerBlindness._DamBlindVals.y;
						}
					}
				}
			}
			else if ((Object)(object)collider != (Object)null)
			{
				Sosig s = ((Component)collider).GetComponent<SosigLink>().S;
				if ((int)s.BodyState != 3 && !IsSosigMasked(s))
				{
					foreach (SosigLink link in s.Links)
					{
						if ((Object)(object)link != (Object)null)
						{
							link.Damage(new Damage
							{
								Dam_Blinding = VolumeGasData.SosigBlindness,
								Dam_Blunt = VolumeGasData.Damage,
								Dam_Stunning = VolumeGasData.SosigStun
							});
							if ((Object)(object)link == (Object)null)
							{
								yield return null;
							}
						}
					}
				}
			}
			yield return (object)new WaitForSeconds(VolumeGasData.EffectTick);
		}
	}

	private GameObject GetSosigOrPlayer(Collider collider)
	{
		GameObject result = null;
		if (Object.op_Implicit((Object)(object)((Component)collider).gameObject.GetComponentInParent<FVRPlayerBody>()))
		{
			result = ((Component)((Component)collider).transform.root).gameObject;
		}
		else if ((Object)(object)((Component)collider).gameObject.GetComponent<SosigLink>() != (Object)null)
		{
			result = ((Component)((Component)collider).gameObject.GetComponent<SosigLink>().S).gameObject;
		}
		return result;
	}

	private bool IsSosigMasked(Sosig _sosig)
	{
		if (ignoresMasks)
		{
			return false;
		}
		for (int i = 0; i < _sosig.Links.Count; i++)
		{
			for (int j = 0; j < sosigMaskList.Length; j++)
			{
				if ((Object)(object)((Component)_sosig.Links[i]).transform.Find(sosigMaskList[j]) != (Object)null)
				{
					return true;
				}
			}
		}
		return false;
	}
}
public class GasMask : MonoBehaviour
{
	public FVRPhysicalObject Mask;

	public float MaskDamageMultiplier;

	public float MaskBlindnessMultiplier;

	public GameObject Audio;

	public static bool UseBreathSFX = true;

	public static List<GasMask> gasMasks = new List<GasMask>();

	public void Awake()
	{
		gasMasks.Add(this);
		if ((Object)(object)Audio != (Object)null && !UseBreathSFX)
		{
			Audio.SetActive(false);
		}
	}

	public void OnDestroy()
	{
		gasMasks.Remove(this);
	}
}
[BepInPlugin("h3vr.andrew_ftw.TGF", "Toxic Gas Framework", "1.0.0")]
public class TGF_BepInEx : BaseUnityPlugin
{
	public ConfigEntry<bool> UseBreathingSFX;

	private GameObject _loadedPrefab;

	public TGF_BepInEx()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Toxic Gas Framework Loaded");
		UseBreathingSFX = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Does use breakthing sfx", true, (ConfigDescription)null);
		GasMask.UseBreathSFX = UseBreathingSFX.Value;
	}

	public void Awake()
	{
		AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "tfgassets"));
		_loadedPrefab = val.LoadAsset<GameObject>("BlurSphere");
		PlayerBlindness.prefab = Object.Instantiate<GameObject>(_loadedPrefab);
	}

	public void Update()
	{
		if ((Object)(object)GM.CurrentPlayerBody != (Object)null && (Object)(object)GM.CurrentPlayerBody.Head != (Object)null && (Object)(object)PlayerBlindness.prefab == (Object)null)
		{
			PlayerBlindness.prefab = Object.Instantiate<GameObject>(_loadedPrefab);
			Debug.Log((object)"spawned the thing again cause the scene probably changed");
		}
	}
}