Decompiled source of PitScripts v1.0.0

PitScripts.dll

Decompiled 11 hours ago
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.Logging;
using FistVR;
using Microsoft.CodeAnalysis;
using Sodalite.Api;
using Sodalite.Utilities;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("localpcnerd")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Scripts for Pit map and gamemode.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PitScripts")]
[assembly: AssemblyTitle("PitScripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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;
		}
	}
}
public class PitController : MonoBehaviour
{
	[Header("Timer")]
	public bool runTimer;

	public float curTime;

	public float finalTime;

	[HideInInspector]
	public float savedBestTimeSosig;

	[HideInInspector]
	public float savedBestTimeTarget;

	[Header("UI")]
	public Text[] timers;

	public Text sosigRecord;

	public Text targetRecord;

	public GameObject useSosigButton;

	public GameObject useTargetButton;

	[Header("Zones")]
	public PitZone[] zones;

	public int zoneInd;

	public int activeZone;

	[Header("Triggers")]
	public PitTrigger[] triggers;

	public bool canFinishCourse;

	[Header("Audio")]
	public AudioSource source;

	public AudioClip zoneFinishClip;

	public AudioClip triggerStartClip;

	public AudioClip triggerFinishClip;

	[Header("Targets")]
	public GameObject targetPrefab;

	public GameObject friendlyTargetPrefab;

	public bool useTargets;

	[Header("Sosigs")]
	public SosigEnemyID[] enemySosigIDs;

	public SosigEnemyID[] friendlySosigIDs;

	public void Start()
	{
		savedBestTimeSosig = PlayerPrefs.GetFloat("savedBestTimeSosig", 6030f);
		savedBestTimeTarget = PlayerPrefs.GetFloat("savedBestTimeTarget", 6030f);
		GM.CurrentPlayerBody.SetPlayerIFF(0);
	}

	public void OnStart()
	{
		curTime = 0f;
		finalTime = 0f;
		runTimer = true;
		zoneInd = 0;
		zones[zoneInd].StartZone();
		PlayClip(1);
	}

	public void OnFinish()
	{
		PlayClip(2);
		runTimer = false;
		finalTime = curTime;
		((MonoBehaviour)this).StartCoroutine(delayResetFinish());
		UpdateSavedScores();
	}

	public void UpdateUI()
	{
		Text[] array = timers;
		foreach (Text val in array)
		{
			int num = Mathf.FloorToInt(curTime / 60f);
			int num2 = Mathf.FloorToInt(curTime - (float)(num * 60));
			int num3 = Mathf.FloorToInt(curTime % 1f * 100f);
			string text = $"{num:00}:{num2:00}:{num3:00}";
			val.text = text;
		}
		int num4 = Mathf.FloorToInt(savedBestTimeSosig / 60f);
		int num5 = Mathf.FloorToInt(savedBestTimeSosig - (float)(num4 * 60));
		int num6 = Mathf.FloorToInt(savedBestTimeSosig % 1f * 100f);
		string text2 = $"{num4:00}:{num5:00}:{num6:00}";
		sosigRecord.text = text2;
		int num7 = Mathf.FloorToInt(savedBestTimeTarget / 60f);
		int num8 = Mathf.FloorToInt(savedBestTimeTarget - (float)(num7 * 60));
		int num9 = Mathf.FloorToInt(savedBestTimeTarget % 1f * 100f);
		string text3 = $"{num7:00}:{num8:00}:{num9:00}";
		targetRecord.text = text3;
	}

	public void ResetSavedTimes()
	{
		PlayerPrefs.DeleteKey("savedBestTimeSosig");
		savedBestTimeSosig = 3060f;
		PlayerPrefs.DeleteKey("savedBestTimeTarget");
		savedBestTimeTarget = 3060f;
	}

	public void PlayClip(int ind)
	{
		switch (ind)
		{
		case 0:
			source.PlayOneShot(zoneFinishClip);
			break;
		case 1:
			source.PlayOneShot(triggerStartClip);
			break;
		case 2:
			source.PlayOneShot(triggerFinishClip);
			break;
		}
	}

