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 humanoidRandomizer v1.6.2
plugins/BalrondHumanoidRandomizer.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.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BalrondHumanoidRandomizer.Compatibility; using BalrondHumanoidRandomizer.Config; using BalrondHumanoidRandomizer.Monsters; using BalrondHumanoidRandomizer.Networking; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BalrondHumanoidRandomizer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BalrondHumanoidRandomizer")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("f405ea1c-ac25-47a3-9aa2-a8f56c14bfd6")] [assembly: AssemblyFileVersion("1.6.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.2.0")] [module: UnverifiableCode] namespace BalrondHumanoidRandomizer { internal static class AudioPrefabService { private sealed class ReferenceComparer<T> : IEqualityComparer<T> where T : class { internal static readonly ReferenceComparer<T> Instance = new ReferenceComparer<T>(); public bool Equals(T x, T y) { return x == y; } public int GetHashCode(T value) { return RuntimeHelpers.GetHashCode(value); } } private static readonly Dictionary<string, AudioMixerGroup> LiveGroups = new Dictionary<string, AudioMixerGroup>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<Type, FieldInfo[]> SerializedFields = new Dictionary<Type, FieldInfo[]>(); private static readonly HashSet<GameObject> Visited = new HashSet<GameObject>(ReferenceComparer<GameObject>.Instance); private static readonly HashSet<object> ManagedVisited = new HashSet<object>(ReferenceComparer<object>.Instance); private static AudioMan _audioMan; private static AudioMixer _liveMixer; private static AudioMixerGroup _master; private static AudioMixerGroup _sfx; private static AudioMixerGroup _ambient; private static AudioMixerGroup _music; private static int _changed; private static int _alreadyValid; private static int _sources; private const int MaxReferencedObjects = 8192; private const int MaxFieldDepth = 12; private static readonly List<GameObject> OwnedRoots = new List<GameObject>(); private static readonly HashSet<GameObject> OwnedRootSet = new HashSet<GameObject>(ReferenceComparer<GameObject>.Instance); private static readonly HashSet<string> Warnings = new HashSet<string>(StringComparer.Ordinal); internal static bool DebugLogging { get; set; } internal static void WarningOnce(string key, string message) { if (Warnings.Add(key)) { Launch.LogWarning("[Audio] " + message); } } internal static void Process(GameObject root) { if ((Object)(object)root != (Object)null && OwnedRootSet.Add(root)) { OwnedRoots.Add(root); } ApplyAfterFxRebinding(); } internal static void Process(IEnumerable<GameObject> roots) { if (roots == null) { return; } foreach (GameObject root in roots) { if ((Object)(object)root != (Object)null && OwnedRootSet.Add(root)) { OwnedRoots.Add(root); } } ApplyAfterFxRebinding(); } internal static void Apply(AudioMan audioMan) { if (!((Object)(object)audioMan == (Object)null) && (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated())) { _audioMan = audioMan; RebuildLiveMixer(audioMan); RouteOwnedPrefabs(); } } internal static void ApplyAfterFxRebinding() { if (!((Object)(object)_audioMan == (Object)null)) { if ((Object)(object)_sfx == (Object)null) { RebuildLiveMixer(_audioMan); } if ((Object)(object)_sfx != (Object)null) { RouteOwnedPrefabs(); } } } internal static void Reset() { OwnedRoots.Clear(); OwnedRootSet.Clear(); Warnings.Clear(); _audioMan = null; _liveMixer = null; _master = (_sfx = (_ambient = (_music = null))); LiveGroups.Clear(); Visited.Clear(); ManagedVisited.Clear(); SerializedFields.Clear(); } private static void RebuildLiveMixer(AudioMan audioMan) { LiveGroups.Clear(); _master = ReadGroup(audioMan, "m_masterMixer"); _ambient = ReadGroup(audioMan, "m_ambientMixer"); _music = ReadGroup(audioMan, "m_musicMixer"); FieldInfo field = typeof(AudioMan).GetField("m_masterMixer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _liveMixer = (AudioMixer)(((object)((field != null) ? /*isinst with value type is only supported in some contexts*/: null)) ?? ((object)(MixerOf(_master) ?? MixerOf(_ambient) ?? MixerOf(_music)))); AddGroup(_master); AddGroup(_ambient); AddGroup(_music); if ((Object)(object)_liveMixer != (Object)null) { try { AudioMixerGroup[] array = _liveMixer.FindMatchingGroups(string.Empty); if (array != null) { for (int i = 0; i < array.Length; i++) { AddGroup(array[i]); } } } catch (Exception ex) { WarningOnce("audio-groups", "Cannot enumerate live mixer groups: " + ex.Message); } } _ambient = _ambient ?? FindGroup("Ambient"); _music = _music ?? FindGroup("Music"); _sfx = FindGroup("SFX") ?? FindGroup("Effects") ?? FindGroup("Sound Effects"); if ((Object)(object)_sfx == (Object)null) { WarningOnce("audio-sfx-missing", "No runtime SFX group found; leaving audio routes intact instead of incorrectly assigning Master."); } } private static void RouteOwnedPrefabs() { if ((Object)(object)_sfx == (Object)null) { return; } Visited.Clear(); ManagedVisited.Clear(); _changed = (_alreadyValid = (_sources = 0)); foreach (GameObject ownedRoot in OwnedRoots) { InspectPrefab(ownedRoot); } if (DebugLogging) { Launch.LogInfo("[Audio] sources=" + _sources + ", rerouted=" + _changed + ", preservedRuntime=" + _alreadyValid + ", prefabGraph=" + Visited.Count + "."); } Visited.Clear(); ManagedVisited.Clear(); } private static void InspectPrefab(GameObject prefab) { if ((Object)(object)prefab == (Object)null || Visited.Count >= 8192 || !Visited.Add(prefab)) { return; } try { AudioSource[] componentsInChildren = prefab.GetComponentsInChildren<AudioSource>(true); for (int i = 0; i < componentsInChildren.Length; i++) { RouteSource(componentsInChildren[i]); } MonoBehaviour[] componentsInChildren2 = prefab.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren2) { if (!((Object)(object)val == (Object)null) && !(val is ZSFX)) { InspectSerializedObject(val, 0); } } } catch (Exception ex) { WarningOnce("audio-prefab:" + ((Object)prefab).GetInstanceID(), "Could not inspect prefab audio graph '" + ((Object)prefab).name + "': " + ex.Message); } } private static void RouteSource(AudioSource source) { if ((Object)(object)source == (Object)null) { return; } _sources++; AudioMixerGroup outputAudioMixerGroup = source.outputAudioMixerGroup; if (IsLiveGroup(outputAudioMixerGroup)) { _alreadyValid++; if (DebugLogging) { Launch.LogInfo("[Audio] preserved live group '" + ((Object)outputAudioMixerGroup).name + "' on '" + ((Object)((Component)source).gameObject).name + "'."); } return; } AudioMixerGroup val = null; if ((Object)(object)outputAudioMixerGroup != (Object)null && !string.IsNullOrEmpty(((Object)outputAudioMixerGroup).name) && !IsMasterName(((Object)outputAudioMixerGroup).name)) { val = FindGroup(((Object)outputAudioMixerGroup).name); } if ((Object)(object)val == (Object)null && (Object)(object)outputAudioMixerGroup != (Object)null && ((Object)outputAudioMixerGroup).name != null) { if (((Object)outputAudioMixerGroup).name.IndexOf("ambient", StringComparison.OrdinalIgnoreCase) >= 0) { val = _ambient; } else if (((Object)outputAudioMixerGroup).name.IndexOf("music", StringComparison.OrdinalIgnoreCase) >= 0) { val = _music; } } if ((Object)(object)val == (Object)null) { val = _sfx; } if (outputAudioMixerGroup == val) { _alreadyValid++; return; } try { source.outputAudioMixerGroup = val; _changed++; if (DebugLogging) { Launch.LogInfo("[Audio] '" + ((Object)((Component)source).gameObject).name + "': '" + (((Object)(object)outputAudioMixerGroup != (Object)null) ? ((Object)outputAudioMixerGroup).name : "<none>") + "' -> '" + ((Object)val).name + "'."); } } catch (Exception ex) { WarningOnce("audio-source:" + ((Object)source).GetInstanceID(), "AudioSource mixer rebinding failed for '" + ((Object)((Component)source).gameObject).name + "': " + ex.Message); } } private static void InspectSerializedObject(object data, int depth) { if (data == null || depth > 12 || Visited.Count >= 8192 || (!data.GetType().IsValueType && !ManagedVisited.Add(data))) { return; } FieldInfo[] serializedFields = GetSerializedFields(data.GetType()); for (int i = 0; i < serializedFields.Length; i++) { object value; try { value = serializedFields[i].GetValue(data); } catch { continue; } InspectValue(value, depth + 1, serializedFields[i].Name); } } private static void InspectValue(object value, int depth, string originField) { if (value == null || depth > 12 || Visited.Count >= 8192) { return; } EffectList val = (EffectList)((value is EffectList) ? value : null); if (val != null) { EffectData[] effectPrefabs = val.m_effectPrefabs; if (effectPrefabs == null) { return; } for (int i = 0; i < effectPrefabs.Length; i++) { if (effectPrefabs[i] != null) { InspectPrefab(effectPrefabs[i].m_prefab); } } return; } GameObject val2 = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val2 != (Object)null) { if (IsAudioLink(originField)) { InspectPrefab(val2); } return; } Component val3 = (Component)((value is Component) ? value : null); if ((Object)(object)val3 != (Object)null) { AudioSource val4 = (AudioSource)(object)((val3 is AudioSource) ? val3 : null); if ((Object)(object)val4 != (Object)null) { RouteSource(val4); } else if (IsAudioLink(originField)) { InspectPrefab(val3.gameObject); } } else { if (value is Object || value is string) { return; } if (value is IEnumerable enumerable) { int num = 0; { foreach (object item in enumerable) { InspectValue(item, depth + 1, originField); if (++num >= 512) { break; } } return; } } Type type = value.GetType(); if (!type.IsPrimitive && !type.IsEnum && !(type == typeof(decimal)) && !(type.Namespace == "System") && type.IsSerializable) { InspectSerializedObject(value, depth + 1); } } } private static bool IsAudioLink(string name) { if (string.IsNullOrEmpty(name)) { return false; } return name.IndexOf("effect", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("sound", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("audio", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("sfx", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("vfx", StringComparison.OrdinalIgnoreCase) >= 0; } private static FieldInfo[] GetSerializedFields(Type type) { if (SerializedFields.TryGetValue(type, out var value)) { return value; } List<FieldInfo> list = new List<FieldInfo>(); Type type2 = type; while (type2 != null && type2 != typeof(MonoBehaviour) && type2 != typeof(Behaviour) && type2 != typeof(Component) && type2 != typeof(Object)) { FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.IsStatic && !fieldInfo.IsNotSerialized && !fieldInfo.IsLiteral && (fieldInfo.IsPublic || Attribute.IsDefined(fieldInfo, typeof(SerializeField)))) { list.Add(fieldInfo); } } type2 = type2.BaseType; } value = list.ToArray(); SerializedFields[type] = value; return value; } private static AudioMixerGroup ReadGroup(AudioMan audioMan, string name) { try { FieldInfo field = typeof(AudioMan).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); object obj = ((field != null) ? field.GetValue(audioMan) : null); AudioSource val = (AudioSource)((obj is AudioSource) ? obj : null); return (AudioMixerGroup)(((Object)(object)val != (Object)null) ? val.outputAudioMixerGroup : ((obj is AudioMixerGroup) ? obj : null)); } catch { return null; } } private static AudioMixer MixerOf(AudioMixerGroup group) { try { return ((Object)(object)group != (Object)null) ? group.audioMixer : null; } catch { return null; } } private static bool IsLiveGroup(AudioMixerGroup group) { if ((Object)(object)group == (Object)null) { return false; } if ((Object)(object)_liveMixer != (Object)null && (Object)(object)MixerOf(group) == (Object)(object)_liveMixer) { return true; } return group == _master || group == _sfx || group == _ambient || group == _music; } private static AudioMixerGroup FindGroup(string name) { if (string.IsNullOrEmpty(name)) { return null; } if (LiveGroups.TryGetValue(name, out var value)) { return value; } if ((Object)(object)_liveMixer == (Object)null) { return null; } try { AudioMixerGroup[] array = _liveMixer.FindMatchingGroups(name); if (array != null) { for (int i = 0; i < array.Length; i++) { AddGroup(array[i]); if ((Object)(object)array[i] != (Object)null && string.Equals(((Object)array[i]).name, name, StringComparison.OrdinalIgnoreCase)) { return array[i]; } } } } catch { } return null; } private static void AddGroup(AudioMixerGroup group) { if ((Object)(object)group != (Object)null && !string.IsNullOrEmpty(((Object)group).name) && !LiveGroups.ContainsKey(((Object)group).name)) { LiveGroups.Add(((Object)group).name, group); } } private static bool IsMasterName(string name) { return string.Equals(name, "Master", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "MasterAudio", StringComparison.OrdinalIgnoreCase) || string.Equals(name, "Master Mixer", StringComparison.OrdinalIgnoreCase); } } public class FxReplacment { private List<GameObject> allPrefabs; private string projectName = "[BalrondHumanoidRandomizer]"; public void setInstance(List<GameObject> gameObjects) { allPrefabs = gameObjects; } public void ReplaceOnObject(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } SpawnArea component = gameObject.GetComponent<SpawnArea>(); if ((Object)(object)component != (Object)null) { EffectList spawnEffects = component.m_spawnEffects; if (spawnEffects != null) { findEffectsAndChange(spawnEffects.m_effectPrefabs); } } Destructible component2 = gameObject.GetComponent<Destructible>(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = component2.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } Projectile component3 = gameObject.GetComponent<Projectile>(); if ((Object)(object)component3 != (Object)null) { EffectList hitEffects = component3.m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList hitWaterEffects = component3.m_hitWaterEffects; if (hitWaterEffects != null) { findEffectsAndChange(hitWaterEffects.m_effectPrefabs); } EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects; if (spawnOnHitEffects != null) { findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs); } } } public void ReplaceOnVegetation(GameObject gameObject) { Pickable component = gameObject.GetComponent<Pickable>(); if ((Object)(object)component != (Object)null) { fixPlant(component); } Destructible component2 = gameObject.GetComponent<Destructible>(); if ((Object)(object)component2 != (Object)null) { fixPDestructable(component2); } MineRock5 component3 = gameObject.GetComponent<MineRock5>(); if ((Object)(object)component3 != (Object)null) { fixMineRock5(component3); } MineRock component4 = gameObject.GetComponent<MineRock>(); if ((Object)(object)component4 != (Object)null) { fixMineRock(component4); } } private void fixPlant(Pickable pickable) { EffectList pickEffector = pickable.m_pickEffector; if (pickEffector != null) { findEffectsAndChange(pickEffector.m_effectPrefabs); } } private void fixPDestructable(Destructible minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock5(MineRock5 minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } private void fixMineRock(MineRock minerock5) { EffectList hitEffect = minerock5.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList destroyedEffect = minerock5.m_destroyedEffect; if (destroyedEffect != null) { findEffectsAndChange(destroyedEffect.m_effectPrefabs); } } public void ReplaceOnMonster(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } Humanoid component = gameObject.GetComponent<Humanoid>(); if ((Object)(object)component == (Object)null) { Debug.LogWarning((object)(projectName + ":: GameObject not found")); return; } EffectList dropEffects = component.m_dropEffects; if (dropEffects != null) { findEffectsAndChange(dropEffects.m_effectPrefabs); } EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects; if (backstabHitEffects != null) { findEffectsAndChange(backstabHitEffects.m_effectPrefabs); } EffectList consumeItemEffects = component.m_consumeItemEffects; if (consumeItemEffects != null) { findEffectsAndChange(consumeItemEffects.m_effectPrefabs); } EffectList critHitEffects = ((Character)component).m_critHitEffects; if (critHitEffects != null) { findEffectsAndChange(critHitEffects.m_effectPrefabs); } EffectList deathEffects = ((Character)component).m_deathEffects; if (deathEffects != null) { findEffectsAndChange(deathEffects.m_effectPrefabs); } EffectList hitEffects = ((Character)component).m_hitEffects; if (hitEffects != null) { findEffectsAndChange(hitEffects.m_effectPrefabs); } EffectList jumpEffects = ((Character)component).m_jumpEffects; if (jumpEffects != null) { findEffectsAndChange(jumpEffects.m_effectPrefabs); } EffectList perfectBlockEffect = component.m_perfectBlockEffect; if (perfectBlockEffect != null) { findEffectsAndChange(perfectBlockEffect.m_effectPrefabs); } EffectList pickupEffects = component.m_pickupEffects; if (pickupEffects != null) { findEffectsAndChange(pickupEffects.m_effectPrefabs); } EffectList slideEffects = ((Character)component).m_slideEffects; if (slideEffects != null) { findEffectsAndChange(slideEffects.m_effectPrefabs); } EffectList tarEffects = ((Character)component).m_tarEffects; if (tarEffects != null) { findEffectsAndChange(tarEffects.m_effectPrefabs); } EffectList waterEffects = ((Character)component).m_waterEffects; if (waterEffects != null) { findEffectsAndChange(waterEffects.m_effectPrefabs); } FootStep component2 = gameObject.GetComponent<FootStep>(); if (!((Object)(object)component2 != (Object)null)) { return; } List<StepEffect> effects = component2.m_effects; foreach (StepEffect item in effects) { GameObject[] effectPrefabs = item.m_effectPrefabs; List<GameObject> list = new List<GameObject>(); list.AddRange(effectPrefabs); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i] != (Object)null) { string name = ((Object)list[i]).name; GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val == (Object)null)) { list[i] = val; } } } } } public void ReplaceOnItem(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } ItemDrop component = gameObject.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null)) { EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect; if (hitTerrainEffect != null) { findEffectsAndChange(hitTerrainEffect.m_effectPrefabs); } EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect; if (holdStartEffect != null) { findEffectsAndChange(holdStartEffect.m_effectPrefabs); } EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect; if (trailStartEffect != null) { findEffectsAndChange(trailStartEffect.m_effectPrefabs); } EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect; if (blockEffect != null) { findEffectsAndChange(blockEffect.m_effectPrefabs); } } } public void ReplaceFxOnPiece(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } Piece component = gameObject.GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { EffectList placeEffect = component.m_placeEffect; if (placeEffect != null) { findEffectsAndChange(placeEffect.m_effectPrefabs); } } WearNTear component2 = gameObject.GetComponent<WearNTear>(); if ((Object)(object)component2 != (Object)null) { EffectList hitEffect = component2.m_hitEffect; if (hitEffect != null) { findEffectsAndChange(hitEffect.m_effectPrefabs); } } } private void findEffectsAndChange(EffectData[] effects) { if (effects == null || effects.Length == 0) { return; } foreach (EffectData val in effects) { if ((Object)(object)val.m_prefab != (Object)null) { string name = ((Object)val.m_prefab).name; GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name); if (!((Object)(object)val2 == (Object)null)) { val.m_prefab = val2; } } } } } public class ShaderReplacment { public static List<GameObject> prefabsToReplaceShader = new List<GameObject>(); public static List<Material> materialsInPrefabs = new List<Material>(); public string[] shaderlist = new string[49] { "Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass", "Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player", "Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water", "Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear", "Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting" }; public static List<Shader> shaders = new List<Shader>(); private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>(); public static bool debug = true; public static Shader findShader(string name) { Shader[] array = Resources.FindObjectsOfTypeAll<Shader>(); if (array.Length == 0) { Debug.LogWarning((object)"SHADER LIST IS EMPTY!"); return null; } if (debug) { } return shaders.Find((Shader x) => ((Object)x).name == name); } public static Shader GetShaderByName(string name) { return shaders.Find((Shader x) => ((Object)x).name == name.Trim()); } public static void debugShaderList(List<Shader> shadersRes) { foreach (Shader shadersRe in shadersRes) { Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name)); } debug = false; } public static void Replace(GameObject gameObject) { prefabsToReplaceShader.Add(gameObject); GetMaterialsInPrefab(gameObject); } public static void GetMaterialsInPrefab(GameObject gameObject) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { continue; } Material[] array2 = sharedMaterials; foreach (Material val2 in array2) { if ((Object)(object)val2 != (Object)null) { materialsInPrefabs.Add(val2); } } } } public static void getMeShaders() { AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { IEnumerable<Shader> enumerable3; try { IEnumerable<Shader> enumerable2; if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val)) { IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>(); enumerable2 = enumerable; } else { enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>) where (Object)(object)shader != (Object)null select shader; } enumerable3 = enumerable2; } catch (Exception) { continue; } if (enumerable3 == null) { continue; } foreach (Shader item in enumerable3) { CachedShaders.Add(item); } } } public static void runMaterialFix() { getMeShaders(); shaders.AddRange(CachedShaders); foreach (Material materialsInPrefab in materialsInPrefabs) { Shader shader = materialsInPrefab.shader; if (!((Object)(object)shader == (Object)null)) { string name = ((Object)shader).name; if (!(name == "Standard") && name.Contains("Balrond")) { setProperValue(materialsInPrefab, name); } } } } private static void setProperValue(Material material, string shaderName) { string name = shaderName.Replace("Balrond", "Custom"); name = checkNaming(name); Shader shaderByName = GetShaderByName(name); if (!((Object)(object)shaderByName == (Object)null)) { material.shader = shaderByName; } } private static string checkNaming(string name) { string result = name; if (name.Contains("Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Tess Bumped")) { result = name.Replace("Custom", "Lux Lit Particles"); } if (name.Contains("Standard Surface")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Surface2", "Standard Surface"); } if (name.Contains("Standard Unlit")) { result = name.Replace("Custom", "Particles"); result = result.Replace("Standard Unlit", "Standard Unlit2"); result = result.Replace("Standard Unlit22", "Standard Unlit2"); } return result; } } public class StatusEffectBuilder { public List<StatusEffect> statusEffects = new List<StatusEffect>(); public void setShieldStatus(SE_LevelShield statusEffect, Sprite icon) { ((StatusEffect)statusEffect).m_icon = icon; ((StatusEffect)statusEffect).m_ttl = 40f; ((Object)statusEffect).name = "SE_LevelShield"; ((StatusEffect)statusEffect).m_name = "Shield_MonsterRandomizer"; ((StatusEffect)statusEffect).m_tooltip = "You been shielded"; ((StatusEffect)statusEffect).m_activationAnimation = ""; statusEffects.Add((StatusEffect)(object)statusEffect); } public StatusEffect cloneShield(StatusEffect shield, int absorb, string name) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown SE_Shield val = (SE_Shield)shield.Clone(); val.m_absorbDamage = absorb; ((StatusEffect)val).m_name = name; ((Object)val).name = name; return (StatusEffect)(object)val; } public static void setupVisualsForStatus(StatusEffect statusEffect, List<GameObject> list) { if ((Object)(object)statusEffect == (Object)null) { Debug.LogWarning((object)"Status Effect is null!"); return; } string name = statusEffect.m_name; string text = name; if (text == "Shield_MonsterRandomizer") { List<EffectData> list2 = new List<EffectData>(); SE_LevelShield sE_LevelShield = (SE_LevelShield)(object)statusEffect; list2.Add(createEffectData(list, "fx_GoblinShieldBreak", attach: false, "", scale: true)); list2.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null); sE_LevelShield.m_breakEffects.m_effectPrefabs = list2.ToArray(); List<EffectData> list3 = new List<EffectData>(); list3.Add(createEffectData(list, "fx_GoblinShieldHit")); list3.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null); sE_LevelShield.m_hitEffects.m_effectPrefabs = list3.ToArray(); List<EffectData> list4 = new List<EffectData>(); list4.Add(createEffectData(list, "vfx_GoblinShield", attach: true, "", scale: true)); list4.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null); ((StatusEffect)sE_LevelShield).m_startEffects.m_effectPrefabs = list4.ToArray(); } } private static EffectData createEffectData(List<GameObject> list, string name, bool attach = false, string attachName = "", bool scale = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown EffectData val = new EffectData(); val.m_variant = -1; val.m_prefab = FindEffect(list, name); val.m_enabled = true; val.m_attach = attach; val.m_scale = scale; val.m_childTransform = attachName; return val; } private static GameObject FindEffect(List<GameObject> list, string name) { if (list == null) { return null; } GameObject val = list.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == name); if ((Object)(object)val != (Object)null) { return val; } return null; } } public class HumanoidExtend : MonoBehaviour { private MonsterAI monster; private Humanoid humanoid; private ZNetView m_nview; private bool itemStolen = false; private int growthAmount = 1; private int maxLevel = 7; private int currentLevel; public bool canSteal = false; public bool levelingEnabled = true; public bool expOnKillEnabled = true; public bool bossLeveling = false; public int chanceToSteal = 25; public int currentGrowth = 0; public int growthToLevel = 40000; public int expForKill = 500; public GameObject levelUpEffect; public GameObject stealEffect; public ItemData stolenItem = null; public bool toggleReset = false; private SphereCollider collider; private void Awake() { humanoid = ((Component)this).GetComponent<Humanoid>(); monster = ((Component)this).GetComponent<MonsterAI>(); m_nview = ((Component)this).GetComponent<ZNetView>(); currentLevel = ((Character)humanoid).GetLevel(); if (!((BaseAI)monster).m_character.IsTamed()) { collider = ((Component)monster).gameObject.AddComponent<SphereCollider>(); collider.radius = 3f; ((Collider)collider).isTrigger = true; } m_nview.Register<string, int>("Steal", (Action<long, string, int>)RPC_StolenItem); if (((Character)humanoid).IsBoss() && bossLeveling && !levelingEnabled) { levelingEnabled = false; bossLeveling = false; } Character character = ((BaseAI)monster).m_character; character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, (Action)delegate { detectKill(((Component)monster).transform); }); Character character2 = ((BaseAI)monster).m_character; character2.m_onDeath = (Action)Delegate.Combine(character2.m_onDeath, (Action)delegate { DropStolen(); }); setMaxExpToLevel(); ((MonoBehaviour)this).InvokeRepeating("CheckLeveling", 1f, 1f); } private void CheckTamed() { if (((BaseAI)monster).m_character.IsTamed()) { Object.DestroyImmediate((Object)(object)collider); } } private void CheckLeveling() { ResetLevel(); CheckTamed(); if (((Component)this).gameObject.activeInHierarchy) { if (levelingEnabled) { currentGrowth += growthAmount; } if (currentGrowth >= growthToLevel && currentLevel < maxLevel) { TransferExpOnLevel(); setMaxExpToLevel(); monsterLevelUp(); } } } private void TransferExpOnLevel() { if (currentGrowth > growthToLevel) { int num = currentGrowth - growthToLevel; if (num > 0) { currentGrowth += num; } } else { currentGrowth = 0; } } private void setMaxExpToLevel() { growthToLevel *= currentLevel; } private void monsterLevelUp() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) currentLevel++; if ((Object)(object)levelUpEffect != (Object)null && ((Character)humanoid).GetLevel() < currentLevel) { Object.Instantiate<GameObject>(levelUpEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null); } if (((Character)humanoid).GetLevel() < currentLevel) { ((Character)humanoid).SetLevel(currentLevel); ((Character)humanoid).RPC_Heal((long)((Object)humanoid).GetInstanceID(), ((Character)humanoid).GetMaxHealth(), false); } } public void detectKill(Transform transform) { //IL_0010: 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_0066: Unknown result type (might be due to invalid IL or missing references) if (!expOnKillEnabled) { return; } Collider[] array = Physics.OverlapSphere(transform.position, 3f, LayerMask.GetMask(new string[1] { "character" })); Collider[] array2 = array; HumanoidExtend humanoidExtend = default(HumanoidExtend); foreach (Collider val in array2) { if (((Component)val).TryGetComponent<HumanoidExtend>(ref humanoidExtend)) { Humanoid component = ((Component)humanoidExtend).GetComponent<Humanoid>(); if (((Character)component).m_faction != ((Character)humanoid).m_faction) { addExpToFound(humanoidExtend); } } } } private void ResetLevel() { if (toggleReset) { ((Character)humanoid).SetLevel(1); toggleReset = false; } } private void addExpToFound(HumanoidExtend humanoidExtend) { humanoidExtend.currentGrowth += expForKill; } private void OnCollisionEnter(Collision collision) { int num = Random.Range(1, 100); Player val = default(Player); if (!itemStolen && num <= 33 && canSteal && collision.gameObject.TryGetComponent<Player>(ref val) && ((Character)val).m_nview.IsValid()) { CustomSteal(monster, val); itemStolen = true; } } private void CustomSteal(MonsterAI monster, Player player) { Inventory inventory = ((Humanoid)player).GetInventory(); FindItemToSteal(inventory, player); } private void FindItemToSteal(Inventory inventory, Player player) { List<ItemData> allItems = inventory.GetAllItems(); List<ItemData> list = allItems.FindAll((ItemData x) => (!x.m_equipped && x.m_quality == 1 && x.m_variant == 0 && !x.IsWeapon()) || ((Object)x.m_dropPrefab).name.Contains("Torch")); if (list.Count > 0) { int index = Random.Range(0, list.Count); GameObject dropPrefab = list[index].m_dropPrefab; string name = list[index].m_shared.m_name; Debug.Log((object)("STOLEN ITEM: " + ((Object)dropPrefab).name)); ((Character)player).Message((MessageType)2, name + " was stolen!", 0, (Sprite)null, false); stolenItem = list[index]; inventory.RemoveItem(list[index]); m_nview.InvokeRPC("Steal", new object[2] { ((Object)list[index].m_dropPrefab).name, list[index].m_stack }); } else { Debug.Log((object)"There was nothing to steal"); } } private void RPC_StolenItem(long sender, string name, int amount) { //IL_00d4: 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) if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items == null) { return; } GameObject val = ObjectDB.instance.m_items.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == name); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null || val2.m_itemData == null) { Debug.LogWarning((object)("BalrondHumanoidRandomizer: Could not restore stolen item prefab: " + name)); return; } stolenItem = val2.m_itemData.Clone(); stolenItem.m_stack = amount; if ((Object)(object)stealEffect != (Object)null) { Object.Instantiate<GameObject>(stealEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null); } } public void CustomDoorInteract(Transform character, Door door) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //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_002b: 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) Vector3 val = ((Component)character).transform.position - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; bool flag = Vector3.Dot(((Component)this).transform.forward, normalized) < 0f; door.m_nview.InvokeRPC("UseDoor", new object[2] { ((Object)((Component)humanoid).GetComponent<ZNetView>()).GetInstanceID(), flag }); } private void DropStolen() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (canSteal && itemStolen && stolenItem != null) { Object.Instantiate<GameObject>(stolenItem.m_dropPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null).GetComponent<ItemDrop>().m_itemData.m_stack = stolenItem.m_stack; } } } [Serializable] public class HumanoidRandomizer : MonoBehaviour { private ZNetView m_zview; private MonsterAI m_monsterAI; private Humanoid m_humanoid; private VisEquipment m_visEquipment; public string newName; public bool isNameSet = false; public List<ItemSet> itemSets; public string m_itemSetName = ""; public string m_itemSetSimplified = ""; public int m_weaponStance = 0; private Animator m_animator; public RuntimeAnimatorController sourceAnimator; public Biome spawnBiome = (Biome)1; public bool hasOriginalEquipmentSnapshot; public GameObject[] originalDefaultItems = (GameObject[])(object)new GameObject[0]; public GameObject[] originalRandomArmor = (GameObject[])(object)new GameObject[0]; public GameObject[] originalRandomShield = (GameObject[])(object)new GameObject[0]; public GameObject[] originalRandomWeapon = (GameObject[])(object)new GameObject[0]; public ItemSet[] originalRandomSets = (ItemSet[])(object)new ItemSet[0]; public ItemDrop originalUnarmedWeapon; public string fixedVariantName = string.Empty; private bool initializedForSpawn; internal void InitializeForSpawn() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (initializedForSpawn) { return; } if (!validatePrefab()) { Debug.LogWarning((object)("I should not be randomized: " + ((Object)((Component)this).gameObject).name)); return; } m_zview = ((Component)this).GetComponent<ZNetView>(); m_monsterAI = ((Component)this).GetComponent<MonsterAI>(); m_humanoid = ((Component)this).GetComponent<Humanoid>(); m_animator = (((Object)(object)m_humanoid != (Object)null) ? ((Character)m_humanoid).m_animator : null); m_visEquipment = ((Component)this).GetComponent<VisEquipment>(); newName = (((Object)(object)m_humanoid != (Object)null) ? ((Character)m_humanoid).m_name : string.Empty); spawnBiome = GetBiome(); if ((Object)(object)m_visEquipment == (Object)null || (Object)(object)m_animator == (Object)null || (Object)(object)m_humanoid == (Object)null || (Object)(object)m_monsterAI == (Object)null || (Object)(object)m_zview == (Object)null || m_zview.m_zdo == null) { Debug.LogWarning((object)("[HUMANOID RANDOMIZER]Incomplete requirments for: " + ((Object)((Component)this).gameObject).name)); if ((Object)(object)m_visEquipment == (Object)null) { Debug.LogWarning((object)"missing: VisEquipment script"); } if ((Object)(object)m_animator == (Object)null) { Debug.LogWarning((object)"missing: animator"); } if ((Object)(object)m_humanoid == (Object)null) { Debug.LogWarning((object)"missing: Humanoid script"); } if ((Object)(object)m_monsterAI == (Object)null) { Debug.LogWarning((object)"missing: MonsterAi script"); } if ((Object)(object)m_zview == (Object)null) { Debug.LogWarning((object)"missing: ZNetView script"); } else if (m_zview.m_zdo == null) { Debug.LogWarning((object)"missing: ZDO"); } return; } initializedForSpawn = true; string prefabName = editZnetName(((Object)((Component)this).gameObject).name); if (!RandomizerConfig.IsCreatureEnabled(prefabName)) { RestoreOriginalEquipment(); if (m_zview.IsOwner()) { m_zview.m_zdo.Set("humanoidRandomizerActive", false); m_zview.m_zdo.Set("humanoidRandomizerSetName", string.Empty); } return; } if (itemSets == null || itemSets.Count == 0) { setupItemSets(); } setAnimatorControler(); bool chosen = m_zview.m_zdo.GetBool("humanoidRandomizerActive", false); PickRandomSet(chosen); if (string.IsNullOrEmpty(m_itemSetName)) { RestoreOriginalEquipment(); return; } if (!string.IsNullOrEmpty(fixedVariantName) && fixedVariantName != m_itemSetName) { string text = " " + fixedVariantName; if (((Character)m_humanoid).m_name.EndsWith(text, StringComparison.Ordinal)) { ((Character)m_humanoid).m_name = ((Character)m_humanoid).m_name.Substring(0, ((Character)m_humanoid).m_name.Length - text.Length) + " " + m_itemSetName; } } setWeaponState(m_itemSetName); m_monsterAI.m_minAttackInterval = 2f; clearMissingFiles(); } public void CaptureOriginalEquipment(Humanoid humanoid) { if (!hasOriginalEquipmentSnapshot && !((Object)(object)humanoid == (Object)null)) { originalDefaultItems = CloneArray(humanoid.m_defaultItems); originalRandomArmor = CloneArray(humanoid.m_randomArmor); originalRandomShield = CloneArray(humanoid.m_randomShield); originalRandomWeapon = CloneArray(humanoid.m_randomWeapon); originalRandomSets = (ItemSet[])((humanoid.m_randomSets != null) ? ((Array)(ItemSet[])humanoid.m_randomSets.Clone()) : ((Array)new ItemSet[0])); originalUnarmedWeapon = humanoid.m_unarmedWeapon; hasOriginalEquipmentSnapshot = true; } } private void RestoreOriginalEquipment() { if (hasOriginalEquipmentSnapshot && !((Object)(object)m_humanoid == (Object)null)) { m_humanoid.m_defaultItems = CloneArray(originalDefaultItems); m_humanoid.m_randomArmor = CloneArray(originalRandomArmor); m_humanoid.m_randomShield = CloneArray(originalRandomShield); m_humanoid.m_randomWeapon = CloneArray(originalRandomWeapon); m_humanoid.m_randomSets = (ItemSet[])((originalRandomSets != null) ? ((Array)(ItemSet[])originalRandomSets.Clone()) : ((Array)new ItemSet[0])); m_humanoid.m_unarmedWeapon = originalUnarmedWeapon; m_itemSetName = string.Empty; m_itemSetSimplified = string.Empty; } } private static GameObject[] CloneArray(GameObject[] source) { return (GameObject[])((source != null) ? ((Array)(GameObject[])source.Clone()) : ((Array)new GameObject[0])); } private void clearMissingFiles() { m_humanoid.m_defaultItems = FilterMissing(m_humanoid.m_defaultItems); m_humanoid.m_randomArmor = FilterMissing(m_humanoid.m_randomArmor); m_humanoid.m_randomShield = FilterMissing(m_humanoid.m_randomShield); } private static GameObject[] FilterMissing(GameObject[] source) { if (source == null || source.Length == 0) { return (GameObject[])(object)new GameObject[0]; } List<GameObject> list = new List<GameObject>(source.Length); foreach (GameObject val in source) { if ((Object)(object)val != (Object)null) { list.Add(val); } } return list.ToArray(); } private void setupItemSets() { switch (editZnetName(((Object)this).name)) { case "Skeleton_Meadows": case "Skeleton_Swamps": case "Skeleton_Mountains": case "Skeleton_DeepNorth": case "Skeleton_aspect": case "Skeleton_Friendly": case "Skeleton": itemSets = VariantTypeCheck.itemSetsSkeleton; break; case "Skeleton_Meadows_noarcher": case "Skeleton_Swamps_noarcher": case "Skeleton_Mountains_noarcher": case "Skeleton_NoArcher": itemSets = VariantTypeCheck.itemSetsSkeletonNoArcher; break; case "Skeleton_Poison": itemSets = VariantTypeCheck.itemSetsSkeletonPoison; break; case "Draugr": itemSets = VariantTypeCheck.itemSetsDraugr; break; case "Draugr_Elite": itemSets = VariantTypeCheck.itemSetsDraugrElite; break; case "Draugr_Ranged": itemSets = VariantTypeCheck.itemSetsDraugrRanged; break; case "Goblin": itemSets = VariantTypeCheck.itemSetsGoblin; break; case "GoblinArcher": itemSets = VariantTypeCheck.itemSetsGoblinArcher; break; case "GoblinShaman": itemSets = VariantTypeCheck.itemSetsGoblinShaman; break; } } private bool validatePrefab() { string[] array = new string[18] { "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman", "Skeleton_Meadows", "Skeleton_Meadows_noarcher", "Skeleton_Swamps", "Skeleton_Swamps_noarcher", "Skeleton_Mountains", "Skeleton_Mountains_noarcher", "Skeleton_DeepNorth", "Skeleton_aspect", "Skeleton_Friendly" }; bool flag = false; string[] array2 = array; foreach (string value in array2) { if (((Object)((Component)this).gameObject).name.Contains(value)) { flag = true; break; } } if (!flag) { return false; } string name = ((Object)((Component)this).gameObject).name; name = editZnetName(name); return array.Contains(name); } private string editZnetName(string name) { return Launch.GetBaseCreatureNameFromString(name); } private Biome GetBiome() { //IL_0007: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) return Heightmap.FindBiome(((Component)this).transform.position); } private void setAnimatorControler() { Animator componentInChildren = ((Component)this).gameObject.GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.runtimeAnimatorController = sourceAnimator; } else { m_animator.runtimeAnimatorController = sourceAnimator; } } private void PickRandomSet(bool chosen = false) { if (itemSets == null || itemSets.Count == 0) { Debug.LogWarning((object)("[HUMANOID RANDOMIZER] No item sets available for " + ((Object)((Component)this).gameObject).name)); return; } string text = null; ItemSet val = null; if (chosen && (Object)(object)m_zview != (Object)null && m_zview.m_zdo != null) { text = m_zview.m_zdo.GetString("humanoidRandomizerSetName", ""); val = FindItemSet(text); if (!IsEligible(val)) { val = null; } } if (val == null && !string.IsNullOrEmpty(fixedVariantName)) { val = FindItemSet(fixedVariantName); if (!IsEligible(val)) { val = null; } else { text = fixedVariantName; } } if (val == null) { text = getWeightedSetName(); val = FindItemSet(text); } if (val == null) { RestoreOriginalEquipment(); if (m_zview.IsOwner()) { m_zview.m_zdo.Set("humanoidRandomizerSetName", string.Empty); m_zview.m_zdo.Set("humanoidRandomizerActive", false); } Debug.LogWarning((object)("[HUMANOID RANDOMIZER] No enabled biome-eligible variant is available for " + editZnetName(((Object)((Component)this).gameObject).name) + "; restoring original equipment.")); return; } if (m_zview.IsOwner()) { m_zview.m_zdo.Set("humanoidRandomizerSetName", text); } m_itemSetName = text; m_itemSetSimplified = text; m_humanoid.m_randomSets = (ItemSet[])(object)new ItemSet[1] { val }; if (m_zview.IsOwner()) { m_zview.m_zdo.Set("humanoidRandomizerActive", true); } } private ItemSet FindItemSet(string setName) { if (string.IsNullOrEmpty(setName) || itemSets == null) { return null; } for (int i = 0; i < itemSets.Count; i++) { ItemSet val = itemSets[i]; if (val != null && string.Equals(val.m_name, setName, StringComparison.Ordinal)) { return val; } } return null; } private string getWeightedSetName() { if (itemSets == null || itemSets.Count == 0) { return null; } string text = editZnetName(((Object)this).name); List<ItemSet> list = new List<ItemSet>(); List<int> list2 = new List<int>(); long num = 0L; for (int i = 0; i < itemSets.Count; i++) { ItemSet val = itemSets[i]; if (val != null && !string.IsNullOrEmpty(val.m_name) && IsEligible(val)) { int variantWeight = RandomizerConfig.GetVariantWeight(val.m_name); if (variantWeight > 0) { list.Add(val); list2.Add(variantWeight); num += variantWeight; } } } if (list.Count == 0 || num <= 0) { return null; } int maxValue = (int)((num > int.MaxValue) ? int.MaxValue : num); int num2 = new Random(m_zview.m_zdo.GetInt(ZDOVars.s_seed, 0)).Next(maxValue); long num3 = 0L; for (int j = 0; j < list.Count; j++) { long val2 = ((num > int.MaxValue) ? ((long)((double)list2[j] / (double)num * 2147483647.0)) : list2[j]); num3 += Math.Max(1L, val2); if (num2 < num3) { return list[j].m_name; } } return list[list.Count - 1].m_name; } private bool IsEligible(ItemSet set) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) return set != null && !string.IsNullOrEmpty(set.m_name) && RandomizerConfig.GetVariantWeight(set.m_name) > 0 && VariantTypeCheck.IsAllowedInBiome(editZnetName(((Object)((Component)this).gameObject).name), set.m_name, spawnBiome); } private void setMonsterName() { if (((Character)m_humanoid).m_name != prototyepname() + " " + m_itemSetSimplified) { newName = prototyepname() + " " + m_itemSetSimplified; ((Character)m_humanoid).m_name = newName; } } private string prototyepname() { GameObject val = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == editZnetName(((Object)((Component)this).gameObject).name)); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"Original not found"); return ((Character)m_humanoid).m_name; } string result = ((Character)val.GetComponent<Humanoid>()).m_name; if (((Object)((Component)this).gameObject).name == "Skeleton_Poison") { result = "Rancid"; } return result; } private string simplifyName(string setName) { if (m_itemSetName.Contains("Guardian")) { return "Guardian"; } if (m_itemSetName.Contains("Marauder")) { return "Marauder"; } if (m_itemSetName.Contains("Warrior")) { return "Warrior"; } return setName; } private void setWeaponState(string setName) { m_animator.SetFloat("weaponStance", 0f); switch (setName) { case "Sailor": case "Bonebreaker": case "Frozenhammer": case "Splasher": m_animator.SetFloat("weaponStance", 3f); break; case "Swordmaster": case "Blackblade": case "Soulcalibur": m_animator.SetFloat("weaponStance", 2f); break; case "Executioner": case "Reaper": case "Reaver": m_animator.SetFloat("weaponStance", 1f); break; case "Arbalist": m_animator.SetFloat("weaponStance", 4f); break; case "Stabber": case "Thief": case "Assassin": case "Savage": case "Corsair": case "Lightbringer": m_animator.SetFloat("weaponStance", 5f); break; default: m_animator.SetFloat("weaponStance", 0f); break; } } public void AddArmorPieces() { if (((Character)m_humanoid).m_level == 1 || (((Object)((Component)this).gameObject).name != "Goblin(Clone)" && ((Object)((Component)this).gameObject).name != "GoblinArcher(Clone)") || ((Character)m_humanoid).m_level == 1) { return; } List<GameObject> list = new List<GameObject>(); list.AddRange(m_humanoid.m_randomSets[0].m_items); GameObject helmet = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinHelmet"); GameObject arms = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinArmband"); GameObject sholders = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinShoulders"); GameObject boots = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinLegband"); switch (((Character)m_humanoid).m_level) { case 2: if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null) { list.Add(arms); } break; case 3: if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null) { list.Add(arms); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null) { list.Add(boots); } break; case 4: if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null) { list.Add(arms); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null) { list.Add(boots); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null) { list.Add(helmet); } break; case 5: case 6: case 7: if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null) { list.Add(arms); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null) { list.Add(boots); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null) { list.Add(helmet); } if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)sholders).name) == (Object)null) { list.Add(sholders); } break; } m_humanoid.m_randomSets[0].m_items = list.ToArray(); } } public class DatabaseAddMethods { public void AddItems(List<GameObject> items) { foreach (GameObject item in items) { AddItem(item); } } public void AddRecipes(List<Recipe> recipes) { foreach (Recipe recipe in recipes) { AddRecipe(recipe); } } public void AddStatuseffects(List<StatusEffect> statusEffects) { foreach (StatusEffect statusEffect in statusEffects) { AddStatus(statusEffect); } } private 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 void AddStatus(StatusEffect status) { if (!IsObjectDBValid()) { return; } if ((Object)(object)status != (Object)null) { if ((Object)(object)ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == ((Object)status).name) == (Object)null) { ObjectDB.instance.m_StatusEffects.Add(status); } } else { Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)status).name + " - Status not found")); } } private void AddRecipe(Recipe recipe) { if (!IsObjectDBValid()) { return; } if ((Object)(object)recipe != (Object)null) { if ((Object)(object)ObjectDB.instance.GetRecipe(recipe.m_item.m_itemData) == (Object)null) { ObjectDB.instance.m_recipes.Add(recipe); } } else { Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)recipe).name + " - Recipe not found")); } } private void AddItem(GameObject newPrefab) { if (!IsObjectDBValid()) { return; } ItemDrop component = newPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null) { ObjectDB.instance.m_items.Add(newPrefab); Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance); dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab; } } else { Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)newPrefab).name + " - ItemDrop not found on prefab")); } } } [BepInPlugin("balrond.astafaraios.BalrondHumanoidRandomizer", "BalrondHumanoidRandomizer", "1.6.2")] public class Launch : BaseUnityPlugin { [HarmonyPatch(typeof(AudioMan), "Awake")] public static class AudioMan_Awake_Path { public static void Postfix(AudioMan __instance) { AudioPrefabService.Apply(__instance); } } [HarmonyPatch(typeof(Game), "Awake")] public static class Game_Awake_Path { public static void Prefix() { hasSpawned = false; SpiritResistanceManager.Reset(); StandaloneLevelEffectsService.Reset(); SetupNewHudElements(); } } [HarmonyPatch(typeof(Humanoid), "GiveDefaultItems")] private static class HumanoidDefaultEquipmentPatch { private static void Prefix(Humanoid __instance) { HumanoidRandomizer component = ((Component)__instance).GetComponent<HumanoidRandomizer>(); if ((Object)(object)component != (Object)null) { component.InitializeForSpawn(); } } } [HarmonyPatch(typeof(MonsterAI), "Awake")] public static class MonsterAI_Path { public static void Postfix(MonsterAI __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject == (Object)null) && (((Object)((Component)__instance).gameObject).name.Contains("Variant") || (Object)(object)((Component)__instance).gameObject.GetComponent<HumanoidRandomizer>() != (Object)null)) { string baseCreatureName = GetBaseCreatureName(((Component)__instance).gameObject); if (RandomizerConfig.IsCreatureEnabled(baseCreatureName)) { __instance.m_minAttackInterval = 2.5f; } } } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class Object_CopyOtherDB_Path { public static void Postfix() { if (!IsObjectDBValid()) { return; } try { StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && ((Object)x).name == "Spirit"); if ((Object)(object)val != (Object)null && modResourceLoader != null) { val.m_icon = modResourceLoader.spiritBurnIcon; } itemEdits.editItems(ObjectDB.instance.m_items); databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); databaseAddMethods.AddRecipes(modResourceLoader.recipes); databaseAddMethods.AddItems(modResourceLoader.attackList); databaseAddMethods.AddItems(modResourceLoader.visualList); } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: Object_CopyOtherDB_Path failed\n" + ex)); } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Path { public static bool hasSpawned; public static void Postfix() { if (!IsObjectDBValid()) { return; } try { StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && ((Object)x).name == "Spirit"); if ((Object)(object)val != (Object)null && modResourceLoader != null) { val.m_icon = modResourceLoader.spiritBurnIcon; } itemEdits.editItems(ObjectDB.instance.m_items); databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects); databaseAddMethods.AddRecipes(modResourceLoader.recipes); databaseAddMethods.AddItems(modResourceLoader.attackList); databaseAddMethods.AddItems(modResourceLoader.visualList); } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: ObjectDB_Awake_Path failed\n" + ex)); } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Path { [HarmonyPriority(0)] public static void Postfix() { AudioPrefabService.ApplyAfterFxRebinding(); } public static void Prefix(ZNetScene __instance) { if ((Object)(object)__instance == (Object)null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: No ZnetScene found"); return; } try { modResourceLoader.AddPrefabsToZnetScene(__instance); if (hasSpawned) { return; } itemSetBuilder.ResetRuntimeState(); itemSetBuilder.setup(__instance.m_prefabs); itemSetBuilder.fixAllReferences(); GameObject val = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton"); GameObject val2 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_NoArcher"); GameObject val3 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Poison"); GameObject val4 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Meadows"); GameObject val5 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Meadows_noarcher"); GameObject val6 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Swamps"); GameObject val7 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Swamps_noarcher"); GameObject val8 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Mountains"); GameObject val9 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Mountains_noarcher"); GameObject val10 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_DeepNorth"); GameObject val11 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_aspect"); GameObject val12 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Friendly"); GameObject val13 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr"); GameObject val14 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr_Ranged"); GameObject val15 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr_Elite"); GameObject val16 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Goblin"); GameObject val17 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "GoblinArcher"); GameObject val18 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "GoblinShaman"); if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_StatusEffects != null) { StatusEffect val19 = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && x.m_name == "Shield_MonsterRandomizer"); if ((Object)(object)val19 != (Object)null) { StatusEffectBuilder.setupVisualsForStatus(val19, __instance.m_prefabs); } } if ((Object)(object)val != (Object)null) { itemSetBuilder.CreateItemSets(val, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton")); } if ((Object)(object)val2 != (Object)null) { itemSetBuilder.CreateItemSets(val2, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_NoArcher")); } if ((Object)(object)val3 != (Object)null) { itemSetBuilder.CreateItemSets(val3, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Poison")); } if ((Object)(object)val4 != (Object)null) { itemSetBuilder.CreateItemSets(val4, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Meadows")); } if ((Object)(object)val5 != (Object)null) { itemSetBuilder.CreateItemSets(val5, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Meadows_noarcher")); } if ((Object)(object)val6 != (Object)null) { itemSetBuilder.CreateItemSets(val6, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Swamps")); } if ((Object)(object)val7 != (Object)null) { itemSetBuilder.CreateItemSets(val7, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Swamps_noarcher")); } if ((Object)(object)val8 != (Object)null) { itemSetBuilder.CreateItemSets(val8, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Mountains")); } if ((Object)(object)val9 != (Object)null) { itemSetBuilder.CreateItemSets(val9, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Mountains_noarcher")); } if ((Object)(object)val10 != (Object)null) { itemSetBuilder.CreateItemSets(val10, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_DeepNorth")); } if ((Object)(object)val11 != (Object)null) { itemSetBuilder.CreateItemSets(val11, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_aspect")); } if ((Object)(object)val12 != (Object)null) { itemSetBuilder.CreateItemSets(val12, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Skeleton_Friendly")); } if ((Object)(object)val13 != (Object)null) { itemSetBuilder.CreateItemSets(val13, modResourceLoader.animatorControllerDraugr, RandomizerConfig.IsCreatureEnabled("Draugr")); } if ((Object)(object)val14 != (Object)null) { itemSetBuilder.CreateItemSets(val14, modResourceLoader.animatorControllerDraugr, RandomizerConfig.IsCreatureEnabled("Draugr_Ranged")); } if ((Object)(object)val15 != (Object)null) { itemSetBuilder.CreateItemSets(val15, modResourceLoader.animatorControllerDraugr, RandomizerConfig.IsCreatureEnabled("Draugr_Elite")); } if ((Object)(object)val16 != (Object)null) { itemSetBuilder.CreateItemSets(val16, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("Goblin")); } if ((Object)(object)val17 != (Object)null) { itemSetBuilder.CreateItemSets(val17, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("GoblinArcher")); } if ((Object)(object)val18 != (Object)null) { itemSetBuilder.CreateItemSets(val18, modResourceLoader.animatorController, RandomizerConfig.IsCreatureEnabled("GoblinShaman")); } addPrefabList(itemSetBuilder.prefabs, __instance.m_prefabs); AudioPrefabService.Process((IEnumerable<GameObject>)itemSetBuilder.prefabs); AudioPrefabService.ApplyAfterFxRebinding(); StandaloneLevelEffectsService.Apply(__instance.m_prefabs); SpiritResistanceManager.ApplyFallback(__instance.m_prefabs); hasSpawned = true; if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated()) { ShaderReplacment.runMaterialFix(); } } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: ZNetScene_Awake_Path failed\n" + ex)); } } } [HarmonyPatch(typeof(EnemyHud), "UpdateHuds")] public static class EnemyHudUpdateHudsPatch { public static void Prefix(EnemyHud __instance) { if ((Object)(object)__instance == (Object)null || __instance.m_huds == null || ExternalHudCompatibility.IsPresent || ExternalHudCompatibility.IsPresent) { return; } foreach (KeyValuePair<Character, HudData> hud in __instance.m_huds) { HudData value = hud.Value; Character val = value?.m_character; if (value == null || (Object)(object)val == (Object)null || (!val.IsPlayer() && !val.IsBoss() && !value.m_isMount && value.m_hoverTimer >= __instance.m_hoverShowDuration)) { continue; } if ((Object)(object)value.m_gui != (Object)null) { value.m_gui.SetActive(true); } int level = val.GetLevel(); if (level < 2) { continue; } bool flag = val.IsBoss(); bool num; if (!flag) { if (level < 4) { continue; } num = level <= 7; } else { if (level < 2) { continue; } num = level <= 7; } if (num) { SetUiStarElement(value, level, flag); } } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class RPC_DamagePatch { public static int chanceForBlunt = 1; public static int chanceForPierce = 1; public static int chanceForSLash = 1; public static void Prefix(Character __instance, ref HitData hit) { if (hit == null) { return; } Character attacker = hit.GetAttacker(); Humanoid val = (Humanoid)(object)((attacker is Humanoid) ? attacker : null); if ((Object)(object)val == (Object)null || ((Character)val).IsPlayer()) { return; } try { HitData val2 = HumanoidRandomizerDamageModificator.modifyOutput(((Component)val).gameObject, hit); if (val2 != null) { hit = val2; } } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: RPC_DamagePatch failed\n" + ex)); } } } private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondHumanoidRandomizer"); private static ManualLogSource log; public const string PluginGUID = "balrond.astafaraios.BalrondHumanoidRandomizer"; public const string PluginName = "BalrondHumanoidRandomizer"; public const string PluginVersion = "1.6.2"; public static ModResourceLoader modResourceLoader = new ModResourceLoader(); public static ItemEdits itemEdits = new ItemEdits(); public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods(); public static ItemSetBuilder itemSetBuilder = new ItemSetBuilder(); public static HumanoidRandomizerDamageModificator HumanoidRandomizerDamageModificator = new HumanoidRandomizerDamageModificator(); public static GameObject RootObject; public static GameObject PrefabContainer; public static GameObject rightHand; public static GameObject leftHand; public static bool hasSpawned = false; private static readonly string MainSceneName = "main"; private static readonly string GuiPath = "_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBase"; private static readonly string GuiBossPath = "_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBaseBoss"; public static GameObject gui; public static GameObject gui2; public static bool CLLCdetected = false; public static bool modDetected = false; public static bool StarLevelSystemDetected = false; private static readonly HashSet<string> MissingStarUiWarnings = new HashSet<string>(StringComparer.Ordinal); public static string[] validNames = new string[18] { "Skeleton_NoArcher", "Skeleton_Poison", "Skeleton", "Skeleton_Meadows", "Skeleton_Meadows_noarcher", "Skeleton_Swamps", "Skeleton_Swamps_noarcher", "Skeleton_Mountains", "Skeleton_Mountains_noarcher", "Skeleton_DeepNorth", "Skeleton_aspect", "Skeleton_Friendly", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman" }; private void Awake() { log = ((BaseUnityPlugin)this).Logger; try { ServerSyncBridge.Initialize("balrond.astafaraios.BalrondHumanoidRandomizer", "BalrondHumanoidRandomizer", "1.6.2"); RandomizerConfig.Initialize(this); createPrefabContainer(); if (modResourceLoader != null) { modResourceLoader.loadAssets(); rightHand = modResourceLoader.rightHand; leftHand = modResourceLoader.leftHand; RegisterOwnedAudioRoots(); AudioPrefabService.Apply(AudioMan.instance); ShieldBashBalance.Apply(modResourceLoader.attackList); } if (HumanoidRandomizerDamageModificator != null) { HumanoidRandomizerDamageModificator.setup(); } VariantTypeCheck.setBiomeRestriction(); harmony.PatchAll(); } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: Awake failed\n" + ex)); } } private static void RegisterOwnedAudioRoots() { if (modResourceLoader != null) { AudioPrefabService.Process((IEnumerable<GameObject>)modResourceLoader.attackList); AudioPrefabService.Process((IEnumerable<GameObject>)modResourceLoader.visualList); AudioPrefabService.Process((IEnumerable<GameObject>)modResourceLoader.otherList); AudioPrefabService.Process(modResourceLoader.rightHand); AudioPrefabService.Process(modResourceLoader.leftHand); GameObject[] roots = (GameObject[])(object)new GameObject[10] { modResourceLoader.lvl4, modResourceLoader.lvl5, modResourceLoader.lvl6, modResourceLoader.lvl7, modResourceLoader.lvl2boss, modResourceLoader.lvl3boss, modResourceLoader.lvl4boss, modResourceLoader.lvl5boss, modResourceLoader.lvl6boss, modResourceLoader.lvl7boss }; AudioPrefabService.Process((IEnumerable<GameObject>)roots); } } private void OnDestroy() { try { harmony.UnpatchSelf(); SpiritResistanceManager.Reset(); StandaloneLevelEffectsService.Reset(); AudioPrefabService.Reset(); ShieldBashBalance.Reset(); ServerSyncBridge.Reset(); } catch (Exception ex) { Debug.LogError((object)("BalrondHumanoidRandomizer: OnDestroy failed\n" + ex)); } } internal static void LogInfo(string message) { if (log != null) { log.LogInfo((object)message); } else { Debug.Log((object)("[BalrondHumanoidRandomizer] " + message)); } } internal static void LogWarning(string message) { if (log != null) { log.LogWarning((object)message); } else { Debug.LogWarning((object)("[BalrondHumanoidRandomizer] " + message)); } } internal static void LogError(string message) { if (log != null) { log.LogError((object)message); } else { Debug.LogError((object)("[BalrondHumanoidRandomizer] " + message)); } } public void createPrefabContainer() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown if ((Object)(object)RootObject == (Object)null) { RootObject = GameObject.Find("_BalrondHumanoidRandomizerRoot"); } if ((Object)(object)RootObject == (Object)null) { RootObject = new GameObject("_BalrondHumanoidRandomizerRoot"); Object.DontDestroyOnLoad((Object)(object)RootObject); } if ((Object)(object)PrefabContainer == (Object)null) { Transform val = RootObject.transform.Find("Prefabs"); if ((Object)(object)val != (Object)null) { PrefabContainer = ((Component)val).gameObject; return; } PrefabContainer = new GameObject("Prefabs"); PrefabContainer.transform.SetParent(RootObject.transform, false); PrefabContainer.SetActive(false); } } public static GameObject cloneMe(GameObject source, string name = "") { if ((Object)(object)source == (Object)null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: cloneMe source is null"); return null; } if ((Object)(object)PrefabContainer == (Object)null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: PrefabContainer is null"); return null; } GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("BalrondHumanoidRandomizer: Failed to clone " + ((Object)source).name)); return null; } ((Object)val).name = ((!string.IsNullOrEmpty(name)) ? name : ((Object)source).name); return val; } internal static string GetBaseCreatureName(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null || string.IsNullOrEmpty(((Object)gameObject).name)) { return string.Empty; } return GetBaseCreatureNameFromString(((Object)gameObject).name); } internal static string GetBaseCreatureNameFromString(string input) { string text = (input ?? string.Empty).Replace("(Clone)", string.Empty); int num = text.IndexOf("_Variant_", StringComparison.OrdinalIgnoreCase); if (num >= 0) { text = text.Substring(0, num); } int num2 = text.IndexOf("(", StringComparison.Ordinal); if (num2 >= 0) { text = text.Substring(0, num2); } return text.Trim(); } private static bool IsObjectDBValid() { return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null && ObjectDB.instance.m_recipes != null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } public static void SetupNewHudElements() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) if (ExternalHudCompatibility.IsPresent) { return; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != MainSceneName) { return; } if ((Object)(object)gui == (Object)null) { gui = GameObject.Find(GuiPath); } if ((Object)(object)gui2 == (Object)null) { gui2 = GameObject.Find(GuiBossPath); } if (modResourceLoader == null) { Debug.LogWarning((object)"Resource loader is empty!"); return; } SetupHud(gui, delegate { modResourceLoader.LoadNewStars(); }, () => (GameObject[])(object)new GameObject[4] { modResourceLoader.lvl4, modResourceLoader.lvl5, modResourceLoader.lvl6, modResourceLoader.lvl7 }, "I did not load the UI", default(Vector3)); SetupHud(gui2, delegate { modResourceLoader.LoadNewBossStars(); }, () => (GameObject[])(object)new GameObject[6] { modResourceLoader.lvl2boss, modResourceLoader.lvl3boss, modResourceLoader.lvl4boss, modResourceLoader.lvl5boss, modResourceLoader.lvl6boss, modResourceLoader.lvl7boss }, "I did not load the BOSS UI", default(Vector3)); } private static void SetupHud(GameObject hud, Action loadAction, Func<GameObject[]> getElements, string warning, Vector3 offset) { //IL_00a9: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hud == (Object)null) { Debug.LogWarning((object)warning); return; } if (getElements == null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: SetupHud element provider is empty"); return; } GameObject[] array = getElements(); if (array == null || array.Length == 0) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: SetupHud elements array is empty"); return; } if ((Object)(object)array[0] == (Object)null) { loadAction?.Invoke(); array = getElements(); } AudioPrefabService.Process((IEnumerable<GameObject>)array); GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val == (Object)null)) { if (offset.x != 0f || offset.y != 0f || offset.z != 0f) { Transform transform = hud.transform; transform.position += offset; } else { val.transform.SetParent(hud.transform, false); } } } } public static void addStatusToAttackField(GameObject gameObject, StatusEffect statusEffect) { if (!((Object)(object)gameObject == (Object)null) && !((Object)(object)statusEffect == (Object)null)) { ItemDrop component = gameObject.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null) { component.m_itemData.m_shared.m_equipStatusEffect = statusEffect; } } } public static void addPrefabList(List<GameObject> newList, List<GameObject> znetScene) { if (newList == null || znetScene == null) { return; } foreach (GameObject prefab in newList) { if ((Object)(object)prefab != (Object)null && znetScene.FindAll((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == ((Object)prefab).name).Count == 0) { znetScene.Add(prefab); } } } public List<GameObject> GeneratePrefabs(GameObject gameObject) { List<GameObject> list = new List<GameObject>(); if ((Object)(object)gameObject == (Object)null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: GeneratePrefabs gameObject is null"); return list; } HumanoidRandomizer component = gameObject.GetComponent<HumanoidRandomizer>(); if ((Object)(object)component == (Object)null || component.itemSets == null) { Debug.LogWarning((object)("BalrondHumanoidRandomizer: GeneratePrefabs no HumanoidRandomizer/itemSets on " + ((Object)gameObject).name)); return list; } List<ItemSet> itemSets = component.itemSets; foreach (ItemSet item in itemSets) { if (item == null) { continue; } GameObject val = cloneMe(gameObject, ((Object)gameObject).name + "_Variant_" + item.m_name); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Unable to clone: " + ((Object)gameObject).name)); continue; } Humanoid component2 = val.GetComponent<Humanoid>(); if ((Object)(object)component2 == (Object)null) { Debug.LogWarning((object)("BalrondHumanoidRandomizer: No Humanoid on cloned variant " + ((Object)val).name)); continue; } component2.m_defaultItems = item.m_items; HumanoidRandomizer component3 = val.GetComponent<HumanoidRandomizer>(); if ((Object)(object)component3 != (Object)null) { component3.fixedVariantName = item.m_name; component2.m_defaultItems = (GameObject[])(object)new GameObject[0]; } if ((Object)(object)((Character)component2).m_animator != (Object)null) { switch (item.m_name) { case "Bonebreaker": ((Character)component2).m_animator.SetFloat("weaponStance", 3f); break; case "Swordmaster": ((Character)component2).m_animator.SetFloat("weaponStance", 2f); break; case "Executioner": ((Character)component2).m_animator.SetFloat("weaponStance", 1f); break; case "Arbalist": ((Character)component2).m_animator.SetFloat("weaponStance", 4f); break; case "Assassin": case "Savage": ((Character)component2).m_animator.SetFloat("weaponStance", 5f); break; default: ((Character)component2).m_animator.SetFloat("weaponStance", 0f); break; } } list.Add(val); } Debug.LogWarning((object)("Generated variants: " + list.Count)); return list; } private static void SetUiStarElement(HudData hudData, int level, bool isBoss) { if (hudData == null) { return; } Transform val = ((!isBoss) ? (((Object)(object)hudData.m_level2 != (Object)null) ? ((Component)hudData.m_level2).transform : null) : (((Object)(object)hudData.m_healthFast != (Object)null) ? ((Component)hudData.m_healthFast).transform : null)); if ((Object)(object)val == (Object)null) { return; } string text = (isBoss ? ("level_" + level + "_boss") : ("level_" + level)); Transform val2 = ((!isBoss) ? (((Object)(object)val.parent != (Object)null) ? val.parent.Find(text) : null) : (((Object)(object)val.parent != (Object)null && (Object)(object)val.parent.parent != (Object)null) ? val.parent.parent.Find(text) : null)); if ((Object)(object)val2 == (Object)null) { if (MissingStarUiWarnings.Add(text)) { LogWarning("Star UI object not found: " + text + ". Further warnings for this element are suppressed."); } } else { GameObject gameObject = ((Component)val2).gameObject; gameObject.SetActive(true); CopyTransform(val, gameObject.transform); } } private static void CopyTransform(Transform source, Transform target) { //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_0037: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null)) { target.position = source.position; target.localPosition = source.localPosition; target.rotation = source.rotation; } } } internal static class ShieldBashBalance { private sealed class Baseline { internal SharedData Shared; internal DamageTypes Damage; internal DamageTypes PerLevel; } private static readonly Dictionary<ItemDrop, Baseline> Originals = new Dictionary<ItemDrop, Baseline>(); internal static void Apply(IEnumerable<GameObject> attacks) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if (attacks == null) { return; } foreach (GameObject attack in attacks) { if ((Object)(object)attack == (Object)null || ((Object)attack).name != "shield_slam_bal") { continue; } ItemDrop component = attack.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null) { SharedData shared = component.m_itemData.m_shared; if (!Originals.TryGetValue(component, out var value) || value.Shared != shared) { value = new Baseline { Shared = shared, Damage = shared.m_damages, PerLevel = shared.m_damagesPerLevel }; Originals[component] = value; } shared.m_damages = value.Damage; shared.m_damagesPerLevel = value.PerLevel; ((DamageTypes)(ref shared.m_damages)).Modify(RandomizerConfig.ShieldBashDamageMultiplier); ((DamageTypes)(ref shared.m_damagesPerLevel)).Modify(RandomizerConfig.ShieldBashDamageMultiplier); } } } internal static void Reset() { Originals.Clear(); } } public class ModResourceLoader { public AssetBundle assetBundle; public List<Recipe> recipes = new List<Recipe>(); public List<StatusEffect> statusEffects = new List<StatusEffect>(); public Sprite spiritBurnIcon = null; public StatusEffectBuilder statusEffectBuilder = new StatusEffectBuilder(); public List<GameObject> attackList = new List<GameObject>(); public List<GameObject> visualList = new List<GameObject>(); public List<GameObject> otherList = new List<GameObject>(); public FxReplacment fxReplacment = null; public GameObject lvl4; public GameObject lvl5; public GameObject lvl6; public GameObject lvl7; public GameObject lvl2boss; public GameObject lvl3boss; public GameObject lvl4boss; public GameObject lvl5boss; public GameObject lvl6boss; public GameObject lvl7boss; public Sprite newLogo = null; public RuntimeAnimatorController animatorController = null; public RuntimeAnimatorController animatorControllerDraugr = null; public GameObject rightHand; public GameObject leftHand; private const string BasePath = "Assets/BalrondNPC/UI/"; public void loadAssets() { assetBundle = GetAssetBundleFromResources("monsterrandomizer"); if ((Object)(object)assetBundle == (Object)null) { throw new InvalidOperationException("Embedded asset bundle 'monsterrandomizer' could not be loaded."); } string text = "Assets/BalrondNPC/"; spiritBurnIcon = assetBundle.LoadAsset<Sprite>(text + "spiritburn1.png"); animatorController = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoid_randomizer.controller"); animatorControllerDraugr = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoidDraugr_randomizer.controller"); rightHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/RightHand_Attach_bal.prefab"); leftHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/LeftHand_Attach_bal.prefab"); LoadNewStars(); LoadNewBossStars(); LoadAttacks(text); LoadVisuals(text); LoadOther(text); prepareOtherEffects(text); } public void LoadNewStars() { lvl4 = LoadPrefabIfNull(lvl4, "level_4.prefab"); lvl5 = LoadPrefabIfNull(lvl5, "level_5.prefab"); lvl6 = LoadPrefabIfNull(lvl6, "level_6.prefab"); lvl7 = LoadPrefabIfNull(lvl7, "level_7.prefab"); } public void LoadNewBossStars() { lvl2boss = LoadPrefabIfNull(lvl2boss, "level_2_boss.prefab"); lvl3boss = LoadPrefabIfNull(lvl3boss, "level_3_boss.prefab"); lvl4boss = LoadPrefabIfNull(lvl4boss, "level_4_boss.prefab"); lvl5boss = LoadPrefabIfNull(lvl5boss, "level_5_boss.prefab"); lvl6boss = LoadPrefabIfNull(lvl6boss, "level_6_boss.prefab"); lvl7boss = LoadPrefabIfNull(lvl7boss, "level_7_boss.prefab"); } private GameObject LoadPrefabIfNull(GameObject current, string prefabName) { if ((Object)(object)current != (Object)null) { return current; } if ((Object)(object)assetBundle == (Object)null) { Debug.LogWarning((object)("AssetBundle is missing. Cannot load: " + prefabName)); return null; } GameObject val = assetBundle.LoadAsset<GameObject>("Assets/BalrondNPC/UI/" + prefabName); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("Could not load prefab: " + prefabName)); return null; } GameObject val2 = Launch.cloneMe(val); if ((Object)(object)val2 == (Object)null) { Debug.LogError((object)("Could not clone prefab: " + prefabName)); return null; } val2.SetActive(false); return val2; } public void AddPrefabsToZnetScene(ZNetScene zNetScene) { if ((Object)(object)zNetScene == (Object)null || zNetScene.m_prefabs == null) { Debug.LogWarning((object)"BalrondHumanoidRandomizer: ZNetScene prefab list is unavailable."); return; } HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); for (int i = 0; i < zNetScene.m_prefabs.Count; i++) { GameObject val = zNetScene.m_prefabs[i]; if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name)) { hashSet.Add(((Object)val).name); } } AddPrefabCollection(zNetScene.m_prefabs, attackList, hashSet); AddPrefabCollection(zNetScene.m_prefabs, visualList, hashSet); AddPrefabCollection(zNetScene.m_prefabs, otherList, hashSet); zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null); } private static void AddPrefabCollection(List<GameObject> target, List<GameObject> source, HashSet<string> registeredNames) { if (source == null) { return; } for (int i = 0; i < source.Count; i++) { GameObject val = source[i]; if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name) && registeredNames.Add(((Object)val).name)) { target.Add(val); } } } public void LoadAttacks(string mainPath) { string[] array = new string[43] { "attack_kick_unarmed_bal", "dual_pierce_bal", "dual_pierce_slash_bal", "dual_slashBLUNT_bal", "dual_slashSLASH_bal", "fireball_bal", "frostbolt_bal", "left_blade_bal", "left_blunt_bal", "left_special_bal", "poisonbolt_bal", "right_blade_bal", "right_blunt_bal", "right_special_bal", "spiritbolt_bal", "thunderbolt_bal", "twoHand_Pierce_bal", "twoHand_slam_bal", "twoHand_slash_bal", "twoHand_spin_bal", "twoHand_swing_bal", "twoHand_sword_bal", "twoHand_uppercutBlunt_bal", "twoHand_uppercutPierce_bal", "twoHand_uppercutSlash_bal", "left_specialBlunt_bal", "right_specialBlunt_bal", "twoHand_slamBlunt_bal", "twoHand_spinBlunt_bal", "twoHand_swingBlunt_bal", "attack_punch_bal", "shield_slam_bal", "arbalest_shoot_bal", "spear_throw_bal", "cast_protect_caster_bal", "cast_protect_guardian_bal", "heal_base_bal", "heal_draugr_bal", "heal_goblin_bal", "poison_spray_bal", "fire_spray_bal", "spirit_spray_bal", "firebomb_bal" }; string[] array2 = array; foreach (string text in array2) { GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Attacks/" + text + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find file with name: " + text)); continue; } ShaderReplacment.Replace(val); val.SetActive(true); attackList.Add(val); } } public void LoadVisuals(string mainPath) { string[] array = new string[64] { "base_arbalest_bal", "base_axe_left_bal", "base_axe_right_bal", "base_bastard_bal", "base_battleaxe_bal", "base_knife_left_bal", "base_knife_right_bal", "base_mace_left_bal", "base_mace_right_bal", "base_sledge_bal", "base_spear_bal", "base_sword_left_bal", "base_sword_right_bal", "dual_dagger_base_bal", "spellhand_left_fire_bal", "spellhand_left_ice_bal", "spellhand_left_poison_bal", "spellhand_left_spirit_bal", "spellhand_left_thunder_bal", "spellhand_right_fire_bal", "spellhand_right_ice_bal", "spellhand_right_poison_bal", "spellhand_right_spirit_bal", "spellhand_right_thunder_bal", "spellhand_left_mage_bal", "spellhand_right_mage_bal", "dual_dagger_kick_bal", "base_torch_bal", "dual_claws_attack_bal", "dual_claws_kick_bal", "dual_claws_pierce_bal", "dual_dagger_slash_bal", "base_saber_left_bal", "base_saber_right_bal", "base_anchor_bal", "base_staff_left_bal", "base_staff_right_bal", "base_sledge_frost_bal", "base_sledge_poison_bal", "base_curse_axe_left_bal", "base_curse_axe_right_bal", "base_bastard_poison_bal", "base_bastard_spirit_bal", "base_battleaxe_poison_bal", "base_mace_frost_bal", "base_mace_left_frost_bal", "draugr_bow_base_bal", "draugr_bow_fire_bal", "draugr_bow_frost_bal", "draugr_bow_poison_bal", "draugr_bow_spirit_bal", "skeleton_bow_base_bal", "skeleton_bow_fire_bal", "skeleton_bow_frost_bal", "skeleton_bow_poison_bal", "skeleton_bow_spirit_bal", "goblin_bow_base_bal", "goblin_bow_fire_bal", "goblin_bow_frost_bal", "goblin_bow_poison_bal", "goblin_bow_spirit_bal", "base_harpoon_bal", "base_torch_right_bal", "base_battleaxe_spirit_bal" }; string[] array2 = array; foreach (string text in array2) { GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Visuals/" + text + ".prefab"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("Could not find file with name: " + text)); continue; } ShaderReplacment.Replace(val); visualList.Add(val); } } public void LoadOther(string mainPath) { string[] array = new string[36] { "fx_firebomb_hit", "bloodbolt_projectile", "fireball_projectile", "flamewave_ground_projectile 1", "frostbolt_pro