using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Soggy_Pancake")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: AssemblyInformationalVersion("1.0.6+33502f6c197c2b3dc034497fa06b896e69abe8a0")]
[assembly: AssemblyProduct("Atlyss_DPSUI")]
[assembly: AssemblyTitle("Atlyss_DPSUI")]
[assembly: AssemblyVersion("1.0.6.0")]
namespace Atlyss_DPSUI;
internal class ClientPatches
{
internal static int _helloRetryCount;
internal static float _helloRetryLast;
private static float clientRetryDelay = 6f;
internal static void ClientSendHello(bool force = false)
{
if (force || (!Player._mainPlayer._isHostPlayer && !(_helloRetryLast > Time.time - clientRetryDelay)))
{
_helloRetryCount++;
Plugin.logger.LogDebug((object)$"Sending hello packet (Attempt {_helloRetryCount})");
DPSClientHelloPacket dPSClientHelloPacket = new DPSClientHelloPacket
{
nickname = Player._mainPlayer._nickname
};
_helloRetryLast = Time.time;
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)dPSClientHelloPacket);
}
}
internal static void Client_RecieveHello(PacketHeader header, PacketBase packet)
{
if (Plugin._serverSupport || !header.SenderIsLobbyOwner)
{
return;
}
Player obj = Plugin.player.NC<Player>();
if ((obj == null || !obj.Network_isHostPlayer) && packet is DPSServerHelloPacket dPSServerHelloPacket && dPSServerHelloPacket.response == "Hello")
{
Plugin.logger.LogInfo((object)("Client recieved hello. Server DPSUI version is " + dPSServerHelloPacket.version));
if (dPSServerHelloPacket.version != "1.0.6")
{
Plugin.logger.LogWarning((object)"Server version mismatch!");
Player._mainPlayer._chatBehaviour.New_ChatMessage("<color=#fce75d>Server AtlyssDPSUI Version mismatch! (Server version: " + dPSServerHelloPacket.version + ")</color>");
}
Plugin._serverSupport = true;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(AtlyssNetworkManager), "OnStartClient")]
[HarmonyPatch(typeof(AtlyssNetworkManager), "OnStopClient")]
internal static void ServerChange()
{
_helloRetryCount = 0;
Plugin._serverSupport = false;
DPSUI_GUI.createdUI = false;
DPSUI_GUI._UI = null;
Plugin.player = null;
DPSUI_GUI.showPartyUI = false;
Plugin.logger.LogInfo((object)"Server status change, server support false");
}
[HarmonyPatch(typeof(Player), "OnPlayerMapInstanceChange")]
[HarmonyPostfix]
internal static void OnMapChanged(MapInstance _old, MapInstance _new)
{
if ((Object)(object)_new != (Object)(object)_old)
{
Plugin.player = Player._mainPlayer;
Plugin._AmServer = Player._mainPlayer.Network_isHostPlayer;
DPSUI_GUI.showPartyUI = false;
Plugin.shownDungeonClearText = false;
Plugin.localDamage?.Clear();
if (DPSUI_GUI.createdUI)
{
DPSUI_GUI._UI?.UpdateDPS(0f);
DPSUI_GUI._UI?.clearDamageValues();
DPSUI_GUI.resetPartyAnim();
}
}
}
[HarmonyPatch(typeof(StatusEntityGUI), "UserCode_Target_Display_FloatingNumber__StatusEntity__FloatTextColor__Int32__Int32__Int32")]
[HarmonyPostfix]
private static void TrackOwnDamage(StatusEntity _followObj, FloatTextColor _floatTextColor, int _value, int _combatElementID, int _conditionGroupID)
{
//IL_0030: 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_0035: Invalid comparison between Unknown and I4
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
if (!Object.op_Implicit((Object)(object)Player._mainPlayer) || (Object)(object)_followObj == (Object)(object)Player._mainPlayer.NC<Player>()?._statusEntity || (int)_floatTextColor == 0 || (int)_floatTextColor == 4 || (int)_floatTextColor == 5)
{
return;
}
float currentTime = Time.unscaledTime;
DamageHistory damageHistory = default(DamageHistory);
damageHistory.time = currentTime;
damageHistory.damage = _value;
DamageHistory item = damageHistory;
List<DamageHistory> localDamage = Plugin.localDamage;
if (DPSUI_Config.keepDamageUntilPause.Value)
{
if (localDamage.Count > 0 && currentTime - localDamage[localDamage.Count - 1].time >= DPSUI_Config.damageHoldTime.Value)
{
localDamage.Clear();
}
localDamage.Add(item);
}
else
{
localDamage.RemoveAll((DamageHistory hit) => currentTime - hit.time >= DPSUI_Config.damageHoldTime.Value);
localDamage.Add(item);
}
float num = localDamage[0].time;
int num2 = 0;
foreach (DamageHistory item2 in localDamage)
{
num2 += item2.damage;
}
if (currentTime == num)
{
num -= 1f;
}
float dps = (float)num2 / Mathf.Max(0.5f, currentTime - num);
Plugin.logger.LogDebug((object)$"Hits tracked: {localDamage.Count} Current hit dmg value: {_value} total time between last valid hit and current: {currentTime - num}");
DPSUI_GUI._UI.UpdateDPS(dps);
}
[HarmonyPatch(typeof(PlayerInteract), "Cmd_InteractWithPortal")]
[HarmonyPrefix]
private static void ClientPortalInteraction(Portal _portal, ZoneDifficulty _setDifficulty)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
Plugin.logger.LogDebug((object)("Portal interaction! portal tag: " + _portal.NC<Portal>()._scenePortal?._spawnPointTag));
if (_portal.NC<Portal>()?._scenePortal == null)
{
return;
}
Player val = Player._mainPlayer.NC<Player>();
if ((Object)(object)val != (Object)null && (int)val.Network_playerZoneType == 2 && _portal._scenePortal._spawnPointTag == "fortSpawn")
{
DPSPacket lastDPSPacket = Plugin.lastDPSPacket;
if (lastDPSPacket != null && lastDPSPacket.bossFightEndTime == 0L)
{
Plugin.logger.LogDebug((object)"Portaled out of finished dungeon!");
}
Plugin.logger.LogDebug((object)"Portaled out of dungeon early?");
}
}
}
internal static class DPSUI_Config
{
internal static ConfigFile config;
internal static ConfigEntry<KeyCode> togglePartyUIBind;
internal static ConfigEntry<KeyCode> toggleLocalUIBind;
internal static ConfigEntry<KeyCode> switchPartyUITypeBind;
internal static ConfigEntry<float> transitionTime;
internal static ConfigEntry<float> damageHoldTime;
internal static ConfigEntry<bool> keepDamageUntilPause;
internal static ConfigEntry<bool> showFullDungeonDamage;
internal static ConfigEntry<bool> showLocalUI;
internal static ConfigEntry<bool> showPartyUI;
internal static ConfigEntry<string> backgroundImage;
internal static ConfigEntry<string> textFont;
public static void init(ConfigFile _config)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
config = _config;
togglePartyUIBind = config.Bind<KeyCode>("KeyBinds", "partyUIToggleKey", (KeyCode)91, (ConfigDescription)null);
switchPartyUITypeBind = config.Bind<KeyCode>("KeyBinds", "partyUITypeKey", (KeyCode)93, (ConfigDescription)null);
toggleLocalUIBind = config.Bind<KeyCode>("KeyBinds", "localToggleKey", (KeyCode)44, (ConfigDescription)null);
ConfigDescription val = new ConfigDescription("Time it takes to slide in party ui in seconds", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
transitionTime = config.Bind<float>("General", "transitionTime", 0.25f, val);
ConfigDescription val2 = new ConfigDescription("Total time in seconds to keep track of damage for when calculating local DPS (Becomes time gap required to reset if keepDamageUntilPause is true)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>());
damageHoldTime = config.Bind<float>("General", "damageHoldTime", 10f, val2);
showLocalUI = config.Bind<bool>("General", "showLocalUI", true, (ConfigDescription)null);
showPartyUI = config.Bind<bool>("General", "showPartyUI", true, (ConfigDescription)null);
keepDamageUntilPause = config.Bind<bool>("General", "keepDamageUntilPause", false, "Keep track of all of the damage since you started attacking until you stop instead of the last x seconds");
showFullDungeonDamage = config.Bind<bool>("General", "showFullDungeonDamage", true, "Show damage totals while in the dungeon instead of just the boss");
backgroundImage = config.Bind<string>("General", "backgroundImage", "_graphic/_ui/bk_06", "Background image to use for the party damage UI");
textFont = config.Bind<string>("General", "textFont", "", "Path of the font to use");
if (Chainloader.PluginInfos.ContainsKey("EasySettings"))
{
addEasySettings();
}
else
{
Plugin.logger.LogWarning((object)"Soft dependency EasySettings not found!");
}
Plugin.logger.LogInfo((object)"Config initalized!");
DPSUI_GUI.userShowPartyUI = showPartyUI.Value;
DPSUI_GUI.userShowLocalUI = showLocalUI.Value;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private static void addEasySettings()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Settings.OnInitialized.AddListener(new UnityAction(ActuallyAdd));
static void ActuallyAdd()
{
SettingsTab modTab = Settings.ModTab;
modTab.AddHeader("Atlyss DPSUI");
modTab.AddToggle(showPartyUI);
modTab.AddToggle(showLocalUI);
modTab.AddKeyButton(togglePartyUIBind);
modTab.AddKeyButton(toggleLocalUIBind);
modTab.AddKeyButton("Switch UI Mode", switchPartyUITypeBind);
modTab.AddAdvancedSlider(transitionTime, false);
modTab.AddAdvancedSlider(damageHoldTime, true);
modTab.AddToggle(keepDamageUntilPause);
modTab.AddToggle(showFullDungeonDamage);
}
}
}
public class DPSValues : Boolable
{
public string steamID;
public string nickname;
public int totalDamage;
public string color;
public string classIcon;
public DPSValues()
{
}
public DPSValues(Player player, int initialDamage)
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
steamID = player._steamID;
nickname = player._nickname;
totalDamage = initialDamage;
classIcon = "_clsIco_novice";
ScriptablePlayerBaseClass @class = player._pStats._class;
if (player._pStats.Network_syncClassTier != 0)
{
int num = player._pStats.Network_syncClassTier - 1;
if (@class._playerClassTiers.Length > num)
{
Sprite classTierIcon = @class._playerClassTiers[num]._classTierIcon;
if ((Object)(object)classTierIcon != (Object)null)
{
classIcon = ((Object)classTierIcon).name;
}
else
{
classIcon = "Null";
}
}
}
else
{
classIcon = ((Object)@class._classIcon).name;
}
Color32 val;
try
{
val = Color32.op_Implicit(((Renderer)player._pVisual._blockOrbRender).material.GetColor("_EmissionColor"));
}
catch
{
val = Color32.op_Implicit(@class._blockEmissionColor);
}
color = ((uint)((val.r << 24) | (val.g << 16) | (val.b << 8) | val.a)).ToString("X");
}
}
internal class DungeonInstance
{
public MapInstance map;
public PatternInstanceManager patternManager;
public CreepSpawner bossSpawner;
public Creep bossEntity;
public uint mapNetID;
public uint bossEntityNetID;
public long dungeonStartTime;
public long dungeonClearTime;
public long bossTeleportTime;
public long bossFightStartTime;
public long bossFightEndTime;
public float lastSentUpdate;
public List<DPSValues> bossDamage;
public List<DPSValues> totalDungeonDamage;
private bool haveLoadedPlayer;
public DungeonInstance(MapInstance newMap)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Invalid comparison between Unknown and I4
map = newMap;
patternManager = map._patternInstance;
if (Object.op_Implicit((Object)(object)patternManager))
{
bossSpawner = patternManager._bossSpawner;
}
mapNetID = ((NetworkBehaviour)newMap).netId;
if ((int)newMap._zoneType != 2)
{
haveLoadedPlayer = true;
}
bossDamage = new List<DPSValues>();
totalDungeonDamage = new List<DPSValues>();
}
public void Print()
{
Plugin.logger.LogInfo((object)$"Dungeon instance ({map._mapName}) [netId: {mapNetID}]");
Plugin.logger.LogInfo((object)$"Pattern manager: {patternManager}");
if (Object.op_Implicit((Object)(object)patternManager))
{
Plugin.logger.LogInfo((object)$"PatternInstance state: isBossEngaged {patternManager._isBossEngaged} netowrkversion {patternManager.Network_isBossEngaged}");
Plugin.logger.LogInfo((object)$"Boss entity: {bossEntity}");
}
Plugin.logger.LogInfo((object)("Dungeon cleared? " + ((dungeonClearTime != 0L) ? "Yes" : "No")));
string text = "Dormant";
if (bossFightStartTime != 0L)
{
text = "In battle";
}
if (bossFightEndTime != 0L)
{
text = "Defeated";
}
Plugin.logger.LogInfo((object)("Boss status: (" + text + ")"));
if (Object.op_Implicit((Object)(object)bossEntity))
{
Plugin.logger.LogInfo((object)$"Boss max hp: {bossEntity._statStruct._maxHealth}");
}
Plugin.logger.LogInfo((object)$"Fight start time: {bossFightStartTime}");
Plugin.logger.LogInfo((object)$"Fight end time: {bossFightEndTime}");
if (text == "Defeated")
{
Plugin.logger.LogInfo((object)$"Boss defeated in {(float)(bossFightEndTime - bossFightStartTime) / 1000f} seconds");
}
Plugin.logger.LogInfo((object)"Current player boss damage totals: ");
foreach (DPSValues item in bossDamage)
{
Plugin.logger.LogInfo((object)$"{item.nickname} ({item.steamID}): {item.totalDamage} damage");
}
Plugin.logger.LogInfo((object)"Current player damage totals: ");
foreach (DPSValues item2 in totalDungeonDamage)
{
Plugin.logger.LogInfo((object)$"{item2.nickname} ({item2.steamID}): {item2.totalDamage} damage");
}
}
public void Update()
{
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Invalid comparison between Unknown and I4
if (!Plugin._SoloMode && Time.time >= lastSentUpdate + 1f && (dungeonStartTime > 0 || (bossFightEndTime == 0L && bossFightStartTime > 0)))
{
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new DPSPacket(this));
Plugin.logger.LogDebug((object)"Sent update packet");
lastSentUpdate = Time.time;
}
if (!haveLoadedPlayer)
{
foreach (Player item in map._peersInInstance)
{
if (Object.op_Implicit((Object)(object)item) && (int)item.Network_currentGameCondition == 1)
{
haveLoadedPlayer = true;
dungeonStartTime = DateTime.UtcNow.Ticks / 10000;
}
}
}
if (Object.op_Implicit((Object)(object)patternManager))
{
if (dungeonClearTime == 0L && patternManager.Network_allArenasBeaten)
{
dungeonClearTime = DateTime.UtcNow.Ticks / 10000;
if (Plugin._SoloMode)
{
Plugin.AddChatMessage($"[DPSUI] Dungeon cleared in {(float)(dungeonClearTime - dungeonStartTime) / 1000f} seconds! (all arenas beaten)");
}
}
if (Object.op_Implicit((Object)(object)patternManager._bossRoomTeleporter) && bossTeleportTime == 0L && patternManager._bossRoomTeleporter.Network_allPlayersInTeleporter)
{
bossTeleportTime = DateTime.UtcNow.Ticks / 10000;
if (Plugin._SoloMode)
{
Plugin.AddChatMessage($"[DPSUI] Boss reached in {(float)(bossTeleportTime - dungeonStartTime) / 1000f} seconds!");
}
}
if (!patternManager.Network_isBossDefeated && patternManager.Network_isBossEngaged && bossFightStartTime == 0L)
{
bossFightStartTime = DateTime.UtcNow.Ticks / 10000;
Plugin.logger.LogInfo((object)("boss engaged " + bossFightStartTime));
if (Object.op_Implicit((Object)(object)bossSpawner) && bossSpawner._spawnedCreeps.Count > 0)
{
bossEntity = bossSpawner._spawnedCreeps[0];
bossEntityNetID = ((NetworkBehaviour)bossEntity).netId;
if (Object.op_Implicit((Object)(object)bossEntity.Network_aggroedEntity._isPlayer))
{
RecordDamage(bossEntity.Network_aggroedEntity._isPlayer, 0, isBossDamage: true);
}
foreach (Player item2 in bossSpawner._playersWithinSpawnerRadius)
{
if (Object.op_Implicit((Object)(object)item2))
{
RecordDamage(item2, 0, isBossDamage: true);
}
}
}
else
{
Plugin.logger.LogError((object)"Boss is engaged but boss not found!");
}
}
if (patternManager.Network_isBossDefeated && bossFightStartTime > 0 && bossFightEndTime == 0L)
{
bossFightEndTime = DateTime.UtcNow.Ticks / 10000;
Plugin.logger.LogInfo((object)"Dungeon Boss Beaten!");
Print();
Plugin.logger.LogInfo((object)" ");
if (!Plugin._SoloMode && Plugin._AmServer)
{
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new DPSPacket(this));
Plugin.logger.LogWarning((object)"Sent final update packet");
}
if (Plugin._SoloMode)
{
Plugin.AddChatMessage($"[DPSUI] Boss beaten in {(float)(bossFightEndTime - bossFightStartTime) / 1000f} seconds!");
Plugin.AddChatMessage($"[DPSUI] Dungeon finished in {(float)(bossFightEndTime - dungeonStartTime) / 1000f} seconds!");
}
}
return;
}
if (!Object.op_Implicit((Object)(object)bossSpawner))
{
CreepSpawner[] array = Resources.FindObjectsOfTypeAll<CreepSpawner>();
CreepSpawner[] array2 = array;
foreach (CreepSpawner val in array2)
{
ManualLogSource logger = Plugin.logger;
if (logger != null)
{
logger.LogInfo((object)(((Object)val).name + " spawn count: " + val._creepCount));
}
if ((Object)(object)val._creepToSpawn != (Object)null && PluginInfo.FIELD_BOSSES.Contains(val._creepToSpawn._creepName))
{
bossSpawner = val;
break;
}
}
if (!Object.op_Implicit((Object)(object)bossSpawner))
{
return;
}
}
if (bossFightStartTime == 0L)
{
if (!Object.op_Implicit((Object)(object)bossSpawner) || bossSpawner._spawnedCreeps.Count == 0 || (Object)(object)bossSpawner._spawnedCreeps[0] == (Object)null)
{
return;
}
if ((Object)(object)bossEntity == (Object)null)
{
bossEntity = bossSpawner._spawnedCreeps[0];
bossEntityNetID = ((NetworkBehaviour)bossEntity).netId;
}
if ((Object)(object)bossEntity._aggroedEntity == (Object)null)
{
return;
}
bossFightStartTime = DateTime.UtcNow.Ticks / 10000;
Plugin.logger.LogInfo((object)$"field boss engaged {bossFightStartTime}");
if (Object.op_Implicit((Object)(object)bossEntity.Network_aggroedEntity._isPlayer))
{
RecordDamage(bossEntity.Network_aggroedEntity._isPlayer, 0, isBossDamage: true);
}
foreach (Player item3 in bossSpawner._playersWithinSpawnerRadius)
{
RecordDamage(item3, 0, isBossDamage: true);
}
}
if (bossFightStartTime > 0 && bossFightEndTime == 0L && bossEntity._statusEntity._currentHealth <= 0)
{
bossFightEndTime = DateTime.UtcNow.Ticks / 10000;
Plugin.logger.LogInfo((object)"Field boss killed!");
Print();
Plugin.logger.LogInfo((object)" ");
if (!Plugin._SoloMode && Plugin._AmServer)
{
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new DPSPacket(this));
Plugin.logger.LogWarning((object)"Sent final update packet");
}
if (Plugin._SoloMode)
{
Plugin.AddChatMessage($"[DPSUI] Boss beaten in {(float)(bossFightEndTime - bossFightStartTime) / 1000f} seconds!");
}
bossFightStartTime = 0L;
bossFightEndTime = 0L;
bossDamage.Clear();
}
}
public void RecordDamage(Player player, int damage, bool isBossDamage)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Invalid comparison between Unknown and I4
if (!Object.op_Implicit((Object)(object)player))
{
return;
}
if (isBossDamage)
{
bool flag = false;
for (int i = 0; i < bossDamage.Count; i++)
{
if (bossDamage[i].steamID == player._steamID)
{
flag = true;
bossDamage[i].totalDamage += damage;
}
}
if (!flag)
{
bossDamage.Add(new DPSValues(player, damage));
}
}
else
{
if ((int)player.Network_playerMapInstance._zoneType != 2)
{
return;
}
bool flag2 = false;
for (int j = 0; j < totalDungeonDamage.Count; j++)
{
if (totalDungeonDamage[j].steamID == player._steamID)
{
flag2 = true;
totalDungeonDamage[j].totalDamage += damage;
}
}
if (!flag2)
{
totalDungeonDamage.Add(new DPSValues(player, damage));
}
}
}
}
public enum UIMode
{
Auto,
Boss,
Party
}
public class DPSUI_GUI : Boolable
{
internal class PartyMemberBar
{
internal GameObject self;
private Text memberInfo;
private Text damageText;
private RectTransform background;
private RectTransform fillBar;
private Image classImg;
public Color fillColor;
private float dataUpdateTime;
internal PartyMemberBar(GameObject self)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0038: Expected O, but got Unknown
//IL_003b: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Expected O, but got Unknown
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Expected O, but got Unknown
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
this.self = self;
fillColor = new Color(Random.value, Random.value, Random.value);
AddBackground(self);
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, Color.white);
GameObject val2 = AddBackground(self, val);
((Object)val2).name = "Fillbar";
fillBar = val2.GetComponent<RectTransform>();
fillBar.sizeDelta = new Vector2(-3f, -2f);
((Graphic)((Component)fillBar).GetComponent<Image>()).color = fillColor;
GameObject val3 = new GameObject("ClassImage", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
classImg = val3.GetComponent<Image>();
setParent(val3, self);
self.GetComponent<RectTransform>();
RectTransform component = val3.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.01f, 0.3f);
component.anchorMax = new Vector2(0.09f, 0.7f);
component.sizeDelta = Vector2.zero;
component.pivot = component.anchorMin;
component.anchoredPosition = Vector2.zero;
int num = 0;
while (classImages != null && num < classImages.Length)
{
if (Object.op_Implicit((Object)(object)classImages[num]) && ((Object)classImages[num]).name == "_clsIco_novice")
{
classImg.sprite = Sprite.Create(classImages[num], new Rect(0f, 0f, (float)((Texture)classImages[num]).width, (float)((Texture)classImages[num]).height), new Vector2(0.5f, 0.5f));
break;
}
num++;
}
GameObject val4 = new GameObject("MemberName", new Type[1] { typeof(Text) });
setupRectTransform(val4, new Vector2(0.16f, 0.5f), self, ignoreParentRect: true);
memberInfo = setupText(val4, 20);
val4.AddComponent<Shadow>();
memberInfo.alignment = (TextAnchor)3;
memberInfo.text = "Dumbass";
val4 = new GameObject("DamageText", new Type[1] { typeof(Text) });
setupRectTransform(val4, new Vector2(0.97f, 0.5f), self, ignoreParentRect: true);
damageText = setupText(val4, 20);
val4.AddComponent<Shadow>();
damageText.alignment = (TextAnchor)5;
damageText.text = "Fuck all";
}
internal void UpdateInfo(DPSValues info, float barFillPercent)
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: 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)
memberInfo.text = info.nickname;
if (info.steamID == Player._mainPlayer.Network_steamID)
{
Text obj = memberInfo;
obj.text += " (You)";
}
string text = info.totalDamage.ToString("n1");
if (text.EndsWith(".0"))
{
text = text.Substring(0, text.Length - 2);
}
damageText.text = text;
barFillPercent = Mathf.Max(barFillPercent, 1E-05f);
fillBar.anchorMax = new Vector2(barFillPercent, 1f);
self.SetActive(true);
if (info.classIcon != ((Object)classImg.sprite.texture).name)
{
for (int i = 0; i < classImages.Length; i++)
{
if (Object.op_Implicit((Object)(object)classImages[i]) && ((Object)classImages[i]).name == info.classIcon)
{
classImg.sprite = Sprite.Create(classImages[i], new Rect(0f, 0f, (float)((Texture)classImages[i]).width, (float)((Texture)classImages[i]).height), new Vector2(0.5f, 0.5f));
break;
}
}
}
try
{
uint num = Convert.ToUInt32(info.color, 16);
if (num != 0)
{
Color32 val = default(Color32);
val.r = (byte)((num >> 24) & 0xFFu);
val.g = (byte)((num >> 16) & 0xFFu);
val.b = (byte)((num >> 8) & 0xFFu);
val.a = byte.MaxValue;
Color32 val2 = val;
((Graphic)((Component)fillBar).GetComponent<Image>()).color = Color32.op_Implicit(val2);
}
}
catch
{
}
}
}
public static DPSUI_GUI _UI;
internal static InGameUI gameUI;
public static UIMode _UIMode;
public static bool showUI;
private static bool _userShowPartyUI;
private static bool _userShowLocalUI;
private static bool _showPartyUI;
private static bool _showLocalUI = true;
private static float partyAnimPos;
public static Font UI_font;
public static Vector2 DPS_Pos = new Vector2(0.61f, 0.14f);
public static Vector2 PartyDPS_MinPos = new Vector2(0.85f, 0.35f);
public static Vector2 PartyDPS_MaxPos = new Vector2(1f, 0.65f);
public static Vector2 PartyDPS_TotalPos = new Vector2(0.05f, 0.95f);
public static Vector2 PartyDPS_DPSPos = new Vector2(0.95f, 0.95f);
public static int MaxShownPartyMembers = 5;
public static float topTextSpace = 0.13f;
public static float edgePadding = 0.03f;
public static float memberSpacing = 0.01f;
public static int topTextSize = 20;
internal static GameObject partyDpsContainer;
internal static GameObject localDpsContainer;
internal static RectTransform partyDpsTransform;
internal static RectTransform localDpsTransform;
internal static AnimationCurve partyAnimCurve;
internal static GameObject partyDpsLabelRoot;
internal Canvas rootCanvas;
internal Text localDpsText;
internal Text partyTotalText;
internal Text partyDpsText;
internal Text partyDpsLabelText;
internal static Texture2D[] classImages;
internal PartyMemberBar[] memberBars;
internal static bool createdUI;
public static bool userShowPartyUI
{
get
{
return _userShowPartyUI;
}
set
{
_userShowPartyUI = value;
_UI?.Update();
}
}
public static bool userShowLocalUI
{
get
{
return _userShowLocalUI;
}
set
{
_userShowLocalUI = value;
_UI?.UpdateVisibility();
}
}
public static bool showPartyUI
{
get
{
return _showPartyUI;
}
set
{
if (!_showPartyUI && value)
{
partyAnimPos = 0f;
}
_showPartyUI = value;
_UI?.Update();
}
}
public static bool showLocalUI
{
get
{
return _showLocalUI;
}
set
{
_showLocalUI = value;
if ((bool)_UI)
{
_UI.UpdateVisibility();
}
}
}
public static void setParent(GameObject child, GameObject parent)
{
//IL_0018: 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)
child.transform.SetParent(parent.transform, false);
child.transform.localPosition = Vector3.zero;
child.transform.localScale = Vector3.one;
}
public static void resetPartyAnim()
{
partyDpsContainer.SetActive(false);
partyAnimPos = 0f;
}
public static RectTransform setupRectTransform(GameObject obj, Vector2 anchor, GameObject parent = null, bool ignoreParentRect = false)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_003f: Unknown result type (might be due to invalid IL or missing references)
RectTransform component = obj.GetComponent<RectTransform>();
component.pivot = anchor;
component.anchorMin = anchor;
component.anchorMax = anchor;
if (Object.op_Implicit((Object)(object)parent))
{
setParent(obj, parent);
if (!ignoreParentRect)
{
RectTransform component2 = parent.GetComponent<RectTransform>();
if (Object.op_Implicit((Object)(object)component2))
{
component.sizeDelta = component2.sizeDelta;
}
}
}
component.anchoredPosition = Vector2.zero;
return component;
}
public static Text setupText(GameObject textObj, int fontSize = 10)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0044: Unknown result type (might be due to invalid IL or missing references)
Text component = textObj.GetComponent<Text>();
if ((Object)(object)component == (Object)null)
{
return null;
}
RectTransform component2 = ((Component)textObj.transform.parent).GetComponent<RectTransform>();
if (Object.op_Implicit((Object)(object)component2) && component2.sizeDelta != Vector2.zero)
{
textObj.GetComponent<RectTransform>().sizeDelta = component2.sizeDelta;
}
((Component)component).gameObject.layer = LayerMask.NameToLayer("UI");
component.font = UI_font;
component.font.material.mainTexture.filterMode = (FilterMode)0;
component.horizontalOverflow = (HorizontalWrapMode)1;
component.alignment = (TextAnchor)8;
component.fontSize = fontSize;
((Component)component).transform.localPosition = Vector3.zero;
RectTransform component3 = ((Component)component).GetComponent<RectTransform>();
if (Object.op_Implicit((Object)(object)component3))
{
component3.anchoredPosition = Vector2.zero;
}
return component;
}
public static GameObject AddBackground(GameObject uiObjt, Texture2D image = null, Sprite sprite = null)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_003a: 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_0050: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Background", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
setParent(val, uiObjt);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
val.gameObject.layer = LayerMask.NameToLayer("UI");
Image component2 = val.GetComponent<Image>();
if (Object.op_Implicit((Object)(object)image))
{
component2.sprite = Sprite.Create(image, new Rect(0f, 0f, (float)((Texture)image).width, (float)((Texture)image).height), new Vector2(0.5f, 0.5f));
component2.type = (Type)1;
}
else if (Object.op_Implicit((Object)(object)sprite))
{
component2.sprite = sprite;
component2.type = (Type)1;
}
else
{
((Graphic)component2).color = Color.black;
}
return val;
}
internal DPSUI_GUI()
{
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Expected O, but got Unknown
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: 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)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Expected O, but got Unknown
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Expected O, but got Unknown
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Expected O, but got Unknown
//IL_035c: 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_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0419: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Expected O, but got Unknown
//IL_042c: Unknown result type (might be due to invalid IL or missing references)
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0474: Expected O, but got Unknown
//IL_0476: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04df: Unknown result type (might be due to invalid IL or missing references)
//IL_04e6: Expected O, but got Unknown
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
//IL_051f: Unknown result type (might be due to invalid IL or missing references)
//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
//IL_05ec: Expected O, but got Unknown
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Unknown result type (might be due to invalid IL or missing references)
//IL_060e: Unknown result type (might be due to invalid IL or missing references)
//IL_061a: Unknown result type (might be due to invalid IL or missing references)
if (classImages == null || classImages.Length == 0)
{
Texture2D[] array = Resources.LoadAll<Texture2D>("_graphic/_ui/_classicons/");
Texture2D val = Resources.Load<Texture2D>("_graphic/_ui/_ico_caution_lv");
((Object)val).name = "Null";
classImages = (Texture2D[])(object)new Texture2D[array.Length + 1];
classImages[0] = val;
Array.Copy(array, 0, classImages, 1, array.Length);
Plugin.logger.LogDebug((object)$"Loaded {classImages.Length} class icons");
Texture2D[] array2 = classImages;
foreach (Texture2D val2 in array2)
{
Plugin.logger.LogDebug((object)("Loaded class " + ((Object)val2).name));
}
}
if (!Object.op_Implicit((Object)(object)InGameUI._current))
{
return;
}
UI_font = Resources.GetBuiltinResource<Font>("Arial.ttf");
GameObject val3 = new GameObject("DPSUI", new Type[3]
{
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
setupMainCanvas(val3);
Plugin.logger.LogInfo((object)$"root {val3}");
GameObject val4 = new GameObject("localDPS", new Type[1] { typeof(RectTransform) });
RectTransform val5 = setupRectTransform(val4, DPS_Pos, val3);
val5.sizeDelta = new Vector2(150f, 50f);
val5.anchoredPosition = Vector2.zero;
localDpsTransform = val5;
GameObject val6 = new GameObject("DpsText", new Type[1] { typeof(Text) });
setupRectTransform(val6, Vector2.right, val4);
localDpsText = setupText(val6, 25);
localDpsText.text = "0 DPS";
Texture2D val7 = null;
Sprite val8 = null;
try
{
Object val9 = (Object)(object)Resources.Load<Sprite>(DPSUI_Config.backgroundImage.Value);
if (val9 != (Object)null)
{
val8 = (Sprite)(object)((val9 is Sprite) ? val9 : null);
}
else
{
Object obj = Resources.Load(DPSUI_Config.backgroundImage.Value);
val7 = (Texture2D)(object)((obj is Texture2D) ? obj : null);
}
}
catch
{
Object obj2 = Resources.Load("_graphic/_ui/bk_06");
val8 = (Sprite)(object)((obj2 is Sprite) ? obj2 : null);
}
if ((Object)(object)val7 != (Object)null)
{
((Texture)val7).filterMode = (FilterMode)0;
}
GameObject val10 = new GameObject("partyDPS", new Type[1] { typeof(RectTransform) });
RectTransform val11 = setupRectTransform(val10, Vector2.zero, val3, ignoreParentRect: true);
val11.anchorMin = PartyDPS_MinPos;
val11.anchorMax = PartyDPS_MaxPos;
val11.sizeDelta = Vector2.zero;
partyDpsTransform = val11;
if ((Object)(object)val8 != (Object)null)
{
AddBackground(val10, null, val8);
}
else if ((Object)(object)val7 != (Object)null)
{
AddBackground(val10, val7);
}
((Graphic)val10.GetComponentInChildren<Image>()).color = new Color(0.9f, 0.9f, 0.9f);
partyAnimCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
{
new Keyframe(0f, 0f, 0f, 1f),
new Keyframe(1f, 1f, 0f, 0f)
});
GameObject val12 = new GameObject("DPS Label", new Type[1] { typeof(RectTransform) });
RectTransform val13 = setupRectTransform(val12, new Vector2(0f, 1f), val3, ignoreParentRect: true);
val13.anchorMin = new Vector2(PartyDPS_MinPos.x, PartyDPS_MaxPos.y);
val13.anchorMax = new Vector2(PartyDPS_MaxPos.x, PartyDPS_MaxPos.y + 0.04f);
val13.sizeDelta = Vector2.zero;
Object obj4 = Resources.Load("_graphic/_ui/bk_04");
val7 = (Texture2D)(object)((obj4 is Texture2D) ? obj4 : null);
((Graphic)AddBackground(val12, val7).GetComponent<Image>()).color = Color32.op_Implicit(new Color32((byte)133, (byte)94, (byte)83, byte.MaxValue));
partyDpsLabelRoot = val12;
GameObject val14 = new GameObject("PartyLabelText", new Type[1] { typeof(Text) });
setupRectTransform(val14, new Vector2(0.5f, 0.5f), val12, ignoreParentRect: true);
partyDpsLabelText = setupText(val14, 20);
partyDpsLabelText.alignment = (TextAnchor)4;
GameObject val15 = new GameObject("PartyTotalText", new Type[1] { typeof(Text) });
RectTransform val16 = setupRectTransform(val15, PartyDPS_TotalPos, val10, ignoreParentRect: true);
partyTotalText = setupText(val15, topTextSize);
val15.AddComponent<Shadow>();
partyTotalText.alignment = (TextAnchor)0;
val16.anchoredPosition = Vector2.zero;
partyTotalText.text = "Total: 8000";
GameObject val17 = new GameObject("PartyDPSText", new Type[1] { typeof(Text) });
RectTransform val18 = setupRectTransform(val17, PartyDPS_DPSPos, val10, ignoreParentRect: true);
partyDpsText = setupText(val17, topTextSize);
val17.AddComponent<Shadow>();
partyDpsText.alignment = (TextAnchor)2;
val18.anchoredPosition = Vector2.zero;
partyDpsText.text = "8000 DPS";
float num = (1f - topTextSpace - (float)(MaxShownPartyMembers - 1) * memberSpacing - edgePadding) / (float)MaxShownPartyMembers;
memberBars = new PartyMemberBar[MaxShownPartyMembers];
Vector2 val19 = default(Vector2);
Vector2 anchorMax = default(Vector2);
for (int num2 = MaxShownPartyMembers - 1; num2 >= 0; num2--)
{
float num3 = edgePadding + memberSpacing * (float)num2 + num * (float)num2;
float num4 = num3 + num;
((Vector2)(ref val19))..ctor(edgePadding, num3);
((Vector2)(ref anchorMax))..ctor(1f - edgePadding, num4);
GameObject val20 = new GameObject($"member{num2}", new Type[1] { typeof(RectTransform) });
RectTransform val21 = setupRectTransform(val20, val19, val10);
val21.anchorMin = val19;
val21.anchorMax = anchorMax;
val21.pivot = Vector2.zero;
val21.anchoredPosition = Vector2.zero;
memberBars[MaxShownPartyMembers - 1 - num2] = new PartyMemberBar(val20);
}
partyDpsContainer = val10;
localDpsContainer = val4;
createdUI = true;
gameUI = InGameUI._current;
partyDpsContainer.SetActive(false);
localDpsContainer.SetActive(false);
UpdateVisibility();
Plugin.logger.LogInfo((object)"Created dps ui!");
void setupMainCanvas(GameObject canvasObj)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
setupRectTransform(canvasObj, Vector2.zero, ((Component)InGameUI._current).gameObject, ignoreParentRect: true);
Canvas component = canvasObj.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
canvasObj.GetComponent<CanvasScaler>().uiScaleMode = (ScaleMode)0;
rootCanvas = component;
}
}
internal void UpdateVisibility()
{
if (!Plugin._AmHeadless && createdUI)
{
localDpsContainer.SetActive(showLocalUI && _userShowLocalUI && showUI);
partyDpsLabelRoot.SetActive(false);
}
}
public void UpdateDPS(float dps)
{
if (createdUI)
{
string text = dps.ToString("n1");
if (text.EndsWith(".0"))
{
text = text.Substring(0, text.IndexOf('.'));
}
string text2 = text + " DPS";
localDpsText.text = text2;
}
}
public void UpdatePartyDamageValues(DPSPacket packet)
{
if (!createdUI || packet == null)
{
return;
}
List<DPSValues> list = packet.partyDamageValues;
long num = packet.dungeonStartTime;
long num2 = packet.bossFightEndTime;
if (_UIMode == UIMode.Auto)
{
List<DPSValues> bossDamageValues = packet.bossDamageValues;
if (bossDamageValues != null && bossDamageValues.Count > 0)
{
list = packet.bossDamageValues;
num = packet.bossFightStartTime;
num2 = packet.bossFightEndTime;
}
}
else if (_UIMode == UIMode.Boss)
{
list = packet.bossDamageValues;
num = packet.bossFightStartTime;
num2 = packet.bossFightEndTime;
}
if (list != null && list.Count == 0)
{
showPartyUI = false;
return;
}
list.Sort((DPSValues b, DPSValues a) => a.totalDamage.CompareTo(b.totalDamage));
bool flag = false;
int num3 = 0;
string steamID = Player._mainPlayer._steamID;
foreach (DPSValues item in list)
{
num3 += item.totalDamage;
if (!flag && item.steamID == steamID)
{
flag = true;
}
}
if (!flag)
{
return;
}
if (num2 == 0L)
{
num2 = DateTime.UtcNow.Ticks / 10000;
}
float num4 = (float)(num2 - num) / 1000f;
float num5 = (float)num3 / num4;
partyTotalText.text = "Total: " + num3;
string text = num5.ToString("n1");
if (text.EndsWith(".0"))
{
text = text.Substring(0, text.Length - 2);
}
partyDpsText.text = text + " DPS";
PartyMemberBar[] array = memberBars;
for (int i = 0; i < array.Length; i++)
{
array[i].self.SetActive(false);
}
showPartyUI = true;
bool flag2 = false;
for (int j = 0; j < list.Count; j++)
{
DPSValues dPSValues = list[j];
float num6 = (float)dPSValues.totalDamage / (float)Mathf.Max(list[0].totalDamage, 1);
Plugin.logger.LogDebug((object)$"{dPSValues.nickname} dmg: {dPSValues.totalDamage} UpdatePartyValues percent fill: {num6}");
if (dPSValues.steamID == steamID)
{
flag2 = true;
}
if (j < 4 || flag2 || !(dPSValues.steamID != steamID))
{
memberBars[Math.Min(4, j)].UpdateInfo(dPSValues, num6);
if (j >= 4 && flag2)
{
break;
}
}
}
}
internal void clearDamageValues()
{
partyTotalText.text = "Total: 0";
partyDpsText.text = "0 DPS";
PartyMemberBar[] array = memberBars;
foreach (PartyMemberBar partyMemberBar in array)
{
partyMemberBar.UpdateInfo(new DPSValues(), 0f);
partyMemberBar.self.SetActive(false);
}
}
public void Update()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
if (!createdUI || Plugin._AmHeadless)
{
return;
}
if ((gameUI._displayUI && !Player._mainPlayer._inUI) != showUI)
{
showUI = gameUI._displayUI && (!Plugin.player._inUI || (int)Plugin.player._currentPlayerCondition == 3);
localDpsContainer.SetActive(showLocalUI && _userShowLocalUI && showUI);
}
Rect rect;
if (showUI && _showPartyUI && _userShowPartyUI && partyAnimPos < 1f)
{
if (!partyDpsContainer.activeSelf)
{
partyDpsContainer.SetActive(true);
}
if (DPSUI_Config.transitionTime.Value == 0f)
{
partyDpsTransform.anchoredPosition = Vector2.zero;
partyAnimPos = 1f;
}
else
{
partyAnimPos += Time.deltaTime / DPSUI_Config.transitionTime.Value;
if (partyAnimPos > 1f)
{
partyAnimPos = 1f;
}
Vector2 zero = Vector2.zero;
rect = partyDpsTransform.rect;
zero.x = ((Rect)(ref rect)).width * (1f - partyAnimCurve.Evaluate(partyAnimPos));
partyDpsTransform.anchoredPosition = zero;
}
}
if ((showUI && _showPartyUI && _userShowPartyUI) || !(partyAnimPos > 0f))
{
return;
}
if (DPSUI_Config.transitionTime.Value == 0f)
{
partyDpsContainer.SetActive(false);
partyAnimPos = 0f;
return;
}
partyAnimPos -= Time.deltaTime / DPSUI_Config.transitionTime.Value;
if (partyAnimPos < 0f)
{
partyAnimPos = 0f;
partyDpsContainer.SetActive(false);
}
Vector2 zero2 = Vector2.zero;
rect = partyDpsTransform.rect;
zero2.x = ((Rect)(ref rect)).width * (1f - partyAnimCurve.Evaluate(partyAnimPos));
partyDpsTransform.anchoredPosition = zero2;
}
}
internal class PluginInfo
{
public const string GUID = "Soggy_Pancake.AtlyssDPSUI";
public const string NAME = "AtlyssDPSUI";
public const string VERSION = "1.0.6";
public const int MAX_HELLO_RETRY = 5;
public const float CLIENT_UPDATE_RATE = 1f;
public const int FIELD_BOSS_TIMEOUT_MS = 30000;
internal static readonly string[] FIELDS_WITH_BOSSES = new string[2] { "Effold Terrace", "Tuul Valley" };
internal static readonly string[] FIELD_BOSSES = new string[2] { "Slime Diva", "Gahool" };
}
public class Boolable
{
public static implicit operator bool(Boolable obj)
{
return obj != null;
}
}
public static class UnityNullFix
{
public static T NC<T>(this T obj) where T : Object
{
if (!Object.op_Implicit((Object)(object)obj))
{
return default(T);
}
return obj;
}
}
public struct DamageHistory
{
public float time;
public int damage;
}
public class DPSPacket : PacketBase
{
[JsonProperty]
public uint mapNetID;
[JsonProperty]
public long dungeonStartTime;
[JsonProperty]
public long dungeonClearTime;
[JsonProperty]
public long bossTeleportTime;
[JsonProperty]
public long bossFightStartTime;
[JsonProperty]
public long bossFightEndTime;
[JsonProperty]
public List<DPSValues> bossDamageValues;
[JsonProperty]
public List<DPSValues> partyDamageValues;
public override string PacketSourceGUID => "Soggy_Pancake.AtlyssDPSUI";
public DPSPacket()
{
}
internal DPSPacket(DungeonInstance instance)
{
mapNetID = instance.mapNetID;
dungeonStartTime = instance.dungeonStartTime;
dungeonClearTime = instance.dungeonClearTime;
bossTeleportTime = instance.bossTeleportTime;
bossFightStartTime = instance.bossFightStartTime;
bossFightEndTime = instance.bossFightEndTime;
bossDamageValues = instance.bossDamage;
partyDamageValues = instance.totalDungeonDamage;
}
public static implicit operator bool(DPSPacket obj)
{
return obj != null;
}
}
public class DPSClientHelloPacket : PacketBase
{
[JsonProperty]
public string version = "1.0.6";
[JsonProperty]
public string nickname = "null";
public override string PacketSourceGUID => "Soggy_Pancake.AtlyssDPSUI";
}
public class DPSServerHelloPacket : PacketBase
{
[JsonProperty]
public string response = "Hello";
[JsonProperty]
public string version = "1.0.6";
public override string PacketSourceGUID => "Soggy_Pancake.AtlyssDPSUI";
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("soggy_pancake.plugins.atlyssDPSUI", "AtlyssDPSUI", "1.0.6")]
public class Plugin : BaseUnityPlugin
{
public static Plugin AtlyssDPSUI;
internal static Harmony _harmony;
internal static ManualLogSource logger;
internal static Player player;
internal static InGameUI GameUI;
public static Text localDpsText;
internal static bool _serverSupport;
internal static bool _AmServer;
internal static bool _AmHeadless;
internal static bool _SoloMode;
internal static bool shownDungeonClearText;
internal static List<DungeonInstance> dungeonInstances = new List<DungeonInstance>();
internal static List<DamageHistory> localDamage = new List<DamageHistory>();
internal static DPSPacket lastDPSPacket;
internal static void Client_ParseDungeonPartyDamage(PacketHeader header, PacketBase packet)
{
if (!(packet is DPSPacket dPSPacket))
{
return;
}
Player obj = Player._mainPlayer.NC<Player>();
if (!Object.op_Implicit((Object)(object)((obj != null) ? obj.Network_playerMapInstance : null)) || dPSPacket.mapNetID != ((NetworkBehaviour)Player._mainPlayer.Network_playerMapInstance).netId)
{
return;
}
logger.LogDebug((object)"Recieved valid packet for instance!");
logger.LogDebug((object)$"Boss fight start {dPSPacket.bossFightStartTime}!");
logger.LogDebug((object)$"Boss fight end {dPSPacket.bossFightEndTime}!");
if (!lastDPSPacket)
{
lastDPSPacket = dPSPacket;
}
if (lastDPSPacket.dungeonClearTime == 0L && dPSPacket.dungeonClearTime > 0)
{
AddChatMessage($"[DPSUI] Dungeon cleared in {(float)(dPSPacket.dungeonClearTime - dPSPacket.dungeonStartTime) / 1000f} seconds!(arenas only)");
}
if (lastDPSPacket.bossTeleportTime == 0L && dPSPacket.bossTeleportTime > 0)
{
AddChatMessage($"[DPSUI] Boss reached in {(float)(dPSPacket.bossTeleportTime - dPSPacket.dungeonStartTime) / 1000f} seconds!");
}
if (lastDPSPacket.bossFightEndTime == 0L && dPSPacket.bossFightEndTime > 0 && dPSPacket.dungeonStartTime > 0)
{
AddChatMessage($"[DPSUI] Boss beaten in {(float)(dPSPacket.bossFightEndTime - dPSPacket.bossFightStartTime) / 1000f} seconds!");
AddChatMessage($"[DPSUI] Dungeon finished in {(float)(dPSPacket.bossFightEndTime - dPSPacket.dungeonStartTime) / 1000f} seconds!");
}
int num = 0;
foreach (DPSValues bossDamageValue in dPSPacket.bossDamageValues)
{
num += bossDamageValue.totalDamage;
}
DPSUI_GUI._UI.UpdatePartyDamageValues(dPSPacket);
lastDPSPacket = dPSPacket;
}
internal static void AddChatMessage(string msg)
{
Player obj = Player._mainPlayer.NC<Player>();
if (obj != null)
{
ChatBehaviour obj2 = obj._chatBehaviour.NC<ChatBehaviour>();
if (obj2 != null)
{
obj2.New_ChatMessage(msg);
}
}
}
internal static void AddGameFeedMessage(string msg)
{
Player obj = Player._mainPlayer.NC<Player>();
if (obj != null)
{
ChatBehaviour obj2 = obj._chatBehaviour.NC<ChatBehaviour>();
if (obj2 != null)
{
obj2.Init_GameLogicMessage(msg);
}
}
}
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
AtlyssDPSUI = this;
logger = ((BaseUnityPlugin)this).Logger;
_harmony = new Harmony("Soggy_Pancake.AtlyssDPSUI");
DPSUI_Config.init(((BaseUnityPlugin)this).Config);
localDamage = new List<DamageHistory>();
logger.LogInfo((object)"Patch successful! Registering network listeners...");
CodeTalkerNetwork.RegisterListener<DPSClientHelloPacket>(new PacketListener(ServerPatches.Server_RecieveHello));
if (!Environment.GetCommandLineArgs().Contains("-server"))
{
_harmony.PatchAll(typeof(ClientPatches));
CodeTalkerNetwork.RegisterListener<DPSServerHelloPacket>(new PacketListener(ClientPatches.Client_RecieveHello));
CodeTalkerNetwork.RegisterListener<DPSPacket>(new PacketListener(Client_ParseDungeonPartyDamage));
}
else
{
logger.LogWarning((object)"Headless mode detected!");
_serverSupport = (_AmHeadless = true);
}
_harmony.PatchAll(typeof(ServerPatches));
}
private void Update()
{
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
if (_AmHeadless || !Object.op_Implicit((Object)(object)player))
{
return;
}
if (!DPSUI_GUI.createdUI && Object.op_Implicit((Object)(object)InGameUI._current))
{
DPSUI_GUI._UI = new DPSUI_GUI();
_SoloMode = AtlyssNetworkManager._current._soloMode;
}
if ((Object)(object)GameUI == (Object)null)
{
GameUI = InGameUI._current;
}
DPSUI_GUI._UI.Update();
if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)303))
{
logger.LogInfo((object)("main player: " + (object)Player._mainPlayer));
logger.LogInfo((object)$"Slide in time: {DPSUI_Config.transitionTime.Value}");
logger.LogInfo((object)$"UI Mode: {DPSUI_GUI._UIMode}");
ClientPatches.ClientSendHello();
LogFullHierarchy();
Portal[] array = Object.FindObjectsOfType<Portal>();
Portal[] array2 = array;
foreach (Portal val in array2)
{
try
{
if (((Component)val).gameObject.activeSelf)
{
logger.LogInfo((object)((Object)((Component)val).gameObject).name);
logger.LogInfo((object)val._scenePortal._portalType);
}
}
catch
{
}
}
ScriptablePlayerBaseClass val2 = player.NC<Player>()?._pStats.NC<PlayerStats>()?._class;
logger.LogInfo((object)("Player base class name " + val2._className));
if (player._pStats._syncClassTier != 0)
{
logger.LogInfo((object)"Has subclass!");
try
{
logger.LogInfo((object)("Player base class name " + ((Object)val2._playerClassTiers[Player._mainPlayer._pStats._syncClassTier - 1]._classTierIcon).name));
}
catch
{
}
}
logger.LogError((object)$"Dungeon instances tracked: {dungeonInstances.Count}");
foreach (DungeonInstance dungeonInstance in dungeonInstances)
{
dungeonInstance.Print();
}
}
if (player._inChat || player._inUI)
{
return;
}
if (Input.GetKeyDown(DPSUI_Config.togglePartyUIBind.Value))
{
DPSUI_Config.showPartyUI.Value = (DPSUI_GUI.userShowPartyUI = !DPSUI_GUI.userShowPartyUI);
AddGameFeedMessage((DPSUI_GUI.userShowPartyUI ? "Enabled" : "Disabled") + " party UI");
}
if (Input.GetKeyDown(DPSUI_Config.toggleLocalUIBind.Value))
{
DPSUI_Config.showLocalUI.Value = (DPSUI_GUI.userShowLocalUI = !DPSUI_GUI.userShowLocalUI);
AddGameFeedMessage((DPSUI_GUI.userShowLocalUI ? "Enabled" : "Disabled") + " local UI");
}
if (Input.GetKeyDown(DPSUI_Config.switchPartyUITypeBind.Value))
{
if (DPSUI_GUI._UIMode == UIMode.Auto)
{
DPSUI_GUI._UIMode = UIMode.Party;
}
else if (DPSUI_GUI._UIMode == UIMode.Party)
{
DPSUI_GUI._UIMode = UIMode.Boss;
}
else if (DPSUI_GUI._UIMode == UIMode.Boss)
{
DPSUI_GUI._UIMode = UIMode.Auto;
}
AddGameFeedMessage($"Set UI Mode to {DPSUI_GUI._UIMode}");
DPSUI_GUI._UI?.UpdatePartyDamageValues(lastDPSPacket);
}
}
private void FixedUpdate()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Invalid comparison between Unknown and I4
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Invalid comparison between Unknown and I4
if ((Object)(object)player != (Object)(object)Player._mainPlayer)
{
player = Player._mainPlayer;
}
if (_AmServer)
{
for (int num = dungeonInstances.Count - 1; num >= 0; num--)
{
DungeonInstance dungeonInstance = dungeonInstances[num];
if (!Object.op_Implicit((Object)(object)dungeonInstances[num].map))
{
dungeonInstances.RemoveAt(num);
logger.LogInfo((object)"Dungeon was unloaded!");
}
else
{
dungeonInstance.Update();
}
}
}
else if (!_serverSupport)
{
Player obj = player.NC<Player>();
if (obj != null && (int)obj.Network_currentGameCondition == 1 && ClientPatches._helloRetryCount < 5)
{
ClientPatches.ClientSendHello();
}
}
if (_AmHeadless || !DPSUI_GUI.showPartyUI)
{
return;
}
if (!Object.op_Implicit((Object)(object)player))
{
DPSUI_GUI.showPartyUI = false;
return;
}
MapInstance val = player.Network_playerMapInstance.NC<MapInstance>();
if (Object.op_Implicit((Object)(object)val) && (int)val._zoneType == 1)
{
DPSPacket dPSPacket = lastDPSPacket;
if (dPSPacket != null && dPSPacket.bossFightEndTime > 0 && lastDPSPacket.bossFightEndTime < DateTime.UtcNow.Ticks / 10000 - 30000)
{
DPSUI_GUI.showPartyUI = false;
logger.LogInfo((object)"Stopped showing field boss info after 30 seconds!");
}
}
}
private static void LogFullHierarchy()
{
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
Player mainPlayer = Player._mainPlayer;
ManualLogSource obj;
object obj3;
if (SceneManager.sceneCount >= 2)
{
ClientPatches.ClientSendHello(force: true);
obj = logger;
Player obj2 = mainPlayer.NC<Player>();
if (obj2 != null)
{
_ = obj2.Network_isHostPlayer;
if (true)
{
obj3 = "yes";
goto IL_0043;
}
}
obj3 = "nah";
goto IL_0043;
}
goto IL_015b;
IL_015b:
ManualLogSource obj4 = logger;
Player obj5 = mainPlayer.NC<Player>();
object obj6;
if (obj5 == null)
{
obj6 = null;
}
else
{
MapInstance obj7 = obj5._playerMapInstance.NC<MapInstance>();
obj6 = ((obj7 != null) ? ((Object)obj7).name : null);
}
obj4.LogInfo(obj6);
logger.LogInfo((object)mainPlayer.NC<Player>()?._playerMapInstance.NC<MapInstance>()?._zoneType);
logger.LogInfo((object)$"Loaded scenes: {SceneManager.sceneCount}");
for (int i = 0; i < SceneManager.sceneCount; i++)
{
Scene sceneAt = SceneManager.GetSceneAt(i);
logger.LogInfo((object)("Loaded scene: " + ((Scene)(ref sceneAt)).name));
}
return;
IL_0043:
obj.LogInfo((object)("Am host: " + (string?)obj3));
logger.LogInfo((object)("_AmHeadless " + _AmHeadless));
logger.LogInfo((object)("Server support " + _serverSupport));
logger.LogInfo((object)("AmServer " + _serverSupport));
logger.LogInfo((object)("last dps packet " + (object)lastDPSPacket));
logger.LogInfo((object)$"Show partyUI: {DPSUI_GUI.showPartyUI}; Show localUI: {DPSUI_GUI.showLocalUI}; Player in ui: {player._inUI}");
if (_AmServer)
{
logger.LogInfo((object)"\nSpawners:");
CreepSpawner[] array = Resources.FindObjectsOfTypeAll<CreepSpawner>();
CreepSpawner[] array2 = array;
foreach (CreepSpawner val in array2)
{
logger.LogInfo((object)(((Object)val).name + " spawn count: " + val._creepCount));
}
}
goto IL_015b;
}
public static void LogHierarchy(Transform root, int depth = 0)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
logger.LogInfo((object)(new string(' ', depth * 2) + ((Object)root).name));
if (!((Object)root).name.StartsWith("_player(") && !((Object)root).name.StartsWith("_raceModelDisplayDolly"))
{
foreach (Transform item in root)
{
Transform root2 = item;
LogHierarchy(root2, depth + 1);
}
return;
}
logger.LogInfo((object)(new string(' ', (depth + 1) * 2) + "..."));
}
}
internal class ServerPatches
{
internal static void Server_RecieveHello(PacketHeader header, PacketBase packet)
{
if (packet is DPSClientHelloPacket dPSClientHelloPacket)
{
Player obj = Player._mainPlayer.NC<Player>();
if (obj != null && obj.Network_isHostPlayer && !header.SenderIsLobbyOwner)
{
Plugin.logger.LogInfo((object)("Server replying to client! (" + dPSClientHelloPacket.nickname + ")"));
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new DPSServerHelloPacket());
}
}
}
[HarmonyPatch(typeof(StatusEntity), "Take_Damage")]
[HarmonyPostfix]
internal static void TrackDamage(StatusEntity __instance, DamageStruct _dmgStruct)
{
//IL_0035: 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_0077: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)__instance.NC<StatusEntity>()?._isCreep))
{
return;
}
foreach (DungeonInstance dungeonInstance in Plugin.dungeonInstances)
{
try
{
MapInstance map = dungeonInstance.map;
StatusEntity obj = _dmgStruct._statusEntity.NC<StatusEntity>();
object obj2;
if (obj == null)
{
obj2 = null;
}
else
{
Player obj3 = obj._isPlayer.NC<Player>();
obj2 = ((obj3 != null) ? obj3.Network_playerMapInstance : null);
}
if ((Object)(object)map == (Object)obj2)
{
dungeonInstance.RecordDamage(_dmgStruct._statusEntity?._isPlayer, _dmgStruct._damageValue, (Object)(object)__instance._isCreep == (Object)(object)dungeonInstance.bossEntity);
break;
}
}
catch
{
}
}
}
[HarmonyPatch(typeof(MapInstance), "Apply_InstanceData")]
[HarmonyPostfix]
internal static void OnMapLoad(MapInstance __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)__instance._zoneType == 2 || PluginInfo.FIELDS_WITH_BOSSES.Contains(__instance._mapName))
{
DungeonInstance dungeonInstance = new DungeonInstance(__instance);
dungeonInstance.Update();
Plugin.dungeonInstances.Add(dungeonInstance);
}
else
{
Plugin.logger.LogInfo((object)(__instance._mapName + " not added to dungeon list."));
}
}
}