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 SocialSystemTweaks v1.0.4
Cjayride.SocialSystemTweaks.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using SocialSystem.Client; using SocialSystem.Core; using SocialSystem.UI; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: IgnoresAccessChecksTo("SocialSystem")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.SocialSystemTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+2a2578c3f2eb67963bac0238426b42bc08a6fcd0")] [assembly: AssemblyProduct("Cjayride.SocialSystemTweaks")] [assembly: AssemblyTitle("Cjayride.SocialSystemTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Cjayride.SocialSystemTweaks { [HarmonyPatch] [HarmonyPriority(0)] internal static class CombatInvites { private static readonly MethodInfo IsInCombat = AccessTools.PropertyGetter(typeof(CombatState), "IsInCombat"); private static readonly MethodInfo Replacement = AccessTools.Method(typeof(CombatInvites), "BlocksPrompts", (Type[])null, (Type[])null); private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(SocialPrompts), "Enqueue", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SocialPrompts), "Tick", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SocialPrompts), "ShowNextIfPossible", (Type[])null, (Type[])null); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, IsInCombat)) { instruction.operand = Replacement; } yield return instruction; } } private static bool BlocksPrompts() { if (Plugin.InvitesDuringCombat.Value) { return false; } return CombatState.IsInCombat; } } [HarmonyPatch] [HarmonyPriority(0)] internal static class HealthText { private sealed class Label { public Text Text; public Outline Outline; public int Shown = int.MinValue; public int ShownMax = int.MinValue; public bool ShowMax; public Vector2 LastAnchorMin; public Vector2 LastAnchorMax; public Vector2 LastPivot; public Vector2 LastPos; public Vector2 LastSize; public Vector3 LastScale; } private static readonly ConditionalWeakTable<HealthBar, Label> Labels = new ConditionalWeakTable<HealthBar, Label>(); private static readonly List<Label> All = new List<Label>(); [HarmonyPatch(typeof(HealthBar), "Update")] [HarmonyPostfix] private static void AfterUpdate(HealthBar __instance, long playerId, SocialClient client) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance?._root == (Object)null) { return; } Label value; if (!Plugin.HealthTextEnabled.Value) { if (Labels.TryGetValue(__instance, out value) && (Object)(object)value.Text != (Object)null && ((Component)value.Text).gameObject.activeSelf) { ((Component)value.Text).gameObject.SetActive(false); } return; } value = Labels.GetValue(__instance, Create); if ((Object)(object)value.Text == (Object)null) { return; } EnsureLabelParent(__instance, value); MemberVitals val = default(MemberVitals); bool num = __instance._root.activeSelf && client != null && client.IsOnline(playerId) && client.TryGetVitals(playerId, ref val) && val.MaxHealth > 0f; GameObject gameObject = ((Component)value.Text).gameObject; if (!num) { if (gameObject.activeSelf) { gameObject.SetActive(false); } return; } Follow(value, (RectTransform)__instance._root.transform); if (!gameObject.activeSelf) { gameObject.SetActive(true); } int num2 = ((!val.IsDead) ? Mathf.CeilToInt(val.Health) : 0); int num3 = Mathf.CeilToInt(val.MaxHealth); bool value2 = Plugin.HealthTextShowMax.Value; if (num2 != value.Shown || num3 != value.ShownMax || value.ShowMax != value2) { value.Shown = num2; value.ShownMax = num3; value.ShowMax = value2; value.Text.text = (value2 ? (num2 + " / " + num3) : num2.ToString()); } } [HarmonyPatch(typeof(HealthBar), "SetVisible")] [HarmonyPostfix] private static void AfterSetVisible(HealthBar __instance, bool visible) { if (!visible && Labels.TryGetValue(__instance, out var value) && !((Object)(object)value.Text == (Object)null) && ((Component)value.Text).gameObject.activeSelf) { ((Component)value.Text).gameObject.SetActive(false); } } private static void EnsureLabelParent(HealthBar bar, Label label) { if ((Object)(object)label.Text == (Object)null || (Object)(object)bar._root == (Object)null) { return; } Transform parent = bar._root.transform.parent; if (!((Object)(object)parent == (Object)null)) { Transform transform = ((Component)label.Text).transform; if ((Object)(object)transform.parent != (Object)(object)parent) { transform.SetParent(parent, false); transform.SetAsLastSibling(); } } } private static Label Create(HealthBar bar) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Label label = new Label(); Transform parent = bar._root.transform.parent; if ((Object)(object)parent == (Object)null) { return label; } GameObject val = new GameObject("CjayrideHealthText", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); val.transform.SetAsLastSibling(); label.Text = val.AddComponent<Text>(); label.Text.font = SocialUiFactory.Font; label.Text.alignment = (TextAnchor)4; label.Text.horizontalOverflow = (HorizontalWrapMode)1; label.Text.verticalOverflow = (VerticalWrapMode)1; ((Graphic)label.Text).raycastTarget = false; label.Outline = val.AddComponent<Outline>(); Style(label); All.Add(label); return label; } private static void Follow(Label label, RectTransform bar) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0020: 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_0027: 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_002f: 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_0037: 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_0051: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00ce: 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_00d6: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00f2: 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_0101: 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_006e: 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_007c: 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_008b: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)label.Text).rectTransform; Vector2 anchorMin = bar.anchorMin; Vector2 anchorMax = bar.anchorMax; Vector2 pivot = bar.pivot; Vector2 anchoredPosition = bar.anchoredPosition; Vector3 localScale = ((Transform)bar).localScale; Rect rect = bar.rect; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Rect)(ref rect)).width * localScale.x, ((Rect)(ref rect)).height * localScale.y); if (!(anchorMin == label.LastAnchorMin) || !(anchorMax == label.LastAnchorMax) || !(pivot == label.LastPivot) || !(anchoredPosition == label.LastPos) || !(val == label.LastSize) || !(localScale == label.LastScale)) { label.LastAnchorMin = anchorMin; label.LastAnchorMax = anchorMax; label.LastPivot = pivot; label.LastPos = anchoredPosition; label.LastSize = val; label.LastScale = localScale; rectTransform.anchorMin = anchorMin; rectTransform.anchorMax = anchorMax; rectTransform.pivot = pivot; rectTransform.anchoredPosition = anchoredPosition; rectTransform.sizeDelta = val; } } private static void Style(Label label) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) label.Text.fontSize = Plugin.HealthTextSize.Value; ((Graphic)label.Text).color = Plugin.HealthTextColor.Value; float value = Plugin.HealthTextShadowThickness.Value; ((Behaviour)label.Outline).enabled = value > 0f; ((Shadow)label.Outline).effectColor = Plugin.HealthTextShadowColor.Value; ((Shadow)label.Outline).effectDistance = new Vector2(value, 0f - value); } internal static void RestyleAll() { All.RemoveAll((Label l) => (Object)(object)l.Text == (Object)null); foreach (Label item in All) { Style(item); } } internal static void RefreshVisibility() { All.RemoveAll((Label l) => (Object)(object)l.Text == (Object)null); if (Plugin.HealthTextEnabled.Value) { return; } foreach (Label item in All) { ((Component)item.Text).gameObject.SetActive(false); } } } [BepInPlugin("cjayride.SocialSystemTweaks", "SocialSystem Tweaks", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "cjayride.SocialSystemTweaks"; public const string PluginName = "SocialSystem Tweaks"; public const string PluginVersion = "1.0.4"; internal static ConfigEntry<bool> InvitesDuringCombat; internal static ConfigEntry<bool> HealthTextEnabled; internal static ConfigEntry<bool> HealthTextShowMax; internal static ConfigEntry<int> HealthTextSize; internal static ConfigEntry<Color> HealthTextColor; internal static ConfigEntry<Color> HealthTextShadowColor; internal static ConfigEntry<float> HealthTextShadowThickness; private void Awake() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) InvitesDuringCombat = ((BaseUnityPlugin)this).Config.Bind<bool>("Invites", "ShowDuringCombat", true, "Show party and friend invite prompts right away, even while in combat. Off keeps SocialSystem's behaviour of holding them until combat ends."); HealthTextEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("PartyHealthText", "Enabled", true, "Draw the HP number on party member health bars."); HealthTextShowMax = ((BaseUnityPlugin)this).Config.Bind<bool>("PartyHealthText", "ShowMaxHealth", true, "Show current / max (for example 85 / 120) instead of only the current HP."); HealthTextSize = ((BaseUnityPlugin)this).Config.Bind<int>("PartyHealthText", "FontSize", 12, new ConfigDescription("HP text size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 32), Array.Empty<object>())); HealthTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("PartyHealthText", "Color", Color.white, "HP text color."); HealthTextShadowColor = ((BaseUnityPlugin)this).Config.Bind<Color>("PartyHealthText", "ShadowColor", Color.black, "Border/shadow color around the HP text."); HealthTextShadowThickness = ((BaseUnityPlugin)this).Config.Bind<float>("PartyHealthText", "ShadowThickness", 1.5f, new ConfigDescription("Border/shadow thickness around the HP text. 0 removes it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); HealthTextSize.SettingChanged += delegate { HealthText.RestyleAll(); }; HealthTextColor.SettingChanged += delegate { HealthText.RestyleAll(); }; HealthTextShadowColor.SettingChanged += delegate { HealthText.RestyleAll(); }; HealthTextShadowThickness.SettingChanged += delegate { HealthText.RestyleAll(); }; HealthTextEnabled.SettingChanged += delegate { HealthText.RefreshVisibility(); }; new Harmony("cjayride.SocialSystemTweaks").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SocialSystem Tweaks 1.0.4 loaded."); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }