Decompiled source of Brighter Pistool Labels v1.1.0

Brighter_Pistool_Labels.dll

Decompiled a month ago
using System.Collections.Generic;
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 FistVR;
using HarmonyLib;
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]
public class Ripper : FVRPhysicalObject
{
	[Header("Ripper")]
	public AudioSource SawAudio;

	public AudioSource StartingAudio;

	public AudioClip AudClip_Start;

	public AudioClip AudClip_Idle;

	public AudioClip AudClip_Buzzing;

	public AudioClip AudClip_Hitting;

	private bool isChainsawRunning;

	private float m_currentCableLength;

	private float m_lastCableLength;

	private float m_motorSpeed;

	private float triggerAmount;

	private float m_sawingIntesity;

	public bool UsesBladeSolidBits = true;

	public Renderer BladeSolid;

	public Renderer BladeBits;

	[Tooltip("Alternative to BladeSolidBits, repeatedly toggles between set of blade objects to emulate movement. When saw is off, defaults to index 0 object.")]
	public bool CycleBladeObjects;

	public GameObject[] BladeObjects;

	[Tooltip("Time each object is enabled, lower to cycle faster.")]
	public float BladeObjectSwitchInterval;

	private Material m_matBladeSolid;

	private Material m_matBladeBits;

	public Collider[] BladeCols;

	private HashSet<Collider> m_bladeCols = new HashSet<Collider>();

	public ParticleSystem Sparks;

	private EmitParams emitParams;

	public Transform BladePoint1;

	public Transform BladePoint2;

	private List<IFVRDamageable> DamageablesToDo;

	private HashSet<IFVRDamageable> DamageablesToDoHS;

	private List<Vector3> DamageableHitPoints;

	private List<Vector3> DamageableHitNormals;

	private float TimeSinceDamageDealing = 0.2f;

	public ParticleSystem EngineSmoke;

	public bool UsesEngineRot = true;

	public Transform EngineRot;

	public float PerceptibleEventVolume = 50f;

	public float PerceptibleEventRange = 30f;

	private float m_timeTilPerceptibleEventTick = 0.2f;

	private float timeSinceCollision = 1f;

	private int framesTilFlash;

	private float bladeObjectCycleTime;

	private int bladeIndex = 0;

	private float timeSinceTryTurnOff;

	public override void Awake()
	{
		//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		((FVRPhysicalObject)this).Awake();
		emitParams = default(EmitParams);
		if (UsesBladeSolidBits)
		{
			m_matBladeSolid = BladeSolid.materials[0];
			m_matBladeBits = BladeBits.material;
		}
		for (int i = 0; i < BladeCols.Length; i++)
		{
			m_bladeCols.Add(BladeCols[i]);
		}
		DamageablesToDo = new List<IFVRDamageable>();
		DamageablesToDoHS = new HashSet<IFVRDamageable>();
		DamageableHitPoints = new List<Vector3>();
		DamageableHitNormals = new List<Vector3>();
	}

	public override void Start()
	{
		((FVRInteractiveObject)this).Start();
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		((FVRPhysicalObject)this).UpdateInteraction(hand);
		if (((FVRInteractiveObject)this).m_hasTriggeredUpSinceBegin && !base.IsAltHeld)
		{
			triggerAmount = hand.Input.TriggerFloat;
			if (((hand.IsInStreamlinedMode && hand.Input.BYButtonDown && isChainsawRunning) || (!hand.IsInStreamlinedMode && hand.Input.TouchpadDown && isChainsawRunning)) && timeSinceTryTurnOff <= 0f)
			{
				timeSinceTryTurnOff = 0.2f;
				Debug.Log((object)"attempting to shut off ripper");
				m_motorSpeed = 0f;
				isChainsawRunning = false;
			}
			if (((hand.IsInStreamlinedMode && hand.Input.BYButtonDown && !isChainsawRunning) || (!hand.IsInStreamlinedMode && hand.Input.TouchpadDown && !isChainsawRunning)) && timeSinceTryTurnOff <= 0f)
			{
				timeSinceTryTurnOff = 0.2f;
				Debug.Log((object)"turning on ripper");
				isChainsawRunning = true;
				m_currentCableLength = 0f;
				SetCableLength(8f);
			}
		}
	}

