using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CommandsExtended.Behaviors;
using CommandsExtended.Commands;
using CommandsExtended.Commands.Common;
using CommandsExtended.Common;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreCommands;
using MoreCommands.Accessors;
using MoreCommands.Common;
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("CommandsExtended")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("An extension to MoreCommands")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+04bf942e9a0681d8d4f8bd2d4ae53bf82c52e01a")]
[assembly: AssemblyProduct("CommandsExtended")]
[assembly: AssemblyTitle("CommandsExtended")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.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 CommandsExtended
{
[BepInPlugin("dotlake.CommandsExtended", "CommandsExtended", "0.1.2")]
[BepInDependency("shishyando.WK.MoreCommands", "0.11.2")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logger;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Registry.RegisterAll();
Logger.LogInfo((object)"dotlake.CommandsExtended is loaded");
}
public static void Assert(bool condition)
{
if (!condition)
{
Logger.LogFatal((object)"Assert failed");
throw new Exception("[CommandsExtended] Assert failed");
}
}
}
public static class Registry
{
public static void RegisterAll()
{
CommandRegistry.Register((ICommand)(object)new Raycast());
CommandRegistry.Register((ICommand)(object)new ShowGrabs());
CommandRegistry.Register((ICommand)(object)new Marathon());
CommandRegistry.Register((ICommand)(object)new Fov());
CommandRegistry.Register((ICommand)(object)new Volume());
CommandRegistry.Register((ICommand)(object)new Music());
CommandRegistry.Register((ICommand)(object)new Sensitivity());
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "dotlake.CommandsExtended";
public const string PLUGIN_NAME = "CommandsExtended";
public const string PLUGIN_VERSION = "0.1.2";
}
}
namespace CommandsExtended.Common
{
public static class String
{
public static bool EqualsIgnoreCase(this string one, string two)
{
return one.Equals(two, StringComparison.OrdinalIgnoreCase);
}
public static bool StartsWithIgnoreCase(this string one, string two)
{
return one.StartsWith(two, StringComparison.OrdinalIgnoreCase);
}
public static bool ContainsIgnoreCase(this string one, string two)
{
return one.Contains(two, StringComparison.OrdinalIgnoreCase);
}
}
}
namespace CommandsExtended.Commands
{
public sealed class Fov : FloatSettingCommand
{
public override string[] Aliases => new string[1] { "fov" };
protected override float Min => 60f;
protected override float Max => 140f;
protected override string SettingName => "Player FOV";
protected override string DisplayPrecision => "F1";
protected override bool RequiresRefresh => false;
protected override float SettingValue
{
get
{
return SettingsManager.settings.playerFOV;
}
set
{
SettingsManager.settings.playerFOV = value;
}
}
}
public sealed class Marathon : CommandBase
{
private static readonly string[] levelOrder = new string[23]
{
"m1_intro_01", "m1_silos_storage_", "m1_silos_safearea_01", "m1_silos_broken_", "m1_silos_air_", "campaign_interlude_silo_to_pipeworks_01", "m2_pipeworks_drainage_", "m2_pipeworks_waste_", "m2_pipeworks_organ_", "campaign_interlude_pipeworks_to_habitation_01",
"m3_habitation_pier_04", "m3_habitation_pier_entrance_01", "m3_habitation_pier_01", "m3_habitation_pier_entrance_01", "m3_habitation_pier_02", "m3_habitation_lab_lobby", "m3_habitation_lab_", "m3_habitation_lab_ending", "campaign_interlude_habitation_to_abyss_01", "m4_abyss_transit_",
"m4_abyss_handle_", "m4_abyss_garden_", "m4_abyss_outro_01"
};
public override string[] Aliases => new string[1] { "marathon" };
public override CommandTag Tag => (CommandTag)1;
public override string Description => "Loads all levels in a completable manner";
public override bool CheatsOnly => false;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
List<string> source = (from x in Prefabs.Levels().Data()
select ((Object)x).name).ToList();
List<string> list = new List<string>();
List<string> list2 = new List<string>();
int i;
for (i = 0; i < levelOrder.Length; i++)
{
list2 = source.Where((string x) => x.EqualsIgnoreCase(levelOrder[i])).ToList();
if (!list2.Any())
{
list2 = source.Where((string x) => x.StartsWithIgnoreCase(levelOrder[i])).ToList();
list2.RemoveAll((string x) => x.ContainsIgnoreCase("lobby"));
list2.RemoveAll((string x) => x.ContainsIgnoreCase("ending"));
}
list.AddRange(list2);
}
CL_GameManager.gMan.LoadLevels(list.ToArray());
};
}
}
public sealed class Music : FloatSettingCommand
{
public override string[] Aliases => new string[1] { "music" };
protected override float Min => 0f;
protected override float Max => 1f;
protected override string SettingName => "music volume";
protected override string DisplayPrecision => "F2";
protected override bool RequiresRefresh => true;
protected override float SettingValue
{
get
{
return SettingsManager.settings.musicVolume;
}
set
{
SettingsManager.settings.musicVolume = value;
}
}
}
public sealed class Raycast : TogglableCommandBase
{
public override string[] Aliases => new string[1] { "raycast" };
public override CommandTag Tag => (CommandTag)1;
public override string Description => "For dev purposes, determines name of game object at crosshair when pressing left click";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("RaycastListener");
if (((TogglableCommandBase)this).Enabled)
{
val.AddComponent<Raycaster>();
}
else
{
Object.Destroy((Object)(object)val);
}
};
}
}
public sealed class Sensitivity : FloatSettingCommand
{
public override string[] Aliases => new string[2] { "sensitivity", "sens" };
protected override float Min => 0f;
protected override float Max => 100f;
protected override string SettingName => "mouse sensitivity";
protected override string DisplayPrecision => "F4";
protected override bool RequiresRefresh => false;
protected override float SettingValue
{
get
{
return SettingsManager.settings.mouseSensitivity;
}
set
{
SettingsManager.settings.mouseSensitivity = value;
}
}
}
public sealed class ShowGrabs : TogglableCommandBase
{
public static Material HighlightMat;
private GameObject animationObj;
private const string rgb = "rgb";
public override string[] Aliases => new string[2] { "showgrabs", "sg" };
public override CommandTag Tag => (CommandTag)1;
public override string Description => "Shows grabbable surfaces.\nPass color like 'red', 'green' or '#RRGGBB' as argument to set custom color, or 'rgb' for rgb mode";
public override bool CheatsOnly => true;
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
if (((TogglableCommandBase)this).Enabled)
{
SetupVisualizer(args);
}
else if (!((TogglableCommandBase)this).Enabled)
{
((CommandBase)this).OnExit();
}
};
}
private void SetupVisualizer(string[] args)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
bool flag = false;
bool flag2 = args.Length != 0;
if (flag2)
{
flag = args[0].EqualsIgnoreCase("rgb");
}
HighlightMat = new Material(Shader.Find("Hidden/Internal-Colored"));
HighlightMat.renderQueue = 2001;
Color green = Color.green;
if (flag2 && !flag)
{
ColorUtility.TryParseHtmlString(args[0], ref green);
}
HighlightMat.color = green;
HighlightMat.DisableKeyword("_EMISSION");
HighlightMat.SetInt("_Cull", 0);
HighlightMat.SetInt("_SrcBlend", 1);
HighlightMat.SetInt("_DstBlend", 0);
HighlightMat.SetInt("_ZWrite", 1);
HighlightMat.SetFloat("_ZBias", -10f);
if ((Object)(object)animationObj == (Object)null && flag)
{
animationObj = new GameObject("ShowGrabsbleAnimation");
animationObj.AddComponent<HandholdRgb>();
}
CL_Handhold[] array = Resources.FindObjectsOfTypeAll<CL_Handhold>();
CL_Handhold[] array2 = array;
foreach (CL_Handhold val in array2)
{
GameObject gameObject = ((Component)val).gameObject;
gameObject.AddComponent<HandholdVisualizer>();
}
}
public override void OnExit()
{
CL_Handhold[] array = Resources.FindObjectsOfTypeAll<CL_Handhold>();
if ((Object)(object)animationObj != (Object)null)
{
Object.Destroy((Object)(object)animationObj);
animationObj = null;
}
CL_Handhold[] array2 = array;
HandholdVisualizer handholdVisualizer = default(HandholdVisualizer);
foreach (CL_Handhold val in array2)
{
GameObject gameObject = ((Component)val).gameObject;
if (gameObject.TryGetComponent<HandholdVisualizer>(ref handholdVisualizer))
{
handholdVisualizer.HideHandholds();
Object.Destroy((Object)(object)handholdVisualizer);
}
}
((TogglableCommandBase)this).Enabled = false;
}
}
public sealed class Volume : FloatSettingCommand
{
public override string[] Aliases => new string[2] { "volume", "vol" };
protected override float Min => 0f;
protected override float Max => 1f;
protected override string SettingName => "master volume";
protected override string DisplayPrecision => "F1";
protected override bool RequiresRefresh => true;
protected override float SettingValue
{
get
{
return SettingsManager.settings.masterVolume;
}
set
{
SettingsManager.settings.masterVolume = value;
}
}
}
}
namespace CommandsExtended.Commands.Common
{
public abstract class FloatSettingCommand : CommandBase
{
public override string Description => $"Change {SettingName}, saves to player's settings (min: {Min}, max: {Max})";
public override CommandTag Tag => (CommandTag)0;
public override bool CheatsOnly => false;
protected abstract float SettingValue { get; set; }
protected abstract string SettingName { get; }
protected abstract float Min { get; }
protected abstract float Max { get; }
protected abstract string DisplayPrecision { get; }
protected abstract bool RequiresRefresh { get; }
public override Action<string[]> GetLogicCallback()
{
return delegate(string[] args)
{
float result;
if (args.Length == 0)
{
CommandConsoleAccessor.EchoToConsole("Current " + SettingName + ": " + SettingValue.ToString(DisplayPrecision));
}
else if (float.TryParse(args[0], out result))
{
if (result < Min)
{
CommandConsoleAccessor.EchoToConsole(SettingName + " cannot be below " + Min.ToString(DisplayPrecision));
}
else if (result > Max)
{
CommandConsoleAccessor.EchoToConsole(SettingName + " cannot be above " + Max.ToString(DisplayPrecision));
}
else
{
SettingsManager.instance.LoadSettings();
SettingValue = result;
SettingsManager.instance.SaveSettings();
if (RequiresRefresh)
{
SettingsManager.RefreshSettings("");
}
CommandConsoleAccessor.EchoToConsole(SettingName + " set to " + result.ToString(DisplayPrecision));
}
}
else
{
CommandConsoleAccessor.EchoToConsole("Invalid arguments for " + SettingName + " command: " + GeneralExtensions.Join<string>((IEnumerable<string>)args, (Func<string, string>)null, " "));
}
};
}
}
}
namespace CommandsExtended.Behaviors
{
public sealed class HandholdRgb : MonoBehaviour
{
private float speed = 0.1f;
public void Update()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ShowGrabs.HighlightMat != (Object)null)
{
float num = Time.time * speed % 1f;
Color val = Color.HSVToRGB(num, 1f, 1f);
ShowGrabs.HighlightMat.SetColor("_Color", val);
}
}
}
public sealed class HandholdVisualizer : MonoBehaviour
{
private Material[] existingMaterials;
private Renderer currentRenderer;
private bool wasEnabled = false;
public void Start()
{
CL_Handhold handhold = default(CL_Handhold);
if (((Component)this).TryGetComponent<CL_Handhold>(ref handhold))
{
RevealHandholds(handhold);
}
}
public void HideHandholds()
{
if ((Object)(object)currentRenderer != (Object)null)
{
currentRenderer.enabled = wasEnabled;
currentRenderer.sharedMaterials = existingMaterials.ToArray();
}
}
private void RevealHandholds(CL_Handhold handhold)
{
MeshFilter filter = default(MeshFilter);
MeshCollider meshCol = default(MeshCollider);
BoxCollider box = default(BoxCollider);
SphereCollider sphere = default(SphereCollider);
if ((Object)(object)handhold.handholdRenderer != (Object)null)
{
RevealRenderer(handhold);
}
else if (((Component)handhold).TryGetComponent<MeshFilter>(ref filter))
{
RevealExistingMesh(handhold, filter);
}
else if (((Component)handhold).TryGetComponent<MeshCollider>(ref meshCol))
{
MatchMeshRendererToCollider(handhold, meshCol);
}
else if (((Component)handhold).TryGetComponent<BoxCollider>(ref box))
{
VisualizeBoxCollider(box);
}
else if (((Component)handhold).TryGetComponent<SphereCollider>(ref sphere))
{
VisualizeSphereCollider(sphere);
}
else
{
Plugin.Logger.LogInfo((object)("Unable to draw handhold: " + ((Object)handhold).name));
}
}
private void RevealRenderer(CL_Handhold handhold)
{
TrackExisting(handhold.handholdRenderer, handhold.handholdRenderer.enabled);
handhold.handholdRenderer.enabled = true;
handhold.handholdRenderer.sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat };
}
private void RevealExistingMesh(CL_Handhold handhold, MeshFilter filter)
{
GameObject gameObject = ((Component)handhold).gameObject;
if ((Object)(object)filter != (Object)null && (Object)(object)filter.sharedMesh != (Object)null)
{
MeshRenderer val = gameObject.GetComponent<MeshRenderer>();
bool enabled = false;
if ((Object)(object)val == (Object)null)
{
val = gameObject.AddComponent<MeshRenderer>();
}
else
{
enabled = ((Renderer)val).enabled;
}
TrackExisting((Renderer)(object)val, enabled);
((Renderer)val).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat };
((Renderer)val).enabled = enabled;
}
}
private void MatchMeshRendererToCollider(CL_Handhold handhold, MeshCollider meshCol)
{
GameObject gameObject = ((Component)handhold).gameObject;
MeshFilter val = gameObject.GetComponent<MeshFilter>();
if ((Object)(object)val == (Object)null)
{
val = gameObject.AddComponent<MeshFilter>();
}
val.sharedMesh = meshCol.sharedMesh;
MeshRenderer val2 = gameObject.GetComponent<MeshRenderer>();
bool flag = false;
if ((Object)(object)val2 == (Object)null)
{
val2 = gameObject.AddComponent<MeshRenderer>();
}
else
{
flag = ((Renderer)val2).enabled;
}
TrackExisting((Renderer)(object)val2, flag);
((Renderer)val2).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat };
((Renderer)val2).enabled = true;
}
private void VisualizeSphereCollider(SphereCollider sphere)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
Object.Destroy((Object)(object)val.GetComponent<SphereCollider>());
val.transform.SetParent(((Component)sphere).transform);
val.transform.localPosition = sphere.center;
val.transform.localRotation = Quaternion.identity;
float num = sphere.radius * 2f;
val.transform.localScale = new Vector3(num, num, num);
MeshRenderer component = val.GetComponent<MeshRenderer>();
TrackExisting((Renderer)(object)component);
((Renderer)component).sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat };
}
private void VisualizeBoxCollider(BoxCollider box)
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
Object.Destroy((Object)(object)val.GetComponent<Collider>());
val.transform.SetParent(((Component)box).transform);
val.transform.localPosition = box.center;
val.transform.localScale = box.size;
val.transform.localRotation = Quaternion.identity;
Renderer component = val.GetComponent<Renderer>();
TrackExisting(component);
component.sharedMaterials = (Material[])(object)new Material[1] { ShowGrabs.HighlightMat };
}
private void TrackExisting(Renderer renderer, bool wasEnabled = false)
{
this.wasEnabled = wasEnabled;
if (currentRenderer == null)
{
currentRenderer = renderer;
}
if (existingMaterials == null)
{
existingMaterials = renderer.sharedMaterials.ToArray();
}
}
}
public sealed class Raycaster : MonoBehaviour
{
public void Update()
{
if (Input.GetMouseButtonDown(0))
{
DoRaycast();
}
}
private void DoRaycast()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
Ray val = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2))
{
Plugin.Logger.LogInfo((object)("Hit Object: " + ((Object)((Component)((RaycastHit)(ref val2)).collider).gameObject).name));
}
}
}
}