	public void UpdateSavedScores()
	{
		if (useTargets)
		{
			if (finalTime < savedBestTimeTarget)
			{
				savedBestTimeTarget = finalTime;
				PlayerPrefs.SetFloat("savedBestTimeTarget", savedBestTimeTarget);
			}
		}
		else if (finalTime < savedBestTimeSosig)
		{
			savedBestTimeSosig = finalTime;
			PlayerPrefs.SetFloat("savedBestTimeSosig", savedBestTimeSosig);
		}
	}

	public void SelectSosig()
	{
		useSosigButton.SetActive(true);
		useTargetButton.SetActive(false);
		useTargets = false;
	}

	public void SelectTarget()
	{
		useSosigButton.SetActive(false);
		useTargetButton.SetActive(true);
		useTargets = true;
	}

	public IEnumerator delayResetFinish()
	{
		yield return (object)new WaitForSeconds(1f);
		PitTrigger[] array = triggers;
		foreach (PitTrigger trig in array)
		{
			trig.hasRun = false;
		}
	}

	public void Update()
	{
		UpdateUI();
		if (runTimer)
		{
			curTime += Time.deltaTime;
		}
	}
}
public class PitSosig : MonoBehaviour
{
	public Sosig sos;

	public bool isDead = false;

	public bool isFriendly;

	public void Start()
	{
		sos = ((Component)this).GetComponent<Sosig>();
	}

	public void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Invalid comparison between Unknown and I4
		if ((int)sos.BodyState == 3)
		{
			isDead = true;
		}
	}
}
public class PitTarget : MonoBehaviour, IFVRDamageable
{
	public bool isHit;

	public AudioSource source;

	public bool isFriendly;

	void IFVRDamageable.Damage(Damage dam)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		if ((int)dam.Class == 1)
		{
			isHit = true;
			source.Play();
			Debug.Log((object)"Target Hit");
		}
	}

	public void DeleteTarget()
	{
	}

	public void Update()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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 (isHit)
		{
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(180f, ((Component)this).transform.localEulerAngles.y, ((Component)this).transform.localEulerAngles.z);
			((Component)this).transform.localEulerAngles = Vector3.Lerp(((Component)this).transform.localEulerAngles, val, 5f * Time.deltaTime);
			Object.Destroy((Object)(object)((Component)this).gameObject, 0.2f);
		}
	}
}
public class PitTrigger : MonoBehaviour
{
	public bool isStart;

	public PitController npc;

	[HideInInspector]
	public bool hasRun = false;

	public void OnTriggerEnter(Collider collider)
	{
		if (((Component)collider).gameObject.tag == "GameController")
		{
			if (isStart)
			{
				StartCourse();
			}
			else
			{
				EndCourse();
			}
		}
	}

	public void StartCourse()
	{
		if (!hasRun)
		{
			npc.OnStart();
		}
		hasRun = true;
	}

	public void EndCourse()
	{
		if (!hasRun)
		{
			npc.OnFinish();
		}
		hasRun = true;
	}
}
public class PitZone : MonoBehaviour
{
	public Transform[] spawnPoints;

	public Transform[] friendlySpawnPoints;

	public GameObject navBlocker;

	public bool isZoneActive;

	[HideInInspector]
	public List<PitSosig> spawnedSosigs = new List<PitSosig>();

	[HideInInspector]
	public List<PitTarget> spawnedTargets = new List<PitTarget>();

	[HideInInspector]
	public List<PitSosig> friendlySpawnedSosigs = new List<PitSosig>();

	[HideInInspector]
	public List<PitTarget> friendlySpawnedTargets = new List<PitTarget>();

	public PitController npc;

	private readonly SpawnOptions spawnOptions = new SpawnOptions
	{
		SpawnState = (SosigOrder)6,
		SpawnActivated = true,
		EquipmentMode = (EquipmentSlots)1,
		SpawnWithFullAmmo = true,
		IFF = 0
	};