	public void OnCollisionStay(Collision col)
	{
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: 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_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		if (!isChainsawRunning || !(m_sawingIntesity > 0.1f))
		{
			return;
		}
		int num = 0;
		for (int i = 0; i < col.contacts.Length; i++)
		{
			if (!m_bladeCols.Contains(((ContactPoint)(ref col.contacts[i])).thisCollider))
			{
				continue;
			}
			IFVRDamageable component = ((Component)((Component)((ContactPoint)(ref col.contacts[i])).otherCollider).transform).gameObject.GetComponent<IFVRDamageable>();
			if (component != null && DamageablesToDoHS.Add(component))
			{
				DamageablesToDo.Add(component);
				DamageableHitPoints.Add(((ContactPoint)(ref col.contacts[i])).point);
				DamageableHitNormals.Add(((ContactPoint)(ref col.contacts[i])).normal);
			}
			if (component == null && (Object)(object)((ContactPoint)(ref col.contacts[i])).otherCollider.attachedRigidbody != (Object)null)
			{
				component = ((Component)((ContactPoint)(ref col.contacts[i])).otherCollider.attachedRigidbody).gameObject.GetComponent<IFVRDamageable>();
				if (DamageablesToDoHS.Add(component))
				{
					DamageablesToDo.Add(component);
					DamageableHitPoints.Add(((ContactPoint)(ref col.contacts[i])).point);
					DamageableHitNormals.Add(((ContactPoint)(ref col.contacts[i])).normal);
				}
			}
			if (num < 2)
			{
				timeSinceCollision = 0f;
				num++;
				Vector3 closestValidPoint = ((FVRInteractiveObject)this).GetClosestValidPoint(BladePoint1.position, BladePoint2.position, ((ContactPoint)(ref col.contacts[i])).point);
				Vector3 val = ((ContactPoint)(ref col.contacts[i])).point - closestValidPoint;
				val = Vector3.ClampMagnitude(val, 0.04f);
				Vector3 val2 = closestValidPoint + val;
				((EmitParams)(ref emitParams)).position = val2;
				Vector3 val3 = Vector3.Cross(((Vector3)(ref val)).normalized, ((Component)this).transform.right) * Random.Range(1f, 10f);
				val3 += Random.onUnitSphere * 3f;
				val3 += val * 2f;
				((EmitParams)(ref emitParams)).velocity = val3;
				Sparks.Emit(emitParams, 1);
				if (framesTilFlash <= 0)
				{
					framesTilFlash = Random.Range(3, 7);
					FXM.InitiateMuzzleFlash(val2, ((ContactPoint)(ref col.contacts[i])).normal, Random.Range(0.25f, 2f), Color.white, Random.Range(0.5f, 1f));
				}
			}
		}
	}

