Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PartyPlus v1.8.0
PartyPlus.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using ModHub; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PartyPlus")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PartyPlus")] [assembly: AssemblyTitle("PartyPlus")] [assembly: AssemblyVersion("1.0.0.0")] [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 PartyPlus { public class PartyMember { public string Name; public bool Online; public bool HasBody; public Vector3 Pos; public Vector3 SmoothPos; public float Hp; public float MaxHp; } public class PartyPing { public string From; public string Label; public Vector3 Pos; public float Expire; } public static class PartyClient { public static readonly List<PartyMember> Members = new List<PartyMember>(); public static readonly List<PartyPing> Pings = new List<PartyPing>(); public static string InviteFrom; private static float _inviteTime; private static float _lastPing = -10f; private static int _mask; public static bool InParty => Members.Count > 0; private static int Mask { get { if (_mask == 0) { _mask = LayerMask.GetMask(new string[14] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle", "character", "character_net", "character_ghost", "character_noenv", "hitbox", "item", "Water" }); } return _mask; } } public static bool IsTeammate(Player p) { if ((Object)(object)p == (Object)null || (Object)(object)p == (Object)(object)Player.m_localPlayer || Members.Count == 0) { return false; } string playerName = p.GetPlayerName(); for (int i = 0; i < Members.Count; i++) { if (Members[i].Name == playerName) { return true; } } return false; } public static bool IsMe(PartyMember m) { return (Object)(object)Player.m_localPlayer != (Object)null && m.Name == Player.m_localPlayer.GetPlayerName(); } public static void Reset() { Members.Clear(); Pings.Clear(); InviteFrom = null; } public static void RPC_State(long sender, ZPackage pkg) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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) if (sender != PartyNet.ServerId) { return; } Dictionary<string, PartyMember> dictionary = new Dictionary<string, PartyMember>(); foreach (PartyMember member in Members) { dictionary[member.Name] = member; } Members.Clear(); int num = pkg.ReadInt(); for (int i = 0; i < num; i++) { PartyMember partyMember = new PartyMember { Name = pkg.ReadString(), Online = pkg.ReadBool(), HasBody = pkg.ReadBool(), Pos = pkg.ReadVector3(), Hp = pkg.ReadSingle(), MaxHp = pkg.ReadSingle() }; partyMember.SmoothPos = ((dictionary.TryGetValue(partyMember.Name, out var value) && value.HasBody && partyMember.HasBody) ? value.SmoothPos : partyMember.Pos); Members.Add(partyMember); } } public static void RPC_InviteReceived(long sender, string from) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (sender == PartyNet.ServerId) { InviteFrom = from; _inviteTime = Time.time; Show((MessageType)2, $"{from} приглашает тебя в пати\n[{PartyPlusPlugin.AcceptKey.Value}] принять [{PartyPlusPlugin.DeclineKey.Value}] отклонить"); } } public static void RPC_Message(long sender, string text) { if (sender == PartyNet.ServerId) { Show((MessageType)1, text); } } public static void RPC_PingShow(long sender, string from, Vector3 pos, string label) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (sender == PartyNet.ServerId) { Pings.RemoveAll((PartyPing p) => p.From == from); Pings.Add(new PartyPing { From = from, Label = label, Pos = pos, Expire = Time.time + PartyPlusPlugin.PingDuration.Value }); Show((MessageType)1, from + ": " + label); } } private static void Show(MessageType type, string text) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowMessage(type, text, 0, (Sprite)null, false, true); } } public static void Invite(string name) { PartyNet.ToServer("PartyPlus_Invite", name); } public static void AcceptInvite() { if (InviteFrom != null) { PartyNet.ToServer("PartyPlus_Accept"); InviteFrom = null; } } public static void DeclineInvite() { if (InviteFrom != null) { PartyNet.ToServer("PartyPlus_Decline"); InviteFrom = null; } } public static void LeaveParty() { PartyNet.ToServer("PartyPlus_Leave"); } public static void TryPing() { //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_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) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (!PartyPlusPlugin.PingsEnabled.Value || Time.time - _lastPing < 0.25f) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return; } float value = PartyPlusPlugin.PingMaxDistance.Value; Vector3 position = ((Component)main).transform.position; Vector3 forward = ((Component)main).transform.forward; RaycastHit[] array = Physics.RaycastAll(position, forward, value + 10f, Mask, (QueryTriggerInteraction)1); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; if (!((Object)(object)((RaycastHit)(ref val)).collider == (Object)null) && (!((Object)(object)Player.m_localPlayer != (Object)null) || !((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(((Component)Player.m_localPlayer).transform))) { Send(((RaycastHit)(ref val)).point, Describe(((RaycastHit)(ref val)).collider)); return; } } Show((MessageType)1, $"Слишком далеко для пинга (макс. {value:0} м)"); } private static void Send(Vector3 point, string label) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) _lastPing = Time.time; PartyNet.ToServer("PartyPlus_Ping", point, label); } private static string Describe(Collider c) { string text = null; Hoverable componentInParent = ((Component)c).GetComponentInParent<Hoverable>(); if (componentInParent != null) { try { text = componentInParent.GetHoverName(); } catch { } } if (string.IsNullOrWhiteSpace(text)) { return "Сюда"; } text = Localization.instance.Localize(text); text = Regex.Replace(text, "<.*?>", "").Trim(); Character componentInParent2 = ((Component)c).GetComponentInParent<Character>(); if ((Object)(object)componentInParent2 != (Object)null && !componentInParent2.IsPlayer() && !componentInParent2.IsTamed()) { text = "Враг: " + text; } return (text.Length > 40) ? text.Substring(0, 40) : text; } public static void Update(float dt) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; Pings.RemoveAll((PartyPing p) => p.Expire < now); if (InviteFrom != null && now - _inviteTime > PartyPlusPlugin.InviteTimeout.Value) { InviteFrom = null; } if (Members.Count == 0) { return; } List<Player> allPlayers = Player.GetAllPlayers(); foreach (PartyMember m in Members) { if (m.Online) { Player val = (Player)(IsMe(m) ? ((object)Player.m_localPlayer) : ((object)((IEnumerable<Player>)allPlayers).FirstOrDefault((Func<Player, bool>)((Player p) => (Object)(object)p != (Object)null && p.GetPlayerName() == m.Name)))); if ((Object)(object)val != (Object)null) { m.SmoothPos = ((Component)val).transform.position; m.Hp = ((Character)val).GetHealth(); m.MaxHp = ((Character)val).GetMaxHealth(); m.HasBody = !((Character)val).IsDead(); } else if (m.HasBody) { m.SmoothPos = Vector3.Lerp(m.SmoothPos, m.Pos, Mathf.Clamp01(dt * 6f)); } } } } } public static class PartyNet { public const string Invite = "PartyPlus_Invite"; public const string Accept = "PartyPlus_Accept"; public const string Decline = "PartyPlus_Decline"; public const string Leave = "PartyPlus_Leave"; public const string Ping = "PartyPlus_Ping"; public const string State = "PartyPlus_State"; public const string InviteReceived = "PartyPlus_InviteReceived"; public const string Message = "PartyPlus_Message"; public const string PingShow = "PartyPlus_PingShow"; public static bool Registered; public static long ServerId { get { if ((Object)(object)ZNet.instance == (Object)null) { return 0L; } if (ZNet.instance.IsServer()) { return ZNet.GetUID(); } return ZNet.instance.GetServerPeer()?.m_uid ?? 0; } } public static void Register() { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null && !((Object)(object)ZNet.instance == (Object)null)) { PartyServer.Reset(); PartyClient.Reset(); if (ZNet.instance.IsServer()) { PartyServer.Load(); instance.Register<string>("PartyPlus_Invite", (Action<long, string>)PartyServer.RPC_Invite); instance.Register("PartyPlus_Accept", (Action<long>)PartyServer.RPC_Accept); instance.Register("PartyPlus_Decline", (Action<long>)PartyServer.RPC_Decline); instance.Register("PartyPlus_Leave", (Action<long>)PartyServer.RPC_Leave); instance.Register<Vector3, string>("PartyPlus_Ping", (Action<long, Vector3, string>)PartyServer.RPC_Ping); } instance.Register<ZPackage>("PartyPlus_State", (Action<long, ZPackage>)PartyClient.RPC_State); instance.Register<string>("PartyPlus_InviteReceived", (Action<long, string>)PartyClient.RPC_InviteReceived); instance.Register<string>("PartyPlus_Message", (Action<long, string>)PartyClient.RPC_Message); instance.Register<string, Vector3, string>("PartyPlus_PingShow", (Action<long, string, Vector3, string>)PartyClient.RPC_PingShow); Registered = true; } } public static void ToServer(string method, params object[] args) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(ServerId, method, args); } } public static void ToPeer(long peer, string method, params object[] args) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(peer, method, args); } } } public static class PartyServer { private class Party { public readonly List<string> Members = new List<string>(); } private struct PendingInvite { public string From; public float Time; } private static readonly Dictionary<string, Party> PartyOf = new Dictionary<string, Party>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, PendingInvite> Invites = new Dictionary<string, PendingInvite>(StringComparer.OrdinalIgnoreCase); private static float _timer; private static string _savePath; private static int MaxSize => PartyPlusPlugin.MaxPartySize.Value; private static float Timeout => PartyPlusPlugin.InviteTimeout.Value; private static bool HostIsPlayer => (Object)(object)ZNet.instance != (Object)null && !ZNet.instance.IsDedicated(); public static void Reset() { PartyOf.Clear(); Invites.Clear(); _timer = 0f; _savePath = null; } public static void Load() { Reset(); try { string text = ZNet.instance.GetWorldName(); if (string.IsNullOrEmpty(text)) { text = "world"; } char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { text = text.Replace(oldChar, '_'); } string text2 = Path.Combine(Paths.ConfigPath, "PartyPlus"); Directory.CreateDirectory(text2); _savePath = Path.Combine(text2, "parties_" + text + ".txt"); if (!File.Exists(_savePath)) { return; } string[] array = File.ReadAllLines(_savePath, Encoding.UTF8); foreach (string text3 in array) { List<string> list = (from n in text3.Split('\t') select n.Trim() into n where n.Length > 0 select n).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList(); if (list.Count < 2) { continue; } Party party = new Party(); foreach (string item in list) { if (!PartyOf.ContainsKey(item)) { party.Members.Add(item); PartyOf[item] = party; } } if (party.Members.Count >= 2) { continue; } foreach (string member in party.Members) { PartyOf.Remove(member); } } Debug.Log((object)$"[PartyPlus] Загружено пати: {PartyOf.Values.Distinct().Count()}"); } catch (Exception ex) { Debug.LogWarning((object)("[PartyPlus] Не удалось загрузить пати: " + ex.Message)); } } private static void Save() { if (_savePath == null) { return; } try { IEnumerable<string> contents = from p in PartyOf.Values.Distinct() where p.Members.Count >= 2 select string.Join("\t", p.Members); File.WriteAllLines(_savePath, contents, Encoding.UTF8); } catch (Exception ex) { Debug.LogWarning((object)("[PartyPlus] Не удалось сохранить пати: " + ex.Message)); } } internal static string GetName(long uid) { if (HostIsPlayer && uid == ZNet.GetUID()) { object result; if (!((Object)(object)Game.instance != (Object)null)) { result = null; } else { PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); result = ((playerProfile != null) ? playerProfile.GetName() : null); } return (string)result; } ZNetPeer peer = ZNet.instance.GetPeer(uid); return (peer != null && peer.IsReady()) ? peer.m_playerName : null; } private static long FindByName(string name) { name = name?.Trim(); if (string.IsNullOrEmpty(name)) { return 0L; } if (HostIsPlayer && string.Equals(GetName(ZNet.GetUID()), name, StringComparison.OrdinalIgnoreCase)) { return ZNet.GetUID(); } foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { if (peer.IsReady() && string.Equals(peer.m_playerName, name, StringComparison.OrdinalIgnoreCase)) { return peer.m_uid; } } return 0L; } private static ZDOID GetCharacterId(long uid) { //IL_004f: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (HostIsPlayer && uid == ZNet.GetUID()) { return ((Object)(object)Player.m_localPlayer != (Object)null) ? ((Character)Player.m_localPlayer).GetZDOID() : ZDOID.None; } return ZNet.instance.GetPeer(uid)?.m_characterID ?? ZDOID.None; } private static void Msg(long uid, string text) { if (uid != 0) { PartyNet.ToPeer(uid, "PartyPlus_Message", text); } } private static void Msg(string name, string text) { Msg(FindByName(name), text); } private static void MsgParty(Party p, string text, string except = null) { foreach (string member in p.Members) { if (!string.Equals(member, except, StringComparison.OrdinalIgnoreCase)) { Msg(member, text); } } } public static void RPC_Invite(long sender, string targetName) { string name = GetName(sender); if (name == null) { return; } long num = FindByName(targetName); if (num == 0) { Msg(sender, "Игрок «" + targetName + "» не в сети"); return; } string name2 = GetName(num); if (!string.Equals(name2, name, StringComparison.OrdinalIgnoreCase)) { if (PartyOf.ContainsKey(name2)) { Msg(sender, name2 + " уже в пати"); return; } if (PartyOf.TryGetValue(name, out var value) && value.Members.Count >= MaxSize) { Msg(sender, "Пати заполнено"); return; } Invites[name2] = new PendingInvite { From = name, Time = Time.time }; PartyNet.ToPeer(num, "PartyPlus_InviteReceived", name); Msg(sender, "Приглашение отправлено: " + name2); } } public static void RPC_Accept(long sender) { string name = GetName(sender); if (name == null) { return; } if (!Invites.TryGetValue(name, out var value)) { Msg(sender, "Нет активных приглашений"); return; } Invites.Remove(name); if (Time.time - value.Time > Timeout) { Msg(sender, "Приглашение истекло"); return; } if (PartyOf.ContainsKey(name)) { RemoveMember(name, "перешёл в другое пати"); } if (!PartyOf.TryGetValue(value.From, out var value2)) { value2 = new Party(); value2.Members.Add(value.From); PartyOf[value.From] = value2; } if (value2.Members.Count >= MaxSize) { Msg(sender, "Пати уже заполнено"); if (value2.Members.Count < 2) { PartyOf.Remove(value.From); } } else { value2.Members.Add(name); PartyOf[name] = value2; Save(); MsgParty(value2, name + " вступил в пати"); SendState(value2); } } public static void RPC_Decline(long sender) { string name = GetName(sender); if (name != null && Invites.TryGetValue(name, out var value)) { Invites.Remove(name); Msg(value.From, name + " отклонил приглашение"); } } public static void RPC_Leave(long sender) { string name = GetName(sender); if (name != null) { if (PartyOf.ContainsKey(name)) { RemoveMember(name, "вышел из пати"); } else { Msg(sender, "Ты не в пати"); } } } public static void RPC_Ping(long sender, Vector3 pos, string label) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!PartyPlusPlugin.PingsEnabled.Value) { return; } string name = GetName(sender); if (name == null) { return; } label = label ?? ""; if (label.Length > 48) { label = label.Substring(0, 48); } if (PartyOf.TryGetValue(name, out var value)) { foreach (string member in value.Members) { long num = FindByName(member); if (num != 0) { PartyNet.ToPeer(num, "PartyPlus_PingShow", name, pos, label); } } return; } PartyNet.ToPeer(sender, "PartyPlus_PingShow", name, pos, label); } private static void RemoveMember(string name, string reason) { if (!PartyOf.TryGetValue(name, out var value)) { return; } string text = value.Members.FirstOrDefault((string m) => string.Equals(m, name, StringComparison.OrdinalIgnoreCase)) ?? name; value.Members.Remove(text); PartyOf.Remove(name); SendEmpty(name); if (value.Members.Count <= 1) { foreach (string member in value.Members) { PartyOf.Remove(member); Msg(member, text + " " + reason + ". Пати распущено"); SendEmpty(member); } value.Members.Clear(); } else { MsgParty(value, text + " " + reason); SendState(value); } Save(); } public static void Tick(float dt) { _timer += dt; if (_timer < Mathf.Max(0.1f, PartyPlusPlugin.SyncInterval.Value)) { return; } _timer = 0f; foreach (string item in (from kv in Invites where Time.time - kv.Value.Time > Timeout select kv.Key).ToList()) { Invites.Remove(item); } foreach (Party item2 in PartyOf.Values.Distinct().ToList()) { SendState(item2); } } private static void SendEmpty(string name) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown long num = FindByName(name); if (num != 0) { ZPackage val = new ZPackage(); val.Write(0); PartyNet.ToPeer(num, "PartyPlus_State", val); } } private static void SendState(Party p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_005d: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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) List<long> list = new List<long>(); ZPackage val = new ZPackage(); val.Write(p.Members.Count); foreach (string member in p.Members) { long num = FindByName(member); ZDO val2 = null; if (num != 0) { list.Add(num); ZDOID characterId = GetCharacterId(num); val2 = (((ZDOID)(ref characterId)).IsNone() ? null : ZDOMan.instance.GetZDO(characterId)); } val.Write(member); val.Write(num != 0); val.Write(val2 != null); val.Write((val2 != null) ? val2.GetPosition() : Vector3.zero); val.Write((val2 != null) ? val2.GetFloat("health", 0f) : 0f); val.Write((val2 != null) ? val2.GetFloat("max_health", 25f) : 25f); } foreach (long item in list) { PartyNet.ToPeer(item, "PartyPlus_State", val); } } } public class PartyUI : MonoBehaviour { private const string HubId = "partyplus"; private static bool _menuOpen; private const float MenuW = 540f; private const float MenuH = 760f; private Vector2 _scroll; private const float CardW = 220f; private const float CardH = 50f; private const float CardGap = 6f; private static GUIStyle _plateName; private static GUIStyle _plateDistance; private static GUIStyle _centerSmall; private bool _dragging; private Vector2 _dragOffset; private Vector2 _dragPos; private static GUIStyle _h; private static GUIStyle _l; private static GUIStyle _d; private static bool _serverDirty; private static readonly Color[] Palette = (Color[])(object)new Color[8] { new Color(0.72f, 0.88f, 0.95f), new Color(0.95f, 0.3f, 0.22f), new Color(0.45f, 0.85f, 0.4f), new Color(0.98f, 0.82f, 0.3f), new Color(0.98f, 0.55f, 0.2f), new Color(0.7f, 0.5f, 0.95f), new Color(0.95f, 0.5f, 0.75f), new Color(0.92f, 0.92f, 0.92f) }; public static bool MenuOpen { get { return _menuOpen; } set { if (_menuOpen != value) { _menuOpen = value; ModHubAPI.SetInputBlock("partyplus", value); if (!value && _serverDirty) { SyncServerConfig(); } } } } private static bool CanMoveHud => !PartyPlusPlugin.HudLocked.Value && Cursor.visible; private static GUIStyle PlateName { get { //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_0026: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (_plateName == null) { _plateName = new GUIStyle(ValheimTheme.NameTag) { fontSize = 17 }; _plateName.normal.textColor = new Color(0.93f, 0.93f, 0.9f); } return _plateName; } } private static GUIStyle PlateDistance { get { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) int value = PartyPlusPlugin.DistanceFontSize.Value; if (_plateDistance == null || _plateDistance.fontSize != value) { _plateDistance = new GUIStyle(ValheimTheme.NameTag) { fontSize = value, fontStyle = (FontStyle)1 }; _plateDistance.normal.textColor = new Color(1f, 0.9f, 0.62f); } return _plateDistance; } } private static GUIStyle CenterSmall { get { //IL_000e: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown object obj = _centerSmall; if (obj == null) { GUIStyle val = new GUIStyle(ValheimTheme.LabelSmall) { alignment = (TextAnchor)4 }; _centerSmall = val; obj = (object)val; } return (GUIStyle)obj; } } private static GUIStyle H => _h ?? (_h = HubUI.HeaderStyle); private static GUIStyle L => _l ?? (_l = HubUI.NoWrap(HubUI.LabelStyle)); private static GUIStyle D => _d ?? (_d = HubUI.LabelDimStyle); private static GUIStyle B => HubUI.ButtonStyle; public static void OpenMenu() { if (!((Object)(object)ZNet.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && PartyNet.Registered) { MenuOpen = true; } } private void Update() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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) if ((Object)(object)ZNet.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || !PartyNet.Registered) { MenuOpen = false; return; } PartyClient.Update(Time.deltaTime); if (IsTyping()) { return; } if (MenuOpen && UnityInput.Current.GetKeyDown((KeyCode)27)) { MenuOpen = false; } if (MenuOpen) { return; } if (PartyClient.InviteFrom != null) { if (Pressed(PartyPlusPlugin.AcceptKey.Value)) { PartyClient.AcceptInvite(); } else if (Pressed(PartyPlusPlugin.DeclineKey.Value)) { PartyClient.DeclineInvite(); } } if (Pressed(PartyPlusPlugin.PingKey.Value) && CanPing()) { PartyClient.TryPing(); } } private static bool Pressed(KeyboardShortcut k) { //IL_0003: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref k)).MainKey == 0 || !UnityInput.Current.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers) { if (!UnityInput.Current.GetKey(modifier)) { return false; } } return true; } private static bool IsTyping() { return ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || Console.IsVisible() || TextInput.IsVisible() || Menu.IsVisible(); } private static bool CanPing() { return !InventoryGui.IsVisible() && !Minimap.IsOpen() && !StoreGui.IsVisible(); } private void OnGUI() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00e1: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ZNet.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && PartyNet.Registered) { ValheimTheme.Init(); float num = Mathf.Clamp(PartyPlusPlugin.UiScale.Value, 0.5f, 3f); GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f)); Camera main = Camera.main; if ((Object)(object)main != (Object)null) { DrawNameplates(main, num); DrawPings(main, num); } if (PartyPlusPlugin.ShowHud.Value && (PartyClient.InParty || CanMoveHud)) { DrawHud(num); } if (PartyClient.InviteFrom != null && !MenuOpen) { DrawInviteBanner(num); } GUI.matrix = Matrix4x4.identity; if (MenuOpen) { DrawMenu(); } } } private void DrawNameplates(Camera cam, float s) { //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_0077: 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_00a4: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) if (!PartyPlusPlugin.NameplatesEnabled.Value) { return; } float value = PartyPlusPlugin.NameplateMaxDistance.Value; Vector3 position = ((Component)Player.m_localPlayer).transform.position; foreach (PartyMember member in PartyClient.Members) { if (PartyClient.IsMe(member) || !member.Online || !member.HasBody) { continue; } float num = Vector3.Distance(position, member.SmoothPos); if (!(value > 0f) || !(num > value)) { Vector3 val = cam.WorldToScreenPoint(member.SmoothPos + Vector3.up * 2.3f); if (!(val.z <= 0f)) { float num2 = val.x / s; float num3 = ((float)Screen.height - val.y) / s; ValheimTheme.OutlineLabel(new Rect(num2 - 120f, num3 - 48f, 240f, 22f), member.Name, PlateName); ValheimTheme.DrawHpBar(new Rect(num2 - 55f, num3 - 24f, 110f, 11f), member.Hp, member.MaxHp, withText: false); ValheimTheme.OutlineLabel(new Rect(num2 - 80f, num3 - 13f, 160f, (float)(PlateDistance.fontSize + 6)), $"{num:0} м", PlateDistance, 2); } } } } private void DrawPings(Camera cam, float s) { //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_005d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_00a4: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) if (PartyClient.Pings.Count == 0) { return; } Vector3 position = ((Component)Player.m_localPlayer).transform.position; float num = Mathf.Clamp(PartyPlusPlugin.PingScale.Value, 0.3f, 2f); float num2 = Mathf.Clamp(PartyPlusPlugin.PingOpacity.Value, 0.1f, 1f); Matrix4x4 matrix = GUI.matrix; Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, num2); Rect r = default(Rect); foreach (PartyPing ping in PartyClient.Pings) { Vector3 val = cam.WorldToScreenPoint(ping.Pos + Vector3.up * 0.5f); if (val.z < 0f) { val.x = (float)Screen.width - val.x; val.y = 0f; } val.x = Mathf.Clamp(val.x, 90f * num, (float)Screen.width - 90f * num); val.y = Mathf.Clamp(val.y, 60f * num, (float)Screen.height - 60f * num); float num3 = val.x / s; float num4 = ((float)Screen.height - val.y) / s; float num5 = Vector3.Distance(position, ping.Pos); GUI.matrix = matrix; GUIUtility.ScaleAroundPivot(new Vector2(num, num), new Vector2(num3 * s, num4 * s)); ValheimTheme.ShadowLabel(new Rect(num3 - 20f, num4 - 34f, 40f, 34f), "▼", ValheimTheme.PingIcon); ((Rect)(ref r))..ctor(num3 - 110f, num4 + 2f, 220f, 26f); ValheimTheme.DrawPanel(r); ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 4f, ((Rect)(ref r)).width, 18f), "<color=#" + ValheimTheme.Hex(ValheimTheme.GoldBright) + ">" + ping.From + "</color>: " + ping.Label, ValheimTheme.NameTag); ValheimTheme.OutlineLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax + 1f, ((Rect)(ref r)).width, (float)(PlateDistance.fontSize + 6)), $"{num5:0} м", PlateDistance, 2); } GUI.matrix = matrix; GUI.color = color; } private void DrawHud(float s) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: 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) List<PartyMember> list = PartyClient.Members.Where((PartyMember m) => !PartyClient.IsMe(m)).ToList(); bool canMoveHud = CanMoveHud; float num = (_dragging ? _dragPos.x : PartyPlusPlugin.HudX.Value); float num2 = (_dragging ? _dragPos.y : PartyPlusPlugin.HudY.Value); int num3 = Mathf.Max(1, list.Count); Rect area = default(Rect); ((Rect)(ref area))..ctor(num, num2, 220f, (float)num3 * 56f - 6f); if (canMoveHud) { GUI.DrawTexture(new Rect(((Rect)(ref area)).x - 3f, ((Rect)(ref area)).y - 3f, ((Rect)(ref area)).width + 6f, ((Rect)(ref area)).height + 6f), (Texture)(object)ValheimTheme.Divider); HandleDrag(area, s); } else if (_dragging) { FinishDrag(); } if (list.Count == 0) { Rect r = default(Rect); ((Rect)(ref r))..ctor(num, num2, 220f, 50f); ValheimTheme.DrawPanel(r); ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 15f, ((Rect)(ref r)).width, 20f), "Панель пати — тащи мышью", ValheimTheme.NameTag); return; } Rect r2 = default(Rect); foreach (PartyMember item in list) { ((Rect)(ref r2))..ctor(num, num2, 220f, 50f); ValheimTheme.DrawPanel(r2); if (!item.Online) { ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 6f, ((Rect)(ref r2)).width - 20f, 20f), item.Name, Dim(ValheimTheme.Title)); ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 26f, ((Rect)(ref r2)).width - 20f, 18f), "не в сети", ValheimTheme.LabelSmall); } else if (!item.HasBody) { ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 6f, ((Rect)(ref r2)).width - 20f, 20f), item.Name, ValheimTheme.Title); ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 26f, ((Rect)(ref r2)).width - 20f, 18f), "<color=#" + ValheimTheme.Hex(ValheimTheme.Danger) + ">мёртв</color>", ValheimTheme.Label); } else { ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 5f, ((Rect)(ref r2)).width - 20f, 20f), item.Name, ValheimTheme.Title); ValheimTheme.DrawHpBar(new Rect(((Rect)(ref r2)).x + 10f, ((Rect)(ref r2)).y + 27f, ((Rect)(ref r2)).width - 20f, 15f), item.Hp, item.MaxHp, withText: true); } num2 += 56f; } } private static GUIStyle Dim(GUIStyle st) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) GUIStyle val = new GUIStyle(st); val.normal.textColor = ValheimTheme.TextDim; return val; } private void HandleDrag(Rect area, float s) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_005e: 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_007f: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00dc: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 Event current = Event.current; if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref area)).Contains(current.mousePosition)) { _dragging = true; _dragPos = new Vector2(((Rect)(ref area)).x, ((Rect)(ref area)).y); _dragOffset = current.mousePosition - _dragPos; current.Use(); } else if (_dragging && (int)current.type == 3) { Vector2 val = current.mousePosition - _dragOffset; _dragPos = new Vector2(Mathf.Clamp(val.x, 0f, (float)Screen.width / s - ((Rect)(ref area)).width), Mathf.Clamp(val.y, 0f, (float)Screen.height / s - ((Rect)(ref area)).height)); current.Use(); } else if (_dragging && (int)current.rawType == 1) { FinishDrag(); current.Use(); } } private void FinishDrag() { _dragging = false; PartyPlusPlugin.HudX.Value = Mathf.Round(_dragPos.x); PartyPlusPlugin.HudY.Value = Mathf.Round(_dragPos.y); } private void DrawInviteBanner(float s) { //IL_0029: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ae: Expected O, but got Unknown //IL_00c8: 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_00e6: 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) float num = 480f; Rect r = default(Rect); ((Rect)(ref r))..ctor(((float)Screen.width / s - num) / 2f, 90f, num, 62f); ValheimTheme.DrawPanel(r); ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 8f, num, 22f), "<color=#" + ValheimTheme.Hex(ValheimTheme.GoldBright) + ">" + PartyClient.InviteFrom + "</color> приглашает тебя в пати", ValheimTheme.NameTag); GUIStyle style = new GUIStyle(ValheimTheme.Label) { alignment = (TextAnchor)4, fontSize = 13 }; ValheimTheme.ShadowLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 34f, num, 20f), $"[{PartyPlusPlugin.AcceptKey.Value}] принять [{PartyPlusPlugin.DeclineKey.Value}] отклонить [{ModHubAPI.HubKey}] меню", style); } private void DrawMenu() { //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_0008: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0037: 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_00e0: 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) //IL_00ff: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) Vector2 val = HubUI.BeginScaled(); try { Rect val2 = HubUI.Centered(val, 540f, Mathf.Min(760f, val.y - 40f)); HubUI.Window(val2, "Party", false); if (HubUI.CloseButton(val2)) { MenuOpen = false; return; } if (GUI.Button(new Rect(((Rect)(ref val2)).x + 22f, ((Rect)(ref val2)).y + 22f, 30f, 30f), "<", B)) { MenuOpen = false; ModHubAPI.OpenHub(); return; } Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 36f, ((Rect)(ref val2)).y + 86f, ((Rect)(ref val2)).width - 72f, ((Rect)(ref val2)).height - 86f - 62f); GUILayout.BeginArea(val3); _scroll = GUILayout.BeginScrollView(_scroll, false, false, GUIStyle.none, GUIStyle.none, Array.Empty<GUILayoutOption>()); DrawMenuContent(); GUILayout.EndScrollView(); GUILayout.EndArea(); GUI.Label(new Rect(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).yMax - 46f, ((Rect)(ref val2)).width - 48f, 22f), $"[{ModHubAPI.HubKey}] / Esc — закрыть · колесо мыши — прокрутка", HubUI.LabelCenterStyle); } finally { HubUI.EndScaled(); } } private void DrawMenuContent() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_05eb: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) if (PartyClient.InviteFrom != null) { GUILayout.Label("Приглашение от <color=#" + ValheimTheme.Hex(ValheimTheme.GoldBright) + ">" + PartyClient.InviteFrom + "</color>", H, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Принять", B, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { PartyClient.AcceptInvite(); } if (GUILayout.Button("Отклонить", B, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { PartyClient.DeclineInvite(); } GUILayout.EndHorizontal(); Section(); } GUILayout.Label("Твоё пати", H, Array.Empty<GUILayoutOption>()); if (!PartyClient.InParty) { GUILayout.Label("Ты не в пати. Пригласи кого-нибудь ниже.", D, Array.Empty<GUILayoutOption>()); } else { foreach (PartyMember member in PartyClient.Members) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string text = (PartyClient.IsMe(member) ? (" <color=#" + ValheimTheme.Hex(ValheimTheme.TextDim) + ">(ты)</color>") : ""); GUILayout.Label(member.Name + text, L, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); string text2 = ((!member.Online) ? ("<color=#" + ValheimTheme.Hex(ValheimTheme.TextDim) + ">не в сети</color>") : ((!member.HasBody) ? ("<color=#" + ValheimTheme.Hex(ValheimTheme.Danger) + ">мёртв</color>") : $"{Mathf.CeilToInt(member.Hp)} / {Mathf.CeilToInt(member.MaxHp)}")); GUILayout.Label(text2, L, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); } GUILayout.Space(4f); if (GUILayout.Button("Покинуть пати", B, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { PartyClient.LeaveParty(); } } Section(); GUILayout.Label("Игроки на сервере", H, Array.Empty<GUILayoutOption>()); string playerName = Player.m_localPlayer.GetPlayerName(); List<string> list = PartyClient.Members.Select((PartyMember m) => m.Name).ToList(); int num = 0; foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { if (!(player.m_name == playerName) && !list.Contains(player.m_name)) { num++; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(player.m_name, L, Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (GUILayout.Button("Пригласить", B, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(140f), GUILayout.Height(30f) })) { PartyClient.Invite(player.m_name); } GUILayout.EndHorizontal(); } } if (num == 0) { GUILayout.Label("Больше никого нет", D, Array.Empty<GUILayoutOption>()); } Section(); GUILayout.Label("Интерфейс", H, Array.Empty<GUILayoutOption>()); bool flag = HubUI.LayoutToggle(PartyPlusPlugin.HudLocked.Value, "Закрепить панель пати на месте", 28f); if (flag != PartyPlusPlugin.HudLocked.Value) { PartyPlusPlugin.HudLocked.Value = flag; } if (!flag) { GUILayout.Label("<color=#" + ValheimTheme.Hex(ValheimTheme.GoldBright) + ">Перетащи панель мышью, потом поставь галочку обратно.</color>", D, Array.Empty<GUILayoutOption>()); } GUILayout.Space(6f); Slider("Размер пинга", PartyPlusPlugin.PingScale, 0.3f, 2f, (float v) => $"{v * 100f:0}%"); Slider("Прозрачность пинга", PartyPlusPlugin.PingOpacity, 0.1f, 1f, (float v) => $"{(1f - v) * 100f:0}%", inverted: true); GUILayout.Space(4f); if (GUILayout.Button("Сбросить позицию панели", B, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) })) { PartyPlusPlugin.HudX.Value = (float)((ConfigEntryBase)PartyPlusPlugin.HudX).DefaultValue; PartyPlusPlugin.HudY.Value = (float)((ConfigEntryBase)PartyPlusPlugin.HudY).DefaultValue; } Section(); GUILayout.Label("Цвет полосы HP", H, Array.Empty<GUILayoutOption>()); ColorPicker(PartyPlusPlugin.HpColor); GUILayout.Space(6f); GUILayout.Label("При малом здоровье", L, Array.Empty<GUILayoutOption>()); ColorPicker(PartyPlusPlugin.HpLowColor); Slider("Порог малого HP", PartyPlusPlugin.HpLowThreshold, 0f, 0.9f, (float v) => (v <= 0f) ? "выкл" : $"{v * 100f:0}%"); GUILayout.Space(4f); Rect rect = GUILayoutUtility.GetRect(200f, 16f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width / 2f - 4f, 14f); ValheimTheme.DrawHpBar(r, 80f, 100f, withText: false); ValheimTheme.DrawHpBar(new Rect(((Rect)(ref r)).xMax + 8f, ((Rect)(ref rect)).y, ((Rect)(ref r)).width, 14f), 15f, 100f, withText: false); GUILayout.Space(6f); Section(); GUILayout.Label("Обводка тиммейтов сквозь стены", H, Array.Empty<GUILayoutOption>()); if (!PartyPlusPlugin.OutlineAllowed.Value) { GUILayout.Label("Выключена админом сервера", D, Array.Empty<GUILayoutOption>()); } else { bool flag2 = HubUI.LayoutToggle(PartyPlusPlugin.OutlineEnabled.Value, "Включить обводку", 28f); if (flag2 != PartyPlusPlugin.OutlineEnabled.Value) { PartyPlusPlugin.OutlineEnabled.Value = flag2; } if (flag2) { ColorPicker(PartyPlusPlugin.OutlineColor); Slider("Яркость", PartyPlusPlugin.OutlineOpacity, 0.1f, 1f, (float v) => $"{v * 100f:0}%"); Slider("Дальность", PartyPlusPlugin.OutlineMaxDistance, 0f, 500f, (float v) => (v <= 0f) ? "без огр." : $"{v:0} м", inverted: false, 10f); } } Section(); DrawServerSettings(); GUILayout.Space(10f); } private static bool CanEditServer() { if ((Object)(object)ZNet.instance == (Object)null) { return false; } if (ZNet.instance.IsServer()) { return true; } try { return SynchronizationManager.Instance.PlayerIsAdmin; } catch { return false; } } private static void DrawServerSettings() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("Сервер", H, Array.Empty<GUILayoutOption>()); bool flag = CanEditServer(); GUILayout.Label(flag ? "Ты админ — изменения разойдутся всем игрокам, когда закроешь меню." : ("<color=#" + ValheimTheme.Hex(ValheimTheme.Danger) + ">Менять может только админ сервера.</color>"), D, Array.Empty<GUILayoutOption>()); GUILayout.Space(4f); bool enabled = GUI.enabled; GUI.enabled = enabled && flag; Rect rect = GUILayoutUtility.GetRect(100f, 30f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); int value = (int)HubUI.Stepper(rect, "Размер пати", (float)PartyPlusPlugin.MaxPartySize.Value, 1f, 2f, 10f, "0"); if (GUI.enabled) { ServerSet(PartyPlusPlugin.MaxPartySize, value); } GUILayout.Space(6f); ServerSlider("Время приглашения", PartyPlusPlugin.InviteTimeout, 5f, 300f, (float v) => $"{v:0} с", 5f); ServerSlider("Частота обновления", PartyPlusPlugin.SyncInterval, 0.1f, 5f, (float v) => $"{v:0.0} с", 0.1f); ServerToggle("Пинги включены", PartyPlusPlugin.PingsEnabled); ServerSlider("Длительность пинга", PartyPlusPlugin.PingDuration, 1f, 60f, (float v) => $"{v:0} с", 1f); ServerSlider("Дальность пинга", PartyPlusPlugin.PingMaxDistance, 10f, 500f, (float v) => $"{v:0} м", 10f); ServerToggle("Ники над тиммейтами", PartyPlusPlugin.NameplatesEnabled); ServerSlider("Дальность ников", PartyPlusPlugin.NameplateMaxDistance, 0f, 10000f, (float v) => (v <= 0f) ? "без огр." : $"{v:0} м", 50f); ServerToggle("Разрешить обводку тиммейтов", PartyPlusPlugin.OutlineAllowed); GUI.enabled = enabled && flag && _serverDirty; GUILayout.Space(6f); if (GUILayout.Button(_serverDirty ? "Отправить на сервер *" : "Отправить на сервер", B, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) })) { SyncServerConfig(); } GUI.enabled = enabled; } private static void ServerSlider(string title, ConfigEntry<float> entry, float min, float max, Func<float, string> format, float step) { if (!GUI.enabled) { HubUI.LayoutSlider(title, entry.Value, min, max, format(entry.Value), 30f, -1f); return; } float value = entry.Value; Slider(title, entry, min, max, format, inverted: false, step); if (!Mathf.Approximately(value, entry.Value)) { _serverDirty = true; } } private static void ServerToggle(string title, ConfigEntry<bool> entry) { bool flag = HubUI.LayoutToggle(entry.Value, title, 28f); if (flag != entry.Value) { entry.Value = flag; _serverDirty = true; } } private static void ServerSet(ConfigEntry<int> entry, int value) { if (value != entry.Value) { entry.Value = value; _serverDirty = true; } } private static void SyncServerConfig() { _serverDirty = false; try { SynchronizationManager instance = SynchronizationManager.Instance; MethodInfo methodInfo = AccessTools.Method(((object)instance).GetType(), "SynchronizeChangedConfig", (Type[])null, (Type[])null); if (methodInfo != null) { methodInfo.Invoke(instance, null); } else { Debug.LogWarning((object)"[PartyPlus] Jotunn SynchronizeChangedConfig not found — server settings will sync on reconnect."); } } catch (Exception ex) { Debug.LogWarning((object)("[PartyPlus] Server config sync failed: " + ex.Message)); } } private static void Slider(string title, ConfigEntry<float> entry, float min, float max, Func<float, string> format, bool inverted = false, float step = 0.05f) { float num = (inverted ? (max + min - entry.Value) : entry.Value); float num2 = HubUI.LayoutSlider(title, num, min, max, format(entry.Value), 30f, -1f); if (inverted) { num2 = max + min - num2; } num2 = Mathf.Round(num2 / step) * step; if (Mathf.Abs(num2 - entry.Value) > 0.001f) { entry.Value = num2; } } private static void ColorPicker(ConfigEntry<Color> entry) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0057: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0132: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Color[] palette = Palette; foreach (Color val in palette) { Rect rect = GUILayoutUtility.GetRect(40f, 22f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(40f), GUILayout.Height(22f) }); ValheimTheme.DrawSwatch(rect, val); if (Mathf.Abs(val.r - entry.Value.r) + Mathf.Abs(val.g - entry.Value.g) + Mathf.Abs(val.b - entry.Value.b) < 0.02f) { GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 4f, ((Rect)(ref rect)).yMax + 1f, ((Rect)(ref rect)).width - 8f, 2f), (Texture)(object)ValheimTheme.Divider); } if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { entry.Value = new Color(val.r, val.g, val.b, entry.Value.a); } } GUILayout.EndHorizontal(); Color value = entry.Value; float num = ColorChannel("R", value.r); float num2 = ColorChannel("G", value.g); float num3 = ColorChannel("B", value.b); if (Mathf.Abs(num - value.r) + Mathf.Abs(num2 - value.g) + Mathf.Abs(num3 - value.b) > 0.001f) { entry.Value = new Color(num, num2, num3, value.a); } } private static float ColorChannel(string name, float value) { float num = HubUI.LayoutSlider(name, value, 0f, 1f, Mathf.RoundToInt(value * 255f).ToString(), 24f, 24f); return Mathf.Round(num * 255f) / 255f; } private static void Section() { HubUI.LayoutDivider(10f); } } [BepInPlugin("com.yourname.partyplus", "PartyPlus", "1.8.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class PartyPlusPlugin : BaseUnityPlugin { public const string ModGuid = "com.yourname.partyplus"; public const string ModName = "PartyPlus"; public const string ModVersion = "1.8.0"; public static ConfigEntry<int> MaxPartySize; public static ConfigEntry<float> SyncInterval; public static ConfigEntry<float> InviteTimeout; public static ConfigEntry<bool> PingsEnabled; public static ConfigEntry<float> PingDuration; public static ConfigEntry<float> PingMaxDistance; public static ConfigEntry<bool> NameplatesEnabled; public static ConfigEntry<float> NameplateMaxDistance; public static ConfigEntry<bool> OutlineAllowed; public static ConfigEntry<KeyboardShortcut> PingKey; public static ConfigEntry<KeyboardShortcut> AcceptKey; public static ConfigEntry<KeyboardShortcut> DeclineKey; public static ConfigEntry<bool> ShowHud; public static ConfigEntry<bool> HudLocked; public static ConfigEntry<float> HudX; public static ConfigEntry<float> HudY; public static ConfigEntry<float> UiScale; public static ConfigEntry<bool> UseGameFont; public static ConfigEntry<bool> HideVanillaBars; public static ConfigEntry<int> DistanceFontSize; public static ConfigEntry<bool> OutlineEnabled; public static ConfigEntry<Color> OutlineColor; public static ConfigEntry<float> OutlineOpacity; public static ConfigEntry<float> OutlineMaxDistance; public static ConfigEntry<float> PingScale; public static ConfigEntry<float> PingOpacity; public static ConfigEntry<Color> HpColor; public static ConfigEntry<Color> HpLowColor; public static ConfigEntry<float> HpLowThreshold; private Harmony _harmony; private void Awake() { //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Expected O, but got Unknown //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Expected O, but got Unknown //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Expected O, but got Unknown //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Expected O, but got Unknown //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) MaxPartySize = ((BaseUnityPlugin)this).Config.Bind<int>("1 - Сервер", "Максимальный размер пати", 5, Admin("Сколько игроков может быть в одном пати.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10))); SyncInterval = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Сервер", "Частота обновления", 0.5f, Admin("Как часто (в секундах) сервер рассылает позиции и HP тиммейтов.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f))); InviteTimeout = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Сервер", "Время жизни приглашения", 30f, Admin("Через сколько секунд приглашение в пати сгорает.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 300f))); PingsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Сервер", "Пинги включены", true, Admin("Разрешить пинги для пати.")); PingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Сервер", "Длительность пинга", 8f, Admin("Сколько секунд пинг висит в мире.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f))); PingMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Сервер", "Дальность пинга", 150f, Admin("Максимальная дальность луча пинга в метрах.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 500f))); NameplatesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Сервер", "Ники над тиммейтами", true, Admin("Показывать ник, HP и дистанцию над тиммейтами (видно сквозь стены).")); NameplateMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("1 - Сервер", "Дальность ников", 0f, Admin("С какой максимальной дистанции видно ник тиммейта. 0 = без ограничений.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10000f))); OutlineAllowed = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - Сервер", "Обводка тиммейтов разрешена", true, Admin("Разрешить игрокам подсвечивать тиммейтов сквозь стены. Если выключено — обводки не будет ни у кого.")); PingKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("2 - Клиент", "Клавиша пинга", new KeyboardShortcut((KeyCode)325, Array.Empty<KeyCode>()), "Поставить пинг туда, куда смотришь (по умолчанию колёсико мыши)."); AcceptKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("2 - Клиент", "Принять приглашение", new KeyboardShortcut((KeyCode)121, Array.Empty<KeyCode>()), "Быстро принять приглашение в пати."); DeclineKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("2 - Клиент", "Отклонить приглашение", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), "Быстро отклонить приглашение в пати."); ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Клиент", "Показывать HUD пати", true, "Панель с никами и HP тиммейтов."); HudLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Клиент", "HUD заблокирован", true, "true = панель пати закреплена на месте. false = свободное перемещение: открой меню пати (или инвентарь) и перетащи панель мышью. Позиция сохраняется сама."); HudX = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "HUD позиция X", 20f, "Отступ панели пати слева (пиксели)."); HudY = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "HUD позиция Y", 260f, "Отступ панели пати сверху (пиксели)."); PingScale = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Размер пинга", 1f, new ConfigDescription("Размер метки пинга на экране (1 = обычный, 0.5 = в два раза меньше).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 2f), Array.Empty<object>())); PingOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Прозрачность пинга", 1f, new ConfigDescription("Непрозрачность метки пинга (1 = полностью видна, 0.2 = почти прозрачная).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); HpColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Клиент", "Цвет полосы HP", new Color(0.72f, 0.88f, 0.95f, 1f), "Цвет полосы здоровья тиммейтов (HEX, например B8E0F2FF). Меняется и в меню пати."); HpLowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Клиент", "Цвет HP при малом здоровье", new Color(0.95f, 0.3f, 0.22f, 1f), "Цвет полосы, когда у тиммейта мало здоровья."); HpLowThreshold = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Порог малого здоровья", 0.3f, new ConfigDescription("При какой доле HP полоса меняет цвет (0.3 = 30%). 0 = никогда.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); HideVanillaBars = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Клиент", "Заменять стандартную полосу над тиммейтами", true, "Убирает ванильную полосу HP над игроками из твоего пати — вместо неё рисуется полоса PartyPlus (ник, HP, дистанция). У мобов и чужих игроков всё как было."); DistanceFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("2 - Клиент", "Размер текста дистанции", 17, new ConfigDescription("Размер цифры расстояния до тиммейта и до пинга.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 32), Array.Empty<object>())); OutlineEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Клиент", "Обводка тиммейтов", true, "Подсвечивать силуэт тиммейта, когда он за стеной, деревом или горой."); OutlineColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2 - Клиент", "Цвет обводки", new Color(0.35f, 0.85f, 1f, 1f), "Цвет силуэта тиммейта сквозь стены (HEX). Меняется и в меню пати."); OutlineOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Непрозрачность обводки", 0.55f, new ConfigDescription("Насколько яркий силуэт (1 = сплошной, 0.2 = еле видно).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); OutlineMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Дальность обводки", 100f, new ConfigDescription("До какого расстояния (м) подсвечивать тиммейтов. 0 = без ограничений.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); UseGameFont = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Клиент", "Шрифт игры", true, "Использовать шрифт Valheim. Если вместо русских букв квадратики — выключи. Применяется после перезапуска."); UiScale = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Клиент", "Масштаб интерфейса", 1f, new ConfigDescription("Масштаб всего интерфейса мода.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); _harmony = new Harmony("com.yourname.partyplus"); _harmony.PatchAll(); ((Component)this).gameObject.AddComponent<PartyUI>(); ModHubAPI.Register("partyplus", "Party", (Action)PartyUI.OpenMenu, (string)null, (Sprite)null, (Color?)Color32.op_Implicit(new Color32((byte)110, (byte)160, (byte)100, byte.MaxValue)), "Пати, приглашения, HUD и пинги", 30, (Func<bool>)(() => PartyNet.Registered), (Action)delegate { PartyUI.MenuOpen = false; }, (Func<bool>)(() => PartyUI.MenuOpen)); ((Component)this).gameObject.AddComponent<TeammateOutline>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PartyPlus 1.8.0 загружен"); } private void Update() { if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null) { PartyNet.Registered = false; } else if (PartyNet.Registered && ZNet.instance.IsServer()) { PartyServer.Tick(Time.deltaTime); } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private static ConfigDescription Admin(string desc, AcceptableValueBase range = null) { //IL_000a: 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_0018: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown return new ConfigDescription(desc, range, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } }); } } [HarmonyPatch(typeof(Game), "Start")] internal static class Game_Start_Patch { private static void Postfix() { PartyNet.Register(); } } public class TeammateOutline : MonoBehaviour { private Material _mat; private bool _shaderMissing; private float _timer; private readonly Dictionary<Player, List<Renderer>> _applied = new Dictionary<Player, List<Renderer>>(); private bool Active => PartyPlusPlugin.OutlineAllowed.Value && PartyPlusPlugin.OutlineEnabled.Value && PartyClient.InParty; private void Update() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00b0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null) { if (_applied.Count > 0) { RemoveAll(); } } else if (!Active) { if (_applied.Count > 0) { RemoveAll(); } } else if (EnsureMaterial()) { Color value = PartyPlusPlugin.OutlineColor.Value; _mat.color = new Color(value.r, value.g, value.b, Mathf.Clamp01(PartyPlusPlugin.OutlineOpacity.Value)); _timer -= Time.deltaTime; if (!(_timer > 0f)) { _timer = 0.4f; Refresh(); } } } private void Refresh() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) Vector3 position = ((Component)Player.m_localPlayer).transform.position; float value = PartyPlusPlugin.OutlineMaxDistance.Value; HashSet<Player> hashSet = new HashSet<Player>(); foreach (Player allPlayer in Player.GetAllPlayers()) { if (!((Object)(object)allPlayer == (Object)null) && PartyClient.IsTeammate(allPlayer) && !((Character)allPlayer).IsDead() && (!(value > 0f) || !(Vector3.Distance(position, ((Component)allPlayer).transform.position) > value))) { hashSet.Add(allPlayer); Apply(allPlayer); } } List<Player> list = new List<Player>(); foreach (KeyValuePair<Player, List<Renderer>> item in _applied) { if ((Object)(object)item.Key == (Object)null || !hashSet.Contains(item.Key)) { list.Add(item.Key); } } foreach (Player item2 in list) { Remove(item2); } } private void Apply(Player p) { if (!_applied.TryGetValue(p, out var value)) { value = new List<Renderer>(); _applied[p] = value; } Renderer[] componentsInChildren = ((Component)p).GetComponentsInChildren<Renderer>(false); foreach (Renderer val in componentsInChildren) { if ((val is SkinnedMeshRenderer || val is MeshRenderer) && !value.Contains(val)) { Material[] sharedMaterials = val.sharedMaterials; if (Array.IndexOf(sharedMaterials, _mat) >= 0) { value.Add(val); continue; } Material[] array = (Material[])(object)new Material[sharedMaterials.Length + 1]; sharedMaterials.CopyTo(array, 0); array[sharedMaterials.Length] = _mat; val.sharedMaterials = array; value.Add(val); } } value.RemoveAll((Renderer r) => (Object)(object)r == (Object)null); } private void Remove(Player p) { if (_applied.TryGetValue(p, out var value)) { foreach (Renderer item in value) { if ((Object)(object)item == (Object)null) { continue; } Material[] sharedMaterials = item.sharedMaterials; if (Array.IndexOf(sharedMaterials, _mat) >= 0) { List<Material> list = new List<Material>(sharedMaterials); list.RemoveAll((Material m) => (Object)(object)m == (Object)(object)_mat); item.sharedMaterials = list.ToArray(); } } } _applied.Remove(p); } private void RemoveAll() { foreach (Player item in new List<Player>(_applied.Keys)) { Remove(item); } _applied.Clear(); } private bool EnsureMaterial() { //IL_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if ((Object)(object)_mat != (Object)null) { return true; } if (_shaderMissing) { return false; } Shader val = Shader.Find("Hidden/Internal-Colored"); if ((Object)(object)val == (Object)null) { _shaderMissing = true; Debug.LogWarning((object)"[PartyPlus] Шейдер Hidden/Internal-Colored не найден — обводка тиммейтов отключена"); return false; } _mat = new Material(val) { name = "PartyPlus_TeammateXRay", hideFlags = (HideFlags)61 }; _mat.SetInt("_SrcBlend", 5); _mat.SetInt("_DstBlend", 10); _mat.SetInt("_Cull", 2); _mat.SetInt("_ZWrite", 0); _mat.SetInt("_ZTest", 5); _mat.renderQueue = 4000; return true; } private void OnDestroy() { RemoveAll(); if ((Object)(object)_mat != (Object)null) { Object.Destroy((Object)(object)_mat); } } } public static class ValheimTheme { public class Pill { public GUIStyle Outline; public GUIStyle Back; public GUIStyle Fill; } public static readonly Color Gold = new Color(0.86f, 0.66f, 0.3f); public static readonly Color GoldBright = new Color(1f, 0.82f, 0.45f); public static readonly Color TextLight = new Color(0.96f, 0.9f, 0.78f); public static readonly Color TextDim = new Color(0.62f, 0.57f, 0.5f); public static readonly Color Danger = new Color(0.95f, 0.38f, 0.3f); public static GUIStyle Window; public static GUIStyle Panel; public static GUIStyle Button; public static GUIStyle Toggle; public static GUIStyle Title; public static GUIStyle Label; public static GUIStyle LabelSmall; public static GUIStyle NameTag; public static GUIStyle BarText; public static GUIStyle PingIcon; public static Texture2D BarBack; public static Texture2D BarFill; public static Texture2D BarFrame; public static Texture2D Divider; private static bool _ready; private static Font _font; private static readonly Dictionary<int, Pill> Pills = new Dictionary<int, Pill>(); public static void Init() { //IL_0045: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) if (!_ready) { _ready = true; if (PartyPlusPlugin.UseGameFont.Value) { _font = FindGameFont(); } Texture2D background = Framed(new Color(0.12f, 0.09f, 0.06f, 0.92f), new Color(0.07f, 0.05f, 0.03f, 0.92f)); Texture2D bg = Framed(new Color(0.13f, 0.1f, 0.07f, 0.97f), new Color(0.08f, 0.06f, 0.04f, 0.97f)); Texture2D background2 = Framed(new Color(0.26f, 0.19f, 0.12f, 1f), new Color(0.18f, 0.13f, 0.08f, 1f)); Texture2D background3 = Framed(new Color(0.36f, 0.27f, 0.16f, 1f), new Color(0.26f, 0.19f, 0.11f, 1f)); Texture2D background4 = Framed(new Color(0.16f, 0.12f, 0.08f, 1f), new Color(0.12f, 0.09f, 0.06f, 1f)); RectOffset border = new RectOffset(5, 5, 5, 5); Window = new GUIStyle(GUI.skin.window) { font = _font, fontSize = 18, fontStyle = (FontStyle)1, alignment = (TextAnchor)1, border = border, padding = new RectOffset(14, 14, 34, 14), contentOffset = new Vector2(0f, 6f) }; SetAll(Window, bg, GoldBright); GUIStyle val = new GUIStyle { border = border }; val.normal.background = background; Panel = val; Button = new GUIStyle(GUI.skin.button) { font = _font, fontSize = 14, fontStyle = (FontStyle)1, border = border, padding = new RectOffset(10, 10, 6, 6), alignment = (TextAnchor)4 }; Button.normal.background = background2; Button.normal.textColor = TextLight; Button.hover.background = background3; Button.hover.textColor = GoldBright; Button.active.background = background4; Button.active.textColor = Gold; Button.focused = Button.normal; Toggle = new GUIStyle(GUI.skin.toggle) { font = _font, fontSize = 14 }; GUIStyleState normal = Toggle.normal; Color textColor = (Toggle.onNormal.textColor = TextLight); normal.textColor = textColor; GUIStyleState hover = Toggle.hover; textColor = (Toggle.onHover.textColor = GoldBright); hover.textColor = textColor; Title = MakeLabel(16, (FontStyle)1, GoldBright); Label = MakeLabel(14, (FontStyle)0, TextLight); LabelSmall = MakeLabel(12, (FontStyle)0, TextDim); NameTag = MakeLabel(15, (FontStyle)1, TextLight); NameTag.alignment = (TextAnchor)4; BarText = MakeLabel(11, (FontStyle)1, TextLight); BarText.alignment = (TextAnchor)4; PingIcon = MakeLabel(26, (FontStyle)1, GoldBright); PingIcon.alignment = (TextAnchor)4; BarBack = Solid(new Color(0.1f, 0.03f, 0.02f, 0.9f)); BarFrame = Solid(new Color(0f, 0f, 0f, 0.95f)); BarFill = VerticalGradient(new Color(0.92f, 0.26f, 0.18f), new Color(0.55f, 0.07f, 0.05f)); Divider = Solid(new Color(Gold.r, Gold.g, Gold.b, 0.45f)); } } public static void DrawPanel(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.Box(r, GUIContent.none, Panel); } public static void DrawHpBar(Rect r, float hp, float max, bool withText) { //IL_0026: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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) float num = Mathf.Clamp01(hp / Mathf.Max(1f, max)); Pill pill = GetPill(Mathf.RoundToInt(((Rect)(ref r)).height)); GUI.Box(r, GUIContent.none, pill.Outline); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - 4f, ((Rect)(ref r)).height - 4f); Pill pill2 = GetPill(Mathf.RoundToInt(((Rect)(ref val)).height)); GUI.Box(val, GUIContent.none, pill2.Back); if (num > 0f) { float value = PartyPlusPlugin.HpLowThreshold.Value; Color val2 = ((value > 0f && num <= value) ? PartyPlusPlugin.HpLowColor.Value : PartyPlusPlugin.HpColor.Value); Color color = GUI.color; GUI.color = new Color(val2.r, val2.g, val2.b, color.a); GUI.BeginGroup(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width * num, ((Rect)(ref val)).height)); GUI.Box(new Rect(0f, 0f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), GUIContent.none, pill2.Fill); GUI.EndGroup(); GUI.color = color; } if (withText) { OutlineLabel(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y - 1f, ((Rect)(ref r)).width, ((Rect)(ref r)).height + 2f), $"{Mathf.CeilToInt(hp)} / {Mathf.CeilToInt(max)}", BarText); } } public static void OutlineLabel(Rect r, string text, GUIStyle style, int thickness = 1) { //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_0021: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) string text2 = Regex.Replace(text, "<.*?>", ""); GUIStyle val = new GUIStyle(style) { richText = false }; val.normal.textColor = new Color(0f, 0f, 0f, 0.85f); for (int i = -thickness; i <= thickness; i++) { for (int j = -thickness; j <= thickness; j++) { if (i != 0 || j != 0) { GUI.Label(new Rect(((Rect)(ref r)).x + (float)i, ((Rect)(ref r)).y + (float)j, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text2, val); } } } GUI.Label(r, text, style); } private static Pill GetPill(int h) { h = Mathf.Clamp(h, 4, 64); if (Pills.TryGetValue(h, out var value)) { return value; } value = new Pill { Outline = PillStyle(h, (int y) => new Color(0.03f, 0.04f, 0.05f, 0.92f)), Back = PillStyle(h, (int y) => new Color(0.1f, 0.13f, 0.16f, 0.85f)), Fill = PillStyle(h, delegate(int y) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0046: 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_0055: 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) float num = (float)y / (float)(h - 1); float num2 = Mathf.Lerp(0.55f, 1f, num); Color val = default(Color); ((Color)(ref val))..ctor(num2, num2, num2, 1f); if (num > 0.6f && num < 0.85f) { val = Color.Lerp(val, Color.white, 0.35f); return val; } return val; }) }; Pills[h] = value; return value; } private static GUIStyle PillStyle(int h, Func<int, Color> colorAtRow) { //IL_00d6: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0056: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) int num = h * 2 + 2; float num2 = (float)h / 2f; Texture2D val = NewTex(num, h); ((Texture)val).filterMode = (FilterMode)1; for (int i = 0; i < h; i++) { for (int j = 0; j < num; j++) { float num3 = (float)j + 0.5f; float num4 = (float)i + 0.5f; float num5 = Mathf.Clamp(num3, num2, (float)num - num2); float num6 = Vector2.Distance(new Vector2(num3, num4), new Vector2(num5, num2)); float num7 = Mathf.Clamp01(num2 - num6 + 0.5f); Color val2 = colorAtRow(i); val2.a *= num7; val.SetPixel(j, i, val2); } } val.Apply(); int num8 = Mathf.FloorToInt(num2); GUIStyle val3 = new GUIStyle { border = new RectOffset(num8, num8, 0, 0) }; val3.normal.background = val; return val3; } public static void DrawSwatch(Rect r, Color c) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or