using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; 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; using BepInEx; using HarmonyLib; using LitJson2; using TMPro; using UnityEngine; using UnityEngine.Events; 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("PlayerColors")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PlayerColors")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("557f8e2f-a3ae-46a6-88b4-1e0416ad09c5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public static class BalrondHashCompat { private static readonly MethodInfo _getStableHashCodeStringBool; private static readonly MethodInfo _getStableHashCodeString; private static readonly bool _initialized; static BalrondHashCompat() { try { Type typeFromHandle = typeof(StringExtensionMethods); _getStableHashCodeStringBool = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(string), typeof(bool) }, null); _getStableHashCodeString = typeFromHandle.GetMethod("GetStableHashCode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(string) }, null); _initialized = true; } catch { _initialized = false; } } public static int StableHash(string value) { if (value == null) { return 0; } try { if (_getStableHashCodeStringBool != null) { return (int)_getStableHashCodeStringBool.Invoke(null, new object[2] { value, false }); } if (_getStableHashCodeString != null) { return (int)_getStableHashCodeString.Invoke(null, new object[1] { value }); } } catch { } return FallbackStableHash(value); } private static int FallbackStableHash(string value) { int num = 5381; int num2 = num; for (int i = 0; i < value.Length; i += 2) { num = ((num << 5) + num) ^ value[i]; if (i == value.Length - 1) { break; } num2 = ((num2 << 5) + num2) ^ value[i + 1]; } return num + num2 * 1566083941; } } namespace BalPlayerColorsrondVnV { [Serializable] public class MappedEffectList { public List pieceEffect; public List destroyedEffects; public List hitEffects; public List switchEffect; public List blockEffect; public List equipEffect; public List hitEffect; public List hitTerrainEffect; public List holdStartEffect; public List startEffect; public List trailStartEffect; public List triggerEffect; public List unequipEffect; public EffectList createEffectListFromInfo(List list) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EffectList val = new EffectList(); List list2 = new List(); val.m_effectPrefabs = list2.ToArray(); return val; } private EffectData createEffectData(EffectInfo info) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown EffectData val = new EffectData(); val.m_inheritParentRotation = info.inheritRotation; val.m_multiplyParentVisualScale = info.multiplyScale; val.m_childTransform = info.childName; val.m_inheritParentScale = info.inheritScale; val.m_variant = info.variant; val.m_scale = info.scale; val.m_attach = info.attach; val.m_follow = info.follow; val.m_prefab = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == info.name); return val; } } [Serializable] public struct EffectInfo { public string name; public bool enabled; public int variant; public bool attach; public bool follow; public bool inheritRotation; public bool inheritScale; public bool multiplyScale; public bool radnomRotation; public bool scale; public string childName; public EffectInfo(string name, bool enabled = true, int variant = -1, bool attach = false, bool follow = false, bool inheritRotation = false, bool inheritScale = false, bool multiplyScale = false, bool radnomRotation = false, bool scale = false, string childName = null) { this.name = name; this.enabled = enabled; this.variant = variant; this.attach = attach; this.follow = follow; this.inheritRotation = inheritRotation; this.inheritScale = inheritScale; this.multiplyScale = multiplyScale; this.radnomRotation = radnomRotation; this.scale = scale; this.childName = childName; } } } namespace PlayerColors { public class BalrondPlayerCustomization : MonoBehaviour { private ZNetView netView; private Player _player; private VisEquipment _visEquipment; private SkinnedMeshRenderer _meshRenderer; private Transform _visual; public Color eyeColor; public Vector3 eyeColorVector; public float height = 0f; public GameObject eyesObject; public GameObject _eyesInstanced; public int eyesItemHash; public bool isFemale = false; private void Start() { netView = ((Component)this).GetComponent(); _player = ((Component)this).GetComponent(); _visEquipment = ((Component)this).GetComponent(); if ((Object)(object)_player == (Object)null || (Object)(object)_visEquipment == (Object)null) { return; } _meshRenderer = _visEquipment.m_bodyModel; if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null) { eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal"); eyesItemHash = (((Object)(object)eyesObject != (Object)null) ? ((object)eyesObject).GetHashCode() : 0); } if ((Object)(object)Launch.eyesObject != (Object)null) { eyesObject = Launch.eyesObject; if ((Object)(object)_eyesInstanced == (Object)null) { _eyesInstanced = Launch.AttachItem(eyesObject, -1, _visEquipment.m_helmet, _visEquipment); Transform val = _eyesInstanced.transform.Find("body"); ((Component)val).GetComponent().sharedMesh = _meshRenderer.sharedMesh; } } _visual = ((Component)_player).transform.Find("Visual"); if ((Object)(object)netView != (Object)null) { GetPlayerColor(); GetPlayerHeight(); } } public void SetEyeColor(Color eyeColor) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //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_001c: Unknown result type (might be due to invalid IL or missing references) this.eyeColor = eyeColor; eyeColorVector = Utils.ColorToVec3(eyeColor); SaveToCustomData(); ApplyColorToInstancedEyes(eyeColor); } public void SetHeight(float height) { this.height = height; SaveHeightToCustomData(); ApplyHeight(height); } public void SaveHeightToCustomData() { if (!((Object)(object)_player == (Object)null)) { _player.m_customData.Remove("BalrondHeight"); _player.m_customData.Add("BalrondHeight", height.ToString()); } } public void SaveToCustomData() { if (!((Object)(object)_player == (Object)null)) { _player.m_customData.Remove("BalrondEyesX"); _player.m_customData.Remove("BalrondEyesY"); _player.m_customData.Remove("BalrondEyesZ"); _player.m_customData.Add("BalrondEyesX", eyeColorVector.x.ToString()); _player.m_customData.Add("BalrondEyesY", eyeColorVector.y.ToString()); _player.m_customData.Add("BalrondEyesZ", eyeColorVector.z.ToString()); } } public float GetHeightFromPlayerCustomData(Player player = null) { string value = "0"; Player val = _player; if ((Object)(object)player != (Object)null) { val = player; } string s = (val.m_customData.TryGetValue("BalrondHeight", out value) ? value : "0"); return float.Parse(s); } public Vector3 GetFromPlayerCustomData(Player player = null) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) string value = "1"; string value2 = "1"; string value3 = "1"; Player val = _player; if ((Object)(object)player != (Object)null) { val = player; } string s = (val.m_customData.TryGetValue("BalrondEyesX", out value) ? value : "1"); string s2 = (val.m_customData.TryGetValue("BalrondEyesY", out value2) ? value2 : "1"); string s3 = (val.m_customData.TryGetValue("BalrondEyesZ", out value3) ? value3 : "1"); return new Vector3(float.Parse(s), float.Parse(s2), float.Parse(s3)); } private void GetPlayerColor() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_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) eyeColorVector = GetFromPlayerCustomData(); eyeColor = new Color(eyeColorVector.x, eyeColorVector.y, eyeColorVector.z, 1f); SetEyeColor(eyeColor); } private void GetPlayerHeight() { height = GetHeightFromPlayerCustomData(); SetHeight(height); } private void ApplyHeight(float height) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (height != 0f && (Object)(object)_visual != (Object)null) { _visual.localScale = new Vector3(0.95f, 0.95f + height, 0.95f); } } private void ApplyColorToInstancedEyes(Color color) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_eyesInstanced == (Object)null)) { Renderer[] componentsInChildren = _eyesInstanced.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { Material material = componentsInChildren[i].material; material.SetColor("_Color", color); material.SetColor("_EmissionColor", color); } } } } public class BalrondTranslator { public static Dictionary> translations = new Dictionary>(); public static Dictionary getLanguage(string language) { if (string.IsNullOrEmpty(language)) { return null; } if (translations.TryGetValue(language, out var value)) { return value; } return null; } } [BepInPlugin("balrond.astafaraios.BalrondCharacterCustomization", "BalrondCharacterCustomization", "0.1.6")] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class Object_CopyOtherDB_Path { public static void Postfix() { if (!IsObjectDBValid()) { return; } databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); ShaderReplacment.runMaterialFix(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hair3"); if (!((Object)(object)itemPrefab != (Object)null)) { return; } Material val = null; Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren(); foreach (Renderer val2 in componentsInChildren) { val = val2.material; } foreach (GameObject itemPrefab2 in modResourceLoader.itemPrefabs) { if (((Object)itemPrefab2).name.Contains("Hair") && (Object)(object)val != (Object)null) { Renderer[] componentsInChildren2 = itemPrefab.GetComponentsInChildren(); foreach (Renderer val3 in componentsInChildren2) { val3.material = val; } } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Path { public static void Postfix() { if (IsObjectDBValid()) { databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); databaseAddMethods.AddRecipes(modResourceLoader.recipes); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Path { public static bool hasSpawned; public static void Prefix(ZNetScene __instance) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { Debug.LogWarning((object)(projectName + ": No ZnetScene found")); return; } modResourceLoader.AddPrefabsToZnetScene(__instance); GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player"); BalrondPlayerCustomization component = val.GetComponent(); if ((Object)(object)component == (Object)null) { val.AddComponent(); } if (!Launch.hasSpawned) { if (new ZNet().IsDedicated()) { Launch.hasSpawned = true; return; } ShaderReplacment.runMaterialFix(); Launch.hasSpawned = true; } } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] private class FejdStartup_SetupGUI { private static void Postfix() { string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary translations = GetTranslations(selectedLanguage); AddTranslations(translations); RefreshLabels(); } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "SetupLanguage")] private class Translation_SetupLanguage { private static void Prefix(Localization __instance, string language) { Dictionary translations = GetTranslations(language); AddTranslations(translations, __instance); RefreshLabels(); } } [HarmonyPriority(800)] [HarmonyPatch(typeof(Localization), "LoadCSV")] private class Translation_LoadCSV { private static void Prefix(Localization __instance, string language) { Dictionary translations = GetTranslations(language); AddTranslations(translations, __instance); RefreshLabels(); } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardLeft")] public static class PlayerCustomizatonOnBeardLeft { public static void Prefix(PlayerCustomizaton __instance) { if (__instance.GetPlayer().GetPlayerModel() == 0) { return; } int num = __instance.GetBeardIndex(); for (int num2 = num - 1; num2 >= 0; num2--) { if (__instance.m_beards[num2].m_itemData.m_shared.m_toolTier <= __instance.m_hairToolTier) { num = num2; break; } } __instance.SetBeard(num); } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardRight")] public static class PlayerCustomizatonOnBeardRight { public static void Prefix(PlayerCustomizaton __instance) { if (__instance.GetPlayer().GetPlayerModel() == 0) { return; } int num = __instance.GetBeardIndex(); for (int i = num + 1; i < __instance.m_beards.Count; i++) { if (__instance.m_beards[i].m_itemData.m_shared.m_toolTier <= __instance.m_hairToolTier) { num = i; break; } } __instance.SetBeard(num); } } [HarmonyPatch(typeof(PlayerCustomizaton), "SetPlayerModel")] public static class PlayerCustomizaton_SetPlayerModel_Patch { public static void Postfix(PlayerCustomizaton __instance, int index) { Player player = __instance.GetPlayer(); if (Object.op_Implicit((Object)(object)player)) { BalrondPlayerCustomization component = ((Component)player).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component._eyesInstanced == (Object)null)) { ((MonoBehaviour)player).StartCoroutine(ApplyEyesMeshNextFrame(player, component, index)); } } } private static IEnumerator ApplyEyesMeshNextFrame(Player player, BalrondPlayerCustomization balrond, int modelIndex) { yield return null; VisEquipment ve = ((Humanoid)player).m_visEquipment; if ((Object)(object)ve == (Object)null || (Object)(object)ve.m_bodyModel == (Object)null) { yield break; } SkinnedMeshRenderer bodySMR = ve.m_bodyModel; Transform eyeTransform = balrond._eyesInstanced.transform.Find("body"); if (!((Object)(object)eyeTransform == (Object)null)) { SkinnedMeshRenderer eyesSMR = ((Component)eyeTransform).GetComponent(); if (!((Object)(object)eyesSMR == (Object)null)) { eyesSMR.sharedMesh = bodySMR.sharedMesh; eyesSMR.rootBone = bodySMR.rootBone; eyesSMR.bones = bodySMR.bones; } } } } [HarmonyPatch(typeof(FejdStartup), "Awake")] public static class FejdStartup_Awake_Patch { public static void Postfix(FejdStartup __instance) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) Transform val = FejdStartup.instance.m_selectCharacterPanel.transform.Find("BottomWindow"); Transform val2 = Object.Instantiate(val.Find("New")); ((Object)val2).name = "Edit"; ((Component)val2).transform.SetParent(val); ((Component)val2).GetComponent().anchoredPosition = Vector2.op_Implicit(new Vector3(-100f, 50f, 0f)); editButton = ((Component)((Component)val2).transform.Find("Text")).GetComponent(); editButton.text = Localization.instance.Localize("$tag_edit_character_button"); ((UnityEventBase)((Component)val2).GetComponent