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 ATS_API;
using ATS_API.Helpers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Eremite;
using Eremite.Buildings;
using Eremite.Characters;
using Eremite.Controller;
using Eremite.Services;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("FirstPersonMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Reskins against the storm to look like warcraft 3")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("FirstPersonMod")]
[assembly: AssemblyTitle("FirstPersonMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 ATS_FirstPersonMod
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "FirstPersonMod";
public const string PLUGIN_NAME = "FirstPersonMod";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace JamesGames
{
public static class Configs
{
private static ConfigEntry<float> m_moveSpeed = Bind("General", "Move Speed", 3f, "How fast you'll move with WASD");
private static ConfigEntry<float> m_cameraSensitivity = Bind("General", "Camera Sensitivity", 3f, "How your camera moves with your mouse. Higher means your camera moves further.");
private static ConfigEntry<bool> m_showUI = Bind("General", "Show UI", defaultValue: true, "If off when in first person mode all UI will be hidden.");
public static float MoveSpeed
{
get
{
return m_moveSpeed.Value;
}
set
{
m_moveSpeed.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public static float CameraSensitivity
{
get
{
return m_cameraSensitivity.Value;
}
set
{
m_cameraSensitivity.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public static bool ShowUI
{
get
{
return m_showUI.Value;
}
set
{
m_showUI.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
return ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
}
}
public class FirstPersonController : MonoBehaviour
{
private const float Height = 0.8f;
private InputAction mouseMoveAction;
private Transform cameraController;
private Transform cameraRotator;
private InputActionMap map;
private bool initialized;
private bool running;
private Vector3 oldControllerPosition;
private Vector3 oldCameraPosition;
private Quaternion cameraRotatorRotation;
private float fieldOfView = 60f;
private float overlayCameraDepth = -1f;
private bool cursorVisible;
private bool UIHidden;
private CursorLockMode cursorLockMode;
public void Initialize()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
int key = Serviceable.BuildingsService.Hearths.Keys.OrderBy((int a) => a).FirstOrDefault();
Hearth val = Serviceable.BuildingsService.Hearths[key];
oldControllerPosition = ((Building)val).entrance.position + new Vector3(0f, 0.8f, 0f);
Quaternion rotation = ((Building)val).entrance.rotation;
cameraRotatorRotation = Quaternion.Euler(0f, 360f - ((Quaternion)(ref rotation)).eulerAngles.y, 0f);
if (!initialized)
{
initialized = true;
Hotkeys.MasterInputAsset.Disable();
map = Hotkeys.MasterInputAsset.FindActionMap("FirstPersonMod", false);
if (map == null)
{
map = new InputActionMap("FirstPersonMod");
InputActionSetupExtensions.AddActionMap(Hotkeys.MasterInputAsset, map);
}
mouseMoveAction = map.FindAction("Movement", false);
if (mouseMoveAction == null)
{
mouseMoveAction = InputActionSetupExtensions.AddAction(map, "Movement", (InputActionType)2, (string)null, (string)null, (string)null, (string)null, (string)null);
BindingSyntax val2 = InputActionSetupExtensions.AddBinding(mouseMoveAction, "<Mouse>/delta", (string)null, (string)null, (string)null);
((BindingSyntax)(ref val2)).WithProcessor("scaleVector2(x=0.05,y=0.05)");
}
Hotkeys.MasterInputAsset.Enable();
Hotkeys.New("FirstPersonMod", "run", "Run", new List<KeyCode>(1) { (KeyCode)120 }, (Action)delegate
{
running = true;
}, (Action)delegate
{
running = false;
});
}
}
private void OnDestroy()
{
if (map != null)
{
Hotkeys.MasterInputAsset.Disable();
InputActionSetupExtensions.RemoveActionMap(Hotkeys.MasterInputAsset, map);
map.Dispose();
map = null;
Hotkeys.MasterInputAsset.Enable();
}
}
public void Enable()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
cameraController = ((Component)GameMB.GameController.CameraController).transform;
cameraRotator = GameMB.GameController.CameraController.rotator;
cursorVisible = Cursor.visible;
cursorLockMode = Cursor.lockState;
Vector3 val = oldControllerPosition;
Quaternion rotation = cameraRotatorRotation;
oldControllerPosition = cameraController.position;
oldCameraPosition = ((Component)GameMB.GameController.CameraController.Camera).transform.localPosition;
cameraRotatorRotation = cameraRotator.rotation;
fieldOfView = GameMB.GameController.CameraController.Camera.fieldOfView;
overlayCameraDepth = MB.BlackboardService.OverlayCamera.Value.depth;
GameMB.GameController.CameraController.Camera.fieldOfView = 60f;
GameMB.GameController.CameraController.MovementLock.Lock((object)this);
GameMB.GameController.CameraController.ZoomLock.Lock((object)this);
GameMB.GameController.CameraController.RotationLock.Lock((object)this);
cameraController.position = new Vector3(val.x, Mathf.Max(0.8f, val.y), val.z);
cameraRotator.rotation = rotation;
((Component)GameMB.GameController.CameraController.Camera).transform.localPosition = Vector3.zero;
MB.BlackboardService.OverlayCamera.Value.depth = 1f;
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)2;
if (!Configs.ShowUI)
{
MB.UIService.SwitchUI((object)this, true);
UIHidden = true;
}
}
public void Disable()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = cameraController.position;
Quaternion rotation = cameraRotator.rotation;
cameraController.position = oldControllerPosition;
cameraRotator.rotation = cameraRotatorRotation;
((Component)GameMB.GameController.CameraController.Camera).transform.localPosition = oldCameraPosition;
GameMB.GameController.CameraController.Camera.fieldOfView = fieldOfView;
MB.BlackboardService.OverlayCamera.Value.depth = overlayCameraDepth;
GameMB.GameController.CameraController.MovementLock.Release((object)this);
GameMB.GameController.CameraController.ZoomLock.Release((object)this);
GameMB.GameController.CameraController.RotationLock.Release((object)this);
cameraRotatorRotation = rotation;
oldControllerPosition = position;
Cursor.visible = cursorVisible;
Cursor.lockState = cursorLockMode;
if (UIHidden)
{
MB.UIService.SwitchUI((object)this, false);
UIHidden = false;
}
}
private void Update()
{
RotateCamera();
Movement();
}
private void RotateCamera()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = mouseMoveAction.ReadValue<Vector2>();
if (val != Vector2.zero)
{
Quaternion rotation = cameraRotator.rotation;
Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
eulerAngles.x -= val.y * Configs.CameraSensitivity;
eulerAngles.y += val.x * Configs.CameraSensitivity;
cameraRotator.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, 0f);
}
}
private void Movement()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0039: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Vector3.zero;
IInputService inputService = MB.InputService;
DefaultActions inputConfig = MB.InputConfig;
if (inputService.IsTriggering(((DefaultActions)(ref inputConfig)).CameraForward))
{
val += cameraRotator.forward * Time.unscaledDeltaTime;
}
IInputService inputService2 = MB.InputService;
inputConfig = MB.InputConfig;
if (inputService2.IsTriggering(((DefaultActions)(ref inputConfig)).CameraBackward))
{
val -= cameraRotator.forward * Time.unscaledDeltaTime;
}
IInputService inputService3 = MB.InputService;
inputConfig = MB.InputConfig;
if (inputService3.IsTriggering(((DefaultActions)(ref inputConfig)).CameraLeft))
{
val -= cameraRotator.right * Time.unscaledDeltaTime;
}
IInputService inputService4 = MB.InputService;
inputConfig = MB.InputConfig;
if (inputService4.IsTriggering(((DefaultActions)(ref inputConfig)).CameraRight))
{
val += cameraRotator.right * Time.unscaledDeltaTime;
}
val.y = 0f;
((Vector3)(ref val)).Normalize();
float num = Configs.MoveSpeed * (running ? 2f : 1f);
Transform obj = cameraController;
obj.position += val * (num * Time.unscaledDeltaTime);
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPatch(typeof(GameInputService), "UpdateGamePointer")]
[HarmonyPrefix]
public static bool UpdateGamePointer(GameInputService __instance)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.FPSModeEnabled)
{
return true;
}
if (Serviceable.MapService.Fields == null || !Application.isFocused)
{
return false;
}
Camera camera = GameMB.GameController.CameraController.Camera;
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)camera).transform.position, ((Component)camera).transform.forward);
Plane val2 = default(Plane);
((Plane)(ref val2))..ctor(Vector3.up, Vector3.zero);
float num = default(float);
if (!((Plane)(ref val2)).Raycast(val, ref num))
{
return false;
}
Vector3 point = ((Ray)(ref val)).GetPoint(num);
__instance.PointerPosition.Value = __instance.ClampPointerPosition(point);
__instance.PointerRoundedPosition.Value = new Vector3(Mathf.Floor(point.x), 0f, Mathf.Floor(point.z));
if (!Serviceable.InputService.IsOverUI() && __instance.currentFocus == null)
{
IMapObject mouseOverObject = __instance.GetMouseOverObject(__instance.CalculateIsoPosition(__instance.PointerRoundedPosition.Value));
__instance.MouseoverObject.Value = mouseOverObject;
if (Serviceable.InputService.IsWorldClicked(Serviceable.ClientPrefsService.PickMouseButton.Value))
{
__instance.PickTarget();
}
if (Serviceable.InputService.WasCanceled())
{
__instance.Unpick();
}
}
return false;
}
[HarmonyPatch(typeof(GameInputService), "RaycastForActor")]
[HarmonyPrefix]
public static bool RaycastForActor(ref Actor __result)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.FPSModeEnabled)
{
return true;
}
GameInputService val = (GameInputService)Serviceable.GameInputService;
Camera value = Serviceable.BlackboardService.MainCamera.Value;
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(((Component)value).transform.position, ((Component)value).transform.forward);
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val2, ref val3, 50f, val.charactersLayer, (QueryTriggerInteraction)2))
{
__result = ((Component)((RaycastHit)(ref val3)).transform).gameObject.GetComponent<Actor>();
}
else
{
__result = null;
}
return false;
}
}
[HarmonyPatch]
[BepInPlugin("ATS_FirstPersonMod", "FirstPersonMod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string GUID = "ATS_FirstPersonMod";
private const string NAME = "FirstPersonMod";
private const string VERSION = "1.1.0";
public static ManualLogSource Log;
private Harmony harmony;
public static bool FPSModeEnabled { get; private set; }
public static FirstPersonController FirstPersonController { get; private set; }
public static Plugin Instance { get; private set; }
private void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
harmony = Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, "ATS_FirstPersonMod");
GameObject fpsController = new GameObject("FirstPersonCameraController");
fpsController.transform.SetParent(((Component)this).transform);
FirstPersonController = fpsController.AddComponent<FirstPersonController>();
fpsController.SetActive(false);
Hotkeys.New("FirstPersonMod", "toggleCamera", "Toggle First Person Mode", new List<KeyCode>(1) { (KeyCode)108 }, (Action)delegate
{
if (GameController.IsGameActive)
{
FPSModeEnabled = !FPSModeEnabled;
Log.LogInfo((object)("Toggling First Person Mode: " + FPSModeEnabled));
fpsController.SetActive(FPSModeEnabled);
if (FPSModeEnabled)
{
FirstPersonController.Enable();
}
else
{
FirstPersonController.Disable();
}
}
}, (Action)null);
EventBus.OnStartGame.AddListener((Action<bool>)OnStartGame);
Log.LogInfo((object)"FirstPersonMod v1.1.0 Plugin loaded");
}
private void OnStartGame(bool obj)
{
FirstPersonController.Initialize();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}