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.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
internal static class log
{
private static ManualLogSource logger;
internal static void start(ManualLogSource logSource)
{
logger = logSource;
}
internal static void start(string name)
{
logger = Logger.CreateLogSource(name);
}
internal static void info(object data)
{
logger.LogInfo(data);
}
internal static void message(object data)
{
logger.LogMessage(data);
}
internal static void warning(object data)
{
logger.LogWarning(data);
}
internal static void error(object data)
{
logger.LogError(data);
}
internal static void fatal(object data)
{
logger.LogFatal(data);
}
}
namespace SeeSaw;
internal static class SSConfig
{
public static ConfigFile SSConfigFile { get; set; }
public static ConfigEntry<bool> SSShader { get; set; }
public static ConfigEntry<bool> SSIcon { get; set; }
public static ConfigEntry<float> SSScale { get; set; }
public static ConfigEntry<Vector4> SSColor { get; set; }
public static ConfigEntry<string> SSIconPath { get; set; }
public static ConfigEntry<bool> SSHudSawNumToggle { get; set; }
public static ConfigEntry<Vector2> SSHudSawNumPos { get; set; }
public static ConfigEntry<int> SSHudSawFontSize { get; set; }
public static ConfigEntry<bool> SSHudBleedToggle { get; set; }
public static ConfigEntry<Vector2> SSHudBleedPos { get; set; }
public static ConfigEntry<int> SSHudBleedFontSize { get; set; }
internal static void DoConfig()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
SSConfigFile = new ConfigFile(Paths.ConfigPath + "//SeeSaw.cfg", true);
SSShader = SSConfigFile.Bind<bool>("Toggle", "Modify shader", true, "If sawmerang's shader should be changed to one that can be seen through objects. Needs restart to apply");
SSIcon = SSConfigFile.Bind<bool>("Toggle", "Add icon", true, "If should add position indicator icon to saws. Needs Restart to apply");
SSScale = SSConfigFile.Bind<float>("Values", "Scale", 0.25f, "Scale of icon");
SSColor = SSConfigFile.Bind<Vector4>("Values", "Color", new Vector4(122f, 223f, 227f, 255f), "Color32 rgba of icon");
SSIconPath = SSConfigFile.Bind<string>("Values", "Icon Path", "Textures/MiscIcons/texBarrelIcon", "Path to icon. Must be sprite or Texture2D.\nAddressables at: https://xiaoxiao921.github.io/GithubActionCacheTest/assetPathsDump.html filter for '.png', include full path.");
SSHudSawNumToggle = SSConfigFile.Bind<bool>("Toggle", "Count saws", true, "Enable counting of saws and displaying it on the hud");
SSHudSawNumPos = SSConfigFile.Bind<Vector2>("Values", "SawHud Position", new Vector2(103f, 17f), "Position of saw count number, starting from bottom left corner");
SSHudSawFontSize = SSConfigFile.Bind<int>("Values", "SawHud Font size", 12, "Font size of saw hud");
SSHudBleedToggle = SSConfigFile.Bind<bool>("Toggle", "Track highest bleed stack", true, "Will track highest bleed stack and display it.");
SSHudBleedPos = SSConfigFile.Bind<Vector2>("Values", "BleedHud Position", new Vector2(103f, 4f), "Position of bleed stack number, starting from bottom left corner");
SSHudBleedFontSize = SSConfigFile.Bind<int>("Values", "Font size", 12, "Font size of bleed hud");
}
[ConCommand(/*Could not decode attribute arguments.*/)]
private static void CCReloadConfig(ConCommandArgs args)
{
SSConfigFile.Reload();
Object.Destroy((Object)(object)Main.prefab);
Main.BuildPrefab();
SSHud.HudReconfigure();
log.info("Config Reloaded");
}
}
internal static class SSHud
{
private static HUD hud;
private static GameObject sawHud;
private static HGTextMeshProUGUI sawTextMesh;
internal static int sawNum;
private static GameObject bleedHud;
private static HGTextMeshProUGUI bleedTextMesh;
internal static int highestBleed;
internal static void DoHud()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
HUD.Awake += new hook_Awake(HudAwake);
HUD.OnDisable += new hook_OnDisable(HudDisable);
}
private static void HudAwake(orig_Awake orig, HUD self)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
hud = self;
if (SSConfig.SSHudSawNumToggle.Value)
{
sawHud = MakeHud(SSConfig.SSHudSawNumPos.Value, SSConfig.SSHudSawFontSize.Value, "SawHudObj", out sawTextMesh);
}
if (SSConfig.SSHudBleedToggle.Value)
{
bleedHud = MakeHud(SSConfig.SSHudBleedPos.Value, SSConfig.SSHudBleedFontSize.Value, "BleedHudObj", out bleedTextMesh);
}
}
private static GameObject MakeHud(Vector2 pos, int fontsize, string name, out HGTextMeshProUGUI textMesh)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name);
val.transform.SetParent(hud.mainContainer.transform);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = Vector2.zero;
val2.anchorMax = Vector2.zero;
val2.sizeDelta = new Vector2(200f, 20f);
val2.anchoredPosition = pos;
textMesh = val.AddComponent<HGTextMeshProUGUI>();
((TMP_Text)textMesh).fontSize = fontsize;
((TMP_Text)textMesh).fontSizeMin = 6f;
((TMP_Text)textMesh).faceColor = Color32.op_Implicit(Color.white);
((TMP_Text)textMesh).outlineColor = Color32.op_Implicit(Color.black);
((TMP_Text)textMesh).fontMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, 0.2f);
((TMP_Text)textMesh).fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.4f);
return val;
}
internal static void HudReconfigure()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hud == (Object)null)
{
log.warning("HUD is not active");
return;
}
if (Object.op_Implicit((Object)(object)sawHud))
{
RectTransform component = sawHud.GetComponent<RectTransform>();
component.anchoredPosition = SSConfig.SSHudSawNumPos.Value;
((TMP_Text)sawTextMesh).fontSize = SSConfig.SSHudSawFontSize.Value;
}
else if (SSConfig.SSHudSawNumToggle.Value)
{
sawHud = MakeHud(SSConfig.SSHudSawNumPos.Value, SSConfig.SSHudSawFontSize.Value, "SawHudObj", out sawTextMesh);
}
if (Object.op_Implicit((Object)(object)bleedHud))
{
RectTransform component2 = bleedHud.GetComponent<RectTransform>();
component2.anchoredPosition = SSConfig.SSHudBleedPos.Value;
((TMP_Text)bleedTextMesh).fontSize = SSConfig.SSHudBleedFontSize.Value;
}
else if (SSConfig.SSHudBleedToggle.Value)
{
bleedHud = MakeHud(SSConfig.SSHudBleedPos.Value, SSConfig.SSHudBleedFontSize.Value, "BleedHudObj", out bleedTextMesh);
}
}
private static void HudDisable(orig_OnDisable orig, HUD self)
{
orig.Invoke(self);
Object.Destroy((Object)(object)sawHud);
Object.Destroy((Object)(object)bleedHud);
highestBleed = 0;
sawNum = 0;
log.info("HUD Destroyed");
}
internal static void UpdateText()
{
if ((Object)(object)hud == (Object)null)
{
log.warning("Null HUD");
return;
}
if (Object.op_Implicit((Object)(object)sawHud))
{
if (sawNum > 0)
{
((TMP_Text)sawTextMesh).SetText(sawNum.ToString(), true);
}
else
{
((TMP_Text)sawTextMesh).SetText("", true);
}
}
if (Object.op_Implicit((Object)(object)bleedHud))
{
if (highestBleed > 0)
{
((TMP_Text)bleedTextMesh).SetText(highestBleed.ToString(), true);
}
else
{
((TMP_Text)bleedTextMesh).SetText("", true);
}
}
}
}
internal class SSText
{
internal static void DoSetup()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
if (SSConfig.SSHudBleedToggle.Value)
{
GlobalEventManager.onClientDamageNotified += On_ClientDamaged;
}
if (SSConfig.SSIcon.Value)
{
UICamera.onUICameraPreCull += new UICameraDelegate(SSManageIndicators.CamUpdate);
}
SSHud.DoHud();
}
private static void On_ClientDamaged(DamageDealtMessage damageDealtMessage)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
if (!SSConfig.SSHudBleedToggle.Value || (int)damageDealtMessage.damageType != 67108864)
{
return;
}
if ((Object)(object)damageDealtMessage.victim == (Object)null)
{
log.error("null bleed victim");
return;
}
CharacterBody component = damageDealtMessage.victim.GetComponent<CharacterBody>();
if ((Object)(object)component == (Object)null)
{
log.warning("Null body from damageDealtMessage");
return;
}
int buffCount = component.GetBuffCount((BuffIndex)4);
if (buffCount > SSHud.highestBleed)
{
SSHud.highestBleed = buffCount;
SSHud.UpdateText();
}
}
}
internal class SSManageIndicators : MonoBehaviour
{
private GameObject indicator;
private static List<SSManageIndicators> indicatorList = new List<SSManageIndicators>();
private void OnEnable()
{
if (SSConfig.SSIcon.Value)
{
indicator = Object.Instantiate<GameObject>(Main.prefab);
if (!Object.op_Implicit((Object)(object)indicator))
{
log.error("Saw indicator did not instantiate");
return;
}
}
indicatorList.Add(this);
if (SSConfig.SSHudSawNumToggle.Value)
{
SSHud.sawNum++;
SSHud.UpdateText();
}
}
private void OnDisable()
{
Object.Destroy((Object)(object)indicator);
indicatorList.Remove(this);
if (SSConfig.SSHudSawNumToggle.Value)
{
SSHud.sawNum--;
SSHud.UpdateText();
}
}
internal static void CamUpdate(UICamera uiCamera)
{
//IL_005a: 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)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
if (!SSConfig.SSIcon.Value)
{
return;
}
Camera sceneCam = uiCamera.cameraRigController.sceneCam;
Camera camera = uiCamera.camera;
foreach (SSManageIndicators indicator in indicatorList)
{
SpriteRenderer component = indicator.indicator.GetComponent<SpriteRenderer>();
Vector3 position = ((Component)indicator).transform.position;
Vector3 val = sceneCam.WorldToScreenPoint(position);
if (val.z <= 0f)
{
((Renderer)component).enabled = false;
continue;
}
((Renderer)component).enabled = true;
val.z = 1f;
Vector3 val2 = camera.ScreenToWorldPoint(val);
indicator.indicator.transform.SetPositionAndRotation(val2, ((Component)camera).transform.rotation);
}
}
}
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("dolso.seesaw", "SeeSaw", "1.1.8")]
public class Main : BaseUnityPlugin
{
internal static GameObject prefab;
private void Awake()
{
log.start(((BaseUnityPlugin)this).Logger);
SSConfig.DoConfig();
SSText.DoSetup();
BuildPrefab();
LoadSawPrefab();
log.info("SeeSaw Done");
}
private void LoadSawPrefab()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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)
//IL_007b: 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)
GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Saw/Sawmerang.prefab").WaitForCompletion();
if ((Object)(object)val == (Object)null)
{
log.error("failed to load Sawmerang.prefab");
return;
}
val.AddComponent<SSManageIndicators>();
if (SSConfig.SSShader.Value)
{
Material val2 = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Saw/matSawmerang.mat").WaitForCompletion();
if ((Object)(object)val2 == (Object)null)
{
log.error("failed to load matSawmerang.mat");
}
else
{
val2.shader = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGUIIgnoreZ.shader").WaitForCompletion();
}
}
}
internal static void BuildPrefab()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
log.info("Loading sprite");
Sprite val = ((!SSConfig.SSIconPath.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Sprite>(SSConfig.SSIconPath.Value) : Addressables.LoadAssetAsync<Sprite>((object)SSConfig.SSIconPath.Value).WaitForCompletion());
if (!Object.op_Implicit((Object)(object)val))
{
Texture2D val2 = ((!SSConfig.SSIconPath.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Texture2D>(SSConfig.SSIconPath.Value) : Addressables.LoadAssetAsync<Texture2D>((object)SSConfig.SSIconPath.Value).WaitForCompletion());
if (Object.op_Implicit((Object)(object)val2))
{
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height);
val = Sprite.Create(val2, val3, new Vector2(0.5f, 0.5f));
}
}
if (!Object.op_Implicit((Object)(object)val))
{
Debug.LogError((object)"Failed to load sprite, using default instead");
val = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texBarrelIcon");
}
else
{
log.info("Loaded " + ((Object)val).name);
}
GameObject val4 = new GameObject("SeeSawSprite");
val4.layer = LayerIndex.ui.intVal;
Transform transform = val4.transform;
transform.localScale *= SSConfig.SSScale.Value / 10f;
SpriteRenderer val5 = val4.AddComponent<SpriteRenderer>();
val5.sprite = val;
val5.color = Color.op_Implicit(SSConfig.SSColor.Value / 255f);
prefab = PrefabAPI.InstantiateClone(val4, "SeeSawSmallPrefab", false);
Object.Destroy((Object)(object)val4);
}
}