using System;
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.Logging;
using HarmonyLib;
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("GoOutsideMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GoOutsideMod")]
[assembly: AssemblyTitle("GoOutsideMod")]
[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;
}
}
}
[BepInPlugin("com.redtree.gooutside", "GoOutside", "1.0.8")]
internal class PluginLoader : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("com.redtree.gooutside");
private static bool initialized;
internal static ManualLogSource StaticLogger { get; private set; }
private void Awake()
{
if (!initialized)
{
initialized = true;
StaticLogger = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll(typeof(GeneralPatches));
StaticLogger.LogInfo((object)"Patches Loaded");
}
}
}
[HarmonyPatch]
public class GeneralPatches
{
[HarmonyPatch(typeof(EnvironmentDirector), "Setup")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void EnvironmentDirector_Setup()
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Expected O, but got Unknown
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Expected O, but got Unknown
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_049a: Unknown result type (might be due to invalid IL or missing references)
//IL_04a1: Expected O, but got Unknown
if (!SemiFunc.RunIsShop())
{
return;
}
Module[] array = Object.FindObjectsByType<Module>((FindObjectsSortMode)0);
Module[] array2 = array;
foreach (Module val in array2)
{
if (val.StartRoom)
{
Transform val2 = ((Component)val).transform.Find("Outside");
if (!Object.op_Implicit((Object)(object)val2))
{
continue;
}
Transform val3 = val2.Find("Floor");
if (Object.op_Implicit((Object)(object)val3) && !Object.op_Implicit((Object)(object)val3.Find("collider")))
{
GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)val4).name = "collider";
val4.transform.position = new Vector3(5f, 0f, -7.5f);
val4.transform.localScale = new Vector3(185f, 0f, 125f);
Object.Destroy((Object)(object)val4.GetComponent<MeshRenderer>());
val4.SetActive(true);
val4.transform.SetParent(val3, true);
PluginLoader.StaticLogger.LogInfo((object)("Added Floor Collision: " + ((Object)val).name));
}
Transform val5 = val2.Find("Grass");
if (!Object.op_Implicit((Object)(object)val5))
{
continue;
}
foreach (Transform item in val5)
{
Transform val6 = item;
if (!Object.op_Implicit((Object)(object)((Component)val6).GetComponent<Collider>()))
{
BoxCollider val7 = ((Component)val6).gameObject.AddComponent<BoxCollider>();
if (val7.size.y == 0f)
{
val7.size = new Vector3(val7.size.x, 0.2f, val7.size.z);
}
((Collider)val7).isTrigger = false;
}
}
PluginLoader.StaticLogger.LogInfo((object)("Added Grass Collisions: " + ((Object)val).name));
}
else if (((Object)val).name.Contains("- DE - Gambling Room"))
{
PluginLoader.StaticLogger.LogInfo((object)("Processing Gambling Room: " + ((Object)val).name));
DisableObjects(((Component)val).transform, "Shop Outside Roof");
DisableObjects(((Component)val).transform, "Shop Outside Bush");
DisableObjects(((Component)val).transform, "Ceiling 1x1");
DeleteObjectsStartingWith(((Component)val).transform, "Wall 01 - 1x1 - Main");
DeleteObjects(((Component)val).transform, "Metal Storage Shelf");
Transform val8 = FindChild(((Component)val).transform, "---- Level ------------");
if (Object.op_Implicit((Object)(object)val8))
{
Transform val9 = val8.Find("Lights");
if (Object.op_Implicit((Object)(object)val9))
{
((Component)val9).gameObject.SetActive(false);
PluginLoader.StaticLogger.LogInfo((object)"Disabled Lights");
}
}
PluginLoader.StaticLogger.LogInfo((object)"Done with Gambling Room");
}
else
{
if (!((Object)val).name.Contains("- DE -"))
{
continue;
}
PluginLoader.StaticLogger.LogInfo((object)("Processing Dead End: " + ((Object)val).name));
foreach (Transform item2 in ((Component)val).transform)
{
Transform val10 = item2;
if (((Object)val10).name != "---- Level ------------" && ((Object)val10).name != "Shop Door")
{
Object.Destroy((Object)(object)((Component)val10).gameObject);
}
}
Transform val11 = ((Component)val).transform.Find("---- Level ------------");
if (Object.op_Implicit((Object)(object)val11))
{
foreach (Transform item3 in val11)
{
Transform val12 = item3;
if (((Object)val12).name != "Walls")
{
((Component)val12).gameObject.SetActive(false);
}
}
Transform val13 = val11.Find("Walls");
if (Object.op_Implicit((Object)(object)val13))
{
foreach (Transform item4 in val13)
{
Transform val14 = item4;
if (!((Object)val14).name.Contains("Door"))
{
((Component)val14).gameObject.SetActive(false);
}
}
}
}
PluginLoader.StaticLogger.LogInfo((object)"Done with Dead End");
}
}
}
private static void DisableObjects(Transform parent, string name)
{
Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(true);
int num = 0;
Transform[] array = componentsInChildren;
foreach (Transform val in array)
{
if (((Object)val).name.Contains(name))
{
((Component)val).gameObject.SetActive(false);
num++;
}
}
if (num > 0)
{
PluginLoader.StaticLogger.LogInfo((object)$"Disabled {num} '{name}' objects");
}
}
private static void DeleteObjects(Transform parent, string name)
{
Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(true);
int num = 0;
Transform[] array = componentsInChildren;
foreach (Transform val in array)
{
if (((Object)val).name.Contains(name))
{
Object.Destroy((Object)(object)((Component)val).gameObject);
num++;
}
}
if (num > 0)
{
PluginLoader.StaticLogger.LogInfo((object)$"Deleted {num} '{name}' objects");
}
}
private static void DeleteObjectsStartingWith(Transform parent, string name)
{
Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren<Transform>(true);
int num = 0;
Transform[] array = componentsInChildren;
foreach (Transform val in array)
{
if (((Object)val).name.StartsWith(name))
{
Object.Destroy((Object)(object)((Component)val).gameObject);
num++;
}
}
if (num > 0)
{
PluginLoader.StaticLogger.LogInfo((object)$"Deleted {num} objects starting with '{name}'");
}
}
private static Transform FindChild(Transform parent, string name)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (((Object)val).name == name)
{
return val;
}
Transform val2 = FindChild(val, name);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
}