using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SideLoader;
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("DirectVisuals")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("DirectVisuals")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 DirectVisuals
{
public static class DirectVisualsMain
{
public static float ScrollSpeed = 2f;
public static bool LockProjectiles = true;
public static Dictionary<int, DirectVisualsPlayer> players = new Dictionary<int, DirectVisualsPlayer>();
public static Dictionary<string, KeybindInfo> keybinds = new Dictionary<string, KeybindInfo>
{
{
"Lock",
new KeybindInfo("Lock Character to Camera")
},
{
"ZoomIn",
new KeybindInfo("Zoom In")
},
{
"ZoomOut",
new KeybindInfo("Zoom Out")
}
};
public static bool isSingleplayer => Global.Lobby.PlayersInLobbyCount < 2;
public static void Setup()
{
foreach (KeybindInfo value in keybinds.Values)
{
value.RegisterKeybind();
}
ScrollSpeed = ((BaseUnityPlugin)DirectVisualsPlugin._instance).Config.Bind<float>("Values", "Zoom Speed", 2f, "The rate at which the camera will zoom.").Value;
LockProjectiles = ((BaseUnityPlugin)DirectVisualsPlugin._instance).Config.Bind<bool>("Values", "Projectiles Auto-Lock", true, "Automatically lock onto an enemy as you would lock-on yourself when using projectile skills.").Value;
}
public static void Stepped()
{
foreach (DirectVisualsPlayer value in players.Values)
{
value.Update();
}
}
}
public class DirectVisualsPlayer
{
private PlayerSystem player;
private Character character;
private string uid;
private readonly List<SpellCastType> autoAims = new List<SpellCastType>
{
(SpellCastType)66,
(SpellCastType)24,
(SpellCastType)37,
(SpellCastType)57,
(SpellCastType)54,
(SpellCastType)754,
(SpellCastType)53,
(SpellCastType)68,
(SpellCastType)49,
(SpellCastType)753,
(SpellCastType)752
};
private bool LockMode = false;
private bool targeted = false;
private LocalCharacterControl characterControl => (LocalCharacterControl)character.CharacterControl;
private int playerId => player.PlayerID;
private bool lockOnOverride => character.PreparingToSleep || character.ReadyToSleep || ((CharacterControl)characterControl).InputLocked;
private bool IsKeyPressed(string key)
{
return DirectVisualsMain.keybinds[key].IsKeyPressed() == playerId;
}
private bool IsKeyDown(string key)
{
return DirectVisualsMain.keybinds[key].IsKeyDown() == playerId;
}
private void UpdateCharacter()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player.ControlledCharacter != (Object)null && (Object)(object)player.ControlledCharacter.CharacterCamera != (Object)null)
{
character = player.ControlledCharacter;
player.ControlledCharacter.CharacterCamera.Offset = new Vector3(0f, 0.72f, 3f);
}
}
public DirectVisualsPlayer(PlayerSystem player)
{
this.player = player;
uid = player.UID;
DirectVisualsMain.players.Add(player.PlayerID, this);
UpdateCharacter();
}
private void SetLock()
{
LocalCharacterControl obj = characterControl;
if (obj != null)
{
obj.FaceLikeCamera = (LockMode || (Object)(object)characterControl.m_targetingSystem.LockingPoint != (Object)null) && !lockOnOverride;
}
if (!DirectVisualsMain.LockProjectiles || !LockMode)
{
return;
}
if (!characterControl.m_targetingSystem.Locked && !targeted)
{
if (CastLockOn())
{
targeted = true;
LocalCharacterControl obj2 = characterControl;
if (obj2 != null)
{
obj2.AcquireTarget();
}
}
}
else if (targeted && !CastLockOn())
{
LocalCharacterControl obj3 = characterControl;
if (obj3 != null)
{
obj3.ReleaseTarget();
}
targeted = false;
}
}
private bool CastLockOn()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
return (int)character.CurrentSpellCast != -1 && autoAims.Contains(character.CurrentSpellCast);
}
public void Update()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)character))
{
UpdateCharacter();
if (!Object.op_Implicit((Object)(object)character))
{
return;
}
}
if (IsKeyPressed("Lock"))
{
LockMode = !LockMode;
}
SetLock();
int num = 0;
if (IsKeyDown("ZoomIn"))
{
num = 1;
}
else if (IsKeyDown("ZoomOut"))
{
num = -1;
}
if (num != 0)
{
float num2 = Mathf.Clamp(character.CharacterCamera.Offset.z + (float)num * DirectVisualsMain.ScrollSpeed * Time.deltaTime, -10f, -0.6f);
character.CharacterCamera.Offset = new Vector3(0f, 0.6f + 0.4f * (0f - num2) / 10f, num2);
}
}
public void Dispose()
{
DirectVisualsMain.players.Remove(playerId);
}
}
public class KeybindInfo
{
public string name;
public KeybindingsCategory category;
public ControlType inputMethod;
public InputType inputType;
public KeybindInfo(string name)
: this(name, (KeybindingsCategory)0, (ControlType)2, (InputType)1)
{
}
public KeybindInfo(string name, KeybindingsCategory category, ControlType inputMethod, InputType inputType)
{
//IL_0010: 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_0017: 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_001e: 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)
this.name = name;
this.category = category;
this.inputMethod = inputMethod;
this.inputType = inputType;
}
public int IsKeyDown()
{
int num = default(int);
return CustomKeybindings.GetKey(name, ref num) ? num : (-1);
}
public int IsKeyPressed()
{
int num = default(int);
return CustomKeybindings.GetKeyDown(name, ref num) ? num : (-1);
}
public void RegisterKeybind()
{
//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
CustomKeybindings.AddAction(name, category, inputMethod, inputType);
}
}
[BepInPlugin("com.Morgenni.DirectVisuals", "Direct Visuals", "0.2.2")]
public class DirectVisualsPlugin : BaseUnityPlugin
{
public static ManualLogSource logger;
public static DirectVisualsPlugin _instance;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.Morgenni.DirectVisuals");
val.PatchAll();
_instance = this;
DirectVisualsMain.Setup();
logger = ((BaseUnityPlugin)this).Logger;
}
internal void Update()
{
DirectVisualsMain.Stepped();
}
}
[HarmonyPatch(typeof(LobbySystem), "AssignUID")]
public class LobbySystem_AssignUID
{
[HarmonyPostfix]
public static void Postfix(LobbySystem __instance, string _uid, PlayerSystem _player)
{
if (_player.IsLocalPlayer)
{
new DirectVisualsPlayer(_player);
}
}
}
[HarmonyPatch(typeof(LobbySystem), "ReleaseUID")]
public class LobbySystem_ReleaseUID
{
[HarmonyPrefix]
public static void Prefix(LobbySystem __instance, string _uid)
{
PlayerSystem playerSystem = __instance.GetPlayerSystem(_uid);
if (playerSystem.IsLocalPlayer && DirectVisualsMain.players.ContainsKey(playerSystem.PlayerID))
{
DirectVisualsMain.players[playerSystem.PlayerID].Dispose();
}
}
}
public static class DirectVisualsPluginInfo
{
public const string PLUGIN_GUID = "com.Morgenni.DirectVisuals";
public const string PLUGIN_NAME = "Direct Visuals";
public const string PLUGIN_VERSION = "0.2.2";
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DirectVisuals";
public const string PLUGIN_NAME = "My first plugin";
public const string PLUGIN_VERSION = "1.0.0";
}
}