	public override void FVRUpdate()
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_0095: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: 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_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_069c: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0580: Unknown result type (might be due to invalid IL or missing references)
		//IL_059f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0713: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05da: Unknown result type (might be due to invalid IL or missing references)
		//IL_05de: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		((FVRPhysicalObject)this).FVRUpdate();
		if (framesTilFlash > 0)
		{
			framesTilFlash--;
		}
		if (timeSinceCollision < 1f)
		{
			timeSinceCollision += Time.deltaTime;
		}
		timeSinceTryTurnOff -= Time.deltaTime;
		if (TimeSinceDamageDealing > 0f)
		{
			TimeSinceDamageDealing -= Time.deltaTime;
		}
		else
		{
			Damage val = new Damage();
			Vector3 velocity = ((FVRPhysicalObject)this).RootRigidbody.velocity;
			val.Dam_Blunt = 100f * Mathf.Clamp(((Vector3)(ref velocity)).magnitude, 1f, 3f);
			Vector3 velocity2 = ((FVRPhysicalObject)this).RootRigidbody.velocity;
			val.Dam_Cutting = 250f * Mathf.Clamp(((Vector3)(ref velocity2)).magnitude, 1f, 2f);
			val.Dam_TotalKinetic = val.Dam_Cutting + val.Dam_Blunt;
			val.Class = (DamageClass)3;
			for (int i = 0; i < DamageablesToDo.Count; i++)
			{
				if ((Object)(MonoBehaviour)DamageablesToDo[i] != (Object)null)
				{
					val.hitNormal = DamageableHitNormals[i];
					val.point = DamageableHitPoints[i];
					val.strikeDir = -val.hitNormal;
					DamageablesToDo[i].Damage(val);
				}
			}
			DamageablesToDo.Clear();
			DamageablesToDoHS.Clear();
			DamageableHitPoints.Clear();
			DamageableHitNormals.Clear();
			TimeSinceDamageDealing = 0.1f;
		}
		if (!isChainsawRunning)
		{
			SawAudio.volume = m_motorSpeed * 0.7f;
			StartingAudio.volume = m_motorSpeed;
			if (m_motorSpeed <= 0f && StartingAudio.isPlaying)
			{
				StartingAudio.Stop();
			}
			if (UsesBladeSolidBits)
			{
				m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0f, 0f)));
				m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0f, 0f)));
			}
			if (CycleBladeObjects)
			{
				GameObject[] bladeObjects = BladeObjects;
				foreach (GameObject val2 in bladeObjects)
				{
					val2.SetActive(false);
				}
				BladeObjects[0].SetActive(true);
			}
			EmissionModule emission = EngineSmoke.emission;
			MinMaxCurve rate = ((EmissionModule)(ref emission)).rate;
			((MinMaxCurve)(ref rate)).mode = (ParticleSystemCurveMode)0;
			((MinMaxCurve)(ref rate)).constantMax = 0f;
			((MinMaxCurve)(ref rate)).constantMin = 0f;
			((EmissionModule)(ref emission)).rate = rate;
		}
		else
		{
			if (bladeObjectCycleTime < BladeObjectSwitchInterval)
			{
				bladeObjectCycleTime += Time.deltaTime;
			}
			else
			{
				CycleBladeObjectArray();
			}
			if (!SawAudio.isPlaying)
			{
				SawAudio.Play();
			}
			triggerAmount += Random.Range(-0.05f, 0.05f);
			if (((FVRInteractiveObject)this).IsHeld)
			{
				m_sawingIntesity = Mathf.Lerp(m_sawingIntesity, triggerAmount, Time.deltaTime * 5f);
			}
			else
			{
				m_sawingIntesity = Mathf.Lerp(m_sawingIntesity, 0f, Time.deltaTime * 2f);
			}
			if (m_sawingIntesity > 0.1f)
			{
				SawAudio.volume = (0.8f + m_sawingIntesity * 0.5f) * 0.3f;
				SawAudio.pitch = 0.6f + m_sawingIntesity * 0.7f;
				if ((double)timeSinceCollision < 0.2)
				{
					if ((Object)(object)SawAudio.clip != (Object)(object)AudClip_Hitting)
					{
						SawAudio.clip = AudClip_Hitting;
					}
				}
				else if ((Object)(object)SawAudio.clip != (Object)(object)AudClip_Buzzing)
				{
					SawAudio.clip = AudClip_Buzzing;
				}
				if (UsesBladeSolidBits)
				{
					m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(m_sawingIntesity, 0f)));
					m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(m_sawingIntesity, 0f)));
				}
				if (CycleBladeObjects)
				{
					bladeObjectCycleTime /= 3f;
				}
			}
			else
			{
				SawAudio.volume = 0.25f;
				SawAudio.pitch = 1f;
				if ((Object)(object)SawAudio.clip != (Object)(object)AudClip_Idle)
				{
					SawAudio.clip = AudClip_Idle;
				}
				if (UsesBladeSolidBits)
				{
					m_matBladeSolid.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0.01f, 0f)));
					m_matBladeBits.SetVector("_MainTexVelocity", Vector4.op_Implicit(new Vector2(0.01f, 0f)));
				}
				if (CycleBladeObjects)
				{
					bladeObjectCycleTime *= 3f;
				}
			}
			EmissionModule emission2 = EngineSmoke.emission;
			MinMaxCurve rate2 = ((EmissionModule)(ref emission2)).rate;
			((MinMaxCurve)(ref rate2)).mode = (ParticleSystemCurveMode)0;
			((MinMaxCurve)(ref rate2)).constantMax = m_motorSpeed * 2f + m_sawingIntesity * 20f;
			((MinMaxCurve)(ref rate2)).constantMin = m_motorSpeed * 2f + m_sawingIntesity * 20f;
			((EmissionModule)(ref emission2)).rate = rate2;
		}
		if (m_motorSpeed >= 1f)
		{
			isChainsawRunning = true;
		}
		else
		{
			m_motorSpeed -= Time.deltaTime * 3f;
			m_motorSpeed = Mathf.Clamp(m_motorSpeed, 0f, 1f);
		}
		if (UsesEngineRot)
		{
			float x = EngineRot.localEulerAngles.x;
			x = ((m_sawingIntesity > 0f) ? (x + Time.deltaTime * (360f + m_sawingIntesity * 1200f)) : (x + Time.deltaTime * (360f * m_motorSpeed)));
			x = Mathf.Repeat(x, 360f);
			EngineRot.localEulerAngles = new Vector3(x, 0f, 0f);
		}
		if (isChainsawRunning)
		{
			m_timeTilPerceptibleEventTick -= Time.deltaTime;
			if (m_timeTilPerceptibleEventTick <= 0f)
			{
				m_timeTilPerceptibleEventTick = Random.Range(0.2f, 0.3f);
			}
		}
	}

	public override void FVRFixedUpdate()
	{
		//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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		((FVRPhysicalObject)this).FVRFixedUpdate();
		if (isChainsawRunning)
		{
			float num = 0.1f;
			num += m_sawingIntesity * 0.3f;
			Rigidbody rootRigidbody = ((FVRPhysicalObject)this).RootRigidbody;
			rootRigidbody.velocity += Random.onUnitSphere * num;
			Rigidbody rootRigidbody2 = ((FVRPhysicalObject)this).RootRigidbody;
			rootRigidbody2.angularVelocity += Random.onUnitSphere * num;
		}
	}

	public void SetCableLength(float f)
	{
		Debug.Log((object)"SetCableLength called");
		if (!isChainsawRunning && f > m_currentCableLength)
		{
			if (!StartingAudio.isPlaying)
			{
				StartingAudio.Play();
			}
			m_motorSpeed += (f - m_currentCableLength) * 1.5f;
		}
		m_currentCableLength = f;
	}

	public void CycleBladeObjectArray()
	{
		bladeObjectCycleTime = 0f;
		if ((Object)(object)BladeObjects[bladeIndex] != (Object)null)
		{
			BladeObjects[bladeIndex].SetActive(false);
		}
		bladeIndex++;
		if (bladeIndex >= BladeObjects.Length)
		{
			bladeIndex = 0;
		}
		if ((Object)(object)BladeObjects[bladeIndex] != (Object)null)
		{
			BladeObjects[bladeIndex].SetActive(true);
		}
	}
}
namespace Okkim.Brighter_Pistool_Labels;

