using System;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LeftAndRightPlayerTerminal.Patches;
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("LeftAndRightPlayerTerminal")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4711552b08ee6bf6a47c8acd53bb14eba3236cb7")]
[assembly: AssemblyProduct("LeftAndRightPlayerTerminal")]
[assembly: AssemblyTitle("LeftAndRightPlayerTerminal")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace LeftAndRightPlayerTerminal
{
[BepInPlugin("com.atomic.lrmap", "LR Map Indicator", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("com.atomic.lrmap");
private static Plugin? instance;
internal static ManualLogSource Logger;
internal static List<Mesh>? Meshes;
internal static List<Material>? Materials;
internal static AssetBundle? bundle;
internal static ConfigEntry<bool>? FixedRotationIndicators;
internal static ConfigEntry<float>? LeftIndicatorColorR;
internal static ConfigEntry<float>? LeftIndicatorColorG;
internal static ConfigEntry<float>? LeftIndicatorColorB;
internal static ConfigEntry<float>? RightIndicatorColorR;
internal static ConfigEntry<float>? RightIndicatorColorG;
internal static ConfigEntry<float>? RightIndicatorColorB;
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
Logger = Logger.CreateLogSource("LRMapIndicator");
Logger.LogInfo((object)"I am alive!");
FixedRotationIndicators = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fixed Rotation Indicators", false, "The L and R symbols rotate with the player's view.");
LeftIndicatorColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Left Indicator Color", "Red", 0f, "Red component (0-255) for the L indicator.");
LeftIndicatorColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Left Indicator Color", "Green", 0f, "Green component (0-255) for the L indicator.");
LeftIndicatorColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Left Indicator Color", "Blue", 255f, "Blue component (0-255) for the L indicator.");
RightIndicatorColorR = ((BaseUnityPlugin)this).Config.Bind<float>("Right Indicator Color", "Red", 255f, "Red component (0-255) for the R indicator.");
RightIndicatorColorG = ((BaseUnityPlugin)this).Config.Bind<float>("Right Indicator Color", "Green", 0f, "Green component (0-255) for the R indicator.");
RightIndicatorColorB = ((BaseUnityPlugin)this).Config.Bind<float>("Right Indicator Color", "Blue", 0f, "Blue component (0-255) for the R indicator.");
harmony.PatchAll(typeof(PlayerControllerBPatch));
Meshes = new List<Mesh>();
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "radardotleftrightindicator"));
if ((Object)(object)bundle == (Object)null)
{
Logger.LogError((object)"Failed to load asset bundle! Abort!!!");
return;
}
Meshes = bundle.LoadAllAssets<Mesh>().ToList();
Materials = bundle.LoadAllAssets<Material>().ToList();
}
}
}
namespace LeftAndRightPlayerTerminal.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
private static Transform? mapDot;
private static Transform? mDI;
private static Transform? mDIR;
private static Transform? mDIL;
private static GameObject? cloneR;
private static GameObject? cloneL;
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void OverrideMapRadarDirectionIndicator(PlayerControllerB __instance)
{
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Expected O, but got Unknown
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected O, but got Unknown
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((Component)__instance).gameObject.transform.Find("Misc").Find("MapDot").Find("MapDirectionIndicatorRight") == (Object)null)
{
mapDot = ((Component)__instance).gameObject.transform.Find("Misc").Find("MapDot");
mDI = mapDot.Find("MapDirectionIndicator");
cloneR = Object.Instantiate<GameObject>(((Component)mDI).gameObject);
cloneL = Object.Instantiate<GameObject>(((Component)mDI).gameObject);
((Object)cloneR).name = "MapDirectionIndicatorRight";
((Object)cloneL).name = "MapDirectionIndicatorLeft";
cloneR.transform.SetParent(mapDot);
cloneL.transform.SetParent(mapDot);
if (Plugin.Meshes == null || Plugin.Materials == null)
{
Plugin.Logger.LogError((object)"Meshes or Materials are not initialized!");
return;
}
cloneR.GetComponent<MeshFilter>().sharedMesh = Plugin.Meshes[1];
cloneL.GetComponent<MeshFilter>().sharedMesh = Plugin.Meshes[0];
Material val = new Material(Plugin.Materials[1]);
val.color = new Color(Plugin.RightIndicatorColorR.Value / 255f, Plugin.RightIndicatorColorG.Value / 255f, Plugin.RightIndicatorColorB.Value / 255f);
((Renderer)cloneR.GetComponent<MeshRenderer>()).material = val;
Material val2 = new Material(Plugin.Materials[0]);
val2.color = new Color(Plugin.LeftIndicatorColorR.Value / 255f, Plugin.LeftIndicatorColorG.Value / 255f, Plugin.LeftIndicatorColorB.Value / 255f);
((Renderer)cloneL.GetComponent<MeshRenderer>()).material = val2;
cloneR.transform.localRotation = Quaternion.Euler(0f, -180f, 0f);
cloneL.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
cloneR.transform.localScale = new Vector3(0.4f, 0.4191016f, 0.7f);
cloneL.transform.localScale = new Vector3(0.4f, 0.4191016f, 0.7f);
cloneR.transform.localPosition = new Vector3(2.05f, 1.42f, 0f);
cloneL.transform.localPosition = new Vector3(-2.14f, 1.42f, 0.37f);
}
mDIR = ((Component)__instance).gameObject.transform.Find("Misc").Find("MapDot").Find("MapDirectionIndicatorRight");
mDIL = ((Component)__instance).gameObject.transform.Find("Misc").Find("MapDot").Find("MapDirectionIndicatorLeft");
if (Plugin.FixedRotationIndicators.Value)
{
Quaternion rotation = mDIR.rotation;
if (((Quaternion)(ref rotation)).eulerAngles.y != 45f)
{
Transform? obj = mDIR;
Vector3 up = Vector3.up;
rotation = mDIR.rotation;
obj.Rotate(up, 0f - ((Quaternion)(ref rotation)).eulerAngles.y + 45f, (Space)1);
}
rotation = mDIL.rotation;
if (((Quaternion)(ref rotation)).eulerAngles.y != 45f)
{
Transform? obj2 = mDIL;
Vector3 up2 = Vector3.up;
rotation = mDIL.rotation;
obj2.Rotate(up2, 0f - ((Quaternion)(ref rotation)).eulerAngles.y + 45f, (Space)1);
}
}
((Renderer)((Component)mDIR).GetComponent<MeshRenderer>()).material.color = new Color(Plugin.RightIndicatorColorR.Value / 255f, Plugin.RightIndicatorColorG.Value / 255f, Plugin.RightIndicatorColorB.Value / 255f);
((Renderer)((Component)mDIL).GetComponent<MeshRenderer>()).material.color = new Color(Plugin.LeftIndicatorColorR.Value / 255f, Plugin.LeftIndicatorColorG.Value / 255f, Plugin.LeftIndicatorColorB.Value / 255f);
}
}
}