using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PocketWatcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("#1 Pocket Watcher")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eee73449a43d6e55057cb2247dc7874e1874dcfd")]
[assembly: AssemblyProduct("PocketWatcher")]
[assembly: AssemblyTitle("PocketWatcher")]
[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 PocketWatcher
{
[BepInPlugin("eth3l.PocketWatcher", "PocketWatcher", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logging;
public static string PluginDirectory;
public static ConfigEntry<int> VarietyChance;
public static GameObject MillerModel;
public static AssetBundle Bundle;
private void Awake()
{
Logging = ((BaseUnityPlugin)this).Logger;
PluginDirectory = ((BaseUnityPlugin)this).Info.Location;
VarietyChance = ((BaseUnityPlugin)this).Config.Bind<int>("Variety", "VarietyChance", 100, "Integer number from 0 to 100 inclusive. A chance in percent to spawn SCP-173 instead of regular Coilhead. Values below 100 allow regular Coilheads to spawn.");
if (VarietyChance.Value < 100)
{
VarietyChance.Value = 0;
}
if (VarietyChance.Value > 100)
{
VarietyChance.Value = 100;
}
LoadAssets();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
Logging.LogInfo((object)"Plugin eth3l.PocketWatcher is loaded!");
}
private void LoadAssets()
{
try
{
Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(PluginDirectory), "modasset"));
}
catch (Exception ex)
{
Logging.LogError((object)("Couldn't load asset bundle: " + ex.Message));
return;
}
try
{
MillerModel = Bundle.LoadAsset<GameObject>("assets/miller/MillerGiant.prefab");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded assets.");
}
catch (Exception ex2)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Couldn't load assets: " + ex2.Message));
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PocketWatcher";
public const string PLUGIN_NAME = "PocketWatcher";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace PocketWatcher.Patches
{
[HarmonyPatch]
public class ForestGiantPatch : MonoBehaviour
{
private static HashSet<ForestGiantAI> scps = new HashSet<ForestGiantAI>();
public static ManualLogSource Logging = Plugin.Logging;
[HarmonyPatch(typeof(EnemyAI), "Start")]
[HarmonyPostfix]
public static void SummonMiller(EnemyAI __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (__instance is ForestGiantAI)
{
ForestGiantAI val;
try
{
val = (ForestGiantAI)__instance;
}
catch (Exception ex)
{
Logging.LogError((object)("Couldn't cast EnemyAI instance to ForestGiantAI: " + ex.Message));
return;
}
if (new Random().Next(100) < Plugin.VarietyChance.Value)
{
scps.Add(val);
Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("FGiantModelContainer").Find("BodyLOD0")).gameObject.GetComponent<SkinnedMeshRenderer>());
Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("FGiantModelContainer").Find("BodyLOD1")).gameObject.GetComponent<SkinnedMeshRenderer>());
Object.Destroy((Object)(object)((Component)((Component)val).transform.Find("FGiantModelContainer").Find("BodyLOD2")).gameObject.GetComponent<SkinnedMeshRenderer>());
RaiseTheMiller(val);
Logging.LogInfo((object)"PocketWatcher resources are loaded.");
}
}
}
private static void RaiseTheMiller(ForestGiantAI parent)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Plugin.MillerModel == (Object)null) && scps.Contains(parent))
{
GameObject obj = Object.Instantiate<GameObject>(Plugin.MillerModel);
obj.transform.SetParent(((Component)parent).transform.Find("FGiantModelContainer"));
obj.transform.localPosition = Vector3.zero;
obj.transform.localRotation = Quaternion.identity;
obj.transform.localScale = Vector3.one;
}
}
}
}