[BepInPlugin("Okkim.Brighter_Pistool_Labels", "Brighter_Pistool_Labels", "1.1.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
public class Brighter_Pistool_LabelsPlugin : 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(), "Okkim.Brighter_Pistool_Labels");
	}
}
public class MagicMirror : MonoBehaviour, IFVRDamageable
{
	public GameObject IntactMirror;

	public MirrorShardSet[] mirrorShardSets;

	public float mirrorHealth;

	public float mirrorDamageThreshold;

	private float currentMirrorHealth;

	public ParticleSystem particles_Repair;

	public ParticleSystem particles_Shatter;

	public AudioEvent sound_Shatter;

	public AudioEvent sound_StartRepair;

	public AudioEvent sound_Repair;

	[Tooltip("How long the mirror waits after the last gift before the mirror begins repairing")]
	public float repairStartDelay;

	private void Awake()
	{
		currentMirrorHealth = mirrorHealth;
	}

	public void Damage(Damage dam)
	{
		if (!(dam.Dam_TotalKinetic < mirrorDamageThreshold))
		{
			currentMirrorHealth -= dam.Dam_TotalKinetic;
			if (currentMirrorHealth <= 0f)
			{
				DestroyMirror();
			}
		}
	}

	private void DestroyMirror()
	{
	}

