Decompiled source of CasualTweaks v1.3.1

plugins/CasualTweaks.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("CasualTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CasualTweaks")]
[assembly: AssemblyTitle("CasualTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class RealTimeSync : MonoBehaviour
{
	private sDayNightCycle cycle;

	private float nextCheckTime = 0f;

	private void Update()
	{
		if ((Object)(object)cycle == (Object)null)
		{
			if (Time.time >= nextCheckTime)
			{
				nextCheckTime = Time.time + 2f;
				FindCycle();
			}
		}
		else
		{
			cycle.time = (float)DateTime.Now.TimeOfDay.TotalSeconds;
			if (cycle.dayDuration != 86400f)
			{
				cycle.dayDuration = 86400f;
			}
		}
	}

	private void FindCycle()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		string name = ((Scene)(ref activeScene)).name;
		if (name == "TitleScreen" || name == "Credits" || name == "Ending")
		{
			return;
		}
		GameObject val = GameObject.Find("Gameplay");
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		Transform val2 = val.transform.Find("Sky");
		if ((Object)(object)val2 != (Object)null)
		{
			cycle = ((Component)val2).GetComponent<sDayNightCycle>();
			if ((Object)(object)cycle != (Object)null)
			{
				Debug.Log((object)("[RealTime] Successfully hooked into " + name + " sky!"));
			}
		}
	}
}
namespace CasualTweaks;

[BepInPlugin("com.laymxd.casualtweaks", "CasualTweaks", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <DelayedSetup>d__10 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Plugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DelayedSetup>d__10(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.ApplyTweaks();
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	internal static ManualLogSource Log;

	private ConfigEntry<float> fuelCapacityMultiplier;

	private ConfigEntry<float> energyCapacityMultiplier;

	private ConfigEntry<float> maxSpeedScaleMultiplier;

	private ConfigEntry<float> jobPriceMultiplier;

	private ConfigEntry<bool> doFuelAndEnergyChanges;

	private ConfigEntry<bool> doSpeedChanges;

	private ConfigEntry<bool> doPriceChanges;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"CasualTweaks loaded");
		fuelCapacityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Multipliers", "FuelCapacityMultiplier", 2f, "Multiplier applied to vehicle fuel capacity");
		energyCapacityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Multipliers", "EnergyCapacityMultiplier", 2f, "Multiplier applied to vehicle energy capacity");
		maxSpeedScaleMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Multipliers", "MaxSpeedScaleMultiplier", 4f, "Multiplier applied to vehicle max speed");
		jobPriceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Multipliers", "JobPriceMultiplier", 6f, "Multiplier applied to job payouts");
		doFuelAndEnergyChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "EnableFuelAndEnergyChanges", true, "Enable fuel and energy capacity changes");
		doSpeedChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "EnableSpeedChanges", false, "Enable car speed multiplier");
		doPriceChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "EnablePriceChanges", true, "Enable job price multiplier");
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Expected O, but got Unknown
		Log.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
		string[] array = new string[4] { "TitleScreen", "Credits", "Ending", "TrainIntro" };
		if (Array.IndexOf(array, ((Scene)(ref scene)).name) == -1)
		{
			GameObject val = new GameObject("CasualTweaksRunner");
			CoroutineRunner coroutineRunner = val.AddComponent<CoroutineRunner>();
			((MonoBehaviour)coroutineRunner).StartCoroutine(DelayedSetup());
		}
	}

	[IteratorStateMachine(typeof(<DelayedSetup>d__10))]
	private IEnumerator DelayedSetup()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedSetup>d__10(0)
		{
			<>4__this = this
		};
	}

	private void ApplyTweaks()
	{
		Log.LogInfo((object)"Applying gameplay tweaks");
		sHUD val = Object.FindObjectOfType<sHUD>();
		sCarController val2 = Object.FindObjectOfType<sCarController>();
		jobBoard val3 = Object.FindObjectOfType<jobBoard>();
		if ((Object)(object)val != (Object)null && doFuelAndEnergyChanges.Value)
		{
			val.fuelCapacity *= fuelCapacityMultiplier.Value;
			val.energyCapacity *= energyCapacityMultiplier.Value;
			Log.LogInfo((object)"Fuel/Energy tweaked");
		}
		else
		{
			Log.LogWarning((object)"HUD not found or fuel/energy disabled");
		}
		if ((Object)(object)val2 != (Object)null && doSpeedChanges.Value)
		{
			val2.maxSpeedScale *= maxSpeedScaleMultiplier.Value;
			Log.LogInfo((object)"Car speed tweaked");
		}
		else
		{
			Log.LogWarning((object)"Car controller not found or speed disabled");
		}
		if ((Object)(object)val3 != (Object)null && doPriceChanges.Value)
		{
			val3.priceBase *= jobPriceMultiplier.Value;
			val3.pricePerKM *= jobPriceMultiplier.Value;
			Log.LogInfo((object)"Job prices tweaked");
		}
		else
		{
			Log.LogWarning((object)"JobBoard not found or price changes disabled");
		}
	}
}
public class CoroutineRunner : MonoBehaviour
{
}