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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using ComfyLib;
using ComfySigns.Commands;
using ComfySigns.Core;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ComfySigns")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ComfySigns")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1a56448b-9dac-4352-a528-d9e3f64f992e")]
[assembly: AssemblyFileVersion("1.10.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.10.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 ComfySigns
{
[BepInPlugin("redseiko.valheim.comfysigns", "ComfySigns", "1.10.0")]
public sealed class ComfySigns : BaseUnityPlugin
{
public const string PluginGuid = "redseiko.valheim.comfysigns";
public const string PluginName = "ComfySigns";
public const string PluginVersion = "1.10.0";
private static GameObject dungeonGO;
private static Vector3? lastPlayerPosition;
private ConfigEntry<string> weaponNamesEntry;
public static ComfySigns Instance { get; private set; }
private void Start()
{
}
public static void AplicarNombresPersonalizados()
{
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
CustomWeaponNameStorage.LoadFromDisk();
foreach (ItemData allItem in ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems())
{
ItemUniqueIdManager.AssignUniqueId(allItem);
string uniqueId = ItemUniqueIdManager.GetUniqueId(allItem);
if (uniqueId != null)
{
string name = allItem.m_shared.m_name;
string customWeaponName = WeaponNameSync.GetCustomWeaponName(uniqueId);
CustomWeaponNameStorage.SetName(uniqueId, customWeaponName);
allItem.m_shared.m_name = customWeaponName;
}
}
}
private void Awake()
{
ComfyConfigUtils.BindConfig(((BaseUnityPlugin)this).Config);
CustomWeaponNameStorage.LoadFromDisk();
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new HuginCommand("redseiko.valheim.comfysigns"));
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SecretBaseCommand());
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ExitBaseCommand());
CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RenameCommand());
PrefabManager.OnVanillaPrefabsAvailable += AddCustomItems;
AplicarNombresPersonalizados();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "redseiko.valheim.comfysigns");
}
private void OnConfigSynchronized(object sender, ConfigurationSynchronizationEventArgs e)
{
if (e.InitialSynchronization)
{
ApplyCustomWeaponNames();
}
}
private void ApplyCustomWeaponNames()
{
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
foreach (ItemData allItem in ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems())
{
string uniqueId = ItemUniqueIdManager.GetUniqueId(allItem);
if (uniqueId != null)
{
string customWeaponName = WeaponNameSync.GetCustomWeaponName(uniqueId);
if (!string.IsNullOrEmpty(customWeaponName))
{
allItem.m_shared.m_name = customWeaponName;
}
}
}
}
public Dictionary<string, string> GetWeaponNames()
{
Dictionary<string, string> dictionary = new Dictionary<string, string>();
string[] array = weaponNamesEntry.Value.Split(new char[1] { ',' });
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(new char[1] { ':' });
if (array3.Length == 2)
{
dictionary[array3[0]] = array3[1];
}
}
return dictionary;
}
private void AddCustomItems()
{
//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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_003a: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0073: 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)
ItemConfig val = new ItemConfig
{
Name = "Piedra Misteriosa",
Description = "Una piedra misteriosa que activa portales especiales. BRUH",
CraftingStation = CraftingStations.Workbench,
MinStationLevel = 1,
StackSize = 1
};
val.AddRequirement(new RequirementConfig("Stone", 1, 0, true));
CustomItem val2 = new CustomItem("PiedraMisteriosa", "Stone", val);
SharedData shared = val2.ItemDrop.m_itemData.m_shared;
shared.m_itemType = (ItemType)19;
shared.m_equipDuration = 0.5f;
shared.m_maxDurability = 100f;
shared.m_useDurability = false;
shared.m_animationState = (AnimationState)0;
ItemManager.Instance.AddItem(val2);
}
public static Vector3 LoadPlayerPosition(string playerName)
{
//IL_0058: 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_0061: Unknown result type (might be due to invalid IL or missing references)
int @int = PlayerPrefs.GetInt(playerName + "_can_back", 0);
float @float = PlayerPrefs.GetFloat(playerName + "_pos_x", 0f);
float float2 = PlayerPrefs.GetFloat(playerName + "_pos_y", 0f);
float float3 = PlayerPrefs.GetFloat(playerName + "_pos_z", 0f);
return new Vector3(@float, float2, float3);
}
public static void SavePlayerPosition(string playerName, Vector3 position)
{
//IL_001e: 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_004c: Unknown result type (might be due to invalid IL or missing references)
PlayerPrefs.SetInt(playerName + "_can_back", 1);
PlayerPrefs.SetFloat(playerName + "_pos_x", position.x);
PlayerPrefs.SetFloat(playerName + "_pos_y", position.y);
PlayerPrefs.SetFloat(playerName + "_pos_z", position.z);
PlayerPrefs.Save();
}
private void OnEnable()
{
Instance = this;
}
public static void RPC_ShowRavenMessage(long senderId, string topic, string message, bool munin = false)
{
//IL_0015: 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_0021: 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_002f: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
string key = Guid.NewGuid().ToString();
RavenText item = new RavenText
{
m_topic = topic,
m_text = message,
m_key = key,
m_label = "",
m_priority = 0,
m_munin = munin,
m_static = false
};
Raven.m_tempTexts.Add(item);
Raven.m_instance.Say("", topic, false, true, false);
}
}
public static class SignUtils
{
public static readonly Regex SizeRegex = new Regex("<size=[^>]*>");
public static void AddFallbackFont(TMP_FontAsset font, TMP_FontAsset fallbackFont)
{
if (Object.op_Implicit((Object)(object)font) && Object.op_Implicit((Object)(object)fallbackFont) && !((Object)(object)fallbackFont == (Object)(object)font))
{
if (font.fallbackFontAssetTable == null)
{
font.fallbackFontAssetTable = new List<TMP_FontAsset>(1) { fallbackFont };
}
else if (!font.fallbackFontAssetTable.Contains(fallbackFont))
{
font.fallbackFontAssetTable.Add(fallbackFont);
}
}
}
public static void AddFallbackFonts(TMP_FontAsset font)
{
AddFallbackFont(font, UIFonts.GetFontAsset(UIFonts.ValheimNorse));
AddFallbackFont(font, UIFonts.GetFontAsset(UIFonts.ValheimNorsebold));
AddFallbackFont(font, UIFonts.GetFontAsset(UIFonts.FallbackNotoSansNormal));
}
public static bool HasSignEffect(TMP_Text textComponent, string effectId)
{
//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_004a: 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)
if (textComponent.text.Length <= 0 || !textComponent.text.StartsWith("<link", StringComparison.Ordinal))
{
return false;
}
TMP_LinkInfo[] linkInfo = textComponent.textInfo.linkInfo;
for (int i = 0; i < linkInfo.Length; i++)
{
TMP_LinkInfo val = linkInfo[i];
if (val.linkTextfirstCharacterIndex == 0 && val.linkTextLength == textComponent.textInfo.characterCount && ((TMP_LinkInfo)(ref val)).GetLinkID() == effectId)
{
return true;
}
}
return false;
}
public static void OnSignConfigChanged()
{
SetupSignPrefabs(ZNetScene.s_instance);
}
public static void OnSignEffectConfigChanged()
{
Sign[] array = Resources.FindObjectsOfTypeAll<Sign>();
foreach (Sign val in array)
{
if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.m_nview) && val.m_nview.IsValid() && Object.op_Implicit((Object)(object)val.m_textWidget))
{
ProcessSignEffect(val);
}
}
}
public static void OnSignTextTagsConfigChanged()
{
Sign[] array = Resources.FindObjectsOfTypeAll<Sign>();
foreach (Sign val in array)
{
if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.m_nview) && val.m_nview.IsValid() && Object.op_Implicit((Object)(object)val.m_textWidget))
{
if (PluginConfig.SignTextIgnoreSizeTags.Value)
{
ProcessSignText(val);
}
else
{
((TMP_Text)val.m_textWidget).text = val.m_currentText;
}
}
}
}
public static void ProcessSignEffect(Sign sign)
{
VertexColorCycler vertexColorCycler2 = default(VertexColorCycler);
if (((Behaviour)sign.m_textWidget).enabled && HasSignEffect((TMP_Text)(object)sign.m_textWidget, "party") && ShouldRenderSignEffect(sign))
{
VertexColorCycler vertexColorCycler = default(VertexColorCycler);
if (!((Component)sign.m_textWidget).gameObject.TryGetComponent<VertexColorCycler>(ref vertexColorCycler))
{
((Component)sign.m_textWidget).gameObject.AddComponent<VertexColorCycler>();
}
}
else if (((Component)sign.m_textWidget).gameObject.TryGetComponent<VertexColorCycler>(ref vertexColorCycler2))
{
Object.Destroy((Object)(object)vertexColorCycler2);
((TMP_Text)sign.m_textWidget).ForceMeshUpdate(true, false);
}
}
public static void ProcessSignText(Sign sign)
{
if (PluginConfig.SignTextIgnoreSizeTags.Value && SizeRegex.IsMatch(((TMP_Text)sign.m_textWidget).text))
{
((TMP_Text)sign.m_textWidget).text = SizeRegex.Replace(((TMP_Text)sign.m_textWidget).text, string.Empty);
}
}
public static void SetupSignFont(Sign sign, TMP_FontAsset fontAsset, Color color)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)((TMP_Text)sign.m_textWidget).font) == Object.op_Implicit((Object)(object)fontAsset))
{
((TMP_Text)sign.m_textWidget).font = fontAsset;
}
if ((Object)(object)((TMP_Text)sign.m_textWidget).fontSharedMaterial != (Object)(object)((TMP_Asset)fontAsset).material)
{
((TMP_Text)sign.m_textWidget).fontSharedMaterial = ((TMP_Asset)fontAsset).material;
}
((Graphic)sign.m_textWidget).color = color;
}
public static void SetupSignPrefabs(ZNetScene netScene)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)netScene))
{
return;
}
TMP_FontAsset fontAsset = UIFonts.GetFontAsset(PluginConfig.SignDefaultTextFontAsset.Value);
Color value = PluginConfig.SignDefaultTextFontColor.Value;
if (PluginConfig.UseFallbackFonts.Value)
{
AddFallbackFonts(fontAsset);
}
Sign sign = default(Sign);
foreach (GameObject value2 in netScene.m_namedPrefabs.Values)
{
if (value2.TryGetComponent<Sign>(ref sign))
{
SetupSignFont(sign, fontAsset, value);
}
}
Sign sign2 = default(Sign);
foreach (ZNetView value3 in netScene.m_instances.Values)
{
if (((Component)value3).TryGetComponent<Sign>(ref sign2))
{
SetupSignFont(sign2, fontAsset, value);
}
}
}
public static bool ShouldRenderSignText(Sign sign)
{
//IL_0013: 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)
return Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)sign).transform.position, ((Component)Player.m_localPlayer).transform.position) <= PluginConfig.SignTextMaximumRenderDistance.Value;
}
public static bool ShouldRenderSignEffect(Sign sign)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
return PluginConfig.SignEffectEnablePartyEffect.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)sign).transform.position) <= PluginConfig.SignEffectMaximumRenderDistance.Value;
}
}
[HarmonyPatch(typeof(Sign))]
internal static class SignPatch
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void AwakePostfix(ref Sign __instance)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
if (PluginConfig.IsModEnabled.Value)
{
__instance.m_characterLimit = 200000;
if (((Component)(object)__instance.m_textWidget).TryGetComponentInParent<Canvas>(out Canvas component))
{
((Component)component).transform.localPosition = new Vector3(0f, 0f, 0.1f);
}
}
}
[HarmonyPostfix]
[HarmonyPatch("SetText")]
private static void SetTextPostfix(ref Sign __instance)
{
if (PluginConfig.IsModEnabled.Value)
{
SignUtils.ProcessSignText(__instance);
SignUtils.ProcessSignEffect(__instance);
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateText")]
private static void UpdateTextPostfix(Sign __instance)
{
if (!PluginConfig.IsModEnabled.Value)
{
return;
}
string text = __instance.GetText();
Match match = Regex.Match(text, "<nolimit(?:=(\\d+))?(?:;(\\d))?>");
float num = 1f;
if (match.Success && match.Groups[1].Success && float.TryParse(match.Groups[1].Value, out var result))
{
num = result;
}
if ((Object)(object)__instance.m_textWidget != (Object)null && ((Component)(object)__instance.m_textWidget).TryGetComponentInParent<Canvas>(out Canvas component))
{
Match match2 = Regex.Match(text, "<nolimit(?:=(\\d+))?(?:;(\\d))?>");
if (match2.Success && match2.Groups[2].Success)
{
__instance.m_isViewable = match2.Groups[2].Value == "1";
}
RectTransform val = default(RectTransform);
if (((Component)component).TryGetComponent<RectTransform>(ref val))
{
val.SetSizeWithCurrentAnchors((Axis)0, num);
}
}
((Behaviour)__instance.m_textWidget).enabled = SignUtils.ShouldRenderSignText(__instance);
SignUtils.ProcessSignEffect(__instance);
}
[HarmonyPostfix]
[HarmonyPatch("OnCheckPermissionCompleted")]
private static void CanAccessResultFuncPostfix(Sign __instance)
{
if (PluginConfig.IsModEnabled.Value)
{
SignUtils.ProcessSignText(__instance);
}
}
}
[HarmonyPatch(typeof(TextInput))]
internal static class TextInputPatch
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void AwakePostfix(TextInput __instance)
{
if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)__instance.m_inputField))
{
__instance.m_panel.GetOrAddComponent<TextInputPanelDragger>();
((TMP_InputField)__instance.m_inputField).richText = false;
}
}
}
[HarmonyPatch(typeof(ZNetScene))]
internal static class ZNetScenePatch
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
private static void AwakePostfix(ZNetScene __instance)
{
if (PluginConfig.IsModEnabled.Value)
{
ComfySigns.AplicarNombresPersonalizados();
SignUtils.SetupSignPrefabs(__instance);
}
}
}
public static class PluginConfig
{
public static ConfigFile CurrentConfig { get; private set; }
public static ConfigEntry<bool> IsModEnabled { get; private set; }
public static ConfigEntry<bool> UseFallbackFonts { get; private set; }
public static ConfigEntry<bool> SuppressUnicodeNotFoundWarning { get; private set; }
public static ConfigEntry<string> SignDefaultTextFontAsset { get; private set; }
public static ConfigEntry<Color> SignDefaultTextFontColor { get; private set; }
public static ConfigEntry<float> SignTextMaximumRenderDistance { get; private set; }
public static ConfigEntry<bool> SignTextIgnoreSizeTags { get; private set; }
public static ConfigEntry<float> SignEffectMaximumRenderDistance { get; private set; }
public static ConfigEntry<bool> SignEffectEnablePartyEffect { get; private set; }
[ComfyConfig]
public static void BindConfig(ConfigFile config)
{
CurrentConfig = config;
IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod.");
UseFallbackFonts = config.BindInOrder("Fonts", "useFallbackFonts", defaultValue: true, "Use fallback fonts to support additional characters.");
}
[ComfyConfig(typeof(FejdStartup), "Awake")]
public static void BindLoggingConfig(ConfigFile config)
{
SuppressUnicodeNotFoundWarning = config.BindInOrder("Logging", "suppressUnicodeNotFoundWarning", defaultValue: true, "Hide 'The character with Unicode value ... was not found...' log warnings.");
SuppressUnicodeNotFoundWarning.OnSettingChanged<bool>(SetWarningsDisabled);
SetWarningsDisabled(SuppressUnicodeNotFoundWarning.Value);
}
private static void SetWarningsDisabled(bool warningsDiabled)
{
TMP_Settings.instance.m_warningsDisabled = warningsDiabled;
}
[ComfyConfig(typeof(FejdStartup), "Awake")]
public static void BindSignConfig(ConfigFile config)
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
string[] array = (from f in Resources.FindObjectsOfTypeAll<TMP_FontAsset>()
select ((Object)f).name).Concat(from f in Resources.FindObjectsOfTypeAll<Font>()
select ((Object)f).name).ToArray();
SignDefaultTextFontAsset = config.BindInOrder("Sign.Text", "defaultTextFontAsset", "Valheim-Norse", "Sign.m_textWidget.fontAsset (TMP) default value.", (AcceptableValueBase)(object)new AcceptableValueList<string>(array));
SignDefaultTextFontAsset.OnSettingChanged<string>(SignUtils.OnSignConfigChanged);
SignDefaultTextFontColor = config.BindInOrder<Color>("Sign.Text", "defaultTextFontColor", Color.white, "Sign.m_textWidget.color default value.");
SignDefaultTextFontColor.OnSettingChanged<Color>(SignUtils.OnSignConfigChanged);
SignTextMaximumRenderDistance = config.BindInOrder("Sign.Text.Render", "maximumRenderDistance", 192f, "Maximum distance that signs can be from player to render sign text.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 192f));
SignTextIgnoreSizeTags = config.Bind<bool>("Sign.Text.Tags", "ignoreSizeTags", false, "if set, ignore any and all <size> tags in sign text when rendered locally.");
SignTextIgnoreSizeTags.OnSettingChanged<bool>(SignUtils.OnSignTextTagsConfigChanged);
}
[ComfyConfig(typeof(FejdStartup), "Awake")]
public static void BindSignEffectConfig(ConfigFile config)
{
SignEffectMaximumRenderDistance = config.BindInOrder("SignEffect", "maximumRenderDistance", 64f, "Maximum distance that signs can be from player to render sign effects.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 128f));
SignEffectMaximumRenderDistance.OnSettingChanged<float>(SignUtils.OnSignEffectConfigChanged);
SignEffectEnablePartyEffect = config.BindInOrder("SignEffect.Party", "enablePartyEffect", defaultValue: false, "Enables the 'Party' Sign effect for signs using the party tag.");
SignEffectEnablePartyEffect.OnSettingChanged<bool>(SignUtils.OnSignEffectConfigChanged);
}
}
public sealed class TextInputPanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
{
private RectTransform _rectTransform;
private Vector2 _lastMousePosition;
private void Start()
{
_rectTransform = ((Component)this).GetComponent<RectTransform>();
}
public void OnBeginDrag(PointerEventData eventData)
{
//IL_0003: 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)
_lastMousePosition = eventData.position;
}
public void OnDrag(PointerEventData eventData)
{
//IL_0002: 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_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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_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_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)
Vector2 val = eventData.position - _lastMousePosition;
RectTransform rectTransform = _rectTransform;
((Transform)rectTransform).position = ((Transform)rectTransform).position + new Vector3(val.x, val.y, 0f);
_lastMousePosition = eventData.position;
}
public void OnEndDrag(PointerEventData eventData)
{
}
}
public sealed class VertexColorCycler : MonoBehaviour
{
private static readonly WaitForSeconds _longWait = new WaitForSeconds(1f);
private static readonly WaitForSeconds _shortWait = new WaitForSeconds(0.05f);
private TMP_Text _textComponent;
private void Awake()
{
_textComponent = ((Component)this).GetComponent<TMP_Text>();
}
private void Start()
{
((MonoBehaviour)this).StartCoroutine(AnimateVertexColors());
}
private IEnumerator AnimateVertexColors()
{
TMP_TextInfo textInfo = _textComponent.textInfo;
int currentCharacter = 0;
while (true)
{
int characterCount = textInfo.characterCount;
if (characterCount == 0)
{
yield return _longWait;
continue;
}
int materialIndex = textInfo.characterInfo[currentCharacter].materialReferenceIndex;
Color32[] vertexColors = textInfo.meshInfo[materialIndex].colors32;
int vertexIndex = textInfo.characterInfo[currentCharacter].vertexIndex;
if (textInfo.characterInfo[currentCharacter].isVisible)
{
vertexColors[vertexIndex + 3] = (vertexColors[vertexIndex + 2] = (vertexColors[vertexIndex + 1] = (vertexColors[vertexIndex] = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), byte.MaxValue))));
_textComponent.UpdateVertexData((TMP_VertexDataUpdateFlags)16);
}
int lastCharacter = currentCharacter;
currentCharacter = (currentCharacter + 1) % characterCount;
yield return (lastCharacter < currentCharacter) ? _shortWait : _longWait;
}
}
}
}
namespace ComfySigns.Patches
{
[HarmonyPatch(typeof(Game), "Start")]
public static class GameStartPatch
{
private static void Prefix()
{
ZRoutedRpc.instance.Register<string, string, bool>("RPC_ShowRavenMessage", (Action<long, string, string, bool>)ComfySigns.RPC_ShowRavenMessage);
ZRoutedRpc.instance.Register<ZPackage>("HuginRelayRPC", (Action<long, ZPackage>)HuginCommand.OnHuginRelayRPC);
ZRoutedRpc.instance.Register<ZPackage>("RPC_ReceiveWeaponNames", (Action<long, ZPackage>)WeaponNameSync.ReceiveWeaponNames);
}
}
[HarmonyPatch(typeof(ItemData))]
[HarmonyPatch("GetTooltip", new Type[] { typeof(int) })]
public class ItemTooltipPatch
{
private static void Postfix(ItemData __instance, ref string __result)
{
string uniqueId = ItemUniqueIdManager.GetUniqueId(__instance);
if (uniqueId != null)
{
string name = CustomWeaponNameStorage.GetName(uniqueId);
if (!string.IsNullOrEmpty(name))
{
__instance.m_shared.m_name = name;
}
}
}
}
[HarmonyPatch(typeof(ItemDrop), "Awake")]
public class ItemAwakePatch
{
private static void Postfix(ItemDrop __instance)
{
string uniqueId = ItemUniqueIdManager.GetUniqueId(__instance.m_itemData);
if (uniqueId != null)
{
string name = CustomWeaponNameStorage.GetName(uniqueId);
__instance.m_itemData.m_shared.m_name = name;
}
}
}
[HarmonyPatch(typeof(Piece), "Awake")]
public static class PlacementAwakePatch
{
private static void Postfix(Piece __instance)
{
__instance.m_allowedInDungeons = true;
}
}
[HarmonyPatch(typeof(Player), "Awake")]
public static class PlayerAwakePatch
{
private static void Postfix()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
SecretBaseCommand.CreateHollowCube(SecretBaseCommand.secretBasePosition);
ComfySigns.AplicarNombresPersonalizados();
}
}
[HarmonyPatch(typeof(TeleportWorld), "Teleport")]
public class PortalInteractPatch
{
private static bool Prefix(TeleportWorld __instance, Player player)
{
//IL_0059: 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_0073: 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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_004a: 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)
if ((Object)(object)player != (Object)null && ((Humanoid)player).GetRightItem()?.m_shared.m_name == "Piedra Misteriosa")
{
if ((Object)(object)player != (Object)null)
{
Vector3 position = ((Component)player).transform.position;
ComfySigns.SavePlayerPosition(player.GetPlayerName(), position);
}
SecretBaseCommand.CreateHollowCube(SecretBaseCommand.secretBasePosition);
((Character)Player.m_localPlayer).TeleportTo(SecretBaseCommand.secretBasePosition + Vector3.up * -60f, ((Component)Player.m_localPlayer).transform.rotation, true);
((Terminal)Chat.instance).AddString("¡Bienvenido a tu base secreta!");
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Raven), "UseItem")]
public static class RavenPatch
{
private static bool Prefix(ref bool __result, ref ItemData item)
{
__result = true;
Raven.m_instance.Say("", "Te voy a dar una paliza, no me interesa tu " + item.m_shared.m_name, false, true, false);
Raven.m_instance.m_animator.SetTrigger("poff");
return true;
}
}
}
namespace ComfySigns.Core
{
public static class CustomWeaponNameStorage
{
private static Dictionary<string, string> WeaponNames = new Dictionary<string, string>();
private static string SavePath => Path.Combine(Paths.ConfigPath, "custom_weapon_names.json");
public static void SetName(string uniqueId, string name)
{
WeaponNames[uniqueId] = name;
SaveToDisk();
}
public static string GetName(string uniqueId)
{
string value;
return WeaponNames.TryGetValue(uniqueId, out value) ? value : null;
}
public static void LoadFromDisk()
{
if (File.Exists(SavePath))
{
string text = File.ReadAllText(SavePath);
WeaponNames = JsonUtility.FromJson<Serialization<string, string>>(text).ToDictionary();
}
}
public static void SaveToDisk()
{
string contents = JsonUtility.ToJson((object)new Serialization<string, string>(WeaponNames), true);
File.WriteAllText(SavePath, contents);
}
}
public static class ItemUniqueIdManager
{
private const string UniqueIdKey = "UniqueId";
public static void AssignUniqueId(ItemData item)
{
if (!item.m_customData.ContainsKey("UniqueId"))
{
string value = Guid.NewGuid().ToString();
item.m_customData["UniqueId"] = value;
}
}
public static string GetUniqueId(ItemData item)
{
if (item.m_customData.TryGetValue("UniqueId", out var value))
{
return value;
}
return null;
}
}
[Serializable]
public class Serialization<TKey, TValue>
{
[SerializeField]
private List<TKey> keys = new List<TKey>();
[SerializeField]
private List<TValue> values = new List<TValue>();
public Dictionary<TKey, TValue> ToDictionary()
{
Dictionary<TKey, TValue> dictionary = new Dictionary<TKey, TValue>();
for (int i = 0; i < Math.Min(keys.Count, values.Count); i++)
{
dictionary[keys[i]] = values[i];
}
return dictionary;
}
public Serialization(Dictionary<TKey, TValue> dict)
{
keys = dict.Keys.ToList();
values = dict.Values.ToList();
}
}
public static class WeaponNameSync
{
private static Dictionary<string, string> weaponNames = new Dictionary<string, string>();
public static void SendWeaponNames()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
ZPackage val = new ZPackage();
val.Write(weaponNames.Count);
foreach (KeyValuePair<string, string> weaponName in weaponNames)
{
val.Write(weaponName.Key);
val.Write(weaponName.Value);
}
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_ReceiveWeaponNames", new object[1] { val });
}
public static void ReceiveWeaponNames(long sender, ZPackage package)
{
int num = package.ReadInt();
for (int i = 0; i < num; i++)
{
string key = package.ReadString();
string value = package.ReadString();
weaponNames[key] = value;
}
}
public static string GetCustomWeaponName(string originalName)
{
if (weaponNames.TryGetValue(originalName, out var value))
{
return value;
}
return originalName;
}
public static void SetCustomWeaponName(string originalName, string customName)
{
weaponNames[originalName] = customName;
SendWeaponNames();
}
}
}
namespace ComfySigns.Commands
{
public class ExitBaseCommand : ConsoleCommand
{
public override string Name => "salirbase";
public override string Help => "Vuelve a tu última posición antes de entrar a la base secreta";
public override void Run(string[] args)
{
//IL_001f: 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_0069: 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)
if (!((Object)(object)Player.m_localPlayer == (Object)null))
{
Vector3 val = ComfySigns.LoadPlayerPosition(Player.m_localPlayer.GetPlayerName());
int @int = PlayerPrefs.GetInt(Player.m_localPlayer.GetPlayerName() + "_can_back", 0);
if (@int == 1)
{
PlayerPrefs.SetInt(Player.m_localPlayer.GetPlayerName() + "_can_back", 0);
((Character)Player.m_localPlayer).TeleportTo(val, ((Component)Player.m_localPlayer).transform.rotation, true);
((Terminal)Chat.instance).AddString("¡Has salido de la base secreta!");
}
else
{
((Terminal)Chat.instance).AddString("No se encontró una posición previa.");
}
}
}
}
public class HuginCommand : ConsoleCommand
{
private static int messageCount;
private static string pluginGuid;
public override string Name => "cuervo";
public override string Help => "Envía un mensaje con Hugin";
public override void Run(string[] args)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
Chat instance = Chat.instance;
if (args.Length == 0)
{
return;
}
if (args.Length < 2)
{
((Terminal)instance).AddString("Uso: /cuervo <jugador> <mensaje> <munin>");
return;
}
string text = args[0];
string text2 = args[1];
string text3 = "0";
if (args.Length == 3)
{
text3 = args[2];
}
string playerName = Player.m_localPlayer.GetPlayerName();
ZPackage val = new ZPackage();
val.Write(playerName);
val.Write(text);
val.Write(text2);
val.Write(text3 == "1");
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "HuginRelayRPC", new object[1] { val });
((Terminal)instance).AddString("[cuervo] Mensaje enviado al host para " + text);
}
public static void OnHuginRelayRPC(long sender, ZPackage pkg)
{
string text = pkg.ReadString();
string text2 = pkg.ReadString();
string text3 = pkg.ReadString();
bool flag = pkg.ReadBool();
Chat instance = Chat.instance;
((Terminal)instance).AddString("[cuervo] Relaying message from '" + text + "' to '" + text2 + "': " + text3);
((Terminal)instance).AddString($"total Jugadores '{ZNet.instance.GetPeers().Count}' .");
foreach (ZNetPeer peer in ZNet.instance.GetPeers())
{
((Terminal)instance).AddString("comprobando Jugador '" + peer.m_playerName + "'.");
if (peer.m_playerName.Equals(text2, StringComparison.OrdinalIgnoreCase))
{
string text4 = "Mensaje de " + text;
ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "RPC_ShowRavenMessage", new object[3] { text4, text3, flag });
return;
}
}
((Terminal)instance).AddString("[cuervo] No se encontró al jugador '" + text2 + "'.");
}
public HuginCommand(string pluginGuid)
{
HuginCommand.pluginGuid = pluginGuid;
}
private void MostrarMensajeConHugin(Player jugador, string mensaje)
{
}
public override List<string> CommandOptionList()
{
ZNetScene instance = ZNetScene.instance;
return (instance != null) ? instance.GetPrefabNames() : null;
}
}
public class RenameCommand : ConsoleCommand
{
public override string Name => "renombrar";
public override string Help => "Renombra el arma equipada.";
public override void Run(string[] args)
{
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
((Terminal)Chat.instance).AddString("No hay un jugador local.");
return;
}
if (args.Length < 1)
{
((Terminal)Chat.instance).AddString("Uso: /renombrar <nombre>");
return;
}
string text = args[0].Trim();
ItemData rightItem = ((Humanoid)Player.m_localPlayer).GetRightItem();
if (rightItem != null)
{
ItemUniqueIdManager.AssignUniqueId(rightItem);
string uniqueId = ItemUniqueIdManager.GetUniqueId(rightItem);
if (uniqueId != null)
{
string name = rightItem.m_shared.m_name;
CustomWeaponNameStorage.SetName(uniqueId, text);
rightItem.m_shared.m_name = text;
((Terminal)Chat.instance).AddString("El arma ha sido renombrada a: " + text);
}
else
{
((Terminal)Chat.instance).AddString("No se pudo asignar un identificador único al arma.");
}
}
else
{
((Terminal)Chat.instance).AddString("No tienes un arma equipada.");
}
}
}
public class SecretBaseCommand : ConsoleCommand
{
public static Vector3 secretBasePosition = new Vector3(0f, 20500f, 0f);
public override string Name => "basesecreta";
public override string Help => "Teletransporta a la base secreta";
public static void CreateHollowCube(Vector3 position, float size = 64f)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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_004b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_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_009f: 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_00bd: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
float num = 0.2f;
GameObject prefab = ZNetScene.instance.GetPrefab("stone_wall_1x1");
object obj;
if (prefab == null)
{
obj = null;
}
else
{
Renderer componentInChildren = prefab.GetComponentInChildren<Renderer>();
obj = ((componentInChildren != null) ? componentInChildren.sharedMaterial : null);
}
Material stoneMat = (Material)obj;
CreateWall(Vector3.down * (size / 2f), new Vector3(size, num, size), "HollowCube_Bottom");
CreateWall(Vector3.forward * (size / 2f), new Vector3(size, size, num), "HollowCube_Front");
CreateWall(Vector3.back * (size / 2f), new Vector3(size, size, num), "HollowCube_Back");
CreateWall(Vector3.left * (size / 2f), new Vector3(num, size, size), "HollowCube_Left");
CreateWall(Vector3.right * (size / 2f), new Vector3(num, size, size), "HollowCube_Right");
void CreateWall(Vector3 localPos, Vector3 scale, string name)
{
//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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)GameObject.Find(name) != (Object)null))
{
GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
val.transform.position = position + localPos;
val.transform.localScale = scale;
((Object)val).name = name;
if ((Object)(object)stoneMat != (Object)null)
{
Renderer component = val.GetComponent<Renderer>();
component.sharedMaterial = stoneMat;
}
ZNetView val2 = val.AddComponent<ZNetView>();
val2.m_persistent = true;
}
}
}
public override void Run(string[] args)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0066: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Player.m_localPlayer == (Object)null))
{
GameObject val = new GameObject("SecretBaseDungeon");
val.transform.position = secretBasePosition;
CreateHollowCube(secretBasePosition);
((Character)Player.m_localPlayer).TeleportTo(secretBasePosition + Vector3.up * -60f, ((Component)Player.m_localPlayer).transform.rotation, true);
((Terminal)Chat.instance).AddString("¡Bienvenido a tu base secreta!");
}
}
}
}
namespace ComfyLib
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class ComfyConfigAttribute : Attribute
{
internal readonly MethodBase TargetMethod;
public ComfyConfigAttribute()
{
TargetMethod = null;
}
public ComfyConfigAttribute(Type lateBindType, string lateBindMethodName)
{
TargetMethod = AccessTools.Method(lateBindType, lateBindMethodName, (Type[])null, (Type[])null);
}
}
[HarmonyPatch]
public static class ComfyConfigUtils
{
private sealed class ConfigBinder
{
public readonly ConfigFile ConfigFile;
public readonly MethodBase TargetMethod;
public readonly MethodBase BindConfigMethod;
public ConfigBinder(ConfigFile configFile, MethodBase targetMethod, MethodBase bindConfigMethod)
{
ConfigFile = configFile;
TargetMethod = targetMethod;
BindConfigMethod = bindConfigMethod;
}
}
private static readonly Dictionary<MethodBase, List<ConfigBinder>> _configBinders = new Dictionary<MethodBase, List<ConfigBinder>>();
private static IEnumerable<MethodBase> TargetMethods()
{
return _configBinders.Keys;
}
private static void Postfix(MethodBase __originalMethod)
{
if (_configBinders.Count <= 0 || !_configBinders.TryGetValue(__originalMethod, out var value))
{
return;
}
foreach (ConfigBinder item in value)
{
item.BindConfigMethod.Invoke(null, new object[1] { item.ConfigFile });
}
value.Clear();
_configBinders.Remove(__originalMethod);
}
public static void BindConfig(ConfigFile config)
{
List<MethodInfo> bindConfigMethods = GetBindConfigMethods(Assembly.GetExecutingAssembly());
foreach (MethodInfo item in bindConfigMethods)
{
ComfyConfigAttribute customAttribute = item.GetCustomAttribute<ComfyConfigAttribute>(inherit: false);
if (customAttribute.TargetMethod == null)
{
item.Invoke(null, new object[1] { config });
}
else
{
AddConfigBinder(config, customAttribute.TargetMethod, item);
}
}
}
private static void AddConfigBinder(ConfigFile configFile, MethodBase targetMethod, MethodBase bindConfigMethod)
{
if (!_configBinders.TryGetValue(targetMethod, out var value))
{
value = new List<ConfigBinder>();
_configBinders[targetMethod] = value;
}
value.Add(new ConfigBinder(configFile, targetMethod, bindConfigMethod));
}
private static List<MethodInfo> GetBindConfigMethods(Assembly assembly)
{
List<MethodInfo> list = new List<MethodInfo>();
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
ComfyConfigAttribute customAttribute = methodInfo.GetCustomAttribute<ComfyConfigAttribute>(inherit: false);
if (customAttribute != null)
{
ParameterInfo[] parameters = methodInfo.GetParameters();
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ConfigFile))
{
list.Add(methodInfo);
}
}
}
}
return list;
}
}
public static class ConfigFileExtensions
{
internal sealed class ConfigurationManagerAttributes
{
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public bool? HideDefaultButton;
public bool? HideSettingName;
public bool? IsAdvanced;
public int? Order;
public bool? ReadOnly;
}
private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>();
private static int GetSettingOrder(string section)
{
if (!_sectionToSettingOrder.TryGetValue(section, out var value))
{
value = 0;
}
_sectionToSettingOrder[section] = value - 1;
return value;
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1]
{
new ConfigurationManagerAttributes
{
Browsable = browsable,
CustomDrawer = null,
HideDefaultButton = hideDefaultButton,
HideSettingName = hideSettingName,
IsAdvanced = isAdvanced,
Order = GetSettingOrder(section),
ReadOnly = readOnly
}
}));
}
public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Browsable = browsable,
CustomDrawer = customDrawer,
HideDefaultButton = hideDefaultButton,
HideSettingName = hideSettingName,
IsAdvanced = isAdvanced,
Order = GetSettingOrder(section),
ReadOnly = readOnly
}
}));
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler)
{
configEntry.SettingChanged += delegate
{
settingChangedHandler();
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler)
{
configEntry.SettingChanged += delegate(object _, EventArgs eventArgs)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
settingChangedHandler((ConfigEntry<T>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue);
};
}
}
public static class ComponentExtensions
{
public static bool TryGetComponentInParent<T>(this Component source, out T component) where T : Component
{
component = source.GetComponentInParent<T>();
return Object.op_Implicit((Object)(object)component);
}
}
public static class GameObjectExtensions
{
public static T GetOrAddComponent<T>(this GameObject gameObject) where T : Component
{
T result = default(T);
if (!gameObject.TryGetComponent<T>(ref result))
{
return gameObject.AddComponent<T>();
}
return result;
}
}
public static class ObjectExtensions
{
public static T FirstByNameOrDefault<T>(this IEnumerable<T> unityObjects, string name) where T : Object
{
foreach (T unityObject in unityObjects)
{
if (((Object)unityObject).name == name)
{
return unityObject;
}
}
return default(T);
}
public static T FirstByNameOrThrow<T>(this IEnumerable<T> unityObjects, string name) where T : Object
{
foreach (T unityObject in unityObjects)
{
if (((Object)unityObject).name == name)
{
return unityObject;
}
}
throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}");
}
public static T Ref<T>(this T unityObject) where T : Object
{
return Object.op_Implicit((Object)(object)unityObject) ? unityObject : default(T);
}
}
public static class RectMask2DExtensions
{
public static RectMask2D SetPadding(this RectMask2D rectMask, float left, float top, float right, float bottom)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
rectMask.padding = new Vector4(left, bottom, right, top);
return rectMask;
}
public static RectMask2D SetSoftness(this RectMask2D rectMask, int horizontal, int vertical)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
rectMask.softness = new Vector2Int(horizontal, vertical);
return rectMask;
}
}
public static class TMPInputFieldExtensions
{
public static TMP_InputField SetRichText(this TMP_InputField inputField, bool richText)
{
inputField.richText = richText;
return inputField;
}
public static TMP_InputField SetTextViewport(this TMP_InputField inputField, RectTransform viewport)
{
inputField.textViewport = viewport;
return inputField;
}
}
public static class TextMeshProUGUIExtensions
{
public static TextMeshProUGUI SetColor(this TextMeshProUGUI text, Color color)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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)
if (((Graphic)text).color != color)
{
((Graphic)text).color = color;
}
return text;
}
public static TextMeshProUGUI SetFont(this TextMeshProUGUI text, TMP_FontAsset font)
{
if ((Object)(object)((TMP_Text)text).font != (Object)(object)font)
{
((TMP_Text)text).font = font;
}
return text;
}
}
public static class UIFonts
{
public static readonly Dictionary<string, Font> FontCache = new Dictionary<string, Font>();
public static readonly string ValheimNorse = "Valheim-Norse";
public static readonly string ValheimNorsebold = "Valheim-Norsebold";
public static readonly string FallbackNotoSansNormal = "Fallback-NotoSansNormal";
public static readonly Dictionary<string, TMP_FontAsset> FontAssetCache = new Dictionary<string, TMP_FontAsset>();
public static Font GetFont(string fontName)
{
if (!FontCache.TryGetValue(fontName, out var value))
{
value = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstByNameOrThrow<Font>(fontName);
FontCache[fontName] = value;
}
return value;
}
public static TMP_FontAsset GetFontAsset(string fontName)
{
if (!FontAssetCache.TryGetValue(fontName, out var value))
{
value = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstByNameOrDefault<TMP_FontAsset>(fontName);
if (!Object.op_Implicit((Object)(object)value))
{
Font font = GetFont(fontName);
value = TMP_FontAsset.CreateFontAsset(font);
((Object)value).name = fontName;
}
FontAssetCache[fontName] = value;
}
return value;
}
}
}