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 balrond character customization v2.0.25
plugins/BalrondCharacterCustomization.dll
Decompiled 2 weeks 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.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using LitJson2; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using Unity.Profiling; using UnityEngine; using UnityEngine.EventSystems; 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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.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; } } } public static class BalrondHashCompat { public static int StableHash(string value) { if (value == null) { return 0; } 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<EffectInfo> pieceEffect; public List<EffectInfo> destroyedEffects; public List<EffectInfo> hitEffects; public List<EffectInfo> switchEffect; public List<EffectInfo> blockEffect; public List<EffectInfo> equipEffect; public List<EffectInfo> hitEffect; public List<EffectInfo> hitTerrainEffect; public List<EffectInfo> holdStartEffect; public List<EffectInfo> startEffect; public List<EffectInfo> trailStartEffect; public List<EffectInfo> triggerEffect; public List<EffectInfo> unequipEffect; public EffectList createEffectListFromInfo(List<EffectInfo> 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<EffectData> list2 = new List<EffectData>(); 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 { [BepInPlugin("balrond.astafaraios.BalrondCharacterCustomization", "BalrondCharacterCustomization", "2.0.25")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Launch : BaseUnityPlugin { private struct ExactRgbState { public int PlayerInstanceId; public Vector3 Color; public bool Valid; } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class Object_CopyOtherDB_Path { public static void Postfix() { if (IsObjectDBValid()) { databaseAddMethods.AddItems(modResourceLoader.itemPrefabs); ShaderReplacment.runMaterialFix(); FixCustomHairAndBeardMaterials(); } } } [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); FixCustomHairAndBeardMaterials(); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Path { public static bool hasSpawned; public static void Prefix(ZNetScene __instance) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { LogWarningOnce("Core/Launch.cs:1", projectName + ": No ZnetScene found"); return; } modResourceLoader.AddPrefabsToZnetScene(__instance); GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player"); if ((Object)(object)val != (Object)null) { VisEquipment component = val.GetComponent<VisEquipment>(); if (!CompatibilityManager.YieldStructuralAppearance && (Object)(object)component != (Object)null) { BodyTypeManager.EnsureSlimModel(component); } BalrondPlayerCustomization component2 = val.GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)component2 == (Object)null) { val.AddComponent<BalrondPlayerCustomization>(); } } if (!Launch.hasSpawned) { if (new ZNet().IsDedicated()) { Launch.hasSpawned = true; return; } ShaderReplacment.runMaterialFix(); Launch.hasSpawned = true; } } } [HarmonyPatch(typeof(VisEquipment), "UpdateBaseModel")] [HarmonyAfter(new string[] { "balrond.astafaraios.BalrondDualMastery", "ishid4.mods.betterarchery", "windstride.bowanimations", "Raelaziel.OdinHorse", "com.nandor.racesofvalheim", "Azathoth.LinejaeserasRace" })] public static class VisEquipment_UpdateBaseModel_BRC_Patch { public static void Postfix(VisEquipment __instance) { if ((Object)(object)__instance == (Object)null) { return; } BalrondPlayerCustomization balrondPlayerCustomization = ((Component)__instance).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)balrondPlayerCustomization == (Object)null) { balrondPlayerCustomization = ((Component)__instance).GetComponentInParent<BalrondPlayerCustomization>(); } if (!((Object)(object)balrondPlayerCustomization == (Object)null)) { if (CompatibilityManager.UseExternalRaceMorphologyOverlay) { balrondPlayerCustomization.OnExternalRaceVisualsChanged(); return; } balrondPlayerCustomization.RefreshEyesBinding(); balrondPlayerCustomization.RefreshTattoo(force: true); } } } [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] [HarmonyAfter(new string[] { "com.nandor.racesofvalheim", "Azathoth.LinejaeserasRace" })] public static class VisEquipment_UpdateVisuals_BRC_ExternalMorph_Patch { [HarmonyPriority(0)] public static void Postfix(VisEquipment __instance) { if (CompatibilityManager.UseExternalRaceMorphologyOverlay && !((Object)(object)__instance == (Object)null)) { BalrondPlayerCustomization balrondPlayerCustomization = ((Component)__instance).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)balrondPlayerCustomization == (Object)null) { balrondPlayerCustomization = ((Component)__instance).GetComponentInParent<BalrondPlayerCustomization>(); } if (!((Object)(object)balrondPlayerCustomization == (Object)null)) { balrondPlayerCustomization.OnExternalRaceVisualsChanged(); } } } } [HarmonyPatch(typeof(VisEquipment), "UpdateColors")] [HarmonyAfter(new string[] { "balrond.astafaraios.BalrondDualMastery", "ishid4.mods.betterarchery", "windstride.bowanimations", "Raelaziel.OdinHorse" })] public static class VisEquipment_UpdateColors_BRC_Patch { public static void Postfix(VisEquipment __instance) { if (!((Object)(object)__instance == (Object)null)) { BalrondPlayerCustomization balrondPlayerCustomization = ((Component)__instance).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)balrondPlayerCustomization == (Object)null) { balrondPlayerCustomization = ((Component)__instance).GetComponentInParent<BalrondPlayerCustomization>(); } if (!((Object)(object)balrondPlayerCustomization == (Object)null)) { balrondPlayerCustomization.RefreshRaceExtraSkinColor(force: false); balrondPlayerCustomization.RefreshTattoo(force: true); } } } } [HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")] [HarmonyAfter(new string[] { "balrond.astafaraios.BalrondDualMastery", "ishid4.mods.betterarchery", "windstride.bowanimations", "Raelaziel.OdinHorse" })] public static class VisEquipment_UpdateEquipmentVisuals_BRC_Patch { public static void Postfix(VisEquipment __instance) { if (!((Object)(object)__instance == (Object)null)) { BalrondPlayerCustomization balrondPlayerCustomization = ((Component)__instance).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)balrondPlayerCustomization == (Object)null) { balrondPlayerCustomization = ((Component)__instance).GetComponentInParent<BalrondPlayerCustomization>(); } if ((Object)(object)balrondPlayerCustomization != (Object)null) { balrondPlayerCustomization.OnEquipmentVisualsChanged(); } } } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] private class FejdStartup_SetupGUI { private static void Postfix() { string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary<string, string> 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<string, string> 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<string, string> translations = GetTranslations(language); AddTranslations(translations, __instance); RefreshLabels(); } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardLeft")] public static class PlayerCustomizatonOnBeardLeft { public static void Prefix(PlayerCustomizaton __instance) { if (CompatibilityManager.YieldStructuralAppearance || (Object)(object)__instance == (Object)null || !BodyTypeManager.IsFemaleModelIndex(__instance.GetPlayer().GetPlayerModel())) { 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 (CompatibilityManager.YieldStructuralAppearance || (Object)(object)__instance == (Object)null || !BodyTypeManager.IsFemaleModelIndex(__instance.GetPlayer().GetPlayerModel())) { 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 bool Prefix(PlayerCustomizaton __instance) { return !BarberUiIsPopulating || !IsBarberCustomization(__instance); } public static void Postfix(PlayerCustomizaton __instance, int index) { if ((Object)(object)__instance == (Object)null || (BarberUiIsPopulating && IsBarberCustomization(__instance))) { return; } Player player = __instance.GetPlayer(); if (Object.op_Implicit((Object)(object)player)) { BalrondPlayerCustomization component = ((Component)player).GetComponent<BalrondPlayerCustomization>(); if (!((Object)(object)component == (Object)null)) { ((MonoBehaviour)player).StartCoroutine(ApplyBodyVisualFollowupNextFrame(player, component)); } } } private static IEnumerator ApplyBodyVisualFollowupNextFrame(Player player, BalrondPlayerCustomization balrond) { yield return null; if (!((Object)(object)player == (Object)null) && !((Object)(object)balrond == (Object)null)) { if (CompatibilityManager.UseExternalRaceMorphologyOverlay) { balrond.OnExternalRaceVisualsChanged(); yield break; } balrond.OnPlayerModelChanged(player.GetPlayerModel()); balrond.RefreshEyesBinding(); balrond.RefreshTattoo(force: true); } } } [HarmonyPatch(typeof(FejdStartup), "Awake")] public static class FejdStartup_Awake_Patch { [CompilerGenerated] private static class <>O { public static UnityAction <0>__StartCharacterEdit; } public static void Postfix(FejdStartup __instance) { //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_039c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } if ((Object)(object)__instance.m_newCharacterPanel != (Object)null) { RaceUI.CaptureCharacterTemplate(__instance.m_newCharacterPanel.transform.Find("CusomizationPanel/SexPanel")); } EnsureEyesPrefab(); if ((Object)(object)__instance.m_playerPrefab != (Object)null) { VisEquipment val = __instance.m_playerPrefab.GetComponent<VisEquipment>(); if ((Object)(object)val == (Object)null) { val = __instance.m_playerPrefab.GetComponentInChildren<VisEquipment>(true); } if (!CompatibilityManager.YieldStructuralAppearance && (Object)(object)val != (Object)null) { BodyTypeManager.EnsureSlimModel(val); } if ((Object)(object)__instance.m_playerPrefab.GetComponent<BalrondPlayerCustomization>() == (Object)null) { __instance.m_playerPrefab.AddComponent<BalrondPlayerCustomization>(); } } if ((Object)(object)__instance.m_selectCharacterPanel == (Object)null || (Object)(object)__instance.m_newCharacterPanel == (Object)null) { return; } Transform val2 = __instance.m_newCharacterPanel.transform.Find("Topic"); if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).GetComponent<TMP_Text>() == (Object)null || (Object)(object)((Component)val2).GetComponent<RectTransform>() == (Object)null) { return; } Transform val3 = __instance.m_selectCharacterPanel.transform.Find("BottomWindow"); if ((Object)(object)val3 == (Object)null || (Object)(object)val3.Find("Edit") != (Object)null) { return; } Transform val4 = val3.Find("New"); if ((Object)(object)val4 == (Object)null || (Object)(object)((Component)val4).GetComponent<RectTransform>() == (Object)null || (Object)(object)((Component)val4).GetComponent<Button>() == (Object)null || (Object)(object)val4.Find("Text") == (Object)null || (Object)(object)((Component)val4.Find("Text")).GetComponent<TMP_Text>() == (Object)null) { return; } Transform val5 = Object.Instantiate<Transform>(val4); ((Object)val5).name = "Edit"; val5.SetParent(val3); ((Component)val5).GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3(-100f, 50f, 0f)); editButton = ((Component)((Component)val5).transform.Find("Text")).GetComponent<TMP_Text>(); editButton.text = Localization.instance.Localize("$tag_edit_character_button"); ((UnityEventBase)((Component)val5).GetComponent<Button>().onClick).RemoveAllListeners(); ((Component)val5).GetComponent<Button>().onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = ((Component)val5).GetComponent<Button>().onClick; object obj = <>O.<0>__StartCharacterEdit; if (obj == null) { UnityAction val6 = StartCharacterEdit; <>O.<0>__StartCharacterEdit = val6; obj = (object)val6; } ((UnityEvent)onClick).AddListener((UnityAction)obj); UIGamePad component = ((Component)val5).GetComponent<UIGamePad>(); if ((Object)(object)component != (Object)null) { component.m_zinputKey = "JoyLTrigger"; } Transform val7 = val5.Find("gamepad_hint/Text"); if ((Object)(object)val7 != (Object)null) { TextMeshProUGUI component2 = ((Component)val7).GetComponent<TextMeshProUGUI>(); if ((Object)(object)component2 != (Object)null) { ((TMP_Text)component2).text = "LT"; } } title = __instance.m_newCharacterPanel.transform.Find("EditTitle"); if ((Object)(object)title == (Object)null) { title = Object.Instantiate<Transform>(val2); } editTitle = ((Component)title).GetComponent<TMP_Text>(); ((Object)title).name = "EditTitle"; title.SetParent(__instance.m_newCharacterPanel.transform); editTitle.text = Localization.instance.Localize("$tag_edit_character_panel"); ((Component)title).GetComponent<RectTransform>().anchoredPosition = ((Component)val2).GetComponent<RectTransform>().anchoredPosition; ((Component)title).gameObject.SetActive(false); } } private sealed class CustomizationSliderBinding { public PlayerCustomizaton Owner; public UnityAction<float> Callback; } [HarmonyPatch(typeof(FejdStartup), "SetupCharacterPreview")] public static class FejdStartup_SetupCharacterPreview_Patch { public static void Postfix(FejdStartup __instance) { //IL_005e: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_01ac: Unknown result type (might be due to invalid IL or missing references) EnsureEyesPrefab(); if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_playerInstance == (Object)null) { return; } BalrondPlayerCustomization component = __instance.m_playerInstance.GetComponent<BalrondPlayerCustomization>(); if (!((Object)(object)component != (Object)null)) { return; } Player previewPlayer = __instance.GetPreviewPlayer(); if ((Object)(object)previewPlayer == (Object)null) { return; } Vector3 fromPlayerCustomData = component.GetFromPlayerCustomData(previewPlayer); float heightFromPlayerCustomData = component.GetHeightFromPlayerCustomData(previewPlayer); string raceFromPlayerCustomData = component.GetRaceFromPlayerCustomData(previewPlayer); BrcBodyType bodyTypeFromPlayerCustomData = component.GetBodyTypeFromPlayerCustomData(previewPlayer); string tattooFromPlayerCustomData = component.GetTattooFromPlayerCustomData(previewPlayer); component.SetBodyType(bodyTypeFromPlayerCustomData, save: false); component.SetRace(raceFromPlayerCustomData, save: false); component.SetTattoo(tattooFromPlayerCustomData, save: false); if ((Object)(object)component._eyesInstanced == (Object)null && (Object)(object)eyesObject != (Object)null && (Object)(object)((Humanoid)previewPlayer).m_visEquipment != (Object)null && (Object)(object)((Humanoid)previewPlayer).m_visEquipment.m_helmet != (Object)null) { component._eyesInstanced = AttachItem(eyesObject, -1, ((Humanoid)previewPlayer).m_visEquipment.m_helmet, ((Humanoid)previewPlayer).m_visEquipment); } component.SetEyeColor(new Color(fromPlayerCustomData.x, fromPlayerCustomData.y, fromPlayerCustomData.z, 1f)); component.SetHeight(heightFromPlayerCustomData); component.RefreshEyesBinding(); component.RefreshRaceExtraSkinColor(force: true); component.RefreshTattoo(force: true); PlayerCustomizaton val = (((Object)(object)__instance.m_newCharacterPanel != (Object)null) ? __instance.m_newCharacterPanel.GetComponent<PlayerCustomizaton>() : null); if ((Object)(object)val != (Object)null && (Object)(object)((Humanoid)previewPlayer).m_visEquipment != (Object)null) { SetExactSkinRgbState(val, previewPlayer, ((Humanoid)previewPlayer).m_visEquipment.m_skinColor); SetExactHairRgbState(val, previewPlayer, previewPlayer.GetHairColor()); if (((Component)val).gameObject.activeInHierarchy) { SyncRgbSlidersFromPlayer(val, previewPlayer); } } } } [HarmonyPatch(typeof(FejdStartup), "OnNewCharacterDone")] public static class FejdStartup_OnNewCharacterDone_Patch { private static bool _externalRaceSavePending; public static bool Prefix(FejdStartup __instance, ref List<PlayerProfile> ___m_profiles) { if (!editingCharacter) { return true; } if (CompatibilityManager.YieldStructuralAppearance) { if (!_externalRaceSavePending) { _externalRaceSavePending = true; ((MonoBehaviour)__instance).StartCoroutine(CompleteEditedCharacterSaveAfterExternalRaceCommit(__instance)); } return false; } CompleteEditedCharacterSave(__instance); return false; } private static IEnumerator CompleteEditedCharacterSaveAfterExternalRaceCommit(FejdStartup instance) { yield return null; try { if ((Object)(object)instance != (Object)null && editingCharacter) { CompleteEditedCharacterSave(instance); } } finally { _externalRaceSavePending = false; } } private static void CompleteEditedCharacterSave(FejdStartup instance) { if ((Object)(object)instance == (Object)null || !editingCharacter) { return; } string text = ((TMP_InputField)instance.m_csNewCharacterName).text; string selectedProfile = text.ToLower(); int profileIndex = instance.m_profileIndex; List<PlayerProfile> profiles = instance.m_profiles; if (profiles == null || profileIndex < 0 || profileIndex >= profiles.Count) { LogWarningOnce("Core/Launch.cs:3", "BalrondCharacterCustomization: could not save edited character because the selected profile is no longer available."); editingCharacter = false; return; } PlayerProfile val = profiles[profileIndex]; GameObject playerInstance = instance.m_playerInstance; Player val2 = (((Object)(object)playerInstance != (Object)null) ? playerInstance.GetComponent<Player>() : null); if ((Object)(object)val2 == (Object)null) { LogWarningOnce("Core/Launch.cs:4", "BalrondCharacterCustomization: could not save edited character because the preview player is unavailable."); editingCharacter = false; return; } EnsureEyesPrefab(); BalrondPlayerCustomization component = playerInstance.GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)component != (Object)null) { if (CustomRacesEnabled) { component.SaveRaceToPlayerData(); } component.SaveToCustomData(); component.SaveHeightToCustomData(); component.SaveBodyTypeToPlayerData(); component.SaveTattooToPlayerData(); } else { LogWarningOnce("Core/Launch.cs:5", "Couldnt save character custom information"); } val.SavePlayerData(val2); val.SetName(text); val.Save(); if ((Object)(object)title != (Object)null) { ((Component)title).gameObject.SetActive(false); } if ((Object)(object)instance.m_newCharacterPanel != (Object)null) { Transform val3 = instance.m_newCharacterPanel.transform.Find("Topic"); if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(true); } } editingCharacter = false; if ((Object)(object)instance.m_selectCharacterPanel != (Object)null) { instance.m_selectCharacterPanel.SetActive(true); } if ((Object)(object)instance.m_newCharacterPanel != (Object)null) { instance.m_newCharacterPanel.SetActive(false); } instance.m_profiles = null; instance.SetSelectedProfile(selectedProfile); } } [HarmonyPatch(typeof(FejdStartup), "OnNewCharacterCancel")] public static class FejdStartup_OnNewCharacterCancel_Patch { public static void Postfix(FejdStartup __instance) { if ((Object)(object)title != (Object)null) { ((Component)title).gameObject.SetActive(false); } if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_newCharacterPanel != (Object)null) { Transform val = __instance.m_newCharacterPanel.transform.Find("Topic"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(true); } } editingCharacter = false; if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.m_newCharacterPanel != (Object)null) { ReleaseCustomizationSession(__instance.m_newCharacterPanel.GetComponent<PlayerCustomizaton>()); } EnsureEyesPrefab(); } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnEnable")] public static class PlayerCustomizaton_OnEnable_Patch { public static void Prefix(PlayerCustomizaton __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)ResolveCreatorStartup(__instance) == (Object)null)) { CaptureSkinBeforeVanillaUi(__instance); } } public static void Postfix(PlayerCustomizaton __instance) { if (IsBarberCustomization(__instance) || !editingCharacter) { return; } FejdStartup val = ResolveCreatorStartup(__instance); if ((Object)(object)val == (Object)null) { return; } Player previewPlayer = val.GetPreviewPlayer(); if ((Object)(object)previewPlayer == (Object)null) { return; } if (BodyTypeManager.IsFemaleModelIndex(previewPlayer.GetPlayerModel())) { if ((Object)(object)__instance.m_maleToggle != (Object)null) { __instance.m_maleToggle.isOn = false; } if ((Object)(object)__instance.m_femaleToggle != (Object)null) { __instance.m_femaleToggle.isOn = true; } } VisEquipment visEquipment = ((Humanoid)previewPlayer).m_visEquipment; if (!((Object)(object)visEquipment == (Object)null)) { BalrondPlayerCustomization component = ((Component)previewPlayer).GetComponent<BalrondPlayerCustomization>(); if (NeedsCharacterCreationUiBuild(__instance)) { EditExistingPanel(); CreateHairPanel(); } if ((Object)(object)component != (Object)null) { component.SetBodyType(component.GetBodyTypeFromPlayerCustomData(previewPlayer), save: false); component.SetRace(component.GetRaceFromPlayerCustomData(previewPlayer), save: false); component.SetTattoo(component.GetTattooFromPlayerCustomData(previewPlayer), save: false); } RaceUI.EnsureCharacterPanel(__instance); BodyTypeUI.EnsureCharacterChoice(__instance); TattooUI.EnsureCharacterPanel(__instance); LayoutCharacterCreationFeatures(__instance); EnsureCustomizationEventBindings(__instance); RestoreCapturedSkinAfterVanillaUi(__instance); SyncRgbSlidersFromPlayer(__instance, previewPlayer); } } } [HarmonyPatch(typeof(FejdStartup), "OnCharacterNew")] public static class OnCharacterNewPatch { public static void Postfix(FejdStartup __instance) { //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_newCharacterPanel == (Object)null) { return; } string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary<string, string> translations = GetTranslations(selectedLanguage); AddTranslations(translations); if (NeedsCharacterCreationUiBuild(__instance)) { EditExistingPanel(); CreateHairPanel(); } EnsureEyesPrefab(); PlayerCustomizaton component = __instance.m_newCharacterPanel.GetComponent<PlayerCustomizaton>(); if ((Object)(object)component != (Object)null) { RaceUI.EnsureCharacterPanel(component); BodyTypeUI.EnsureCharacterChoice(component); TattooUI.EnsureCharacterPanel(component); LayoutCharacterCreationFeatures(component); EnsureCustomizationEventBindings(component); Player previewPlayer = __instance.GetPreviewPlayer(); if ((Object)(object)previewPlayer != (Object)null && (Object)(object)((Humanoid)previewPlayer).m_visEquipment != (Object)null) { SetExactSkinRgbState(component, previewPlayer, ((Humanoid)previewPlayer).m_visEquipment.m_skinColor); SyncRgbSlidersFromPlayer(component, previewPlayer); } } RefreshLabels(); } } [HarmonyPatch(typeof(Player), "SetHairColor")] [HarmonyAfter(new string[] { "com.nandor.racesofvalheim", "Azathoth.LinejaeserasRace" })] private static class Player_SetHairColor_BrcRgbUiGuard_Patch { [HarmonyPriority(0)] private static void Prefix(Player __instance, ref Vector3 __0) { //IL_0051: 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) PlayerCustomizaton cachedCustomizationOwner = _cachedCustomizationOwner; if (!((Object)(object)__instance == (Object)null) && !((Object)(object)cachedCustomizationOwner == (Object)null) && IsExactHairRgbUiActive(cachedCustomizationOwner)) { Player customizationPlayer = GetCustomizationPlayer(cachedCustomizationOwner); if (!((Object)(object)customizationPlayer != (Object)(object)__instance) && TryGetExactHairRgbState(cachedCustomizationOwner, __instance, out var color)) { __0 = color; } } } } [HarmonyPatch(typeof(Player), "SetSkinColor")] [HarmonyAfter(new string[] { "com.nandor.racesofvalheim", "Azathoth.LinejaeserasRace" })] private static class Player_SetSkinColor_BrcRgbUiGuard_Patch { [HarmonyPriority(0)] private static void Prefix(Player __instance, ref Vector3 __0) { //IL_0051: 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) PlayerCustomizaton cachedCustomizationOwner = _cachedCustomizationOwner; if (!((Object)(object)__instance == (Object)null) && !((Object)(object)cachedCustomizationOwner == (Object)null) && IsExactSkinRgbUiActive(cachedCustomizationOwner)) { Player customizationPlayer = GetCustomizationPlayer(cachedCustomizationOwner); if (!((Object)(object)customizationPlayer != (Object)(object)__instance) && TryGetExactSkinRgbState(cachedCustomizationOwner, __instance, out var color)) { __0 = color; } } } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnCancel")] private static class BarberCancelSessionPatch { private static void Prefix(PlayerCustomizaton __instance) { //IL_006d: 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) if ((Object)(object)__instance == (Object)null || (Object)(object)PlayerCustomizaton.m_barberInstance != (Object)(object)__instance) { return; } SeneaLUiBridge.BarberCancel(__instance); BarberUiRuntime component = ((Component)__instance).GetComponent<BarberUiRuntime>(); BarberEditSession barberEditSession = (((Object)(object)component != (Object)null) ? component.Session : null); if (barberEditSession == null) { return; } try { if ((Object)(object)barberEditSession.Player == (Object)(object)Player.m_localPlayer) { SetExactHairRgbState(__instance, barberEditSession.Player, barberEditSession.HairColor); SetExactSkinRgbState(__instance, barberEditSession.Player, barberEditSession.SkinColor); barberEditSession.Restore(); } } catch (Exception ex) { Debug.LogError((object)("BalrondCharacterCustomization: Barber rollback failed; native Cancel will still close the UI. " + ex)); } finally { component.Session = null; } } } [HarmonyPatch(typeof(PlayerCustomizaton), "OnApply")] private static class BarberApplySessionPatch { private static void Prefix(PlayerCustomizaton __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)(object)__instance)) { SeneaLUiBridge.BarberApply(__instance); BarberUiRuntime component = ((Component)__instance).GetComponent<BarberUiRuntime>(); if ((Object)(object)component != (Object)null) { component.Session = null; } } } } private static class CharacterCreationLayout { internal const float RootOffsetY = 165f; internal const float BackgroundMoveY = -142f; internal const float BackgroundScaleMultiplierY = 1.4f; internal const float BackgroundExtraHeightWithTattoo = 220f; internal const float BackgroundExtraHeightWithoutTattoo = 170f; internal const float PanelOffsetY = 115f; internal const float StackTopOffsetY = 20f; internal const float RaceToBodyGap = 5f; internal const float BodyToHeightGap = 8f; internal const float HeightToSkinGap = 5f; internal const float SkinToHairGap = 10f; internal const float HairToBeardGap = -15f; internal const float BeardToHairColorGap = 10f; internal const float HairColorToTattooGap = 15f; internal const float TattooToEyeColorGap = 0f; internal const float EyeColorToActionButtonsGap = 15f; internal const float ActionButtonHorizontalGap = 8f; internal const float RandomizeBelowTattooGap = -15f; internal const float ColorGroupWidth = 190f; internal const float ColorGroupHeight = 145f; internal const float ColorTitleY = 5f; internal const float ColorFirstRowY = -35f; internal const float ColorRowPitch = 40f; internal const float ColorRowWidth = 190f; internal const float ColorRowHeight = 40f; internal const float ColorRowLabelY = 10f; internal const float ColorRowSliderY = -15f; internal const float HeightGroupWidth = 190f; internal const float HeightGroupHeight = 72f; internal const float HeightTitleY = -5f; internal const float HeightSliderY = -38f; internal const float ActionButtonFallbackWidth = 90f; internal const float ActionButtonFallbackHeight = 34f; } private static class BarberLayout { internal const float RootOffsetY = 130f; internal const float BackgroundScaleYWithTattoo = 3.65f; internal const float BackgroundScaleYWithoutTattoo = 3.3f; internal const float BackgroundMoveYWithTattoo = -395f; internal const float BackgroundMoveYWithoutTattoo = -350f; internal const float ButtonsMoveYWithTattoo = -900f; internal const float ButtonsMoveYWithoutTattoo = -815f; internal const float TitleOffsetY = 140f; internal const float ExtensionOffsetY = -300f; internal const float ExtensionHeight = 960f; internal const float ExtensionFallbackWidth = 320f; internal const float StackTopPadding = 18f; } private struct BarberOpenState { public bool HasPlayer; public bool Skip; public IDisposable Population; public Vector3 Hair; public Vector3 Skin; } private sealed class BarberPopulationScope : IDisposable { private bool _disposed; internal BarberPopulationScope() { _barberPopulationDepth++; } public void Dispose() { if (!_disposed) { _disposed = true; _barberPopulationDepth--; } } } [HarmonyPatch(typeof(PlayerCustomizaton), "ShowBarberGui")] private static class PlayerCustomizaton_ShowBarberGui_Patch { private static bool Prefix(ref BarberOpenState __state) { //IL_00b2: 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_00d5: 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) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) __state = default(BarberOpenState); try { PlayerCustomizaton barberInstance = PlayerCustomizaton.m_barberInstance; if (SeneaLUiBridge.IsActiveBarberFor(barberInstance)) { __state.Skip = true; return true; } BarberUiRuntime barberUiRuntime = BarberUiRuntime.Ensure(barberInstance); if ((Object)(object)barberInstance != (Object)null && (Object)(object)barberInstance.m_rootPanel != (Object)null && barberInstance.m_rootPanel.activeInHierarchy && (Object)(object)barberUiRuntime != (Object)null && barberUiRuntime.Session != null && (Object)(object)barberUiRuntime.Session.Player == (Object)(object)Player.m_localPlayer) { __state.Skip = true; return false; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } __state.Hair = localPlayer.GetHairColor(); VisEquipment visEquipment = ((Humanoid)localPlayer).m_visEquipment; __state.Skin = (((Object)(object)visEquipment != (Object)null) ? visEquipment.m_skinColor : Vector3.one); __state.HasPlayer = true; BalrondPlayerCustomization component = ((Component)localPlayer).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)barberUiRuntime == (Object)null || (Object)(object)component == (Object)null || !component.AppearanceStateReady) { __state.Skip = true; return false; } if (barberUiRuntime.Session == null || (Object)(object)barberUiRuntime.Session.Player != (Object)(object)localPlayer) { barberUiRuntime.Session = new BarberEditSession(localPlayer, component); SetExactHairRgbState(barberInstance, localPlayer, __state.Hair); SetExactSkinRgbState(barberInstance, localPlayer, __state.Skin); } __state.Population = BeginBarberPopulation(); } catch (Exception ex) { if (!_barberCaptureWarningLogged) { _barberCaptureWarningLogged = true; LogWarningOnce("UI/BarberCustomizationUI.cs:1", "BalrondCharacterCustomization: Barber pre-open capture was skipped safely: " + ex.GetType().Name + ": " + ex.Message); } } return true; } private static void Finalizer(BarberOpenState __state) { if (__state.Population != null) { __state.Population.Dispose(); } } private static void Postfix(BarberOpenState __state) { //IL_0063: 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_0068: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00af: 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_00df: 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_00cf: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if (__state.Skip) { return; } PlayerCustomizaton barberInstance = PlayerCustomizaton.m_barberInstance; try { if ((Object)(object)barberInstance == (Object)null || (Object)(object)barberInstance.m_rootPanel == (Object)null) { return; } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { Vector3 val = (__state.HasPlayer ? __state.Hair : localPlayer.GetHairColor()); Vector3 val2 = (__state.HasPlayer ? __state.Skin : (((Object)(object)((Humanoid)localPlayer).m_visEquipment != (Object)null) ? ((Humanoid)localPlayer).m_visEquipment.m_skinColor : Vector3.one)); if (!TryGetExactHairRgbState(barberInstance, localPlayer, out var color)) { color = val; SetExactHairRgbState(barberInstance, localPlayer, color); } if (!TryGetExactSkinRgbState(barberInstance, localPlayer, out var color2)) { color2 = val2; SetExactSkinRgbState(barberInstance, localPlayer, color2); } if (!ApproximatelyRgb(localPlayer.GetHairColor(), color)) { localPlayer.SetHairColor(color); } if ((Object)(object)((Humanoid)localPlayer).m_visEquipment == (Object)null || !ApproximatelyRgb(((Humanoid)localPlayer).m_visEquipment.m_skinColor, color2)) { localPlayer.SetSkinColor(color2); } EnsureExpandedBarberUi(barberInstance, color); BarberUiRuntime.Ensure(barberInstance); } } catch (Exception ex) { if (!_barberBuildWarningLogged) { _barberBuildWarningLogged = true; Debug.LogError((object)("BalrondCharacterCustomization: Barber extension failed safely after vanilla ShowBarberGui: " + ex.GetType().Name + ": " + ex.Message)); } } } } private readonly Harmony _harmony = new Harmony("balrond.astafaraios.BalrondCharacterCustomization"); private float _nextSeneaLInstallProbe; private int _remainingSeneaLInstallProbes = 30; public static JsonLoader jsonLoader = new JsonLoader(); public static GameObject RootObject; public static GameObject PrefabContainer; public static ModResourceLoader modResourceLoader = new ModResourceLoader(); public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods(); public static string projectName = "BalrondCharacterCustomization"; public static bool hasSpawned = false; public const string PluginGuid = "balrond.astafaraios.BalrondCharacterCustomization"; public const string PluginName = "BalrondCharacterCustomization"; public const string PluginVersion = "2.0.25"; internal static RaceCustomizationConfig Settings; public static bool disableTutorials; public static bool newHardcorePlayer; public static bool skipIntro; public static bool editedBarber = false; public static GameObject uiPanel; public static GameObject uiHairPanel; public static Slider sliderR; public static Slider sliderG; public static Slider sliderB; public static Slider sliderSR; public static Slider sliderSG; public static Slider sliderSB; public static Slider sliderS; public static Slider sliderER; public static Slider sliderEG; public static Slider sliderEB; public static Slider sliderH; public static float myR = 99f; public static float myG = 99f; public static float myB = 99f; public static Transform CustomizationPanel; public static Transform BarberCustomizationPanel; public static Transform hairPanel; public static Transform barberhairPanel; private static PlayerCustomizaton _cachedCustomizationOwner; private static int _cachedCustomizationOwnerId; private static int _barberLayoutRootInstanceId = int.MinValue; private static readonly Dictionary<int, Vector2> BarberLayoutBasePositions = new Dictionary<int, Vector2>(); private static readonly Dictionary<int, Vector3> BarberLayoutBaseScales = new Dictionary<int, Vector3>(); private static bool _suppressCustomizationEvents; private static readonly Dictionary<int, ExactRgbState> ExactSkinRgbStates = new Dictionary<int, ExactRgbState>(); private static readonly Dictionary<int, ExactRgbState> ExactHairRgbStates = new Dictionary<int, ExactRgbState>(); private static readonly Dictionary<int, Vector3> PreEnableSkinColors = new Dictionary<int, Vector3>(); private static readonly Dictionary<int, Vector3> PreEnableHairColors = new Dictionary<int, Vector3>(); public static bool tryToFind = true; private static readonly HashSet<string> ReportedWarningSites = new HashSet<string>(); public static bool editingCharacter = false; public static Transform title; public static int eyesItemHash = 0; public static GameObject eyesObject; public static Dictionary<string, Vector3> eyeColors = new Dictionary<string, Vector3>(); public static Dictionary<string, TextMeshProUGUI> textMeshProUGUIs = new Dictionary<string, TextMeshProUGUI>(); public static TMP_Text editButton; public static TMP_Text editTitle; private const string EyesPrefabName = "eyes_bal"; private static readonly ConditionalWeakTable<Slider, CustomizationSliderBinding> SliderBindings = new ConditionalWeakTable<Slider, CustomizationSliderBinding>(); private static readonly string[] BarberStackNames = new string[9] { "BalrondRacePanelBarber", "BalrondBodyTypePanelBarber", "HeightGroup", "SkinColorGroup", "HairPanel", "BeardPanel", "HairColorGroup", "BalrondTattooPanelBarber", "EyeColorGroup" }; private static int _lastCreationLayoutRootId = int.MinValue; private static readonly string[] CharacterFeatureNames = new string[9] { "BalrondRacePanel", "BalrondBodyTypePanel", "HeightGroup", "SkinColorGroup", "HairPanel", "BeardPanel", "HairColorGroup", "BalrondTattooPanel", "EyeColorGroup" }; private static readonly string[] BarberFeatureNames = new string[9] { "BalrondRacePanelBarber", "BalrondBodyTypePanelBarber", "HeightGroup", "SkinColorGroup", "HairPanel", "BeardPanel", "HairColorGroup", "BalrondTattooPanelBarber", "EyeColorGroup" }; private static int _barberPopulationDepth; private static bool _barberCaptureWarningLogged; private static bool _barberBuildWarningLogged; public static bool CustomRacesEnabled => Settings == null || Settings.EnableCustomRaces.Value; public static bool TattoosEnabled => Settings == null || Settings.EnableTattoos.Value; public static bool DebugDiagnosticsEnabled => Settings != null && Settings.EnableDebugDiagnostics != null && Settings.EnableDebugDiagnostics.Value; public static bool isDebug => DebugDiagnosticsEnabled; internal static bool BarberUiIsPopulating => _barberPopulationDepth > 0; internal static void LogWarningOnce(string site, string message) { if (DebugDiagnosticsEnabled || ReportedWarningSites.Add(site)) { Debug.LogWarning((object)message); } } private static void EnsureEyesPrefab() { if (!((Object)(object)eyesObject != (Object)null) && !((Object)(object)ObjectDB.instance == (Object)null)) { eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal"); if ((Object)(object)eyesObject != (Object)null) { eyesItemHash = ((object)eyesObject).GetHashCode(); } } } internal static FejdStartup ResolveCreatorStartup(PlayerCustomizaton customization) { if ((Object)(object)customization == (Object)null) { return null; } FejdStartup instance = FejdStartup.instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_newCharacterPanel != (Object)null && (Object)(object)instance.m_newCharacterPanel.GetComponent<PlayerCustomizaton>() == (Object)(object)customization) { return instance; } FejdStartup componentInParent = ((Component)customization).GetComponentInParent<FejdStartup>(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.m_newCharacterPanel != (Object)null && (Object)(object)componentInParent.m_newCharacterPanel.GetComponent<PlayerCustomizaton>() == (Object)(object)customization) { return componentInParent; } return null; } private static Player GetCustomizationPlayer(PlayerCustomizaton customization) { if ((Object)(object)customization == (Object)null) { return null; } if (IsBarberCustomization(customization)) { return Player.m_localPlayer; } FejdStartup val = ResolveCreatorStartup(customization); if ((Object)(object)val != (Object)null) { return val.GetPreviewPlayer(); } try { Player player = customization.GetPlayer(); if ((Object)(object)player != (Object)null) { return player; } } catch { } if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null) { try { Player player2 = PlayerCustomizaton.m_barberInstance.GetPlayer(); if ((Object)(object)player2 != (Object)null) { return player2; } } catch { } } return Player.m_localPlayer; } private static void EnsureCustomizationLifetime(PlayerCustomizaton customization) { if (!((Object)(object)customization == (Object)null)) { BrcUiSessionLifetime brcUiSessionLifetime = ((Component)customization).GetComponent<BrcUiSessionLifetime>(); if ((Object)(object)brcUiSessionLifetime == (Object)null) { brcUiSessionLifetime = ((Component)customization).gameObject.AddComponent<BrcUiSessionLifetime>(); } brcUiSessionLifetime.Bind(customization); } } private static void SetExactSkinRgbState(PlayerCustomizaton customization, Player player, Vector3 color) { //IL_005a: 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) if (!((Object)(object)customization == (Object)null) && !((Object)(object)player == (Object)null)) { if (!ExactSkinRgbStates.ContainsKey(((Object)customization).GetInstanceID())) { EnsureCustomizationLifetime(customization); } ExactSkinRgbStates[((Object)customization).GetInstanceID()] = new ExactRgbState { PlayerInstanceId = ((Object)player).GetInstanceID(), Color = color, Valid = true }; } } private static void SetExactHairRgbState(PlayerCustomizaton customization, Player player, Vector3 color) { //IL_005a: 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) if (!((Object)(object)customization == (Object)null) && !((Object)(object)player == (Object)null)) { if (!ExactHairRgbStates.ContainsKey(((Object)customization).GetInstanceID())) { EnsureCustomizationLifetime(customization); } ExactHairRgbStates[((Object)customization).GetInstanceID()] = new ExactRgbState { PlayerInstanceId = ((Object)player).GetInstanceID(), Color = color, Valid = true }; } } private static bool TryGetExactRgbState(Dictionary<int, ExactRgbState> states, PlayerCustomizaton customization, Player player, out Vector3 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_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) color = Vector3.one; if (states == null || (Object)(object)customization == (Object)null || (Object)(object)player == (Object)null) { return false; } if (!states.TryGetValue(((Object)customization).GetInstanceID(), out var value) || !value.Valid || value.PlayerInstanceId != ((Object)player).GetInstanceID()) { return false; } color = value.Color; return true; } private static bool TryGetExactSkinRgbState(PlayerCustomizaton customization, Player player, out Vector3 color) { return TryGetExactRgbState(ExactSkinRgbStates, customization, player, out color); } private static bool TryGetExactHairRgbState(PlayerCustomizaton customization, Player player, out Vector3 color) { return TryGetExactRgbState(ExactHairRgbStates, customization, player, out color); } private static bool IsCustomizationSessionActive(PlayerCustomizaton customization) { if (SeneaLUiBridge.Owns(customization)) { return true; } if ((Object)(object)customization == (Object)null || (Object)(object)_cachedCustomizationOwner != (Object)(object)customization || !((Behaviour)customization).isActiveAndEnabled) { return false; } if (IsBarberCustomization(customization)) { BarberUiRuntime component = ((Component)customization).GetComponent<BarberUiRuntime>(); return (Object)(object)customization.m_rootPanel != (Object)null && customization.m_rootPanel.activeInHierarchy && (Object)(object)component != (Object)null && component.Session != null && (Object)(object)component.Session.Player == (Object)(object)Player.m_localPlayer; } FejdStartup val = ResolveCreatorStartup(customization); return (Object)(object)val != (Object)null && (Object)(object)val.m_newCharacterPanel != (Object)null && val.m_newCharacterPanel.activeInHierarchy; } private static bool IsExactSkinRgbUiActive(PlayerCustomizaton customization) { return IsCustomizationSessionActive(customization) && ExactSkinRgbStates.ContainsKey(((Object)customization).GetInstanceID()); } private static bool IsExactHairRgbUiActive(PlayerCustomizaton customization) { return IsCustomizationSessionActive(customization) && ExactHairRgbStates.ContainsKey(((Object)customization).GetInstanceID()); } internal static void ReleaseCustomizationSession(PlayerCustomizaton customization) { if (!((Object)(object)customization == (Object)null)) { ReleaseCustomizationSession(((Object)customization).GetInstanceID()); } } internal static void ReleaseCustomizationSession(int ownerId) { if (ownerId != 0) { ExactSkinRgbStates.Remove(ownerId); ExactHairRgbStates.Remove(ownerId); PreEnableSkinColors.Remove(ownerId); PreEnableHairColors.Remove(ownerId); if (_cachedCustomizationOwnerId == ownerId) { _cachedCustomizationOwner = null; _cachedCustomizationOwnerId = 0; ResetCustomizationUiCache(); } } } private static void CaptureSkinBeforeVanillaUi(PlayerCustomizaton customization) { //IL_005d: 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) Player customizationPlayer = GetCustomizationPlayer(customization); if (!((Object)(object)customization == (Object)null) && !((Object)(object)customizationPlayer == (Object)null)) { EnsureCustomizationLifetime(customization); int instanceID = ((Object)customization).GetInstanceID(); if ((Object)(object)((Humanoid)customizationPlayer).m_visEquipment != (Object)null) { PreEnableSkinColors[instanceID] = ((Humanoid)customizationPlayer).m_visEquipment.m_skinColor; } PreEnableHairColors[instanceID] = customizationPlayer.GetHairColor(); } } private static void RestoreCapturedSkinAfterVanillaUi(PlayerCustomizaton customization) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_009f: 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_005f: 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) //IL_0066: 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_00cf: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)customization == (Object)null) { return; } Player customizationPlayer = GetCustomizationPlayer(customization); if ((Object)(object)customizationPlayer == (Object)null) { return; } int instanceID = ((Object)customization).GetInstanceID(); Vector3 value; Vector3 value2; if (CompatibilityManager.YieldStructuralAppearance) { value = (((Object)(object)((Humanoid)customizationPlayer).m_visEquipment != (Object)null) ? ((Humanoid)customizationPlayer).m_visEquipment.m_skinColor : Vector3.one); value2 = customizationPlayer.GetHairColor(); } else { if (!PreEnableSkinColors.TryGetValue(instanceID, out value)) { if ((Object)(object)((Humanoid)customizationPlayer).m_visEquipment == (Object)null) { return; } value = ((Humanoid)customizationPlayer).m_visEquipment.m_skinColor; } if (!PreEnableHairColors.TryGetValue(instanceID, out value2)) { value2 = customizationPlayer.GetHairColor(); } } SetExactSkinRgbState(customization, customizationPlayer, value); SetExactHairRgbState(customization, customizationPlayer, value2); if ((Object)(object)((Humanoid)customizationPlayer).m_visEquipment == (Object)null || !ApproximatelyRgb(((Humanoid)customizationPlayer).m_visEquipment.m_skinColor, value)) { customizationPlayer.SetSkinColor(value); } if (!ApproximatelyRgb(customizationPlayer.GetHairColor(), value2)) { customizationPlayer.SetHairColor(value2); } } private static void ResetCustomizationUiCache() { CustomizationPanel = null; BarberCustomizationPanel = null; hairPanel = null; barberhairPanel = null; sliderR = null; sliderG = null; sliderB = null; sliderSR = null; sliderSG = null; sliderSB = null; sliderS = null; sliderER = null; sliderEG = null; sliderEB = null; sliderH = null; } private static void CacheCustomizationPanel(PlayerCustomizaton customization) { if ((Object)(object)customization == (Object)null) { return; } if ((Object)(object)_cachedCustomizationOwner != (Object)(object)customization) { if (_cachedCustomizationOwnerId != 0) { ReleaseCustomizationSession(_cachedCustomizationOwnerId); } EnsureCustomizationLifetime(customization); _cachedCustomizationOwner = customization; _cachedCustomizationOwnerId = ((Object)customization).GetInstanceID(); ResetCustomizationUiCache(); } if (IsBarberCustomization(customization) && (Object)(object)customization.m_rootPanel != (Object)null && (Object)(object)CustomizationPanel != (Object)null && (Object)(object)CustomizationPanel != (Object)(object)customization.m_rootPanel.transform) { ResetCustomizationUiCache(); } if ((Object)(object)CustomizationPanel != (Object)null && (Object)(object)CustomizationPanel != (Object)(object)((Component)customization).transform && !CustomizationPanel.IsChildOf(((Component)customization).transform) && (!IsBarberCustomization(customization) || !((Object)(object)customization.m_rootPanel != (Object)null) || !((Object)(object)CustomizationPanel == (Object)(object)customization.m_rootPanel.transform))) { ResetCustomizationUiCache(); } if ((Object)(object)CustomizationPanel != (Object)null) { return; } if (IsBarberCustomization(customization) && (Object)(object)customization.m_rootPanel != (Object)null) { CustomizationPanel = customization.m_rootPanel.transform; } else if (!((Object)(object)customization.m_hairTone == (Object)null)) { Transform transform = ((Component)customization.m_hairTone).transform; if ((Object)(object)transform.parent != (Object)null && (Object)(object)transform.parent.parent != (Object)null && (Object)(object)transform.parent.parent.parent != (Object)null) { CustomizationPanel = transform.parent.parent.parent; } } } private static void CachePanelsAndSliders() { if ((Object)(object)CustomizationPanel == (Object)null) { return; } if (((Object)(object)sliderR != (Object)null && !((Component)sliderR).transform.IsChildOf(CustomizationPanel)) || ((Object)(object)sliderSR != (Object)null && !((Component)sliderSR).transform.IsChildOf(CustomizationPanel)) || ((Object)(object)sliderER != (Object)null && !((Component)sliderER).transform.IsChildOf(CustomizationPanel)) || ((Object)(object)sliderH != (Object)null && !((Component)sliderH).transform.IsChildOf(CustomizationPanel))) { ResetCustomizationUiCache(); CacheCustomizationPanel(_cachedCustomizationOwner); } if ((Object)(object)CustomizationPanel == (Object)null) { return; } bool flag = IsBarberCustomization(_cachedCustomizationOwner); if (!flag && (Object)(object)hairPanel == (Object)null) { hairPanel = CustomizationPanel; } bool flag2 = (flag ? ((Object)(object)barberhairPanel == (Object)null) : ((Object)(object)hairPanel == (Object)null)); bool flag3 = (Object)(object)sliderR == (Object)null || (Object)(object)sliderG == (Object)null || (Object)(object)sliderB == (Object)null || (Object)(object)sliderSR == (Object)null || (Object)(object)sliderSG == (Object)null || (Object)(object)sliderSB == (Object)null || (Object)(object)sliderER == (Object)null || (Object)(object)sliderEG == (Object)null || (Object)(object)sliderEB == (Object)null || (Object)(object)sliderH == (Object)null; if (!flag2 && !flag3) { return; } Transform[] componentsInChildren = ((Component)CustomizationPanel).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { string name = ((Object)val).name; if (flag2) { if ((Object)(object)hairPanel == (Object)null && name == "BalrondCustomizationPanel") { hairPanel = val; } else if ((Object)(object)barberhairPanel == (Object)null && name == "BarberHairPanel") { barberhairPanel = val; } } if (!flag3) { continue; } Slider component = ((Component)val).GetComponent<Slider>(); if (!((Object)(object)component == (Object)null)) { switch (name) { case "Red_Slider": sliderR = component; break; case "Green_Slider": sliderG = component; break; case "Blue_Slider": sliderB = component; break; case "RedSkin_Slider": sliderSR = component; break; case "GreenSkin_Slider": sliderSG = component; break; case "BlueSkin_Slider": sliderSB = component; break; case "Skin slider": sliderS = component; break; case "RedEye_Slider": sliderER = component; break; case "GreenEye_Slider": sliderEG = component; break; case "BlueEye_Slider": sliderEB = component; break; case "Height_Slider": sliderH = component; break; } } } } private void Awake() { ServerSyncBridge.Initialize("balrond.astafaraios.BalrondCharacterCustomization", "BalrondCharacterCustomization", "2.0.25"); Settings = new RaceCustomizationConfig(this); Settings.EnableCustomRaces.SettingChanged += OnCustomRacesSettingChanged; Settings.EnableTattoos.SettingChanged += OnTattoosSettingChanged; jsonLoader.loadJson(); createPrefabContainer(); modResourceLoader.loadAssets(); _harmony.PatchAll(); CompatibilityManager.Initialize(); } private void Start() { SeneaLUiBridge.Install(_harmony); } private void Update() { if (!SeneaLUiBridge.Installed && _remainingSeneaLInstallProbes > 0 && !(Time.unscaledTime < _nextSeneaLInstallProbe)) { _nextSeneaLInstallProbe = Time.unscaledTime + 2f; _remainingSeneaLInstallProbes--; SeneaLUiBridge.Install(_harmony); } } private void OnCustomRacesSettingChanged(object sender, EventArgs e) { RaceUI.SetCustomRacesEnabled(CustomRacesEnabled); BalrondPlayerCustomization[] array = Resources.FindObjectsOfTypeAll<BalrondPlayerCustomization>(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { array[i].RefreshRacePolicy(); } } } private void OnTattoosSettingChanged(object sender, EventArgs e) { TattooUI.SetTattoosEnabled(TattoosEnabled); BalrondPlayerCustomization[] array = Resources.FindObjectsOfTypeAll<BalrondPlayerCustomization>(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null) { array[i].RefreshTattoo(force: true); } } } internal ConfigEntry<T> LocalConfig<T>(string section, string key, T defaultValue, ConfigDescription description) { return ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description); } internal ConfigEntry<bool> LockingConfig(string section, string key, bool defaultValue, ConfigDescription description) { ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>(section, key, defaultValue, description); ServerSyncBridge.AddLockingConfigEntry(val); return val; } internal ConfigEntry<T> SyncedConfig<T>(string section, string key, T defaultValue, ConfigDescription description) { ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, defaultValue, description); ServerSyncBridge.AddConfigEntry<T>(val); return val; } public void createPrefabContainer() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown RootObject = new GameObject("_BalrondRaceCustomizationRoot"); Object.DontDestroyOnLoad((Object)(object)RootObject); RuntimeAppearanceScheduler.AttachTo(RootObject); PrefabContainer = new GameObject("Prefabs"); PrefabContainer.transform.parent = RootObject.transform; PrefabContainer.SetActive(false); } public static GameObject cloneMe(GameObject source, string name) { GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform); ((Object)val).name = name; fixMaterials(val, source); val.SetActive(true); return val; } public static GameObject fixMaterials(GameObject clone, GameObject source) { MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val in componentsInChildren) { MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val2 in componentsInChildren2) { if (((Object)val).name == ((Object)val2).name) { ((Renderer)val2).materials = ((Renderer)val).sharedMaterials; ((Renderer)val2).sharedMaterials = ((Renderer)val).sharedMaterials; break; } } } return clone; } private void OnDestroy() { if (Settings != null) { Settings.EnableCustomRaces.SettingChanged -= OnCustomRacesSettingChanged; Settings.EnableTattoos.SettingChanged -= OnTattoosSettingChanged; } SeneaLUiBridge.Shutdown(); _harmony.UnpatchSelf(); if ((Object)(object)uiHairPanel != (Object)null && ((Object)uiHairPanel).name == "BarberHairPanel") { Object.Destroy((Object)(object)uiHairPanel); } uiPanel = null; uiHairPanel = null; ExactSkinRgbStates.Clear(); ExactHairRgbStates.Clear(); PreEnableSkinColors.Clear(); PreEnableHairColors.Clear(); _cachedCustomizationOwner = null; _cachedCustomizationOwnerId = 0; ResetCustomizationUiCache(); RaceUI.DestroyPanels(); TattooUI.DestroyPanels(); TattooManager.Dispose(); Settings = null; ServerSyncBridge.Reset(); } private static bool IsObjectDBValid() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } private static void FixCustomHairAndBeardMaterials() { if ((Object)(object)ObjectDB.instance == (Object)null || modResourceLoader == null || modResourceLoader.itemPrefabs == null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hair3"); if ((Object)(object)itemPrefab == (Object)null) { return; } Material val = null; Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)val == (Object)null)) { break; } Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.IndexOf("PlayerHair", StringComparison.OrdinalIgnoreCase) >= 0) { val = val2; break; } } } if ((Object)(object)val == (Object)null) { for (int k = 0; k < componentsInChildren.Length; k++) { if (!((Object)(object)val == (Object)null)) { break; } Material[] sharedMaterials2 = componentsInChildren[k].sharedMaterials; for (int l = 0; l < sharedMaterials2.Length; l++) { if ((Object)(object)sharedMaterials2[l] != (Object)null) { val = sharedMaterials2[l]; break; } } } } if ((Object)(object)val == (Object)null) { return; } int num = 0; foreach (GameObject itemPrefab2 in modResourceLoader.itemPrefabs) { if ((Object)(object)itemPrefab2 == (Object)null || string.IsNullOrEmpty(((Object)itemPrefab2).name)) { continue; } bool flag = ((Object)itemPrefab2).name.StartsWith("Hair", StringComparison.OrdinalIgnoreCase); bool flag2 = ((Object)itemPrefab2).name.StartsWith("Beard", StringComparison.OrdinalIgnoreCase); if (!flag && !flag2) { continue; } Renderer[] componentsInChildren2 = itemPrefab2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren2) { Material[] sharedMaterials3 = val3.sharedMaterials; bool flag3 = false; for (int n = 0; n < sharedMaterials3.Length; n++) { Material val4 = sharedMaterials3[n]; if (!((Object)(object)val4 == (Object)null) && ((Object)val4).name.IndexOf("PlayerHair", StringComparison.OrdinalIgnoreCase) >= 0 && (Object)(object)val4 != (Object)(object)val) { sharedMaterials3[n] = val; flag3 = true; num++; } } if (flag3) { val3.sharedMaterials = sharedMaterials3; } } } if (num > 0 && DebugDiagnosticsEnabled) { Debug.Log((object)string.Format("{0}: Rebound {1} custom Hair/Beard material slot(s) to vanilla PlayerHair.", "BalrondCharacterCustomization", num)); } } public static GameObject FindPrefabInZnet(string name, ZNetScene zNetScene) { GameObject value = null; zNetScene.m_namedPrefabs.TryGetValue(BalrondHashCompat.StableHash(name), out value); if ((Object)(object)value == (Object)null) { value = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name); } return value; } private static Dictionary<string, string> GetTranslations(string language) { Dictionary<string, string> result = BalrondTranslator.getLanguage("English"); if (!string.Equals(language, "English", StringComparison.OrdinalIgnoreCase)) { Dictionary<string, string> language2 = BalrondTranslator.getLanguage(language); if (language2 != null) { result = language2; } else if (DebugDiagnosticsEnabled) { Debug.Log((object)("BalrondCharacterCustomization: Did not find translation file for '" + language + "', loading English")); } } return result; } private static void AddTranslations(Dictionary<string, string> translations, Localization localizationInstance = null) { RaceUI.AddDefaultLocalization(localizationInstance); BodyTypeUI.AddDefaultLocalization(localizationInstance); TattooUI.AddDefaultLocalization(localizationInstance); Localization val = localizationInstance ?? Localization.instance; if (val != null) { val.AddWord("brc_skin_color", "Skin Color"); } if (translations == null) { LogWarningOnce("Core/Launch.cs:2", "BalrondCharacterCustomization: No translation file found!"); return; } if (localizationInstance != null) { foreach (KeyValuePair<string, string> translation in translations) { localizationInstance.AddWord(translation.Key, translation.Value); } return; } foreach (KeyValuePair<string, string> translation2 in translations) { Localization.instance.AddWord(translation2.Key, translation2.Value); } } public static string ColorToString(Color color) { //IL_000d: 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_0029: 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) return $"{color.r} {color.g} {color.b} {color.a}"; } public static GameObject AttachItem(GameObject itemPrefab, int variant, Transform joint, VisEquipment visEquipment, bool enableEquipEffects = true, bool backAttach = false) { //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)itemPrefab == (Object)null) { if (DebugDiagnosticsEnabled) { Debug.Log((object)"Optional appearance attachment prefab is unavailable."); } return null; } GameObject val = null; Transform val2 = itemPrefab.transform.Find("equipoffset"); int childCount = itemPrefab.transform.childCount; for (int i = 0; i < childCount; i++) { Transform child = itemPrefab.transform.GetChild(i); if (backAttach && ((Object)((Component)child).gameObject).name == "attach_back") { val = ((Component)child).gameObject; break; } if (((Object)((Component)child).gameObject).name == "attach" || (!backAttach && ((Object)((Component)child).gameObject).name == "attach_skin")) { val = ((Component)child).gameObject; break; } } if ((Object)(object)val == (Object)null) { return null; } GameObject val3 = Object.Instantiate<GameObject>(val); val3.SetActive(true); CleanupInstance(val3); if (((Object)val).name == "attach_skin") { val3.transform.SetParent(((Component)visEquipment.m_bodyModel).transform.parent); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; SkinnedMeshRenderer[] componentsInChildren = val3.GetComponentsInChildren<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val4 in array) { val4.rootBone = visEquipment.m_bodyModel.rootBone; val4.bones = visEquipment.m_bodyModel.bones; } } else { val3.transform.SetParent(joint); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; } if ((Object)(object)val2 != (Object)null) { Transform transform = val3.transform; transform.localPosition += val2.position; Transform transform2 = val3.transform; transform2.localRotation *= val2.rotation; } IEquipmentVisual componentInChildren = val3.GetComponentInChildren<IEquipmentVisual>(); if (componentInChildren != null) { componentInChildren.Setup(variant); } return val3; } private static void CleanupInstance(GameObject instance) { Collider[] componentsInChildren = instance.GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { val.enabled = false; } } private static void BindCustomizationSliderOnce(Slider slider, PlayerCustomizaton owner, UnityAction<float> callback) { if ((Object)(object)slider == (Object)null || callback == null) { return; } CustomizationSliderBinding orCreateValue = SliderBindings.GetOrCreateValue(slider); if (!((Object)(object)orCreateValue.Owner == (Object)(object)owner) || orCreateValue.Callback == null) { if (orCreateValue.Callback != null) { ((UnityEvent<float>)(object)slider.onValueChanged).RemoveListener(orCreateValue.Callback); } orCreateValue.Owner = owner; orCreateValue.Callback = callback; ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(callback); } } private static void EnsureCustomizationEventBindings(PlayerCustomizaton customization) { if (!((Object)(object)customization == (Object)null)) { CacheCustomizationPanel(customization); CachePanelsAndSliders(); BindCustomizationSliderOnce(sliderR, customization, delegate { ApplyHairRgb(customization); }); BindCustomizationSliderOnce(sliderG, customization, delegate { ApplyHairRgb(customization); }); BindCustomizationSliderOnce(sliderB, customization, delegate { ApplyHairRgb(customization); }); BindCustomizationSliderOnce(sliderSR, customization, delegate { ApplySkinRgb(customization); }); BindCustomizationSliderOnce(sliderSG, customization, delegate { ApplySkinRgb(customization); }); BindCustomizationSliderOnce(sliderSB, customization, delegate { ApplySkinRgb(customization); }); BindCustomizationSliderOnce(sliderER, customization, delegate { ApplyEyeRgb(customization); }); BindCustomizationSliderOnce(sliderEG, customization, delegate { ApplyEyeRgb(customization); }); BindCustomizationSliderOnce(sliderEB, customization, delegate { ApplyEyeRgb(customization); }); BindCustomizationSliderOnce(sliderH, customization, delegate { ApplyHeight(customization); }); } } private static void ApplyHairRgb(PlayerCustomizaton customization) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!BarberUiIsPopulating && !_suppressCustomizationEvents && !((Object)(object)customization == (Object)null) && !((Object)(object)_cachedCustomizationOwner != (Object)(object)customization) && !((Object)(object)sliderR == (Object)null) && !((Object)(object)sliderG == (Object)null) && !((Object)(object)sliderB == (Object)null)) { SetEditorHairRgb(customization, new Vector3(sliderR.value, sliderG.value, sliderB.value)); } } private static void ApplySkinRgb(PlayerCustomizaton customization) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (!BarberUiIsPopulating && !_suppressCustomizationEvents && !((Object)(object)customization == (Object)null) && !((Object)(object)_cachedCustomizationOwner != (Object)(object)customization) && !((Object)(object)sliderSR == (Object)null) && !((Object)(object)sliderSG == (Object)null) && !((Object)(object)sliderSB == (Object)null)) { SetEditorSkinRgb(customization, new Vector3(sliderSR.value, sliderSG.value, sliderSB.value)); } } private static void ApplyEyeRgb(PlayerCustomizaton customization) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!BarberUiIsPopulating && !_suppressCustomizationEvents && !((Object)(object)customization == (Object)null) && !((Object)(object)_cachedCustomizationOwner != (Object)(object)customization) && !((Object)(object)sliderER == (Object)null) && !((Object)(object)sliderEG == (Object)null) && !((Object)(object)sliderEB == (Object)null)) { SetEditorEyeRgb(customization, new Color(sliderER.value, sliderEG.value, sliderEB.value, 1f)); } } internal static void PrimeExactRgbRollback(PlayerCustomizaton customization, Player player, Vector3 skin, Vector3 hair) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)customization == (Object)null) && !((Object)(object)player == (Object)null)) { SetExactHairRgbState(customization, player, ClampEditorRgb(hair)); SetExactSkinRgbState(customization, player, ClampEditorRgb(skin)); } } internal static bool SetEditorHairRgb(PlayerCustomizaton customization, Vector3 hair) { //IL_001e: 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_0024: 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_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_0043: Unknown result type (might be due to invalid IL or missing references) CacheCustomizationPanel(customization); Player customizationPlayer = GetCustomizationPlayer(customization); if ((Object)(object)customizationPlayer == (Object)null) { return false; } hair = ClampEditorRgb(hair); SetExactHairRgbState(customization, customizationPlayer, hair); if (!ApproximatelyRgb(customizationPlayer.GetHairColor(), hair)) { customizationPlayer.SetHairColor(hair); } return true; } internal static bool SetEditorSkinRgb(PlayerCustomizaton customization, Vector3 skin) { //IL_001f: 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_0025: 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_0041: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) CacheCustomizationPanel(customization); Player customizationPlayer = GetCustomizationPlayer(customization); if ((Object)(object)customizationPlayer == (Object)null) { return false; } skin = ClampEditorRgb(skin); SetExactSkinRgbState(customization, customizationPlayer, skin); VisEquipment visEquipment = ((Humanoid)customizationPlayer).m_visEquipment; if ((Object)(object)visEquipment == (Object)null || !ApproximatelyRgb(visEquipment.m_skinColor, skin)) { customizationPlayer.SetSkinColor(skin); } BalrondPlayerCustomization component = ((Component)customizationPlayer).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)component != (Object)null) { component.RefreshRaceExtraSkinColor(skin, force: false); } return true; } internal static bool SetEditorEyeRgb(PlayerCustomizaton customization, Color eyes) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0056: Unknown result type (might be due to invalid IL or missing references) Player customizationPlayer = GetCustomizationPlayer(customization); if ((Object)(object)customizationPlayer == (Object)null) { return false; } BalrondPlayerCustomization component = ((Component)customizationPlayer).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)component == (Object)null) { return false; } component.SetEyeColor(new Color(Mathf.Clamp01(eyes.r), Mathf.Clamp01(eyes.g), Mathf.Clamp01(eyes.b), 1f)); return true; } private static Vector3 ClampEditorRgb(Vector3 color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) return new Vector3(Mathf.Clamp01(color.x), Mathf.Clamp01(color.y), Mathf.Clamp01(color.z)); } private static bool ApproximatelyRgb(Vector3 a, Vector3 b) { //IL_0001: 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_001a: 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_0033: 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) return Mathf.Abs(a.x - b.x) <= 0.0001f && Mathf.Abs(a.y - b.y) <= 0.0001f && Mathf.Abs(a.z - b.z) <= 0.0001f; } private static void ApplyHeight(PlayerCustomizaton customization) { if (!BarberUiIsPopulating && !_suppressCustomizationEvents && !((Object)(object)customization == (Object)null) && !((Object)(object)_cachedCustomizationOwner != (Object)(object)customization) && !((Object)(object)sliderH == (Object)null)) { SetEditorHeight(customization, sliderH.value); } } internal static bool SetEditorHeight(PlayerCustomizaton customization, float height) { Player customizationPlayer = GetCustomizationPlayer(customization); if ((Object)(object)customizationPlayer == (Object)null) { return false; } BalrondPlayerCustomization component = ((Component)customizationPlayer).GetComponent<BalrondPlayerCustomization>(); if ((Object)(object)component == (Object)null) { return false; } float num = Mathf.Clamp(height, -0.05f, 0.05f); if (!Mathf.Approximately(num, component.height)) { component.SetHeight(num); } return true; } private static void SyncRgbSlidersFromPlayer(PlayerCustomizaton customization, Player player) { //IL_0040: 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_0048: 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_009e: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_0086: 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_0103: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_01f1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)customization == (Object)null || (Object)(object)player == (Object)null) { return; } CacheCustomizationPanel(customization); CachePanelsAndSliders(); if (!TryGetExactHairRgbState(customization, player, out var color)) { color = player.GetHairColor(); SetExactHairRgbState(customization, player, color); } if (!TryGetExactSkinRgbState(customization, player, out var color2)) { color2 = (((Object)(object)((Humanoid)player).m_visEquipment != (Object)null) ? ((Humanoid)player).m_visEquipment.m_skinColor : Vector3.one); SetExactSkinRgbState(customization, player, color2); } BalrondPlayerCustomization component = ((Component)player).GetComponent<BalrondPlayerCustomization>(); Vector3 val = (((Object)(object)component != (Object)null) ? component.eyeColorVector : Vector3.one); float valueWithoutNotify = (((Object)(object)component != (Object)null) ? component.height : 0f); _suppressCustomizationEvents = true; try { if ((Object)(object)sliderR != (Object)null) { sliderR.SetValueWithoutNotify(color.x); } if ((Object)(object)sliderG != (Object)null) { sliderG.SetValueWithoutNotify(color.y); } if ((Object)(object)sliderB != (Object)null) { sliderB.SetValueWithoutNotify(color.z); } if ((Object)(object)sliderSR != (Object)null) { sliderSR.SetValueWithoutNotify(color2.x); } if ((Object)(object)sliderSG != (Object)null) { sliderSG.SetValueWithoutNotify(color2.y); } if ((Object)(object)sliderSB != (Object)null) { sliderSB.SetValueWithoutNotify(color2.z); } if ((Object)(object)sliderER != (Object)null) { sliderER.SetValueWithoutNotify(val.x); } if ((Object)(object)sliderEG != (Object)null) { sliderEG.SetValueWithoutNotify(val.y); } if ((Object)(object)sliderEB != (Object)null) { sliderEB.SetValueWithoutNotify(val.z); } if ((Object)(object)sliderH != (Object)null) { sliderH.SetValueWithoutNotify(valueWithoutNotify); } } finally { _suppressCustomizationEvents = false; } } private static bool HasSliderGroup(Transform root, string name, int requiredSliders) { if ((Object)(object)root == (Object)null) { return false; } Transform val = root.Find(name); return (Object)(object)val != (Object)null && ((Component)val).GetComponentsInChildren<Slider>(true).Length >= requiredSliders; } private static bool NeedsCharacterCreationUiBuild(PlayerCustomizaton customization) { if ((Object)(object)customization == (Object)null) { return false; } FejdStartup val = ResolveCreatorStartup(customization); if ((Object)(object)val == (Object)null || (Object)(object)val.m_newCharacterPanel == (Object)null) { return false; } Transform val2 = val.m_newCharacterPanel.transform.Find("CusomizationPanel"); if ((Object)(object)val2 == (Object)null) { return false; } if ((Object)(object)uiPanel == (Object)null || (Object)(object)uiPanel.transform != (Object)(object)val2) { return true; } return !HasSliderGroup(val2, "SkinColorGroup", 3) || !HasSliderGroup(val2, "HairColorGroup", 3) || !HasSliderGroup(val2, "EyeColorGroup", 3) || !HasSliderGroup(val2, "HeightGroup", 1) || (Object)(object)FindDescendantTransform(val2, "BRC_RandomizeButton") == (Object)null || (Object)(object)FindDescendantTransform(val2, "BRC_ResetButton") == (Object)null; } private static bool NeedsCharacterCreationUiBuild(FejdStartup startup) { return (Object)(object)startup != (Object)null && (Object)(object)startup.m_newCharacterPanel != (Object)null && NeedsCharacterCreationUiBuild(startup.m_newCharacterPanel.GetComponent<PlayerCustomizaton>()); } public static void StartCharacterEdit() { //IL_017e: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) string selectedLanguage = Localization.instance.GetSelectedLanguage(); Dictionary<string, string> translations = GetTranslations(selectedLanguage); AddTranslations(translations); FejdStartup instance = FejdStartup.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.m_newCharacterPanel == (Object)null) && !((Object)(object)instance.m_selectCharacterPanel == (Object)null) && !((Object)(object)instance.m_csNewCharacterName == (Object)null) && !((Object)(object)instance.m_newCharacterError == (Object)null) && instance.m_profiles != null && instance.m_profileIndex >= 0 && instance.m_profileIndex < instance.m_profiles.Count && !((Object)(object)title == (Object)null)) { editingCharacter = true; ((Component)title).gameObject.SetActive(true); Transform val = instance.m_newCharacterPanel.transform.Find("Topic"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } PlayerProfile val2 = FejdStartup.instance.m_profiles[FejdStartup.instance.m_profileIndex]; FejdStartup.instance.m_newCharacterPanel.SetActive(true); FejdStartup.instance.m_selectCharacterPanel.SetActive(false); ((TMP_InputField)FejdStartup.instance.m_csNewCharacterName).text = val2.GetName(); FejdStartup.instance.m_newCharacterError.SetActive(false); Player previewPlayer = FejdStartup.instance.GetPreviewPlayer(); BalrondPlayerCustomization balrondPlayerCustomization = ((previewPlayer != null) ? ((Component)previewPlayer).GetComponent<BalrondPlayerCustomization>() : null); if ((Object)(object)balrondPlayerCustomization != (Object)null) { Vector3 fromPlayerCustomData = balrondPlayerCustomization.GetFromPlayerCustomData(FejdStartup.instance.GetPreviewPlayer()); float heightFromPlayerCustomData = balrondPlayerCustomization.GetHeightFromPlayerCustomData(FejdStartup.instance.GetPreviewPlayer()); balrondPlayerCustomization.SetEyeColor(new Color(fromPlayerCustomData.x, fromPlayerCustomData.y, fromPlayerCustomData.z, 1f)); balrondPlayerCustomization.SetHeight(heightFromPlayerCustomData); } FejdStartup.instance.SetupCharacterPreview(val2); Gogan.LogEvent("Screen", "Enter", "CreateCharacter", 0L); } } private static void PrepareBarberChoiceContainers(PlayerCustomizaton owner) { Transform transform = owner.m_rootPanel.transform; Transform obj = FindDescendantTransform(transform, "HairPanel"); GroupFlatBarberChoice((RectTransform)(object)((obj is RectTransform) ? obj : null), owner.m_selectedHair); GroupFlatBarberChoice(owner.m_beardPanel, owner.m_selectedBeard); SetActiveIfFound(transform, "SkinTone", state: false); SetActiveIfFound(transform, "SexPanel", state: false); } private static void GroupFlatBarberChoice(RectTransform panel, TMP_Text selected) { if ((Object)(object)panel == (Object)null || (Object)(object)selected == (Object)null || selected.transform.IsChildOf((Transform)(object)panel) || (Object)(object)selected.transform.parent != (Object)(object)((Transform)panel).parent) { return; } Transform parent = ((Transform)panel).parent; int num = ((Transform)panel).GetSiblingIndex() + 1; int siblingIndex = selected.transform.GetSiblingIndex(); for (int num2 = siblingIndex; num2 >= num; num2--) { Transform child = parent.GetChild(num2); if ((Object)(object)child == (Object)(object)selected.transform || (Object)(object)((Component)child).GetComponent<Button>() != (Object)null || string.Equals(((Object)child).name, "Topic", StringComparison.OrdinalIgnoreCase)) { child.SetParent((Transform)(object)panel, false); } } NormalizeBarberChoice(panel, null); } private static RectTransform BarberRect(string name, Transform parent) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown Transform val = parent.Find(name); if ((Object)(object)val != (Object)null) { return (RectTransform)(object)((val is RectTransform) ? val : null);