Decompiled source of SR Downtown v1.0.4

SR_Downtown.dll

Decompiled 4 months 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 Atlas;
using BepInEx;
using BepInEx.Logging;
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]
namespace tiktokfamous.SR_Downtown;

[BepInPlugin("tiktokfamous.SR_Downtown", "SR_Downtown", "1.0.3")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class SR_DowntownPlugin : 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(), "tiktokfamous.SR_Downtown");
		AtlasPlugin.RegisterScene(Path.Combine(BasePath, "downdawn"));
	}
}
[RequireComponent(typeof(MeshRenderer))]
public class ScrollingMaterial : MonoBehaviour
{
	public float Speed;

	public Material TargetMaterial;

	private float _uvFactor;

	private void Awake()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)TargetMaterial == (Object)null)
		{
			Debug.LogError((object)"TargetMaterial is not assigned in the inspector!");
			return;
		}
		float x = TargetMaterial.GetTextureScale("_MainTex").x;
		float x2 = ((Component)this).transform.localScale.x;
		_uvFactor = x / x2;
	}

	private void Update()
	{
		//IL_001f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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)
		if ((Object)(object)TargetMaterial != (Object)null)
		{
			TargetMaterial.mainTextureOffset = new Vector2(TargetMaterial.mainTextureOffset.x + Time.deltaTime * Speed * _uvFactor, TargetMaterial.mainTextureOffset.y);
		}
	}
}
[RequireComponent(typeof(MeshRenderer))]
public class ScrollingMaterial2 : MonoBehaviour
{
	public float Speed;

	public Material TargetMaterial;

	private float _uvFactor;

	private void Awake()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)TargetMaterial == (Object)null)
		{
			Debug.LogError((object)"TargetMaterial is not assigned in the inspector!");
			return;
		}
		float x = TargetMaterial.GetTextureScale("_MainTex").x;
		float x2 = ((Component)this).transform.localScale.x;
		_uvFactor = x / x2;
	}

	private void Update()
	{
		//IL_001f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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)
		if ((Object)(object)TargetMaterial != (Object)null)
		{
			TargetMaterial.mainTextureOffset = new Vector2(TargetMaterial.mainTextureOffset.x + Time.deltaTime * Speed * _uvFactor, TargetMaterial.mainTextureOffset.y);
		}
	}
}
public class SoundScapeManager : MonoBehaviour
{
	public AudioClip[] fighterFlyoverSounds;

	public AudioClip[] cannonSounds;

	public AudioClip[] artillerySounds;

	public AudioClip[] distantGunfireSounds;

	public AudioClip[] metalSounds;

	public AudioClip[] glassSounds;

	public AudioClip[] debrisSounds;

	public AudioClip[] woodSounds;

	public AudioClip[] paperSounds;

	public AudioClip[] windLeavesSounds;

	public AudioClip[] lampPostRattleSounds;

	public AudioClip[] fliesBuzzingSounds;

	public AudioClip[] windWispySounds;

	public AudioClip[] cicadaSounds;

	public AudioClip[] electricityArcingSounds;

	public AudioClip[] waterLappingSounds;

	public AudioClip[] seagullsCallSounds;

	private AudioSource audioSource;

	private void Start()
	{
		audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
		((MonoBehaviour)this).StartCoroutine(PlaySoundScapes());
	}

	private IEnumerator PlaySoundScapes()
	{
		while (true)
		{
			PlayBattleSoundScape();
			PlayPaperSoundScape();
			PlayDebrisSoundScape();
			yield return null;
		}
	}

	private void PlayBattleSoundScape()
	{
		audioSource.volume = 1f;
		audioSource.pitch = Random.Range(0.9f, 1.1f);
		audioSource.time = Random.Range(20f, 60f);
		audioSource.clip = fighterFlyoverSounds[Random.Range(0, fighterFlyoverSounds.Length)];
		audioSource.Play();
	}

	private void PlayPaperSoundScape()
	{
		audioSource.volume = 0.4f;
		audioSource.pitch = 1f;
		audioSource.time = Random.Range(10f, 15f);
		audioSource.clip = paperSounds[Random.Range(0, paperSounds.Length)];
		audioSource.Play();
	}

