Decompiled source of Preserve Photo Mode v1.1.0

PhotoModePreserve.dll

Decompiled 9 months ago
using System;
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 Colossal.Logging;
using Game;
using Game.Common;
using Game.Modding;
using Game.Rendering;
using Game.Rendering.CinematicCamera;
using Game.UI.InGame;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PhotoModePreserve.Systems;
using Unity.Entities;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PhotoModePreserve")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Preserve Photo Mode")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("PhotoModePreserve")]
[assembly: AssemblyTitle("PhotoModePreserve")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 PhotoModePreserve
{
	[BepInPlugin("com.nyoko.photomodepreserve", "Photo Mode Preserve", "1.1")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "com.nyoko.photomodepreserve";

		private Mod _mod;

		public bool Compatible;

		private PhotoModeUISystem m_PhotoModeUISystem;

		private static CameraUpdateSystem m_CameraUpdateSystem;

		public static bool orbitMode { get; set; }

		public void Awake()
		{
			_mod = new Mod();
			_mod.OnLoad();
			if (Application.version.ToString().Equals("1.0.19f1"))
			{
				Compatible = true;
			}
			if (Compatible)
			{
				Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.nyoko.photomodepreserve");
				Console.WriteLine(" ────────────────────────────────── ");
				Console.WriteLine(" ────────────────────────────────── ");
				Console.WriteLine("Preserve Photo Mode 1.1", ConsoleColor.Blue, ConsoleColor.Blue);
				Console.WriteLine("Support: https://discord.gg/5gZgRNm29e", ConsoleColor.Blue, ConsoleColor.Blue);
				Console.WriteLine("Donate: https://shorturl.at/hmpCW", ConsoleColor.Blue, ConsoleColor.Blue);
				Console.ForegroundColor = ConsoleColor.Magenta;
				Console.WriteLine(" ────────────────────────────────── ");
				Console.WriteLine(" PPM doesn't save lightning values. Consider looking at ColorAdjustments mod instead.");
				Console.WriteLine("https://thunderstore.io/c/cities-skylines-ii/p/Nyoko/ColorAdjustments/");
				Console.WriteLine(" ────────────────────────────────── ");
				Console.ResetColor();
			}
			else
			{
				Debug.Log((object)"Preserve Photo Mode is not compatible with your current game version. Contact the developer https://discord.gg/5gZgRNm29e ");
			}
		}

		[HarmonyPatch(typeof(SystemOrder), "Initialize")]
		[HarmonyPostfix]
		private static void InjectSystems(UpdateSystem updateSystem)
		{
			Mod.Instance.OnCreateWorld(updateSystem);
		}

		[HarmonyPatch(typeof(PhotoModeUISystem), "Activate")]
		[HarmonyPrefix]
		public static bool OverrideActivate(PhotoModeRenderSystem ___m_PhotoModeRenderSystem)
		{
			___m_PhotoModeRenderSystem.Enable(true);
			return false;
		}

		[HarmonyPatch(typeof(PhotoModeRenderSystem), "DisableAllCameraProperties")]
		[HarmonyPrefix]
		public static bool DontDisableAllCameraPropertiesPlease(PhotoModeRenderSystem __instance)
		{
			foreach (KeyValuePair<string, PhotoModeProperty> photoModeProperty in __instance.photoModeProperties)
			{
				photoModeProperty.Value.setEnabled?.Invoke(obj: true);
			}
			return false;
		}
	}
	internal static class Initializer
	{
		public static void OnLoad()
		{
		}

		public static void OnInitialized()
		{
		}
	}
	public sealed class Mod : IMod
	{
		public const string ModName = "Photo Mode Preserve";

		public static bool Compatible;

		public static Mod Instance { get; private set; }

		internal ILog Log { get; private set; }

		public void OnLoad()
		{
			Instance = this;
			Log = LogManager.GetLogger("Photo Mode Preserve", true);
			Log.Info((object)"setting logging level to Debug");
			Log.effectivenessLevel = Level.Debug;
			Log.Info((object)"loading");
		}

		public void OnCreateWorld(UpdateSystem updateSystem)
		{
			updateSystem.UpdateAt<ModeSystem>((SystemUpdatePhase)12);
		}

		public void OnDispose()
		{
			Log.Info((object)"disposing");
			Instance = null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PhotoModePreserve";

		public const string PLUGIN_NAME = "PhotoModePreserve";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace PhotoModePreserve.Systems
{
	public class ModeSystem : SystemBase
	{
		protected override void OnUpdate()
		{
		}
	}
}