using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Atomicrops.Game.GameState;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obracrops;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: BuildDateTime("2024-02-24T22:54:56")]
[assembly: AssemblyCompany("Obracrops")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1064bf376bc272ebc1b0b0ccac215b9aa3bc1649")]
[assembly: AssemblyProduct("Obracrops")]
[assembly: AssemblyTitle("Obracrops")]
[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 Template
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Obracrops";
public const string PLUGIN_NAME = "Obracrops";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Obracrops
{
[AttributeUsage(AttributeTargets.Assembly)]
public class BuildDateTimeAttribute : Attribute
{
public DateTime Built { get; }
public BuildDateTimeAttribute(string date)
{
Built = DateTime.Parse(date);
}
}
public class AwesomeScreenShader : MonoBehaviour
{
public Shader awesomeShader = null;
private Material m_renderMaterial;
private float step = 0.01f;
private void Start()
{
if ((Object)(object)awesomeShader == (Object)null && (Object)(object)Mat.mat == (Object)null && (Object)(object)Mat.mat.shader == (Object)null)
{
Debug.LogError((object)"awesome shader not set");
m_renderMaterial = null;
}
else
{
awesomeShader = Mat.mat.shader;
m_renderMaterial = Mat.mat;
}
}
public void SetMat(Material m)
{
m_renderMaterial = m;
awesomeShader = m.shader;
Camera.main.targetTexture = null;
}
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit((Texture)(object)source, destination, m_renderMaterial);
}
private void Update()
{
if (Input.GetKey((KeyCode)44))
{
float @float = m_renderMaterial.GetFloat("_Lum");
@float -= step;
m_renderMaterial.SetFloat("_Lum", @float);
}
else if (Input.GetKey((KeyCode)46))
{
float float2 = m_renderMaterial.GetFloat("_Lum");
float2 += step;
m_renderMaterial.SetFloat("_Lum", float2);
}
}
}
public static class Mat
{
public static Material mat;
public static Texture2D dithTex;
public static Texture2D rampTex;
public static void SetUp(string path)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
AssetBundle val = AssetBundle.LoadFromFile(path);
Shader val2 = (Shader)val.LoadAsset("Dither");
mat = new Material(val2);
dithTex = (Texture2D)val.LoadAsset("bayer1920x1080");
rampTex = (Texture2D)val.LoadAsset("ramp4x1");
mat.SetTexture("_Dither", (Texture)(object)dithTex);
mat.SetTexture("_ColorRamp", (Texture)(object)rampTex);
Debug.Log((object)("_MainTex: " + (object)mat.GetTexture("_MainTex")));
Debug.Log((object)("_Dither: " + (object)mat.GetTexture("_Dither")));
Debug.Log((object)("_ColorRamp: " + (object)mat.GetTexture("_ColorRamp")));
}
}
[HarmonyPatch(typeof(GameStateManager), "AwakeSub")]
internal class GameStateManager_AwakeSub_Patch
{
public static string ModDirectory => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static void Postfix(GameStateManager __instance)
{
ApplyDitherOnCam(__instance);
}
private static void ApplyDitherOnCam(GameStateManager inst)
{
Mat.SetUp(Path.Combine(ModDirectory, "AssetBundles", "dithab"));
Camera val = (((Object)(object)Camera.current != (Object)null) ? Camera.current : Camera.main);
AwesomeScreenShader awesomeScreenShader = ((Component)val).gameObject.AddComponent<AwesomeScreenShader>();
awesomeScreenShader.SetMat(Mat.mat);
}
}
[HarmonyPatch(typeof(GameStateManager), "Update")]
internal class GameStateManager_Update_Patch
{
private static void Postfix(GameStateManager __instance)
{
Camera current = Camera.current;
if ((Object)(object)current != (Object)null && (Object)(object)((Component)current).gameObject.GetComponent<AwesomeScreenShader>() == (Object)null)
{
AwesomeScreenShader awesomeScreenShader = ((Component)current).gameObject.AddComponent<AwesomeScreenShader>();
awesomeScreenShader.SetMat(Mat.mat);
}
}
}
[HarmonyPatch(typeof(GameStateManager), "OnSceneStart")]
internal class GameStateManager_OnSceneStart_Patch
{
private class Waiter : MonoBehaviour
{
public void Wait(Action action)
{
((MonoBehaviour)this).StartCoroutine(Rout(action));
static IEnumerator Rout(Action action)
{
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForEndOfFrame();
yield return (object)new WaitForEndOfFrame();
action?.Invoke();
}
}
public void Wait(float seconds, Action action)
{
((MonoBehaviour)this).StartCoroutine(Rout(seconds, action));
static IEnumerator Rout(float seconds, Action action)
{
yield return (object)new WaitForSeconds(seconds);
action?.Invoke();
}
}
}
private class Cathcer : MonoBehaviour
{
public static Cathcer Inst;
public static string Name = "CamCatcherObj";
public GameObject cam;
private void Start()
{
if ((Object)(object)Inst != (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
Inst = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
GameObject val = GameObject.Find(Name);
if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)((Component)this).gameObject)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
else
{
((MonoBehaviour)this).StartCoroutine(Rtn());
}
IEnumerator Rtn()
{
while ((Object)(object)cam == (Object)null)
{
yield return (object)new WaitForEndOfFrame();
GameObject found = GameObject.Find("UiCam");
if ((Object)(object)found != (Object)null)
{
cam = found;
Debug.Log((object)$"CamCatcher found camera: {found}");
break;
}
}
}
}
public void DoWhenFind(string objPath, Action action)
{
GameObject found = null;
((MonoBehaviour)this).StartCoroutine(R());
IEnumerator R()
{
while ((Object)(object)found == (Object)null)
{
found = GameObject.Find(objPath);
yield return (object)new WaitForSeconds(0.1f);
}
action();
}
}
}
private static void Postfix(GameStateManager __instance)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)$"Camera.main == null: {(Object)(object)Camera.main == (Object)null}");
Debug.Log((object)$"Camera.main.GetComponent<PixelPerfectCamera>(): {((Component)Camera.main).GetComponent<PixelPerfectCamera>()}");
DisableAndEnablePixelPerfectCamera();
new GameObject(Cathcer.Name, new Type[1] { typeof(Cathcer) });
Scene activeScene = SceneManager.GetActiveScene();
Debug.Log((object)("--OnSceneStart.Postfix, cur scene: " + ((Scene)(ref activeScene)).name));
activeScene = SceneManager.GetActiveScene();
switch (((Scene)(ref activeScene)).name)
{
case "NewGameScene":
HandleLoadingScreen();
break;
case "MainMenu":
HandleMainMenu();
break;
case "FarmHouse":
HandleFarmHouse();
break;
case "Farm":
HandleFarm();
break;
case "Town":
HandleTown();
break;
}
}
private static void HandleLoadingScreen()
{
ChangeLoadScreen_ColorOnly();
}
private static void ChangeLoadScreen_ColorOnly()
{
GameObject val = GameObject.Find("/__UiLoadingSreen");
Canvas component = val.GetComponent<Canvas>();
component.renderMode = (RenderMode)1;
component.worldCamera = Camera.main;
}
private static void HandleMainMenu()
{
ChangeScaleLocPos(GameObject.Find("/Canvas"), "MainMenu");
ChangeLoadScreen_ColorOnly();
}
private static void HandleFarmHouse()
{
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
ChangeLoadScreen_ColorOnly();
ChangeScaleLocPos(GameObject.Find("/NoTransform/CopiaHud"), "Image", "Text");
ChangeScaleLocPos(GameObject.Find("/NoTransform/HudCatCount"), "Grp");
ChangeScaleLocPos(GameObject.Find("/UiDialogInfoRegion(Clone)"), "UiDialogInfoRegion");
ChangeScaleLocPos(GameObject.Find("/NoTransform/UiMetaUpgradeDisplay"), "Grp");
ChangeScaleLocPos(GameObject.Find("/NoTransform/UiCatMetaGame"), "Grp");
ChangeScaleLocPos(GameObject.Find("/NoTransform/ChangeYearUi"), "Grp");
ChangeScaleLocPos(GameObject.Find("/Placeables/ChangeCharacterHatch/ChangeCharacterHatchUi"), "Grp");
ChangeScaleLocPos_FindClones("/NoTransform/UiPauseScreen");
Scene sceneByName = SceneManager.GetSceneByName("HideAndDontSave");
GameObject parent = ((Scene)(ref sceneByName)).GetRootGameObjects().First((GameObject obj) => "UiPopupManager(Clone)".Contains(((Object)obj).name));
ChangeScaleLocPos(parent);
}
private static void HandleFarm()
{
ChangeLoadScreen_ColorOnly();
ChangeScaleLocPos(GameObject.Find("/MainUi2(Clone)"));
ChangeScaleLocPos(GameObject.Find("/UiHudSeedWheel"));
ChangeScaleLocPos(GameObject.Find("/UiHudTime"));
ChangeScaleLocPos(GameObject.Find("/Atomicrops.Game.Ui.Hud.UiHudDate"));
ChangeScaleLocPos(GameObject.Find("/UiHudTractor"));
ChangeScaleLocPos(GameObject.Find("/UiHudNightWaves"));
ChangeScaleLocPos(GameObject.Find("/UiHudCropLevelingProg"));
ChangeScaleLocPos_FindClones("/UiInfoScreen");
ChangeScaleLocPos_FindClones("/UiPauseScreen");
ChangeScaleLocPos_FindClones("/UiHudEnergized");
ChangeScaleLocPos_FindClones("/UiPopupManager");
}
private static void HandleTown()
{
ChangeLoadScreen_ColorOnly();
ChangeScaleLocPos(GameObject.Find("/MainUi2(Clone)"));
ChangeScaleLocPos(GameObject.Find("/UiHudSeedWheel"));
ChangeScaleLocPos(GameObject.Find("/UiHudTime"));
ChangeScaleLocPos(GameObject.Find("/Atomicrops.Game.Ui.Hud.UiHudDate"));
ChangeScaleLocPos(GameObject.Find("/UiHudTractor"));
ChangeScaleLocPos(GameObject.Find("/UiHudNightWaves"));
ChangeScaleLocPos(GameObject.Find("/UiHudCropLevelingProg"));
ChangeScaleLocPos(GameObject.Find("UiDialogInfoRegion(Clone)"));
HandleUiHudNewGunDialog();
ChangeScaleLocPos_FindClones("/UiInfoScreen");
ChangeScaleLocPos_FindClones("/UiPauseScreen");
ChangeScaleLocPos_FindClones("/UiPopupManager");
}
public static void ChangeScaleLocPos_FindClones(string name, params string[] chldNames)
{
GameObject val = (from c in (IEnumerable<GameObject>)(object)new GameObject[2]
{
GameObject.Find(name + "(Clone)"),
GameObject.Find(name)
}
where (Object)(object)c != (Object)null
where Object.op_Implicit((Object)(object)c.GetComponent<Canvas>())
select c).FirstOrDefault();
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("couldnt find " + name + " or clone"));
}
ChangeScaleLocPos(val);
}
public static void ChangeScaleLocPos(GameObject parent, params string[] chldNames)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
Canvas component = parent.GetComponent<Canvas>();
Vector3 localScale = ((Component)component).transform.localScale;
List<(Transform, Vector3)> list = (from c in chldNames
select parent.transform.Find(c) into c
select (c, c.localPosition)).ToList();
if (list.Count < chldNames.Length)
{
Debug.LogError((object)$"children.Count < chldNames.Length: {list.Count} < {chldNames.Length}");
}
component.renderMode = (RenderMode)1;
component.worldCamera = Camera.main;
foreach (var (val, val2) in list)
{
val.localPosition = new Vector3(val2.x / localScale.x, val2.y / localScale.y, 1f);
val.localScale = new Vector3(val.localScale.x / localScale.x, val.localScale.y / localScale.y, 1f);
}
}
public static void ChangeScaleLocPos(GameObject parent)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
Canvas component = parent.GetComponent<Canvas>();
Vector3 localScale = ((Component)component).transform.localScale;
List<(Transform, Vector3)> list = (from c in parent.transform.GetTopLevelChildren()
select (c, c.localPosition)).ToList();
component.renderMode = (RenderMode)1;
component.worldCamera = Camera.main;
foreach (var (val, val2) in list)
{
val.localPosition = new Vector3(val2.x / localScale.x, val2.y / localScale.y, 1f);
val.localScale = new Vector3(val.localScale.x / localScale.x, val.localScale.y / localScale.y, 1f);
}
}
private static void HandleUiHudNewGunDialog()
{
//IL_0027: 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)
GameObject val = GameObject.Find("/UiHudNewGunDialog");
ChangeScaleLocPos(val);
Transform child = val.transform.GetChild(0);
child.localPosition = new Vector3(58f, child.localPosition.y, 1f);
}
private static void DisableAndEnablePixelPerfectCamera()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
PixelPerfectCamera ppc = ((Component)Camera.main).GetComponent<PixelPerfectCamera>();
GameObject go = new GameObject("temp", new Type[1] { typeof(Waiter) });
Waiter component = go.GetComponent<Waiter>();
if ((Object)(object)ppc != (Object)null)
{
((Behaviour)ppc).enabled = false;
component.Wait(delegate
{
((Behaviour)ppc).enabled = true;
Object.Destroy((Object)(object)go);
});
}
}
}
[HarmonyPatch(typeof(UiTallyDaily2), "Awake")]
internal class UiTallyDaily2_Awake_Patch
{
private static void Postfix(UiTallyDaily2 __instance)
{
GameStateManager_OnSceneStart_Patch.ChangeScaleLocPos(((Component)__instance).gameObject);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "fhghaha.plugin.Obracrops";
public const string PLUGIN_NAME = "Obracrops";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("fhghaha.plugin.Obracrops", "Obracrops", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Log;
private void Awake()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogMessage((object)"---------------Plugin fhghaha.plugin.Obracrops is loaded!---------------");
((BaseUnityPlugin)this).Logger.LogMessage((object)$"---------------{GetBuildDateTime()}---------------");
Harmony val = new Harmony("fhghaha.plugin.Obracrops");
val.PatchAll();
}
private static DateTime? GetBuildDateTime()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
return (Attribute.GetCustomAttribute(executingAssembly, typeof(BuildDateTimeAttribute)) is BuildDateTimeAttribute buildDateTimeAttribute) ? new DateTime?(buildDateTimeAttribute.Built) : null;
}
}
public static class TransformExtensions
{
public static IEnumerable<Transform> GetTopLevelChildren(this Transform parent)
{
foreach (Transform item in parent)
{
yield return item;
}
}
}
}