using System;
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 BepInEx;
using CornBdayPack.Replacements;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CornBdayPack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A Birthday For Corn")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CornBdayPack")]
[assembly: AssemblyTitle("CornBdayPack")]
[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 CornBdayPack
{
[HarmonyPatch(typeof(animatedSun))]
internal class AnimatedSunPatch
{
private static readonly GameObject cornPrefab = Plugin.Bundle.LoadAsset<GameObject>("Assets/SunTexture.prefab");
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ref animatedSun __instance)
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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)
Debug.Log((object)("GARP __instance is " + ((Object)((Component)__instance).gameObject).name));
GameObject gameObject = ((Component)((Component)__instance).gameObject.transform.Find("SunTexture")).gameObject;
GameObject val = Object.Instantiate<GameObject>(cornPrefab);
val.transform.parent = ((Component)__instance).gameObject.transform;
val.transform.position = gameObject.transform.position;
val.transform.rotation = gameObject.transform.rotation;
val.transform.localPosition = gameObject.transform.localPosition;
val.transform.localRotation = gameObject.transform.localRotation;
val.transform.localScale = new Vector3(10f, 10f, 10f);
gameObject.SetActive(false);
}
}
[HarmonyPatch(typeof(ItemDropship))]
internal class ItemDropshipPatch
{
private static readonly GameObject cornShip = Plugin.Bundle.LoadAsset<GameObject>("Assets/corn_ship.prefab");
[HarmonyPatch("LandShipClientRpc")]
[HarmonyPostfix]
private static void LandShipClientRpcPatch(ref ItemDropship __instance)
{
//IL_0060: 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_0088: Unknown result type (might be due to invalid IL or missing references)
if (__instance.shipAnimator.GetBool("landing") && (Object)(object)((Component)__instance).gameObject.transform.Find("corn_ship(Clone)") == (Object)null)
{
Transform transform = ((Component)__instance).gameObject.transform;
Transform transform2 = Object.Instantiate<GameObject>(cornShip).transform;
transform2.parent = transform;
transform2.localPosition = Vector3.zero;
transform2.localScale = new Vector3(125f, 125f, 125f);
transform2.rotation = transform.rotation;
}
}
}
[BepInPlugin("CornBdayPack", "CornBdayPack", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("GARPEden.CornBdayPack");
public static string bundlePath;
public static string costumeBundlePath;
public static readonly AssetBundle Bundle;
public static readonly AssetBundle CornCostumes;
static Plugin()
{
bundlePath = "CornBdayPack.Resources.cornbdayassets";
costumeBundlePath = "CornBdayPack.Resources.corncostumes";
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(costumeBundlePath);
CornCostumes = AssetBundle.LoadFromStream(stream);
using Stream stream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream(bundlePath);
Bundle = AssetBundle.LoadFromStream(stream2);
}
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CornBdayPack is loaded!");
PopulateAssets();
try
{
ModelReplacementAPI.RegisterSuitModelReplacement("CornDay", typeof(CornReplacement));
}
catch (Exception ex)
{
Debug.Log((object)"Apparently it didn't work...");
Debug.LogException(ex);
}
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(ItemDropshipPatch));
harmony.PatchAll(typeof(AnimatedSunPatch));
}
private void PopulateAssets()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if (!((Object)Bundle == (Object)null))
{
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
private static readonly Texture2D tipsPosterNew = Plugin.Bundle.LoadAsset<Texture2D>("Assets/tips_poster_new.png");
private static readonly Texture2D cornPosters = Plugin.Bundle.LoadAsset<Texture2D>("Assets/posters_new.png");
private static readonly Texture2D cornTexture = Plugin.Bundle.LoadAsset<Texture2D>("Assets/RealCorn.png");
private static readonly Mesh cornMesh = Plugin.Bundle.LoadAsset<Mesh>("Assets/RealCorn.fbx");
private static readonly Texture2D stickyNote = Plugin.Bundle.LoadAsset<Texture2D>("Assets/StickyNoteTex.png");
private static readonly string squeezeHover = "Squeeze Real Corn : [E]";
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(ref StartOfRound __instance)
{
BuyPlushiePajamaMan(__instance);
}
[HarmonyPatch("ResetShip")]
[HarmonyPostfix]
private static void ResetShipPatch(ref StartOfRound __instance)
{
BuyPlushiePajamaMan(__instance);
}
[HarmonyPatch("PlayerLoadedClientRpc")]
[HarmonyPostfix]
private static void PlayerLoadedClientRpcPatch(ref StartOfRound __instance)
{
UpdateRealCornMesh(__instance);
UpdateStickyNote(__instance);
UpdatePosters(__instance);
}
private static void BuyPlushiePajamaMan(StartOfRound __instance)
{
try
{
int num = __instance.unlockablesList.unlockables.FindIndex((UnlockableItem i) => i.unlockableName == "Plushie pajama man");
StartOfRound val = Object.FindFirstObjectByType<StartOfRound>();
int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
__instance.BuyShipUnlockableServerRpc(num, groupCredits);
}
catch (Exception ex)
{
Debug.Log((object)("Something went wrong, and I have no idea why:" + ex));
}
}
private static void UpdateRealCornMesh(StartOfRound __instance)
{
try
{
UnlockableItem val = __instance.unlockablesList.unlockables.Where((UnlockableItem i) => i.unlockableName == "Plushie pajama man").FirstOrDefault();
((Renderer)val.prefabObject.GetComponentInChildren<MeshRenderer>()).material.mainTexture = (Texture)(object)cornTexture;
val.prefabObject.GetComponentInChildren<MeshFilter>().mesh = cornMesh;
val.prefabObject.GetComponentInChildren<InteractTrigger>().hoverTip = squeezeHover;
GameObject val2 = GameObject.Find("PlushiePJManContainer(Clone)");
if ((Object)(object)val2 != (Object)null)
{
((Renderer)val2.GetComponentInChildren<MeshRenderer>()).material.mainTexture = (Texture)(object)cornTexture;
val2.GetComponentInChildren<MeshFilter>().mesh = cornMesh;
val2.GetComponentInChildren<InteractTrigger>().hoverTip = "Squeeze Real Corn : [E]";
}
}
catch (Exception ex)
{
Debug.LogError((object)"An exception was thrown while updating \"Real Corn\"'s model");
Debug.LogException(ex);
}
}
private static void UpdatePosters(StartOfRound __instance)
{
try
{
GameObject val = GameObject.Find("HangarShip");
GameObject gameObject = ((Component)val.transform.Find("Plane.001")).gameObject;
if ((Object)(object)gameObject != (Object)null)
{
Material[] materials = ((Renderer)gameObject.GetComponentInChildren<MeshRenderer>()).materials;
materials[0].mainTexture = (Texture)(object)cornPosters;
materials[1].mainTexture = (Texture)(object)tipsPosterNew;
}
}
catch (Exception ex)
{
Debug.LogError((object)"An exception was thrown while updating poster textures.");
Debug.LogException(ex);
}
}
private static void UpdateStickyNote(StartOfRound __instance)
{
try
{
GameObject val = GameObject.Find("StickyNoteItem");
((Renderer)val.GetComponentInChildren<MeshRenderer>()).material.mainTexture = (Texture)(object)stickyNote;
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CornBdayPack";
public const string PLUGIN_NAME = "CornBdayPack";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CornBdayPack.Replacements
{
public class CornReplacement : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
string text = "Assets/corn_costume.prefab";
return Plugin.CornCostumes.LoadAsset<GameObject>(text);
}
}
}