	private void RepairMirror()
	{
	}
}
public class MirrorShardSet
{
	public GameObject[] mirrorShards;
}

BrighterPistoolLabels.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using Microsoft.CodeAnalysis;
using On.FistVR;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("BrighterPistoolLabels")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BrighterPistoolLabels")]
[assembly: AssemblyTitle("BrighterPistoolLabels")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace BrighterPistoolLabels
{
	[BepInPlugin("okkim.brighterpistoollabels", "Brighter Pistool Labels", "1.1.0")]
	[BepInProcess("h3vr.exe")]
	public class PistoolMatSwapper : BaseUnityPlugin
	{
		private const string ASSET_BUNDLE_NAME = "brighterpistoollabels";

		private static readonly Dictionary<Type, Material> ToolGunMats = new Dictionary<Type, Material>();

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			ToolBoxDrawer.InitializeBays += new hook_InitializeBays(ToolBoxDrawer_InitializeBays);
			ToolBoxTool.OnSpawned += new hook_OnSpawned(ToolBoxTool_OnSpawned);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "brighterpistoollabels"));
			ToolGunMats[typeof(TG_Cloner)] = val.LoadAsset<Material>("mat_Cloner_blank");
			ToolGunMats[typeof(TG_Deletos)] = val.LoadAsset<Material>("mat_Deletos_blank");
			ToolGunMats[typeof(TG_Locker)] = val.LoadAsset<Material>("mat_Locker_blank");
			ToolGunMats[typeof(TG_Measurizer)] = val.LoadAsset<Material>("mat_Measurizer_blank");
			ToolGunMats[typeof(TG_NoClipper)] = val.LoadAsset<Material>("mat_NoClipper_blank");
			ToolGunMats[typeof(TG_Rotato)] = val.LoadAsset<Material>("mat_Rotato_blank");
			ToolGunMats[typeof(TG_Tractor)] = val.LoadAsset<Material>("mat_Tractor_blank");
			ToolGunMats[typeof(TG_Pointer)] = val.LoadAsset<Material>("mat_Pointer_blank");
		}

		private void ToolBoxDrawer_InitializeBays(orig_InitializeBays orig, ToolBoxDrawer self)
		{
			orig.Invoke(self);
			foreach (ToolBoxDrawerBay bay in self.Bays)
			{
				if ((Object)(object)bay.ActualPrefab.GetComponent<ToolGun>() != (Object)null)
				{
					bay.ActualPrefab.GetComponentsInChildren<MeshRenderer>();
					if (ToolGunMats.TryGetValue(((object)bay.ActualPrefab.GetComponent<ToolGun>()).GetType(), out Material value))
					{
						bay.ProxyMat_Holstered = RebuildMaterial(ref value, bay.ProxyMat_Holstered);
						bay.SpawnedProxy.material = bay.ProxyMat_Holstered;
					}
					else
					{
						Debug.LogError((object)("emissive missing or invalid toolgun type for " + ((Object)bay.ActualPrefab).name + "!"));
					}
				}
			}
		}

		private void ToolBoxTool_OnSpawned(orig_OnSpawned orig, ToolBoxTool self)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			orig.Invoke(self);
			if (!(self is ToolGun))
			{
				return;
			}
			ToolGun val = (ToolGun)self;
			MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val2 in componentsInChildren)
			{
				if ((Object)(object)((Component)val2).gameObject != (Object)(object)((Component)val.Laser).gameObject)
				{
					((Renderer)val2).material = ToolGunMats[((object)val).GetType()];
				}
			}
		}

		private Material RebuildMaterial(ref Material _blankMat, Material _oldMat)
		{
			_blankMat.SetTexture("_MainTex", _oldMat.GetTexture("_MainTex"));
			_blankMat.SetTexture("_SpecTex", _oldMat.GetTexture("_SpecTex"));
			_blankMat.SetTexture("_BumpMap", _oldMat.GetTexture("_BumpMap"));
			return _blankMat;
		}
	}
	internal static class PluginInfo
	{
		internal const string NAME = "Brighter Pistool Labels";

		internal const string GUID = "okkim.brighterpistoollabels";

		internal const string VERSION = "1.1.0";
	}
}