Decompiled source of TeraSpace v0.6.2

TeraScript.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using LethalLevelLoader;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("TeraScript")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TeraScript")]
[assembly: AssemblyTitle("TeraScript")]
[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;
		}
	}
}
namespace TeraScript
{
	public class DSBlinking : MonoBehaviour
	{
		[Serializable]
		public class DSBlinkingValues
		{
			public enum SwitchMode
			{
				simple,
				multi,
				broken
			}

			public bool IsActive;

			[Header("Max HDR bright")]
			[ColorUsage(true, true)]
			public Color MaxBright;

			[Header("blinking")]
			public float SwitchTime = 0.1f;

			[Header("Simple blinking, Increasing Blinking, Broken lamp")]
			public SwitchMode SwitchModes = SwitchMode.simple;

			[HideInInspector]
			public int mode;

			[HideInInspector]
			public int count;

			[Header("Shared Material")]
			public Material SharedMaterial;

			[Header("Shader String")]
			public string WorkingString = "_EmissiveColor";

			public IEnumerator ColorSwitch(float random)
			{
				while (true)
				{
					yield return (object)new WaitForSeconds(SwitchTime + random);
					if (SwitchModes == SwitchMode.simple)
					{
						mode = 1 - mode;
						if (mode == 0)
						{
							SharedMaterial.SetColor(WorkingString, Color.black);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
					}
					else if (SwitchModes == SwitchMode.multi)
					{
						mode++;
						if (mode > 2)
						{
							mode = 0;
						}
						if (mode == 0)
						{
							SharedMaterial.SetColor(WorkingString, Color.black);
						}
						else if (mode == 1)
						{
							SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
					}
					else
					{
						if (count < 10)
						{
							mode++;
							if (mode > 2)
							{
								mode = 0;
							}
							if (mode == 0)
							{
								SharedMaterial.SetColor(WorkingString, Color.black);
							}
							else if (mode == 1)
							{
								SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
							}
							else
							{
								SharedMaterial.SetColor(WorkingString, MaxBright);
							}
						}
						else if (count < 20)
						{
							SharedMaterial.SetColor(WorkingString, MaxBright * 0.5f);
						}
						else
						{
							SharedMaterial.SetColor(WorkingString, MaxBright);
						}
						count++;
						if (count > 50)
						{
							count = 0;
						}
					}
					random = 0f;
				}
			}
		}

		public DSBlinkingValues[] _DSBlinkingValues;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		private void Awake()
		{
			Random.InitState((int)DateTime.Now.Ticks * 1000);
		}

		private void Start()
		{
			for (int i = 0; i < _DSBlinkingValues.Length; i++)
			{
				if (_DSBlinkingValues[i].IsActive)
				{
					float random = Random.Range(0.07f, 0.95f);
					((MonoBehaviour)this).StartCoroutine(_DSBlinkingValues[i].ColorSwitch(random));
				}
			}
		}

		private void Update()
		{
		}

		private void OnDestroy()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _DSBlinkingValues.Length; i++)
			{
				if (_DSBlinkingValues[i].IsActive)
				{
					_DSBlinkingValues[i].SharedMaterial.SetColor(WorkingString, _DSBlinkingValues[i].MaxBright);
				}
			}
		}
	}
	public class DSCaster : MonoBehaviour
	{
		[Header("'Water' - one of built in Unity layers:")]
		public string InteractLayer;

		[Space(10f)]
		public GameObject Canvas;

		public float RayLength = 1f;

		private int buttonsMask;

		private Material PrevMat = null;

		private Color PrevColor;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		private void Awake()
		{
			buttonsMask = LayerMask.GetMask(new string[1] { InteractLayer });
			if (Object.op_Implicit((Object)(object)Canvas))
			{
				Canvas.SetActive(false);
			}
		}

		private void Start()
		{
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Linecast(((Component)this).transform.position, ((Component)this).transform.TransformPoint(new Vector3(0f, 0f, RayLength)), ref val, buttonsMask))
			{
				if (Object.op_Implicit((Object)(object)Canvas))
				{
					Canvas.SetActive(true);
				}
				if (Input.GetMouseButtonUp(0))
				{
					((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<DSTrigger>().DSTriggerExecute();
				}
				Material val2 = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent<Renderer>().materials[0];
				Color color = val2.GetColor(WorkingString);
				if ((Object)(object)PrevMat != (Object)(object)val2)
				{
					if (Object.op_Implicit((Object)(object)PrevMat))
					{
						PrevMat.SetColor(WorkingString, PrevColor);
					}
					PrevMat = val2;
					PrevColor = color;
					val2.SetColor(WorkingString, new Color(0f, 1.27f, 5f));
				}
			}
			else
			{
				if (Object.op_Implicit((Object)(object)Canvas))
				{
					Canvas.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)PrevMat))
				{
					PrevMat.SetColor(WorkingString, PrevColor);
					PrevMat = null;
				}
			}
		}