	private void PlayDebrisSoundScape()
	{
		audioSource.volume = 0.6f;
		audioSource.pitch = 1f;
		audioSource.time = Random.Range(10f, 20f);
		audioSource.clip = debrisSounds[Random.Range(0, debrisSounds.Length)];
		audioSource.Play();
	}
}
public class AmbienceController : MonoBehaviour
{
	public AudioSource audioSource1;

	public AudioSource audioSource2;

	public AudioClip[] audioClips;

	public float maxVolume = 1f;

	public float minTime = 2f;

	public float maxTime = 10f;

	public float fadeDuration = 1f;

	private bool isAudioSource1Playing = true;

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(PlayAmbience());
	}

	private IEnumerator PlayAmbience()
	{
		while (true)
		{
			AudioClip audioClip = audioClips[Random.Range(0, audioClips.Length)];
			float clipDuration = Random.Range(minTime, maxTime);
			if (isAudioSource1Playing)
			{
				((MonoBehaviour)this).StartCoroutine(CrossFade(audioSource1, audioSource2, audioClip, clipDuration, fadeDuration));
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(CrossFade(audioSource2, audioSource1, audioClip, clipDuration, fadeDuration));
			}
			yield return (object)new WaitForSeconds(clipDuration);
			isAudioSource1Playing = !isAudioSource1Playing;
		}
	}

	private IEnumerator CrossFade(AudioSource fadeOutSource, AudioSource fadeInSource, AudioClip audioClip, float clipDuration, float fadeDuration)
	{
		fadeInSource.clip = audioClip;
		fadeInSource.Play();
		fadeInSource.volume = 0f;
		float currentTime = 0f;
		while (currentTime < fadeDuration)
		{
			float normalizedTime = currentTime / fadeDuration;
			fadeOutSource.volume = Mathf.Lerp(maxVolume, 0f, normalizedTime);
			fadeInSource.volume = Mathf.Lerp(0f, maxVolume, normalizedTime);
			currentTime += Time.deltaTime;
			yield return null;
		}
		fadeOutSource.Stop();
		fadeOutSource.volume = maxVolume;
	}
}
public class AmbientSoundScript : MonoBehaviour
{
	public AudioSource[] sourcesAmb;

	private AudioSource sourceAmb;

	public AudioClip[] clips;

	private AudioClip clip;

	public int chance = 25;

	public float timeBetween = 20f;

	private float timeOfLast;

	public float pitchAmb = 0.3f;

	public float volumeAmb = 0.3f;

	private void Start()
	{
		timeOfLast = Time.time;
	}

	private void Update()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).transform.eulerAngles = new Vector3(0f, 0f, 0f);
		if (clips.Length > 0 && sourcesAmb.Length > 0)
		{
			if (Time.time - timeOfLast > timeBetween && Random.Range(0, 100) < chance)
			{
				sourceAmb = sourcesAmb[Random.Range(0, sourcesAmb.Length - 1)];
				clip = clips[Random.Range(0, clips.Length - 1)];
				sourceAmb.clip = clip;
				sourceAmb.pitch = pitchAmb;
				sourceAmb.volume = volumeAmb;
				sourceAmb.Play();
				timeOfLast = Time.time;
			}
		}
		else
		{
			Debug.Log((object)"no sounds or clips loaded");
		}
	}
}
public class ambi : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
public class ScrollTexture : MonoBehaviour
{
	public string targetMaterialName = "tsdisplay01_ny";

	public float scrollSpeed = 0.5f;

	private Material targetMaterial;

	private Renderer renderer;

	private void Start()
	{
		renderer = ((Component)this).GetComponent<Renderer>();
		targetMaterial = FindTargetMaterial(targetMaterialName);
		if ((Object)(object)targetMaterial == (Object)null)
		{
			Debug.LogError((object)"Target material not found!");
		}
	}

	private void Update()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)targetMaterial != (Object)null)
		{
			float num = Time.time * scrollSpeed;
			targetMaterial.SetTextureOffset("tsdisplay01_ny", new Vector2(num, 0f));
		}
	}

	private Material FindTargetMaterial(string materialName)
	{
		Material[] materials = renderer.materials;
		Material[] array = materials;
		foreach (Material val in array)
		{
			if (((Object)val).name.Equals(materialName))
			{
				return val;
			}
		}
		return null;
	}
}