	public void StartZone()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		isZoneActive = true;
		SosigEnemyID random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)npc.enemySosigIDs);
		SosigEnemyID random2 = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)npc.friendlySosigIDs);
		Transform[] array = spawnPoints;
		foreach (Transform sp in array)
		{
			if (npc.useTargets)
			{
				SpawnTarget(sp, friendly: false, npc.targetPrefab);
			}
			else
			{
				SpawnSosig(sp, random, friendly: false);
			}
		}
		Transform[] array2 = friendlySpawnPoints;
		foreach (Transform sp2 in array2)
		{
			if (npc.useTargets)
			{
				SpawnTarget(sp2, friendly: true, npc.friendlyTargetPrefab);
			}
			else
			{
				SpawnSosig(sp2, random2, friendly: true);
			}
		}
		navBlocker.SetActive(true);
	}

	public void FinishZone()
	{
		if (npc.useTargets)
		{
			foreach (PitTarget friendlySpawnedTarget in friendlySpawnedTargets)
			{
				friendlySpawnedTarget.isHit = true;
				friendlySpawnedTargets.Remove(friendlySpawnedTarget);
			}
		}
		else
		{
			foreach (PitSosig friendlySpawnedSosig in friendlySpawnedSosigs)
			{
				friendlySpawnedSosig.sos.ClearSosig();
				friendlySpawnedSosigs.Remove(friendlySpawnedSosig);
			}
		}
		isZoneActive = false;
		navBlocker.SetActive(false);
		npc.zoneInd++;
		if (npc.zoneInd < npc.zones.Length)
		{
			npc.zones[npc.zoneInd].StartZone();
		}
		npc.PlayClip(0);
	}

	private void SpawnSosig(Transform sp, SosigEnemyID id, bool friendly)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		Sosig val = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[id], spawnOptions, sp.position, sp.rotation);
		PitSosig pitSosig = ((Component)val).gameObject.AddComponent<PitSosig>();
		pitSosig.isFriendly = friendly;
		if (friendly)
		{
			friendlySpawnedSosigs.Add(pitSosig);
		}
		else
		{
			spawnedSosigs.Add(pitSosig);
		}
	}

	private void SpawnTarget(Transform sp, bool friendly, GameObject target)
	{
		//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)
		GameObject val = Object.Instantiate<GameObject>(target, sp.position, sp.rotation, sp);
		PitTarget component = val.GetComponent<PitTarget>();
		component.isFriendly = friendly;
		if (friendly)
		{
			friendlySpawnedTargets.Add(component);
		}
		else
		{
			spawnedTargets.Add(component);
		}
	}

	public void Update()
	{
		if (!isZoneActive)
		{
			return;
		}
		if (npc.useTargets)
		{
			foreach (PitTarget spawnedTarget in spawnedTargets)
			{
				if (spawnedTarget.isHit)
				{
					spawnedTargets.Remove(spawnedTarget);
					break;
				}
			}
			foreach (PitTarget friendlySpawnedTarget in friendlySpawnedTargets)
			{
				if (friendlySpawnedTarget.isHit)
				{
					friendlySpawnedTargets.Remove(friendlySpawnedTarget);
					break;
				}
			}
			if (spawnedTargets.Count <= 0 && isZoneActive)
			{
				FinishZone();
			}
			return;
		}
		foreach (PitSosig spawnedSosig in spawnedSosigs)
		{
			if (spawnedSosig.isDead)
			{
				spawnedSosig.sos.ClearSosig();
				spawnedSosigs.Remove(spawnedSosig);
				break;
			}
		}
		foreach (PitSosig friendlySpawnedSosig in friendlySpawnedSosigs)
		{
			if (friendlySpawnedSosig.isDead)
			{
				friendlySpawnedSosig.sos.ClearSosig();
				friendlySpawnedSosigs.Remove(friendlySpawnedSosig);
				break;
			}
		}
		if (spawnedSosigs.Count <= 0 && isZoneActive)
		{
			FinishZone();
		}
	}
}
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 localpcnerd
{
	[BepInProcess("h3vr.exe")]
	[BepInPlugin("PitScripts", "PitScripts", "1.0.0")]
	public class PitPlugin : BaseUnityPlugin
	{
		public const string Id = "PitScripts";

		internal static ManualLogSource Logger { get; private set; }

		public static string Name => "PitScripts";

		public static string Version => "1.0.0";

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogMessage((object)("PitScripts: PitScripts, " + Name + ", " + Version + "."));
		}
	}
}