		private void FixedUpdate()
		{
		}
	}
	public class DSElevator : MonoBehaviour
	{
		[Header("Current mesh position, e.g. 1,2,3,4.. floor (from 1)")]
		public int StartFloor;

		[Space(10f)]
		public int TotalFloors;

		[Header("smaller = faster")]
		public float Speed = 5f;

		[HideInInspector]
		public bool IsMoving;

		[HideInInspector]
		public bool CallerBusy;

		[HideInInspector]
		public int CurrentFloor;

		private float TimeStart;

		private Vector3 StartPos;

		private Vector3 EndPos;

		private void Start()
		{
			CurrentFloor = StartFloor;
		}

		private void Update()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			if (IsMoving)
			{
				float num = Time.time - TimeStart;
				float num2 = num / Speed;
				((Component)this).transform.position = Vector3.Lerp(StartPos, EndPos, num2);
				if (num2 >= 1f)
				{
					IsMoving = false;
				}
			}
		}

		public void StartMoving(bool direction)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (!(!IsMoving & !CallerBusy))
			{
				return;
			}
			if (direction)
			{
				if (CurrentFloor + 1 > TotalFloors)
				{
					return;
				}
				CurrentFloor++;
			}
			else
			{
				if (CurrentFloor - 1 < 1)
				{
					return;
				}
				CurrentFloor--;
			}
			IsMoving = true;
			TimeStart = Time.time;
			StartPos = ((Component)this).transform.position;
			if (direction)
			{
				EndPos = ((Component)this).transform.position + Vector3.up * 4f;
			}
			else
			{
				EndPos = ((Component)this).transform.position - Vector3.up * 4f;
			}
		}
	}
	public class DSElevatorCaller : MonoBehaviour
	{
		[Header("!caller doesn't work with Y pos < 0 (negative numbers)!")]
		public DSElevator _DSElevator;

		[Header("smaller = faster")]
		public float Speed = 5f;

		private bool IsMoving;

		private float TimeStart;

		private Vector3 StartPos;

		private Vector3 EndPos;

		private void Start()
		{
			//IL_0002: 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_000d: 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)
			StartPos = Vector3.zero;
			EndPos = Vector3.zero;
		}

		private void Update()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (IsMoving)
			{
				float num = Time.time - TimeStart;
				float num2 = num / Speed;
				((Component)_DSElevator).transform.position = new Vector3(((Component)_DSElevator).transform.position.x, Mathf.Lerp(StartPos.y, EndPos.y, num2), ((Component)_DSElevator).transform.position.z);
				if (num2 >= 1f)
				{
					IsMoving = false;
					_DSElevator.CallerBusy = false;
				}
			}
		}

		public void StartMoving()
		{
			//IL_0032: 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)
			if (!(!IsMoving & !_DSElevator.IsMoving))
			{
				return;
			}
			StartPos.y = ((Component)_DSElevator).transform.position.y;
			EndPos.y = (int)((Component)this).transform.position.y;
			EndPos.y = (int)EndPos.y / 4;
			EndPos.y *= 4f;
			if (EndPos.y == StartPos.y)
			{
				return;
			}
			IsMoving = true;
			_DSElevator.CallerBusy = true;
			TimeStart = Time.time;
			int num = 0;
			num = ((!((StartPos.y < 0f) | (EndPos.y < 0f))) ? ((int)Mathf.Abs(StartPos.y - EndPos.y)) : ((int)(Mathf.Abs(StartPos.y) + Mathf.Abs(EndPos.y))));
			num /= 4;
			if (StartPos.y != EndPos.y)
			{
				if (StartPos.y > EndPos.y)
				{
					_DSElevator.CurrentFloor -= num;
				}
				else
				{
					_DSElevator.CurrentFloor += num;
				}
			}
		}
	}
	internal class DSGates : MonoBehaviour
	{
		public enum StartStates
		{
			opened,
			closed
		}

		public string AnimationOpen;

		public string AnimationClose;

		public StartStates StartState = StartStates.closed;

		private bool CurrentState;

		private void Start()
		{
			if (StartState == StartStates.closed)
			{
				((Component)this).GetComponent<Animation>().Play(AnimationClose);
				CurrentState = true;
			}
			else
			{
				((Component)this).GetComponent<Animation>().Play(AnimationOpen);
				CurrentState = false;
			}
		}

		private void Update()
		{
		}

		public void StartOpenClose()
		{
			if (((Component)this).GetComponent<Animation>().isPlaying)
			{
				return;
			}
			CurrentState = !CurrentState;
			if (CurrentState)
			{
				if (!((Component)this).GetComponent<Animation>().isPlaying)
				{
					((Component)this).GetComponent<Animation>().Play(AnimationClose);
				}
			}
			else if (!((Component)this).GetComponent<Animation>().isPlaying)
			{
				((Component)this).GetComponent<Animation>().Play(AnimationOpen);
			}
		}
	}
	public class DSReparent : MonoBehaviour
	{
		private void Start()
		{
		}

		private void Update()
		{
		}

		private void OnTriggerEnter(Collider other)
		{
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<CharacterController>()))
			{
				((Component)other).gameObject.transform.parent = ((Component)this).transform;
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if (Object.op_Implicit((Object)(object)((Component)other).gameObject.GetComponent<CharacterController>()))
			{
				((Component)other).gameObject.transform.parent = null;
			}
		}
	}
	public class DSScrollTexture : MonoBehaviour
	{
		[Header("Texture Offsets")]
		public Vector2[] MoveRate;

		[Header("Shared Materials")]
		public Material[] SharedMaterials;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColorMap";

		private void Start()
		{
		}

		private void Update()
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0031: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SharedMaterials.Length; i++)
			{
				Vector2 textureOffset = SharedMaterials[i].GetTextureOffset(WorkingString);
				textureOffset += MoveRate[i] * Time.deltaTime;
				textureOffset.x %= 50f;
				textureOffset.y %= 50f;
				SharedMaterials[i].SetTextureOffset(WorkingString, textureOffset);
			}
		}

		private void OnDestroy()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < SharedMaterials.Length; i++)
			{
				SharedMaterials[i].SetTextureOffset(WorkingString, Vector2.zero);
			}
		}
	}
	public class DSTrigger : MonoBehaviour
	{
		public enum ExecMode
		{
			elevator_up,
			elevator_dwn,
			gate,
			elevator_call
		}

		public bool IsActive = true;

		public GameObject Executor;

		public ExecMode ExecModes = ExecMode.gate;

		private void Start()
		{
		}

		private void Update()
		{
		}

		public void DSTriggerExecute()
		{
			if (IsActive)
			{
				if (ExecModes == ExecMode.elevator_up)
				{
					Executor.GetComponent<DSElevator>().StartMoving(direction: true);
				}
				else if (ExecModes == ExecMode.elevator_dwn)
				{
					Executor.GetComponent<DSElevator>().StartMoving(direction: false);
				}
				else if (ExecModes == ExecMode.gate)
				{
					Executor.GetComponent<DSGates>().StartOpenClose();
				}
				else if (ExecModes == ExecMode.elevator_call)
				{
					Executor.GetComponent<DSElevatorCaller>().StartMoving();
				}
			}
		}
	}
	public class DSTvMovie : MonoBehaviour
	{
		[Serializable]
		public class DSTvMovieValues
		{
			public bool IsActive;

			[Header("max emission bright")]
			public float MaxBright = 3f;

			[Header("frames speed")]
			public float Speed;

			[Header("shared material")]
			public Material SharedMaterial;

			[Header("frames")]
			public Texture[] Frames;

			[HideInInspector]
			public int i;
		}

		public DSTvMovieValues[] _DSTvMovieValues;

		[Header("Shader String")]
		public string WorkingString = "_EmissiveColor";

		[Header("Shader String 2")]
		public string WorkingString2 = "_EmissiveColorMap";

		private void Awake()
		{
			Random.InitState((int)DateTime.Now.Ticks * 1000);
		}

		private void Start()
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
					float num = Random.Range(1.5f, _DSTvMovieValues[i].MaxBright);
					float num2 = Random.Range(0.2f, 0.8f);
					float num3 = Random.Range(0.2f, 0.8f);
					float num4 = Random.Range(0.2f, 0.8f);
					_DSTvMovieValues[i].SharedMaterial.SetColor(WorkingString, new Color(num + num2, num + num3, num + num4));
				}
				else
				{
					_DSTvMovieValues[i].SharedMaterial.SetColor(WorkingString, Color.black);
				}
			}
		}

		private void Update()
		{
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
					_DSTvMovieValues[i].i = (int)(Time.time * _DSTvMovieValues[i].Speed);
					_DSTvMovieValues[i].i = _DSTvMovieValues[i].i % _DSTvMovieValues[i].Frames.Length;
					_DSTvMovieValues[i].SharedMaterial.SetTexture(WorkingString2, _DSTvMovieValues[i].Frames[_DSTvMovieValues[i].i]);
				}
			}
		}

		private void OnDestroy()
		{
			for (int i = 0; i < _DSTvMovieValues.Length; i++)
			{
				if (_DSTvMovieValues[i].IsActive)
				{
				}
			}
		}
	}
	[BepInPlugin("Tolian.TeraSpace", "TeraSpace", "0.8.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "Tolian.TeraSpace";

		public const string NAME = "TeraSpace";

		public const string VERSION = "0.8.0";

		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "teraspace"));
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load Interior Dungeon assets.");
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Interior Assets loaded successfully");
			ExtendedDungeonFlow val2 = val.LoadAsset<ExtendedDungeonFlow>("Assets/LethalCompany/Mods/TeraSpace/TeraDungFlow.asset");
			PatchedContent.RegisterExtendedDungeonFlow(val2);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Extended DungeonFlow");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TeraScript";

		public const string PLUGIN_NAME = "TeraScript";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}