Please disclose if your mod was created primarily 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 Hugos Armory v8.3.6
ValheimHTDArmory.dll
Decompiled 2 years 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 System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ValheimHTDArmory")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimHTDArmory")] [assembly: AssemblyDescription("")] [assembly: AssemblyFileVersion("8.3.5")] [assembly: Guid("3f0e3454-5e9d-41aa-a53d-c3f412189855")] [assembly: ComVisible(false)] [assembly: AssemblyTrademark("")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("8.3.5.0")] [module: UnverifiableCode] public class UpgradeMods : MonoBehaviour { private bool persistPastLevel2 = true; private bool persistPastLevel3 = true; private void Start() { ((Component)((Component)this).transform.Find("levelmods/lvl1")).gameObject.SetActive(false); ((Component)((Component)this).transform.Find("levelmods/lvl2")).gameObject.SetActive(false); ((Component)((Component)this).transform.Find("levelmods/lvl3")).gameObject.SetActive(false); } private void Update() { } private void TryApplyMods(ItemDrop itemInstance) { ItemData itemData = itemInstance.m_itemData; if ((itemData.m_quality == 2 && !persistPastLevel2) || (itemData.m_quality >= 2 && persistPastLevel2)) { ((Component)((Component)this).transform.Find("levelmods/lvl2")).gameObject.SetActive(true); } if ((itemData.m_quality == 3 && !persistPastLevel3) || (itemData.m_quality >= 3 && persistPastLevel3)) { ((Component)((Component)this).transform.Find("levelmods/lvl3")).gameObject.SetActive(true); } if (itemData.m_quality >= 4) { ((Component)((Component)this).transform.Find("levelmods/lvl4")).gameObject.SetActive(true); } } } namespace ValheimHTDArmory { public class SE_Stats_ProgressiveSet : SE_Stats { private Player player; private float bonusModifier = 0f; private float timer; private float baseTime = 2f; private static Dictionary<string, float> allProgressiveSEs = new Dictionary<string, float>(); private void CrunchNumbers() { if ((Object)(object)player != (Object)null) { bonusModifier = 0f; ItemData rightItem = ((Humanoid)player).m_rightItem; object obj; if (rightItem == null) { obj = null; } else { StatusEffect setStatusEffect = rightItem.m_shared.m_setStatusEffect; obj = ((setStatusEffect != null) ? ((Object)setStatusEffect).name : null); } if ((string?)obj == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_rightItem); } ItemData leftItem = ((Humanoid)player).m_leftItem; object obj2; if (leftItem == null) { obj2 = null; } else { StatusEffect setStatusEffect2 = leftItem.m_shared.m_setStatusEffect; obj2 = ((setStatusEffect2 != null) ? ((Object)setStatusEffect2).name : null); } if ((string?)obj2 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_leftItem); } ItemData helmetItem = ((Humanoid)player).m_helmetItem; object obj3; if (helmetItem == null) { obj3 = null; } else { StatusEffect setStatusEffect3 = helmetItem.m_shared.m_setStatusEffect; obj3 = ((setStatusEffect3 != null) ? ((Object)setStatusEffect3).name : null); } if ((string?)obj3 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_helmetItem); } ItemData chestItem = ((Humanoid)player).m_chestItem; object obj4; if (chestItem == null) { obj4 = null; } else { StatusEffect setStatusEffect4 = chestItem.m_shared.m_setStatusEffect; obj4 = ((setStatusEffect4 != null) ? ((Object)setStatusEffect4).name : null); } if ((string?)obj4 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_chestItem); } ItemData legItem = ((Humanoid)player).m_legItem; object obj5; if (legItem == null) { obj5 = null; } else { StatusEffect setStatusEffect5 = legItem.m_shared.m_setStatusEffect; obj5 = ((setStatusEffect5 != null) ? ((Object)setStatusEffect5).name : null); } if ((string?)obj5 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_legItem); } ItemData shoulderItem = ((Humanoid)player).m_shoulderItem; object obj6; if (shoulderItem == null) { obj6 = null; } else { StatusEffect setStatusEffect6 = shoulderItem.m_shared.m_setStatusEffect; obj6 = ((setStatusEffect6 != null) ? ((Object)setStatusEffect6).name : null); } if ((string?)obj6 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_shoulderItem); } ItemData utilityItem = ((Humanoid)player).m_utilityItem; object obj7; if (utilityItem == null) { obj7 = null; } else { StatusEffect setStatusEffect7 = utilityItem.m_shared.m_setStatusEffect; obj7 = ((setStatusEffect7 != null) ? ((Object)setStatusEffect7).name : null); } if ((string?)obj7 == ((Object)this).name) { DoMathStuff(ref bonusModifier, ((Humanoid)player).m_utilityItem); } if ((Object)(object)player == (Object)(object)Player.m_localPlayer) { allProgressiveSEs[((Object)this).name] = bonusModifier; } } } private void DoMathStuff(ref float mainValue, ItemData id) { mainValue += (float)(id.m_quality - 1) / (float)id.m_shared.m_maxQuality / (float)id.m_shared.m_setSize; } public override void Setup(Character character) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown ((SE_Stats)this).Setup(character); if (character is Player) { ZNetView component = ((Component)character).gameObject.GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null) { player = (Player)character; CrunchNumbers(); } } } public override void UpdateStatusEffect(float dt) { ((SE_Stats)this).UpdateStatusEffect(dt); if (timer > 0f) { timer -= dt; return; } timer = baseTime; CrunchNumbers(); } public override void ModifyAttack(SkillType skill, ref HitData hitData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (skill == base.m_modifyAttackSkill || (int)base.m_modifyAttackSkill == 999) { float num = (base.m_damageModifier - 1f) * (1f + bonusModifier); ((DamageTypes)(ref hitData.m_damage)).Modify(1f + num); } } public override string GetTooltipString() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if (base.m_damageModifier != 1f && (int)base.m_modifyAttackSkill > 0) { float num = (allProgressiveSEs.ContainsKey(((Object)this).name) ? allProgressiveSEs[((Object)this).name] : 0f); float num2 = (base.m_damageModifier - 1f) * (1f + num); StringBuilder stringBuilder = new StringBuilder(256); stringBuilder.Append(((SE_Stats)this).GetTooltipString()); stringBuilder.AppendFormat("$inventory_damage: <color=orange>{0}%</color>\n", (num2 * 100f).ToString("+0;-0")); return stringBuilder.ToString(); } return ((SE_Stats)this).GetTooltipString(); } public override void Stop() { ((StatusEffect)this).Stop(); if ((Object)(object)player == (Object)(object)Player.m_localPlayer && allProgressiveSEs.ContainsKey(((Object)this).name)) { allProgressiveSEs.Remove(((Object)this).name); } } } internal class AudioManager { public enum AudioType { ZSFX, AudioSource } private class PendingAudioTask { public GameObject myPrefab; private List<AudioTask> targets = new List<AudioTask>(); } private class AudioTask { private string myNode; private bool copyTargetToMe = false; private AudioType type; private List<AudioTarget> targets = new List<AudioTarget>(); public void ApplyTask(GameObject go) { if (targets.Count <= 0) { return; } Transform val = RecursiveSearchFunctions.ChildNodeFinderDepthFirst(go.transform, myNode); List<AudioClip> list = new List<AudioClip>(); if (!((Object)(object)val != (Object)null)) { return; } foreach (AudioTarget target in targets) { switch (type) { case AudioType.ZSFX: { ZSFX component = ((Component)val).GetComponent<ZSFX>(); if (!((Object)(object)component != (Object)null) || !((Object)(object)val != (Object)null)) { break; } ZSFX component2 = ((Component)val).GetComponent<ZSFX>(); if ((Object)(object)component2 != (Object)null && target.targetIndex == -1) { AudioClip[] audioClips = component2.m_audioClips; foreach (AudioClip item in audioClips) { list.Add(item); } } break; } } } } } private class AudioTarget { public string targetPrefab; public string targetNode; public int targetIndex = -1; } private List<PendingAudioTask> pendingAudioTasks = new List<PendingAudioTask>(); } internal class BiomePlacer : MonoBehaviour { private void Awake() { //IL_00dc: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) Terrain[] componentsInChildren = ((Component)this).GetComponentsInChildren<Terrain>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } Terrain[] array = componentsInChildren; foreach (Terrain val in array) { TerrainData val2 = Object.Instantiate<TerrainData>(val.terrainData); Terrain val3 = Object.Instantiate<Terrain>(val); val2.treeInstances = (TreeInstance[])(object)new TreeInstance[0]; val2.treePrototypes = (TreePrototype[])(object)new TreePrototype[0]; val3.terrainData = val2; ((Component)val3).gameObject.SetActive(true); TerrainCollider component = ((Component)((Component)val3).transform).GetComponent<TerrainCollider>(); if ((Object)(object)component != (Object)null) { component.terrainData = val2; } TreeInstance[] treeInstances = val.terrainData.treeInstances; TreePrototype[] treePrototypes = val.terrainData.treePrototypes; if (treeInstances.Length != 0) { TreeInstance[] array2 = treeInstances; foreach (TreeInstance val4 in array2) { Vector3 val5 = new Vector3(val4.position.x * val.terrainData.size.x, val4.position.y * val.terrainData.size.y, val4.position.z * val.terrainData.size.z) + ((Component)val).transform.position; Quaternion val6 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); GameObject val7 = Object.Instantiate<GameObject>(treePrototypes[val4.prototypeIndex].prefab, val5, val6); val7.transform.localScale = new Vector3(val4.widthScale, val4.heightScale, val4.widthScale); } } } Object.DestroyImmediate((Object)(object)((Component)this).gameObject); } } public static class MaterialScraper { private class MaterialTarget { private int stringIdHash = 0; public string targetPrefabName; public string targetMaterialChild; public int GetIdHash() { return stringIdHash; } public MaterialTarget(string stringId, string targetPrefab, string childName) { stringIdHash = StringExtensionMethods.GetStableHashCode(stringId); targetPrefabName = targetPrefab; targetMaterialChild = childName; } public bool IsTargetPrefab(string prefabName) { return targetPrefabName == prefabName; } } public static string boarTexture = "boarskintexture"; public static string boarHTDTexture = "boarskintexturehtd"; public static string boarHTDTextureTS = "boarskintexturehtdtwosided"; public static string boarTusk = "boartusk"; private static List<MaterialTarget> targets = new List<MaterialTarget>(); public static void Init() { targets.Add(new MaterialTarget(boarTexture, "Boar", "Poly Art Boar")); targets.Add(new MaterialTarget(boarTusk, "Boar", "Fangs 004")); } public static void ScrapeParticleMaterials(GameObject go) { if (go.transform.childCount <= 0) { return; } for (int i = 0; i < go.transform.childCount; i++) { Transform child = go.transform.GetChild(i); ParticleSystemRenderer[] array = ((child != null) ? ((Component)child).GetComponentsInChildren<ParticleSystemRenderer>(true) : null); if (array == null || array.Length == 0) { continue; } ParticleSystemRenderer[] array2 = array; foreach (ParticleSystemRenderer val in array2) { if (((Renderer)val).sharedMaterials != null) { Material[] sharedMaterials = ((Renderer)val).sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { MyReferences.SetStoredMaterial(((Object)val2).name, val2); MyReferences.SetStoredShader(((Object)val2.shader).name, val2.shader); } } } if ((Object)(object)val.trailMaterial != (Object)null) { MyReferences.SetStoredMaterial(((Object)val.trailMaterial).name, val.trailMaterial); MyReferences.SetStoredShader(((Object)val.trailMaterial.shader).name, val.trailMaterial.shader); } } } } public static void ScrapeTargetMaterials(GameObject go) { if (targets.Count <= 0) { return; } foreach (MaterialTarget target in targets) { if (target.IsTargetPrefab(((Object)go).name)) { Transform val = RecursiveSearchFunctions.ChildNodeFinderDepthFirst(go.transform, ref target.targetMaterialChild); if ((Object)(object)val != (Object)null) { Renderer component = ((Component)val).GetComponent<Renderer>(); MyReferences.SetStoredMaterial(target.GetIdHash(), component.sharedMaterial); } } } } public static void ScrapRendererMaterials(GameObject go) { Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return; } Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (val.sharedMaterials == null) { continue; } Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if ((Object)(object)val2 != (Object)null) { MyReferences.SetStoredMaterial(((Object)val2).name, val2); MyReferences.SetStoredShader(((Object)val2.shader).name, val2.shader); } } } } public static void ScrapeItemRelatedMaterials(GameObject go) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Invalid comparison between Unknown and I4 ItemDrop component = go.GetComponent<ItemDrop>(); if (!((Object)(object)component != (Object)null)) { return; } ParticleSystemRenderer component2 = go.GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component2 != (Object)null) { MyReferences.SetStoredMaterial("item_particle", ((Renderer)component2).sharedMaterial); } SharedData shared = component.m_itemData.m_shared; if ((int)shared.m_itemType == 3 || (int)shared.m_itemType == 14 || (int)shared.m_itemType == 4) { if (!MyReferences.listOfMaterials.ContainsKey(StringExtensionMethods.GetStableHashCode("club_trail"))) { Transform val = RecursiveSearchFunctions.ChildNodeFinderBreadthFirst(go.transform, "attach"); if ((Object)(object)val != (Object)null) { val = RecursiveSearchFunctions.ChildNodeFinderBreadthFirst(val, "equiped"); if ((Object)(object)val != (Object)null) { Transform val2 = RecursiveSearchFunctions.ChildNodeFinderDepthFirst(val, "trail"); if ((Object)(object)val2 != (Object)null) { MeleeWeaponTrail component3 = ((Component)val2).gameObject.GetComponent<MeleeWeaponTrail>(); if ((Object)(object)component3 != (Object)null) { MyReferences.SetStoredMaterial("club_trail", component3._material); } } } } } MyReferences.TryExtractEffectsFromItemDropShared(shared); } ScrapePieceMaterials(shared); } public static void ScrapePieceMaterials(SharedData shared) { if (shared == null || !((Object)(object)shared.m_buildPieces != (Object)null) || shared.m_buildPieces.m_pieces == null) { return; } List<GameObject> pieces = shared.m_buildPieces.m_pieces; if (pieces == null) { return; } foreach (GameObject item in pieces) { if (!((Object)(object)item == (Object)null) && ((Object)item).name != null) { Incinerator component = item.GetComponent<Incinerator>(); if ((Object)(object)component != (Object)null && (Object)(object)component.m_lightingAOEs != (Object)null) { ScrapeParticleMaterials(component.m_lightingAOEs); } MyReferences.SetStoredPiecePrefab(((Object)item).name, item); StationExtension component2 = item.GetComponent<StationExtension>(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.m_connectionPrefab != (Object)null) { MyReferences.SetStoredEffectPrefab(((Object)component2.m_connectionPrefab).name, component2.m_connectionPrefab); } CraftingStation component3 = item.GetComponent<CraftingStation>(); if ((Object)(object)component3 != (Object)null && !MyReferences.listOfCraftingStations.ContainsKey(StringExtensionMethods.GetStableHashCode(((Object)item).name))) { MyReferences.listOfCraftingStations.Add(StringExtensionMethods.GetStableHashCode(((Object)item).name), component3); } CookingStation component4 = item.GetComponent<CookingStation>(); if ((Object)(object)component4 != (Object)null && !MyReferences.listOfCookingStations.ContainsKey(StringExtensionMethods.GetStableHashCode(((Object)item).name))) { MyReferences.listOfCookingStations.Add(StringExtensionMethods.GetStableHashCode(((Object)item).name), component4); } Piece component5 = item.GetComponent<Piece>(); if ((Object)(object)component5 != (Object)null) { ExtractEffectsFromPiece(component5.m_placeEffect); } WearNTear component6 = item.GetComponent<WearNTear>(); if ((Object)(object)component6 != (Object)null) { ExtractEffectsFromPiece(component6.m_destroyedEffect); ExtractEffectsFromPiece(component6.m_hitEffect); ExtractEffectsFromPiece(component6.m_switchEffect); } } } } private static void ExtractEffectsFromPiece(EffectList el) { if (el.m_effectPrefabs == null || el.m_effectPrefabs.Length == 0) { return; } EffectData[] effectPrefabs = el.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if ((Object)(object)val.m_prefab != (Object)null) { MyReferences.SetStoredEffectPrefab(((Object)val.m_prefab).name, val.m_prefab); } } } private static void ExtractEffectsFromPiece(EffectList el, string listName) { try { if (el.m_effectPrefabs == null || el.m_effectPrefabs.Length == 0) { return; } EffectData[] effectPrefabs = el.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if ((Object)(object)val.m_prefab != (Object)null) { MyReferences.SetStoredEffectPrefab(((Object)val.m_prefab).name, val.m_prefab); } } } catch (Exception ex) { Plugin.Log.LogError((object)("Error trying to access piece data in list " + listName)); Plugin.Log.LogError((object)ex.Message); Plugin.Log.LogError((object)ex.StackTrace); } } } public static class MeshScraper { private class MeshTarget { private int stringIdHash = 0; public string targetPrefabName; public string targetMeshChild; public int GetIdHash() { return stringIdHash; } public MeshTarget(string stringId, string targetPrefab, string childName) { stringIdHash = StringExtensionMethods.GetStableHashCode(stringId.ToLower()); targetPrefabName = targetPrefab; targetMeshChild = childName; } public bool IsTargetPrefab(string prefabName) { return targetPrefabName == prefabName; } } public static string surtCoreMeshName = "surtcore"; public static string standMeshName = "standmesh"; public static string clothesGroundMesh = "clothesground"; public static string stakeWallMesh = "wallstake"; public static string woodMesh = "wood"; private static List<MeshTarget> targets = new List<MeshTarget>(); public static void Init() { targets.Add(new MeshTarget(surtCoreMeshName, "SurtlingCore", "core")); targets.Add(new MeshTarget(standMeshName, "wood_wall_roof_top", "top")); targets.Add(new MeshTarget(clothesGroundMesh, "ArmorRagsChest", "log")); targets.Add(new MeshTarget(stakeWallMesh, "stake_wall", "Stake")); targets.Add(new MeshTarget(woodMesh, "Wood", "log (1)")); } public static void CollectMeshes(GameObject go) { if (targets.Count <= 0) { return; } foreach (MeshTarget target in targets) { if (!target.IsTargetPrefab(((Object)go).name)) { continue; } GameObject gameObject = ((Component)RecursiveSearchFunctions.ChildNodeFinderDepthFirst(go.transform, target.targetMeshChild)).gameObject; if (!((Object)(object)gameObject != (Object)null)) { continue; } MeshFilter component = gameObject.GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { MyReferences.listOfMeshes[target.GetIdHash()] = component.sharedMesh; continue; } SkinnedMeshRenderer component2 = gameObject.GetComponent<SkinnedMeshRenderer>(); if ((Object)(object)component2 != (Object)null) { MyReferences.listOfMeshes[target.GetIdHash()] = component2.sharedMesh; } } } } public class PrefabFixer { public class NodeData { public class MaterialTask { private string materialNameOverride; private string materialName; private string shaderName; private bool useCurrentMaterial = false; private bool fixShaderOnly = false; private bool mainColorChange = false; private Color mainTextureColor; private bool emissionColorChange = false; private bool emissionColorIsVector = false; private Color emissionColor; private bool metalColorChange = false; private bool metalColorIsVector = false; private Color metalColor; private int myMaterialIndex = 0; private bool metalGlossChange = false; private float metalGloss = 0f; private bool setTwoSided = false; private bool setTwoSidedNormals = false; private bool addRain = false; public MaterialTask(string materialName) { this.materialName = materialName; } public MaterialTask(string materialNameOverride, string materialName) { this.materialNameOverride = materialNameOverride; this.materialName = materialName; } public MaterialTask UseCurrentMaterial() { useCurrentMaterial = true; return this; } public MaterialTask SetShader(string shader) { shaderName = shader; return this; } public MaterialTask SetMainColor(Color col) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) mainTextureColor = col; mainColorChange = true; return this; } public MaterialTask SetEmissionColor(Color col, bool isVector = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) emissionColor = col; emissionColorChange = true; emissionColorIsVector = isVector; return this; } public MaterialTask SetMetalColor(Color col, bool isVector = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) metalColor = col; metalColorChange = true; metalColorIsVector = isVector; return this; } public MaterialTask SetMetalGloss(float value) { metalGloss = value; metalGlossChange = true; return this; } public MaterialTask SetMaterialIndex(int index) { myMaterialIndex = index; return this; } public MaterialTask FixShaderOnly() { fixShaderOnly = true; return this; } private void ApplyColor(ref Material mat, string field, Color col, bool isVector) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references) if (isVector) { mat.SetVector(field, new Vector4(col.r, col.g, col.b, col.a)); } else { mat.SetColor(field, col); } } public MaterialTask SetTwoSided(bool normals = false) { setTwoSided = true; setTwoSidedNormals = normals; return this; } public MaterialTask AddRain() { addRain = true; return this; } private void ApplyTwoSided(ref Material mat) { if (setTwoSided) { mat.SetFloat("_Cull", 0f); } if (setTwoSidedNormals) { mat.SetFloat("_TwoSidedNormals", 1f); } } public void TryApplyTask(Transform child) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Expected O, but got Unknown //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Material val = null; if (shaderName != null && fixShaderOnly) { Renderer component = ((Component)child).GetComponent<Renderer>(); if (!((Object)(object)component == (Object)null) || !((Object)(object)component.sharedMaterial == (Object)null)) { val = component.sharedMaterial; Shader storedShader = MyReferences.GetStoredShader(shaderName); if ((Object)(object)storedShader != (Object)null) { val.shader = storedShader; } if (mainColorChange) { val.SetColor("_Color", mainTextureColor); } if (emissionColorChange) { ApplyColor(ref val, "_EmissionColor", emissionColor, emissionColorIsVector); } if (metalColorChange) { ApplyColor(ref val, "_MetalColor", metalColor, metalColorIsVector); val.SetFloat("_Metallic", 1f); val.SetFloat("_UseGlossmap", 1f); } if (metalGlossChange) { val.SetFloat("_MetalGloss", metalGloss); } ApplyTwoSided(ref val); if (addRain) { val.SetFloat("_AddRain", 1f); } component.sharedMaterial = val; } return; } if (materialNameOverride != null) { val = MyReferences.GetStoredMaterial(materialNameOverride); if ((Object)(object)val != (Object)null) { flag = true; } } if ((Object)(object)val == (Object)null && materialName != null && !useCurrentMaterial) { val = MyReferences.GetStoredMaterial(materialName); } Renderer component2 = ((Component)child).GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null && (Object)(object)val == (Object)null && useCurrentMaterial) { val = component2.sharedMaterials[myMaterialIndex]; } else if ((Object)(object)val == (Object)null) { return; } if (!flag && materialNameOverride != null && !fixShaderOnly) { Material mat = new Material(val); ((Object)mat).name = materialNameOverride; if (shaderName != null) { Shader storedShader2 = MyReferences.GetStoredShader(shaderName); if ((Object)(object)storedShader2 != (Object)null) { mat.shader = storedShader2; } } if (mainColorChange) { mat.SetColor("_Color", mainTextureColor); } if (emissionColorChange) { ApplyColor(ref mat, "_EmissionColor", emissionColor, emissionColorIsVector); } if (metalColorChange) { ApplyColor(ref mat, "_MetalColor", metalColor, metalColorIsVector); mat.SetFloat("_Metallic", 1f); mat.SetFloat("_UseGlossmap", 1f); } if (metalGlossChange) { mat.SetFloat("_MetalGloss", metalGloss); } ApplyTwoSided(ref mat); if (addRain) { mat.SetFloat("_AddRain", 1f); } MyReferences.SetNewStoredMaterial(materialNameOverride, mat); val = mat; } if (useCurrentMaterial && materialName != null) { Material storedMaterial = MyReferences.GetStoredMaterial(materialName); if ((Object)(object)storedMaterial != (Object)null) { val.SetTexture("_MainTex", storedMaterial.GetTexture("_MainTex")); val.SetTexture("_MetallicGlossMap", storedMaterial.GetTexture("_MetallicGlossMap")); val.SetTexture("_BumpMap", storedMaterial.GetTexture("_BumpMap")); if (shaderName != null) { Shader storedShader3 = MyReferences.GetStoredShader(shaderName); if ((Object)(object)storedShader3 != (Object)null) { val.shader = storedShader3; } } } } if ((Object)(object)component2 != (Object)null) { Material[] sharedMaterials = component2.sharedMaterials; if (sharedMaterials.Length != 0 && myMaterialIndex < sharedMaterials.Length) { sharedMaterials[myMaterialIndex] = val; } component2.sharedMaterials = sharedMaterials; } } } public class ParticleTask { private string materialNameOverride; private string materialName; private string shaderName; private bool setTrailMat = false; public ParticleTask(string materialName) { this.materialName = materialName; } public ParticleTask(string materialNameOverride, string materialName) { this.materialNameOverride = materialNameOverride; this.materialName = materialName; } public void SetShader(string shader) { shaderName = shader; } public void SetTrail() { setTrailMat = true; } public void TryApplyTask(Transform child) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown bool flag = false; Material val = null; if (materialNameOverride != null) { val = MyReferences.GetStoredMaterial(materialNameOverride); flag = true; } else if (materialName != null) { val = MyReferences.GetStoredMaterial(materialName); } if (!((Object)(object)val != (Object)null)) { return; } if (shaderName != null) { Shader storedShader = MyReferences.GetStoredShader(shaderName); if ((Object)(object)storedShader != (Object)null) { val.shader = storedShader; } } if (!flag && materialNameOverride != null) { Material val2 = new Material(val); ((Object)val2).name = materialNameOverride; MyReferences.SetNewStoredMaterial(materialNameOverride.GetHashCode(), val2); val = val2; } ParticleSystemRenderer component = ((Component)child).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component != (Object)null) { if (setTrailMat) { component.trailMaterial = val; } else { ((Renderer)component).sharedMaterial = val; } } } } public class MeshTask { private string meshName; private bool scaleChanged = false; private Vector3 scale = Vector3.one; public MeshTask(string meshName) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) this.meshName = meshName; } public MeshTask(string meshName, Vector3 scale) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) this.meshName = meshName; this.scale = scale; scaleChanged = true; } public void TryApplyTask(Transform child) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) int stableHashCode = StringExtensionMethods.GetStableHashCode(meshName); Mesh val = null; if (MyReferences.listOfMeshes.ContainsKey(stableHashCode)) { val = MyReferences.listOfMeshes[stableHashCode]; } if (!((Object)(object)val != (Object)null)) { return; } MeshFilter component = ((Component)child).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { component.sharedMesh = val; } else { SkinnedMeshRenderer component2 = ((Component)child).GetComponent<SkinnedMeshRenderer>(); if ((Object)(object)component2 != (Object)null) { component2.sharedMesh = val; } } if (scaleChanged) { child.localScale = scale; } } } private List<Transform> GameObjectChildren = new List<Transform>(); public int numberOfInstances = 1; public string targetChildName; private MaterialTask currentMaterialTask; private ParticleTask currentParticleTask; private MeshTask currentMeshTask; private List<MaterialTask> materialTasks = new List<MaterialTask>(); private List<ParticleTask> particleTasks = new List<ParticleTask>(); private List<MeshTask> meshTasks = new List<MeshTask>(); public NodeData(string prefabChild, int instanceCount) { targetChildName = prefabChild; numberOfInstances = instanceCount; } public void TryFix(GameObject go) { RecursiveSearchFunctions.ChildNodesFinderDepthFirst(go.transform, ref targetChildName, ref numberOfInstances, ref GameObjectChildren); if (GameObjectChildren.Count == 0) { return; } if (currentMaterialTask != null) { materialTasks.Add(currentMaterialTask); } if (currentParticleTask != null) { particleTasks.Add(currentParticleTask); } if (currentMeshTask != null) { meshTasks.Add(currentMeshTask); } foreach (Transform gameObjectChild in GameObjectChildren) { if (materialTasks.Count > 0) { foreach (MaterialTask materialTask in materialTasks) { materialTask.TryApplyTask(gameObjectChild); } } if (particleTasks.Count > 0) { foreach (ParticleTask particleTask in particleTasks) { particleTask.TryApplyTask(gameObjectChild); } } if (meshTasks.Count <= 0) { continue; } foreach (MeshTask meshTask in meshTasks) { meshTask.TryApplyTask(gameObjectChild); } } } public MaterialTask AddMaterialTask(string materialName, bool useCurrentMaterial = false) { if (currentMaterialTask != null) { materialTasks.Add(currentMaterialTask); } currentMaterialTask = new MaterialTask(materialName); if (useCurrentMaterial) { currentMaterialTask.UseCurrentMaterial(); } return currentMaterialTask; } public MaterialTask AddMaterialTask(string materialNameOverride, string materialName, bool useCurrentMaterial = false) { if (currentMaterialTask != null) { materialTasks.Add(currentMaterialTask); } currentMaterialTask = new MaterialTask(materialNameOverride, materialName); if (useCurrentMaterial) { currentMaterialTask.UseCurrentMaterial(); } return currentMaterialTask; } public MaterialTask SetMaterialTaskMainColor(Color col) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (currentMaterialTask != null) { currentMaterialTask.SetMainColor(col); } return currentMaterialTask; } public MaterialTask SetMaterialTaskEmissionColor(Color col) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (currentMaterialTask != null) { currentMaterialTask.SetEmissionColor(col); } return currentMaterialTask; } public MaterialTask SetMaterialTaskMetalColor(Color col) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (currentMaterialTask != null) { currentMaterialTask.SetMetalColor(col); } return currentMaterialTask; } public MaterialTask SetMaterialTaskShader(string shader) { if (currentMaterialTask != null) { currentMaterialTask.SetShader(shader); } return currentMaterialTask; } public ParticleTask AddParticleTask(string materialName, bool setTrail = false) { if (currentParticleTask != null) { particleTasks.Add(currentParticleTask); } currentParticleTask = new ParticleTask(materialName); if (setTrail) { currentParticleTask.SetTrail(); } return currentParticleTask; } public ParticleTask AddParticleTask(string materialNameOverride, string materialName, bool setTrail = false) { if (currentParticleTask != null) { particleTasks.Add(currentParticleTask); } currentParticleTask = new ParticleTask(materialNameOverride, materialName); if (setTrail) { currentParticleTask.SetTrail(); } return currentParticleTask; } public ParticleTask SetParticleTaskShader(string shader) { if (currentParticleTask != null) { currentParticleTask.SetShader(shader); } return currentParticleTask; } public NodeData AddMeshTask(string meshName) { if (currentMeshTask != null) { meshTasks.Add(currentMeshTask); } currentMeshTask = new MeshTask(meshName); return this; } public NodeData AddMeshTask(string meshName, Vector3 scale) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (currentMeshTask != null) { meshTasks.Add(currentMeshTask); } currentMeshTask = new MeshTask(meshName, scale); return this; } } private NodeData currentNode; private List<NodeData> nodeData = new List<NodeData>(); public NodeData Current() { return currentNode; } public NodeData New(string childName, int instanceCount = 1) { if (currentNode != null) { nodeData.Add(currentNode); } currentNode = new NodeData(childName, instanceCount); return currentNode; } public void Run(ref GameObject go) { if (currentNode != null) { nodeData.Add(currentNode); currentNode = null; } foreach (NodeData nodeDatum in nodeData) { nodeDatum.TryFix(go); } } } internal class CharacterAnimEventPatch { } public class CookingRecipe { public string fromPrefabName; public ItemDrop fromItemDrop; public string toPrefabName; public ItemDrop toItemDrop; public float cookingTime; public string cookingStationName; public CookingRecipe(string fromPrefabName, string toPrefabName, float cookingTime, string cookingStationName) { this.fromPrefabName = fromPrefabName; this.toPrefabName = toPrefabName; this.cookingTime = cookingTime; this.cookingStationName = cookingStationName; } public CookingRecipe(ItemDrop fromItemDrop, ItemDrop toItemDrop, float cookingTime, string cookingStationName) { this.fromItemDrop = fromItemDrop; this.toItemDrop = toItemDrop; this.cookingTime = cookingTime; this.cookingStationName = cookingStationName; } public ItemDrop GetFromItemDrop() { if ((Object)(object)fromItemDrop != (Object)null) { return fromItemDrop; } CustomItem? customItem = Plugin.myCustomItems.Where((CustomItem mil) => ((Object)mil.gameObject).name == fromPrefabName).FirstOrDefault(); ItemDrop val = ((customItem != null) ? customItem.gameObject.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { return MyReferences.listOfAllGameObjects[StringExtensionMethods.GetStableHashCode(fromPrefabName)].GetComponent<ItemDrop>(); } return val; } public ItemDrop GetToItemDrop() { if ((Object)(object)toItemDrop != (Object)null) { return toItemDrop; } CustomItem? customItem = Plugin.myCustomItems.Where((CustomItem mil) => ((Object)mil.gameObject).name == toPrefabName).FirstOrDefault(); ItemDrop val = ((customItem != null) ? customItem.gameObject.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { return MyReferences.listOfAllGameObjects[StringExtensionMethods.GetStableHashCode(toPrefabName)].GetComponent<ItemDrop>(); } return val; } } public static class CustomConfigParser { public static string SerializeObject<T>(T obj) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Object:" + obj.GetType().Name); FieldInfo[] fields = obj.GetType().GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { stringBuilder.AppendLine($"\t{fieldInfo.Name}: {fieldInfo.GetValue(obj)}"); } return stringBuilder.ToString(); } } public class CustomPiece { public enum EffectListEnum { PLACEMENT, DESTORYED, HIT, SWITCH } public GameObject myPiece; private bool lookUpToolPrefab = false; private string buildToolPrefabName; private ItemDrop buildToolID; public string craftingStationName; public List<string> placeEffectNames = new List<string>(); public List<string> destoryedEffectNames = new List<string>(); public List<string> hitEffectNames = new List<string>(); public List<string> switchEffectNames = new List<string>(); private List<ResourceElement> craftingResources = new List<ResourceElement>(); public CustomPiece SetBuildTool(string buildToolPrefabName) { this.buildToolPrefabName = buildToolPrefabName; lookUpToolPrefab = true; return this; } public CustomPiece SetBuildTool(ItemDrop buildToolID) { this.buildToolID = buildToolID; return this; } public CustomPiece AddEffect(EffectListEnum list, string effectName) { switch (list) { case EffectListEnum.PLACEMENT: placeEffectNames.Add(effectName); break; case EffectListEnum.DESTORYED: destoryedEffectNames.Add(effectName); break; case EffectListEnum.HIT: hitEffectNames.Add(effectName); break; case EffectListEnum.SWITCH: switchEffectNames.Add(effectName); break; } return this; } public CustomPiece AddEffect(EffectListEnum list, string[] effectNames) { switch (list) { case EffectListEnum.PLACEMENT: foreach (string item4 in effectNames) { placeEffectNames.Add(item4); } break; case EffectListEnum.DESTORYED: foreach (string item2 in effectNames) { destoryedEffectNames.Add(item2); } break; case EffectListEnum.HIT: foreach (string item3 in effectNames) { hitEffectNames.Add(item3); } break; case EffectListEnum.SWITCH: foreach (string item in effectNames) { switchEffectNames.Add(item); } break; } return this; } public CustomPiece AddResourceRequirement(string prefabName, int amount, int amountPerLevel, bool recover = true) { craftingResources.Add(new ResourceElement(prefabName, amount, amountPerLevel, recover)); return this; } public void AddPiece() { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(buildToolPrefabName); if (!((Object)(object)itemPrefab != (Object)null)) { return; } ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if (!((Object)(object)component != (Object)null)) { return; } SharedData shared = component.m_itemData.m_shared; if ((Object)(object)shared.m_buildPieces != (Object)null) { shared.m_buildPieces.m_pieces.RemoveAll((GameObject bp) => ((Object)bp).name == ((Object)myPiece).name); shared.m_buildPieces.m_pieces.Add(myPiece); } } public void UpdateRequirements() { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0105: Expected O, but got Unknown if (craftingResources.Count <= 0) { return; } List<Requirement> list = new List<Requirement>(); GameObject val = null; foreach (ResourceElement craftingResource in craftingResources) { if (MyReferences.listOfItemPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(craftingResource.prefabItemName))) { val = MyReferences.listOfItemPrefabs[StringExtensionMethods.GetStableHashCode(craftingResource.prefabItemName)]; } else { val = ObjectDB.instance.GetItemPrefab(craftingResource.prefabItemName); if ((Object)(object)val != (Object)null && !MyReferences.listOfItemPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(craftingResource.prefabItemName))) { MyReferences.listOfItemPrefabs.Add(StringExtensionMethods.GetStableHashCode(craftingResource.prefabItemName), val); } } list.Add(new Requirement { m_resItem = val.GetComponent<ItemDrop>(), m_amount = craftingResource.amount, m_amountPerLevel = craftingResource.amountPerLevel, m_recover = craftingResource.recover }); val = null; } myPiece.GetComponent<Piece>().m_resources = list.ToArray(); } public void CompileAndAddPiece() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown Piece component = myPiece.GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { component.m_craftingStation = MyReferences.listOfCraftingStations[StringExtensionMethods.GetStableHashCode(craftingStationName)]; if (placeEffectNames != null && placeEffectNames.Count > 0) { EffectList val = new EffectList(); List<EffectData> list = new List<EffectData>(); foreach (string placeEffectName in placeEffectNames) { EffectData val2 = new EffectData(); val2.m_prefab = MyReferences.GetStoredEffectPrefab(placeEffectName); list.Add(val2); } val.m_effectPrefabs = list.ToArray(); component.m_placeEffect = val; } } WearNTear component2 = myPiece.GetComponent<WearNTear>(); if ((Object)(object)component2 != (Object)null) { if (destoryedEffectNames != null && destoryedEffectNames.Count > 0) { EffectList val3 = new EffectList(); List<EffectData> list2 = new List<EffectData>(); foreach (string destoryedEffectName in destoryedEffectNames) { EffectData val4 = new EffectData(); val4.m_prefab = MyReferences.GetStoredEffectPrefab(destoryedEffectName); list2.Add(val4); } val3.m_effectPrefabs = list2.ToArray(); component2.m_destroyedEffect = val3; } if (hitEffectNames != null && hitEffectNames.Count > 0) { EffectList val5 = new EffectList(); List<EffectData> list3 = new List<EffectData>(); foreach (string hitEffectName in hitEffectNames) { EffectData val6 = new EffectData(); val6.m_prefab = MyReferences.GetStoredEffectPrefab(hitEffectName); list3.Add(val6); } val5.m_effectPrefabs = list3.ToArray(); component2.m_hitEffect = val5; } if (switchEffectNames != null && switchEffectNames.Count > 0) { EffectList val7 = new EffectList(); List<EffectData> list4 = new List<EffectData>(); foreach (string switchEffectName in switchEffectNames) { EffectData val8 = new EffectData(); val8.m_prefab = MyReferences.GetStoredEffectPrefab(switchEffectName); list4.Add(val8); } val7.m_effectPrefabs = list4.ToArray(); component2.m_switchEffect = val7; } } UpdateRequirements(); AddPiece(); } } internal interface ICustomSerializable { string GetPrettyOutput(); } public static class MyReferences { public static Dictionary<int, CraftingStation> listOfCraftingStations = new Dictionary<int, CraftingStation>(); public static Dictionary<int, CookingStation> listOfCookingStations = new Dictionary<int, CookingStation>(); public static Dictionary<int, StatusEffect> myStatusEffects = new Dictionary<int, StatusEffect>(); public static List<int> prefabsThatUpgradeAtLevelOneAlways = new List<int>(); public static Dictionary<int, GameObject> listOfAllGameObjects = new Dictionary<int, GameObject>(); public static Dictionary<int, GameObject> listOfItemPrefabs = new Dictionary<int, GameObject>(); public static Dictionary<int, GameObject> listOfPieces = new Dictionary<int, GameObject>(); public static Dictionary<int, GameObject> listOfEffects = new Dictionary<int, GameObject>(); public static Dictionary<int, Material> listOfMaterials = new Dictionary<int, Material>(); public static Dictionary<int, Material> listOfNewMaterials = new Dictionary<int, Material>(); public static Dictionary<int, Mesh> listOfMeshes = new Dictionary<int, Mesh>(); public static Dictionary<int, Shader> listOfShaders = new Dictionary<int, Shader>(); public static Dictionary<int, Attack> myListOfExtraAttacks = new Dictionary<int, Attack>(); public static void CleanupReferences() { listOfAllGameObjects = null; listOfItemPrefabs = null; listOfPieces = null; listOfEffects = null; listOfMaterials = null; listOfNewMaterials = null; listOfMeshes = null; listOfShaders = null; } public static GameObject GetStoredEffectPrefab(int hash) { if (listOfEffects.ContainsKey(hash)) { return listOfEffects[hash]; } return null; } public static GameObject GetStoredEffectPrefab(string name) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); return GetStoredEffectPrefab(stableHashCode); } public static void SetStoredEffectPrefab(int hash, GameObject prefab) { listOfEffects[hash] = prefab; } public static void SetStoredEffectPrefab(string name, GameObject prefab) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredEffectPrefab(stableHashCode, prefab); } public static Material GetStoredMaterial(int hash) { if (listOfNewMaterials.ContainsKey(hash)) { return listOfNewMaterials[hash]; } if (listOfMaterials.ContainsKey(hash)) { return listOfMaterials[hash]; } return null; } public static Material GetStoredMaterial(string name) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); return GetStoredMaterial(stableHashCode); } public static void SetStoredMaterial(int hash, Material mat) { listOfMaterials[hash] = mat; } public static void SetStoredMaterial(string name, Material mat) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredMaterial(stableHashCode, mat); } public static void SetNewStoredMaterial(int hash, Material mat) { listOfNewMaterials[hash] = mat; } public static void SetNewStoredMaterial(string name, Material mat) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetNewStoredMaterial(stableHashCode, mat); } public static Shader GetStoredShader(int hash) { if (listOfShaders.ContainsKey(hash)) { return listOfShaders[hash]; } return null; } public static Shader GetStoredShader(string name) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); return GetStoredShader(stableHashCode); } public static void SetStoredShader(string name, Shader shader) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredShader(stableHashCode, shader); } public static void SetStoredShader(int hash, Shader shader) { listOfShaders[hash] = shader; } public static void SetStoredGameObjectPrefab(int hash, GameObject go) { listOfAllGameObjects[hash] = go; } public static void SetStoredGameObjectPrefab(string name, GameObject go) { if ((Object)(object)go != (Object)null) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredGameObjectPrefab(stableHashCode, go); } } public static void SetStoredItemPrefab(int hash, GameObject go) { listOfItemPrefabs[hash] = go; SetStoredGameObjectPrefab(hash, go); } public static void SetStoredItemPrefab(string name, GameObject go) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredItemPrefab(stableHashCode, go); } public static void SetStoredPiecePrefab(int hash, GameObject go) { listOfPieces[hash] = go; SetStoredGameObjectPrefab(hash, go); } public static void SetStoredPiecePrefab(string name, GameObject go) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredPiecePrefab(stableHashCode, go); } public static void SetStoredAttack(int hash, Attack attack) { myListOfExtraAttacks[hash] = attack; } public static void SetStoredAttack(string name, Attack attack) { string text = name.ToLower(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); SetStoredAttack(stableHashCode, attack); } public static void TryAddToStatusEffectList(StatusEffect effect) { if (!myStatusEffects.ContainsKey(StringExtensionMethods.GetStableHashCode(((Object)effect).name))) { myStatusEffects.Add(StringExtensionMethods.GetStableHashCode(((Object)effect).name), effect); } } public static void TryExtractEffectsFromItemDropShared(SharedData shared) { CollectEffectsFromItemDrop(shared.m_hitEffect); CollectEffectsFromItemDrop(shared.m_hitTerrainEffect); CollectEffectsFromItemDrop(shared.m_holdStartEffect); CollectEffectsFromItemDrop(shared.m_startEffect); CollectEffectsFromItemDrop(shared.m_triggerEffect); CollectEffectsFromItemDrop(shared.m_blockEffect); CollectEffectsFromItemDrop(shared.m_trailStartEffect); } private static void CollectEffectsFromItemDrop(EffectList list) { if (list == null || list.m_effectPrefabs == null || list.m_effectPrefabs.Length == 0) { return; } EffectData[] effectPrefabs = list.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if (val != null && (Object)(object)val.m_prefab != (Object)null) { SetStoredEffectPrefab(((Object)val.m_prefab).name, val.m_prefab); } } } } public class CustomConfig { [Serializable] public class ConfigArmorData { public string ItemPrefab; public bool Enabled = true; public int MaxQuality = -1; public float Weight = -1f; public bool UseDurability = true; public float MaxDurability = -1f; public float DurabilityPerLevel = -1f; public float MovementModifier = -1f; public float Armor = -1f; public float ArmorPerLevel = -1f; public void WriteConfigDataToArmor(ref ItemDrop item) { SharedData shared = item.m_itemData.m_shared; shared.m_maxQuality = ((MaxQuality == -1) ? shared.m_maxQuality : MaxQuality); shared.m_weight = ((Weight == -1f) ? shared.m_weight : Weight); shared.m_useDurability = UseDurability; item.m_itemData.m_durability = ((MaxDurability == -1f) ? shared.m_maxDurability : MaxDurability); shared.m_maxDurability = ((MaxDurability == -1f) ? shared.m_maxDurability : MaxDurability); shared.m_durabilityPerLevel = ((DurabilityPerLevel == -1f) ? shared.m_durabilityPerLevel : DurabilityPerLevel); shared.m_movementModifier = ((MovementModifier == -1f) ? shared.m_movementModifier : MovementModifier); shared.m_armor = ((Armor == -1f) ? shared.m_armor : Armor); shared.m_armorPerLevel = ((ArmorPerLevel == -1f) ? shared.m_armorPerLevel : ArmorPerLevel); } public void ReadConfigDataFromArmor(GameObject go) { SharedData shared = go.GetComponent<ItemDrop>().m_itemData.m_shared; ItemPrefab = ((Object)go).name; UseDurability = shared.m_useDurability; MaxQuality = shared.m_maxQuality; Weight = shared.m_weight; MaxDurability = shared.m_maxDurability; DurabilityPerLevel = shared.m_durabilityPerLevel; MovementModifier = shared.m_movementModifier; Armor = shared.m_armor; ArmorPerLevel = shared.m_armorPerLevel; } } [Serializable] public class ConfigItemData { public string ItemPrefab; public bool Enabled = true; public int MaxQuality = -1; public float Weight = -1f; public bool UseDurability = true; public float MaxDurability = -1f; public float DurabilityPerLevel = -1f; public float MovementModifier = -1f; public float BlockAmount = -1f; public float BlockAmountPerLevel = -1f; public float DeflectionForce = -1f; public float DeflectionForcePerLevel = -1f; public float ParryBonus = -1f; public float Knockback_Power = -1f; public float Backstab_Bonus = -1f; public float DamageBlunt = -1f; public float DamageSlash = -1f; public float DamagePierce = -1f; public float DamageChop = -1f; public float DamagePickaxe = -1f; public float DamageFire = -1f; public float DamageFrost = -1f; public float DamageLightning = -1f; public float DamagePoison = -1f; public float DamageSpirit = -1f; public float DamageBluntPerLevel = -1f; public float DamageSlashPerLevel = -1f; public float DamagePiercePerLevel = -1f; public float DamageChopPerLevel = -1f; public float DamagePickaxePerLevel = -1f; public float DamageFirePerLevel = -1f; public float DamageFrostPerLevel = -1f; public float DamageLightningPerLevel = -1f; public float DamagePoisonPerLevel = -1f; public float DamageSpiritPerLevel = -1f; public void WriteConfigDataToItem(ref ItemDrop item) { //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) SharedData shared = item.m_itemData.m_shared; shared.m_maxQuality = ((MaxQuality == -1) ? shared.m_maxQuality : MaxQuality); shared.m_weight = ((Weight == -1f) ? shared.m_weight : Weight); shared.m_useDurability = UseDurability; item.m_itemData.m_durability = ((MaxDurability == -1f) ? shared.m_maxDurability : MaxDurability); shared.m_maxDurability = ((MaxDurability == -1f) ? shared.m_maxDurability : MaxDurability); shared.m_durabilityPerLevel = ((DurabilityPerLevel == -1f) ? shared.m_durabilityPerLevel : DurabilityPerLevel); shared.m_movementModifier = ((!Enabled) ? 0f : ((MovementModifier == -1f) ? shared.m_movementModifier : MovementModifier)); shared.m_blockPower = ((BlockAmount == -1f) ? shared.m_blockPower : BlockAmount); shared.m_blockPowerPerLevel = ((BlockAmountPerLevel == -1f) ? shared.m_blockPowerPerLevel : BlockAmountPerLevel); shared.m_deflectionForce = ((DeflectionForce == -1f) ? shared.m_deflectionForce : DeflectionForce); shared.m_deflectionForcePerLevel = ((DeflectionForcePerLevel == -1f) ? shared.m_deflectionForcePerLevel : DeflectionForcePerLevel); shared.m_timedBlockBonus = ((ParryBonus == -1f) ? shared.m_timedBlockBonus : ParryBonus); shared.m_attackForce = ((Knockback_Power == -1f) ? shared.m_attackForce : Knockback_Power); shared.m_backstabBonus = ((Backstab_Bonus == -1f) ? shared.m_backstabBonus : Backstab_Bonus); shared.m_damages = (Enabled ? SetDamageValues() : disabledDamages); shared.m_damagesPerLevel = (Enabled ? SetDamagePerLevelValues() : disabledDamages); } public void ReadConfigDataFromItem(GameObject go) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) SharedData shared = go.GetComponent<ItemDrop>().m_itemData.m_shared; ItemPrefab = ((Object)go).name; UseDurability = shared.m_useDurability; MaxQuality = shared.m_maxQuality; Weight = shared.m_weight; MaxDurability = shared.m_maxDurability; DurabilityPerLevel = shared.m_durabilityPerLevel; MovementModifier = shared.m_movementModifier; BlockAmount = shared.m_blockPower; BlockAmountPerLevel = shared.m_blockPowerPerLevel; DeflectionForce = shared.m_deflectionForce; DeflectionForcePerLevel = shared.m_deflectionForcePerLevel; ParryBonus = shared.m_timedBlockBonus; Knockback_Power = shared.m_attackForce; Backstab_Bonus = shared.m_backstabBonus; GetDamageValues(shared.m_damages); GetDamagePerLevelValues(shared.m_damagesPerLevel); } private DamageTypes SetDamageValues() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) DamageTypes result = default(DamageTypes); result.m_blunt = DamageBlunt; result.m_slash = DamageSlash; result.m_pierce = DamagePierce; result.m_chop = DamageChop; result.m_pickaxe = DamagePickaxe; result.m_fire = DamageFire; result.m_frost = DamageFrost; result.m_lightning = DamageLightning; result.m_poison = DamagePoison; result.m_spirit = DamageSpirit; return result; } private DamageTypes SetDamagePerLevelValues() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) DamageTypes result = default(DamageTypes); result.m_blunt = DamageBluntPerLevel; result.m_slash = DamageSlashPerLevel; result.m_pierce = DamagePiercePerLevel; result.m_chop = DamageChopPerLevel; result.m_pickaxe = DamagePickaxePerLevel; result.m_fire = DamageFirePerLevel; result.m_frost = DamageFrostPerLevel; result.m_lightning = DamageLightningPerLevel; result.m_poison = DamagePoisonPerLevel; result.m_spirit = DamageSpiritPerLevel; return result; } private void GetDamageValues(DamageTypes damageList) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) DamageBlunt = damageList.m_blunt; DamageSlash = damageList.m_slash; DamagePierce = damageList.m_pierce; DamageChop = damageList.m_chop; DamagePickaxe = damageList.m_pickaxe; DamageFire = damageList.m_fire; DamageFrost = damageList.m_frost; DamageLightning = damageList.m_lightning; DamagePoison = damageList.m_poison; DamageSpirit = damageList.m_spirit; } private void GetDamagePerLevelValues(DamageTypes damageList) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) DamageBluntPerLevel = damageList.m_blunt; DamageSlashPerLevel = damageList.m_slash; DamagePiercePerLevel = damageList.m_pierce; DamageChopPerLevel = damageList.m_chop; DamagePickaxePerLevel = damageList.m_pickaxe; DamageFirePerLevel = damageList.m_fire; DamageFrostPerLevel = damageList.m_frost; DamageLightningPerLevel = damageList.m_lightning; DamagePoisonPerLevel = damageList.m_poison; DamageSpiritPerLevel = damageList.m_spirit; } } [Serializable] public class ConfigResource { public string ItemPrefab; public int CraftingCost = 0; public int UpgradePerLevelCost = 0; } [Serializable] public class ConfigRecipeData { public string ItemPrefab; public bool Enabled = true; public string CraftingStation = "forge"; public string RepairStation = "forge"; public int MinimumStationLevel = 1; public ConfigResource[] CraftingRequirementsArray; public string CraftingRequirements; public RecipeHelper LoadConfigedRecipeHelper(GameObject itemToCraft) { RecipeHelper recipeHelper = new RecipeHelper(itemToCraft, CraftingStation, MinimumStationLevel, 1); recipeHelper.recipeEnabled = Enabled; ConfigResource[] craftingRequirementsArray = CraftingRequirementsArray; foreach (ConfigResource configResource in craftingRequirementsArray) { recipeHelper.AddResource(configResource.ItemPrefab, configResource.CraftingCost, configResource.UpgradePerLevelCost); } return recipeHelper; } public void ReadConfigFromRecipeHelper(RecipeHelper rh) { ItemPrefab = rh.GetPrefabName(); CraftingStation = rh.GetCraftingStation(); RepairStation = rh.GetRepairStation(); MinimumStationLevel = rh.GetRecipeInstance().m_minStationLevel; ResourceElement[] resourceElements = rh.GetResourceElements(); List<ConfigResource> list = new List<ConfigResource>(); ResourceElement[] array = resourceElements; foreach (ResourceElement resourceElement in array) { ConfigResource configResource = new ConfigResource(); configResource.ItemPrefab = resourceElement.prefabItemName; configResource.CraftingCost = resourceElement.amount; configResource.UpgradePerLevelCost = resourceElement.amountPerLevel; list.Add(configResource); } CraftingRequirementsArray = list.ToArray(); } } public List<ConfigItemData> itemConfigs = new List<ConfigItemData>(); public List<ConfigRecipeData> recipeConfigs = new List<ConfigRecipeData>(); public List<ConfigArmorData> armorConfigs = new List<ConfigArmorData>(); private Dictionary<string, ConfigItemData> itemConfigsToApply = new Dictionary<string, ConfigItemData>(); private Dictionary<string, ConfigRecipeData> recipeConfigsToApply = new Dictionary<string, ConfigRecipeData>(); private Dictionary<string, ConfigArmorData> armorConfigsToApply = new Dictionary<string, ConfigArmorData>(); public CustomSyncedValue<string> syncedItemConfigsToApply = new CustomSyncedValue<string>(Plugin.configSync, "itemConfigs"); public CustomSyncedValue<string> syncedRecipeConfigsToApply = new CustomSyncedValue<string>(Plugin.configSync, "recipeConfigs"); public CustomSyncedValue<string> syncedArmorConfigsToApply = new CustomSyncedValue<string>(Plugin.configSync, "armorConfigs"); private bool itemConfigFound = false; private bool recipeConfigFound = false; private bool armorConfigFound = false; private string itemConfigSuffix = "_itemdata"; private string recipeConfigSuffix = "_recipeData"; private string armorConfigSuffix = "_armorData"; private static DamageTypes disabledDamages = default(DamageTypes); public CustomConfig() { syncedItemConfigsToApply.ValueChanged += ItemConfigsChanged; syncedRecipeConfigsToApply.ValueChanged += RecipeConfigChanged; syncedArmorConfigsToApply.ValueChanged += ArmorConfigChanged; } private void ItemConfigsChanged() { itemConfigs.Clear(); itemConfigsToApply.Clear(); foreach (ConfigItemData item in DeserializeItemDataConfig(syncedItemConfigsToApply.Value)) { itemConfigs.Add(item); if (!itemConfigsToApply.ContainsKey(item.ItemPrefab)) { itemConfigsToApply.Add(item.ItemPrefab, item); } } Plugin.RebuildItems(); } private void RecipeConfigChanged() { recipeConfigs.Clear(); recipeConfigsToApply.Clear(); foreach (ConfigRecipeData item in DeserializeRecipeDataConfig(syncedRecipeConfigsToApply.Value)) { recipeConfigs.Add(item); if (!recipeConfigsToApply.ContainsKey(item.ItemPrefab)) { recipeConfigsToApply.Add(item.ItemPrefab, item); } } Plugin.RebuildRecipes(); } private void ArmorConfigChanged() { armorConfigs.Clear(); armorConfigsToApply.Clear(); foreach (ConfigArmorData item in DeserializeArmorDataConfig(syncedArmorConfigsToApply.Value)) { armorConfigs.Add(item); if (!armorConfigsToApply.ContainsKey(item.ItemPrefab)) { armorConfigsToApply.Add(item.ItemPrefab, item); } } } public void AddItemDataAsConfigRecord(GameObject go) { ConfigItemData configItemData = new ConfigItemData(); configItemData.ReadConfigDataFromItem(go); itemConfigs.RemoveAll((ConfigItemData ic) => ic.ItemPrefab == ((Object)go).name); itemConfigs.Add(configItemData); } public void ApplyItemDataFromConfigRecord(ref GameObject go) { if (itemConfigsToApply.Count > 0 && itemConfigsToApply.ContainsKey(((Object)go).name)) { ItemDrop item = go.GetComponent<ItemDrop>(); itemConfigsToApply[((Object)go).name].WriteConfigDataToItem(ref item); itemConfigsToApply.Remove(((Object)go).name); } } public void AddRecipeAsConfigRecord(RecipeHelper rh) { ConfigRecipeData configRecipeData = new ConfigRecipeData(); ConfigRecipeData configRecipeData2 = recipeConfigs.Where((ConfigRecipeData rc) => rc.ItemPrefab == rh.GetPrefabName()).FirstOrDefault(); if (configRecipeData2 != null) { configRecipeData.Enabled = configRecipeData2.Enabled; } configRecipeData.ReadConfigFromRecipeHelper(rh); recipeConfigs.RemoveAll((ConfigRecipeData rc) => rc.ItemPrefab == rh.GetPrefabName()); recipeConfigs.Add(configRecipeData); } public RecipeHelper ApplyRecipeHelperFromConfigRecord(GameObject go) { if (recipeConfigsToApply.Count > 0 && recipeConfigsToApply.ContainsKey(((Object)go).name)) { RecipeHelper result = recipeConfigsToApply[((Object)go).name].LoadConfigedRecipeHelper(go); recipeConfigsToApply.Remove(((Object)go).name); return result; } return null; } public void AddArmorDataAsConfigRecord(GameObject go) { ConfigArmorData configArmorData = new ConfigArmorData(); configArmorData.ReadConfigDataFromArmor(go); armorConfigs.RemoveAll((ConfigArmorData ic) => ic.ItemPrefab == ((Object)go).name); armorConfigs.Add(configArmorData); } public void ApplyArmorDataFromConfigRecord(ref GameObject go) { if (armorConfigsToApply.Count > 0 && armorConfigsToApply.ContainsKey(((Object)go).name)) { ItemDrop item = go.GetComponent<ItemDrop>(); armorConfigsToApply[((Object)go).name].WriteConfigDataToArmor(ref item); armorConfigsToApply.Remove(((Object)go).name); } } public IEnumerable<ConfigItemData> DeserializeItemDataConfig(string data) { if (data.Trim().Length <= 0) { yield break; } data = data.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty); string[] splitData = data.Split(new char[1] { '@' }); if (splitData.Length != 0) { string[] array = splitData; foreach (string itemData in array) { yield return JsonUtility.FromJson<ConfigItemData>(itemData); } } } public IEnumerable<ConfigRecipeData> DeserializeRecipeDataConfig(string data) { data = data.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty); if (data.Trim().Length <= 0) { yield break; } string[] splitData = data.Split(new char[1] { '@' }); if (splitData.Length == 0) { yield break; } for (int i = 0; i < splitData.Length; i++) { string frontHalf2 = splitData[i].Substring(0, splitData[i].IndexOf("\"CraftingRequirements\":")); string backHalf3 = splitData[i].Substring(splitData[i].IndexOf("\"CraftingRequirements\":")); frontHalf2 += "\"CraftingRequirements\": \"\"}"; backHalf3 = backHalf3.Substring(backHalf3.IndexOf(":") + 1); backHalf3 = backHalf3.Remove(backHalf3.Length - 1); ConfigRecipeData itemData = JsonUtility.FromJson<ConfigRecipeData>(frontHalf2); string[] splitResourceData = backHalf3.Split(new char[1] { '#' }); if (splitResourceData.Length != 0) { List<ConfigResource> res = new List<ConfigResource>(); for (int j = 0; j < splitResourceData.Length; j++) { res.Add(JsonUtility.FromJson<ConfigResource>(splitResourceData[j])); } itemData.CraftingRequirementsArray = res.ToArray(); } yield return itemData; } } public IEnumerable<ConfigArmorData> DeserializeArmorDataConfig(string data) { if (data.Trim().Length <= 0) { yield break; } data = data.Replace("\t", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty); string[] splitData = data.Split(new char[1] { '@' }); if (splitData.Length != 0) { string[] array = splitData; foreach (string itemData in array) { yield return JsonUtility.FromJson<ConfigArmorData>(itemData); } } } public void LoadInitialConfigs(string bepinexConfigPath) { itemConfigFound = Load(itemConfigSuffix, syncedItemConfigsToApply); recipeConfigFound = Load(recipeConfigSuffix, syncedRecipeConfigsToApply); armorConfigFound = Load(armorConfigSuffix, syncedArmorConfigsToApply); bool Load(string fileSuffix, CustomSyncedValue<string> configValue) { string path = bepinexConfigPath + fileSuffix + ".cfg"; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Path.GetDirectoryName(path), Path.GetFileName(path)); fileSystemWatcher.Changed += consumeConfigFileEvent; fileSystemWatcher.Created += consumeConfigFileEvent; fileSystemWatcher.Renamed += consumeConfigFileEvent; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; return LoadConfig(path, configValue); void consumeConfigFileEvent(object sender, FileSystemEventArgs args) { LoadConfig(path, configValue); } } } public bool LoadConfig(string bepinexConfigPath, CustomSyncedValue<string> configValue) { try { using StreamReader streamReader = new StreamReader(bepinexConfigPath); configValue.AssignLocalValue(streamReader.ReadToEnd()); return true; } catch (FileNotFoundException) { Plugin.Log.LogWarning((object)("Failed to find '" + bepinexConfigPath + "' will create config of same name with default values.")); } catch (IOException ex2) { Plugin.Log.LogError((object)("An IO Exception was thrown. [" + bepinexConfigPath + "]")); Plugin.Log.LogError((object)ex2.Message); Plugin.Log.LogError((object)ex2.StackTrace); } return false; } public string SerializeItemDataConfig() { StringBuilder stringBuilder = new StringBuilder(); foreach (ConfigItemData itemConfig in itemConfigs) { if (stringBuilder.Length > 0) { stringBuilder.Append("\r\n@\r\n"); } stringBuilder.Append(JsonUtility.ToJson((object)itemConfig, true)); } return stringBuilder.ToString(); } public string SerializeRecipeDataConfig() { StringBuilder stringBuilder = new StringBuilder(); foreach (ConfigRecipeData recipeConfig in recipeConfigs) { if (stringBuilder.Length > 0) { stringBuilder.Append("\r\n@\r\n"); } if (recipeConfig.CraftingRequirementsArray.Length != 0) { bool flag = false; ConfigResource[] craftingRequirementsArray = recipeConfig.CraftingRequirementsArray; foreach (ConfigResource configResource in craftingRequirementsArray) { if (flag) { recipeConfig.CraftingRequirements += "#"; } recipeConfig.CraftingRequirements += JsonUtility.ToJson((object)configResource); flag = true; } } string text = JsonUtility.ToJson((object)recipeConfig, true); text = text.Replace("\"{", "\r\n\t{\r\n\t\t"); text = text.Replace("}\"", "\r\n\t}"); text = text.Replace(",\\\"", ",\r\n\t\t\""); text = text.Replace("\\\"", "\""); text = text.Replace("}#{", "\r\n\t}\r\n\t#\r\n\t{\r\n\t\t"); stringBuilder.Append(text); } return stringBuilder.ToString(); } public string SerializeArmorDataConfig() { StringBuilder stringBuilder = new StringBuilder(); foreach (ConfigArmorData armorConfig in armorConfigs) { if (stringBuilder.Length > 0) { stringBuilder.Append("\r\n@\r\n"); } stringBuilder.Append(JsonUtility.ToJson((object)armorConfig, true)); } return stringBuilder.ToString(); } public void WriteConfigs(string bepinexConfigPath) { try { if (itemConfigs.Count > 0) { using StreamWriter streamWriter = new StreamWriter(bepinexConfigPath + itemConfigSuffix + ".cfg"); streamWriter.Write(SerializeItemDataConfig()); } } catch (IOException ex) { Plugin.Log.LogError((object)("An IO Exception was thrown. [" + itemConfigSuffix + "]")); Plugin.Log.LogError((object)ex.Message); Plugin.Log.LogError((object)ex.StackTrace); } try { if (recipeConfigs.Count > 0) { using StreamWriter streamWriter2 = new StreamWriter(bepinexConfigPath + recipeConfigSuffix + ".cfg"); streamWriter2.Write(SerializeRecipeDataConfig()); } } catch (IOException ex2) { Plugin.Log.LogError((object)("An IO Exception was thrown. [" + recipeConfigSuffix + "]")); Plugin.Log.LogError((object)ex2.Message); Plugin.Log.LogError((object)ex2.StackTrace); } try { if (armorConfigs.Count > 0) { using (StreamWriter streamWriter3 = new StreamWriter(bepinexConfigPath + armorConfigSuffix + ".cfg")) { streamWriter3.Write(SerializeArmorDataConfig()); return; } } } catch (IOException ex3) { Plugin.Log.LogError((object)("An IO Exception was thrown. [" + armorConfigSuffix + "]")); Plugin.Log.LogError((object)ex3.Message); Plugin.Log.LogError((object)ex3.StackTrace); } } } public class CustomItem { public GameObject gameObject; public EffectsManager effectHandler = new EffectsManager(); public PrefabFixer prefabFixer = new PrefabFixer(); public CustomItem(GameObject gameObject) { this.gameObject = gameObject; } public void FixReferences() { effectHandler.ApplyEffects(gameObject); prefabFixer.Run(ref gameObject); } } public class CustomLocalization { private string currentLanguage = "English"; private string fileSuffix = "_localization"; private List<string> localizationLines = new List<string>(); public Dictionary<string, string> localizedWords = new Dictionary<string, string>(); public bool addedLocalization = false; public CustomLocalization() { string @string = PlayerPrefs.GetString("language", ""); if (@string != "") { currentLanguage = @string; } } public void LoadLocalization(string bepinexConfigPath) { string path = bepinexConfigPath + fileSuffix + ".tsv"; bool flag = false; if (Plugin.useLocalizationInConfigFolder) { try { using StreamReader reader = new StreamReader(path); ReadLocalization(reader); flag = true; } catch (FileNotFoundException) { Plugin.Log.LogWarning((object)("Failed to find '" + bepinexConfigPath + fileSuffix + "' will create config of same name with default values.")); } catch (IOException ex2) { Plugin.Log.LogError((object)("An IO Exception was thrown. [" + fileSuffix + "]")); Plugin.Log.LogError((object)ex2.Message); Plugin.Log.LogError((object)ex2.StackTrace); } } if (!flag) { ReadDefaultLocalization(); if (Plugin.useLocalizationInConfigFolder) { WriteLocalization(path); } } ParseLocalization(); } private void ParseLocalization() { int num = -1; bool flag = true; int num2 = 0; foreach (string localizationLine in localizationLines) { try { string[] array = localizationLine.Split(new char[1] { '\t' }); if (flag) { flag = false; for (int i = 1; i < array.Length; i++) { if (array[i] == currentLanguage) { num = i; break; } } } else if (num > -1) { FilterData(array, num); } num2++; } catch (Exception ex) { Plugin.Log.LogError((object)$"Exception Thrown trying to localize line {num2}: <{localizationLine}>"); Plugin.Log.LogError((object)("Exception Message: <" + ex.Message + ">")); } } } private void FilterData(string[] splitData, int languageIndex) { string text = splitData[languageIndex]; if (text.Trim() == string.Empty) { text = splitData[1]; } localizedWords[splitData[0]] = text; } private void WriteLocalization(string path) { StringBuilder stringBuilder = new StringBuilder(); foreach (string localizationLine in localizationLines) { stringBuilder.AppendLine(localizationLine); } using StreamWriter streamWriter = new StreamWriter(path); streamWriter.Write(stringBuilder.ToString()); } private void ReadLocalization(StreamReader reader) { while (!reader.EndOfStream) { localizationLines.Add(reader.ReadLine()); } } private void ReadDefaultLocalization() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith("localization.tsv")); using Stream stream = executingAssembly.GetManifestResourceStream(name); using StreamReader streamReader = new StreamReader(stream); while (!streamReader.EndOfStream) { string item = streamReader.ReadLine(); localizationLines.Add(item); } } } public static class ItemManager { private static AssetBundle assetBundle; private static RecipeHelper currentRecipeHelper; private static GameObject currentItem; private static CustomItem currentCustom; private static Color colBlackMetal = new Color(0.3820755f, 1f, 0.3991793f, 1f); public static void BuildLists() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_249f: Unknown result type (might be due to invalid IL or missing references) //IL_1e73: Unknown result type (might be due to invalid IL or missing references) //IL_1e78: Unknown result type (might be due to invalid IL or missing references) //IL_27c1: Unknown result type (might be due to invalid IL or missing references) //IL_2b4b: Unknown result type (might be due to invalid IL or missing references) //IL_2e6d: Unknown result type (might be due to invalid IL or missing references) //IL_32db: Unknown result type (might be due to invalid IL or missing references) //IL_3604: Unknown result type (might be due to invalid IL or missing references) //IL_435a: Unknown result type (might be due to invalid IL or missing references) //IL_45d7: Unknown result type (might be due to invalid IL or missing references) //IL_4854: Unknown result type (might be due to invalid IL or missing references) //IL_4ad1: Unknown result type (might be due to invalid IL or missing references) //IL_4d48: Unknown result type (might be due to invalid IL or missing references) //IL_5024: Unknown result type (might be due to invalid IL or missing references) //IL_5300: Unknown result type (might be due to invalid IL or missing references) //IL_55dc: Unknown result type (might be due to invalid IL or missing references) //IL_58b8: Unknown result type (might be due to invalid IL or missing references) //IL_5b2f: Unknown result type (might be due to invalid IL or missing references) //IL_5da6: Unknown result type (might be due to invalid IL or missing references) //IL_601d: Unknown result type (might be due to invalid IL or missing references) //IL_6294: Unknown result type (might be due to invalid IL or missing references) //IL_6570: Unknown result type (might be due to invalid IL or missing references) //IL_684c: Unknown result type (might be due to invalid IL or missing references) //IL_6b28: Unknown result type (might be due to invalid IL or missing references) assetBundle = GetAssetBundleFromResources("twohandedweapons"); StatusEffect effect = assetBundle.LoadAsset<StatusEffect>("SEUnholyRegenHTD"); MyReferences.TryAddToStatusEffectList(effect); effect = assetBundle.LoadAsset<StatusEffect>("SEBoarBerserkerSetHTD"); SE_Stats_ProgressiveSet sE_Stats_ProgressiveSet = ScriptableObject.CreateInstance<SE_Stats_ProgressiveSet>(); ((StatusEffect)sE_Stats_ProgressiveSet).m_name = effect.m_name; ((StatusEffect)sE_Stats_ProgressiveSet).m_icon = effect.m_icon; ((StatusEffect)sE_Stats_ProgressiveSet).m_tooltip = effect.m_tooltip; ((SE_Stats)sE_Stats_ProgressiveSet).m_runStaminaDrainModifier = -0.2f; ((SE_Stats)sE_Stats_ProgressiveSet).m_jumpStaminaUseModifier = -0.2f; ((SE_Stats)sE_Stats_ProgressiveSet).m_healthRegenMultiplier = 0.5f; ((SE_Stats)sE_Stats_ProgressiveSet).m_staminaRegenMultiplier = 1.6f; ((SE_Stats)sE_Stats_ProgressiveSet).m_modifyAttackSkill = (SkillType)999; ((SE_Stats)sE_Stats_ProgressiveSet).m_damageModifier = 1.15f; ((SE_Stats)sE_Stats_ProgressiveSet).m_speedModifier = 0.1f; ((Object)sE_Stats_ProgressiveSet).name = "SEBoarBerserkerSetHTD"; MyReferences.TryAddToStatusEffectList((StatusEffect)(object)sE_Stats_ProgressiveSet); currentItem = ExtractGameObjectFromBundle(assetBundle, "ArmorHelmetBoarHTD"); ItemDrop component = currentItem.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)sE_Stats_ProgressiveSet; currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "piece_workbench", 1, 1); currentRecipeHelper.AddResource("TrophyBoar", 1, 0).AddResource("LeatherScraps", 6, 3).AddResource("BoneFragments", 12, 6); } Plugin.customConfigInstance.AddArmorDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model0", 4).AddMaterialTask("", useCurrentMaterial: true).FixShaderOnly() .SetShader("custom/creature"); currentCustom.prefabFixer.Current().AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.Current().AddMaterialTask(MaterialScraper.boarTexture, useCurrentMaterial: true).SetShader("custom/creature") .SetMaterialIndex(2); Plugin.myCustomItems.Add(currentCustom); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentItem = ExtractGameObjectFromBundle(assetBundle, "ArmorChestBoarHTD"); component = currentItem.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)sE_Stats_ProgressiveSet; currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "piece_workbench", 1, 1); currentRecipeHelper.AddResource("TrophyBoar", 1, 0).AddResource("LeatherScraps", 10, 4).AddResource("BoneFragments", 12, 6); } Plugin.customConfigInstance.AddArmorDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model0", 8).AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.New("model1", 6).AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.New("log").AddMaterialTask("rags"); currentCustom.prefabFixer.Current().AddMeshTask(MeshScraper.clothesGroundMesh); Plugin.myCustomItems.Add(currentCustom); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentItem = ExtractGameObjectFromBundle(assetBundle, "ArmorLegsBoarHTD"); component = currentItem.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)sE_Stats_ProgressiveSet; currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "piece_workbench", 1, 1); currentRecipeHelper.AddResource("TrophyBoar", 1, 0).AddResource("LeatherScraps", 10, 4); } Plugin.customConfigInstance.AddArmorDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model0", 4).AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.New("model1", 3).AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.New("log").AddMaterialTask("rags"); currentCustom.prefabFixer.Current().AddMeshTask(MeshScraper.clothesGroundMesh); Plugin.myCustomItems.Add(currentCustom); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentItem = ExtractGameObjectFromBundle(assetBundle, "ArmorShoulderBoarHTD"); component = currentItem.GetComponent<ItemDrop>(); component.m_itemData.m_shared.m_setStatusEffect = (StatusEffect)(object)sE_Stats_ProgressiveSet; currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "piece_workbench", 1, 1); currentRecipeHelper.AddResource("TrophyBoar", 1, 0).AddResource("LeatherScraps", 8, 3).AddResource("BoneFragments", 6, 3); } Plugin.customConfigInstance.AddArmorDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model0", 4).AddMaterialTask(MaterialScraper.boarTusk).SetMaterialIndex(1); currentCustom.prefabFixer.New("log").AddMaterialTask("rags"); currentCustom.prefabFixer.Current().AddMeshTask(MeshScraper.clothesGroundMesh); Plugin.myCustomItems.Add(currentCustom); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentItem = ExtractGameObjectFromBundle(assetBundle, "WoodSwordHTD"); component = currentItem.GetComponent<ItemDrop>(); currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "", 1, 1); currentRecipeHelper.AddResource("Wood", 4, 2); } currentRecipeHelper.SetRepairStation("piece_workbench"); Plugin.customConfigInstance.AddItemDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model").AddMeshTask(MeshScraper.woodMesh); currentCustom.prefabFixer.Current().AddMaterialTask("wood_item"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT).AddEffect("sfx_club_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT_TERRAIN).AddEffect("sfx_club_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("sfx_wood_blocked", EffectsManager.EffectList.BLOCK).AddEffect("vfx_blocked").AddEffect("fx_block_camshake"); currentCustom.effectHandler.AddEffect("fx_swing_camshake", EffectsManager.EffectList.TRIGGER); currentCustom.effectHandler.AddEffect("sfx_club_swing", EffectsManager.EffectList.TRAIL); Plugin.myCustomItems.Add(currentCustom); currentItem = ExtractGameObjectFromBundle(assetBundle, "WoodPolearmHTD"); component = currentItem.GetComponent<ItemDrop>(); currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "", 1, 1); currentRecipeHelper.AddResource("Wood", 6, 2); } currentRecipeHelper.SetRepairStation("piece_workbench"); Plugin.customConfigInstance.AddItemDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("model").AddMeshTask(MeshScraper.stakeWallMesh); currentCustom.prefabFixer.Current().AddMaterialTask("stake"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT).AddEffect("sfx_club_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT_TERRAIN).AddEffect("sfx_club_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("sfx_wood_blocked", EffectsManager.EffectList.BLOCK).AddEffect("vfx_blocked").AddEffect("fx_block_camshake"); currentCustom.effectHandler.AddEffect("fx_swing_camshake", EffectsManager.EffectList.TRIGGER); currentCustom.effectHandler.AddEffect("sfx_club_swing", EffectsManager.EffectList.TRAIL); Plugin.myCustomItems.Add(currentCustom); currentItem = ExtractGameObjectFromBundle(assetBundle, "LeatherFistsHTD"); component = currentItem.GetComponent<ItemDrop>(); currentRecipeHelper = ApplyConfigChangesAndRecipes(ref currentItem); if (currentRecipeHelper == null) { currentRecipeHelper = new RecipeHelper(currentItem, "piece_workbench", 1, 1); currentRecipeHelper.AddResource("LeatherScraps", 4, 2); } Plugin.customConfigInstance.AddItemDataAsConfigRecord(currentItem); Plugin.customConfigInstance.AddRecipeAsConfigRecord(currentRecipeHelper); Plugin.myRecipeHelperList.Add(currentRecipeHelper); currentCustom = new CustomItem(currentItem); currentCustom.prefabFixer.New("LeatherFists").AddMaterialTask("", useCurrentMaterial: true).FixShaderOnly() .SetShader("custom/creature"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT).AddEffect("sfx_unarmed_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("vfx_clubhit", EffectsManager.EffectList.HIT_TERRAIN).AddEffect("sfx_unarmed_hit").AddEffect("fx_hit_camshake"); currentCustom.effectHandler.AddEffect("sfx_unarmed_blocked", EffectsManager.EffectList.BLOCK).AddEffect("vfx_blocked").AddEffect("fx_block_camshake"); currentCust