using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BalrondBiomes_Meadows;
using BepInEx;
using HarmonyLib;
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("ProjectAshlands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectAshlands")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f405ea1c-ac25-47a3-9aa2-a8f56c14bfd6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BalrondBiomes_Meadows
{
public class ShaderReplacment
{
public string[] shaderlist = new string[49]
{
"Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass",
"Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player",
"Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water",
"Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear",
"Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting"
};
public List<Shader> shaders = new List<Shader>();
public void findShadersByName()
{
string[] array = shaderlist;
foreach (string text in array)
{
Shader val = Shader.Find(text);
if ((Object)(object)val != (Object)null)
{
shaders.Add(val);
}
}
}
public void ReplaceShadersInObject(GameObject gameObject)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if (new ZNet().IsDedicated() || (Object)(object)gameObject == (Object)null)
{
return;
}
Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
if (componentsInChildren == null || componentsInChildren.Length == 0)
{
return;
}
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material[] sharedMaterials = val.sharedMaterials;
if (sharedMaterials != null && sharedMaterials.Length != 0)
{
fixMaterial(sharedMaterials);
}
}
}
private void fixMaterial(Material[] shared)
{
foreach (Material val in shared)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Shader shader = val.shader;
if (!((Object)(object)shader == (Object)null))
{
string name = ((Object)shader).name;
if (!(name == "Standard") && name.Contains("Balrond"))
{
setProperValue(val, name);
}
}
}
}
public Material setProperValue(Material material, string shaderName)
{
string name = shaderName.Replace("Balrond", "Custom");
name = checkNaming(name);
Shader val = Shader.Find(name);
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Shader not found " + name));
return material;
}
material.shader = val;
return material;
}
private string checkNaming(string name)
{
string result = name;
if (name.Contains("Bumped"))
{
result = name.Replace("Custom", "Lux Lit Particles");
}
if (name.Contains("Tess Bumped"))
{
result = name.Replace("Custom", "Lux Lit Particles");
}
if (name.Contains("Standard Surface"))
{
result = name.Replace("Custom", "Particles");
result = result.Replace("Standard Surface2", "Standard Surface");
}
if (name.Contains("Standard Unlit"))
{
result = name.Replace("Custom", "Particles");
result = result.Replace("Standard Unlit", "Standard Unlit2");
result = result.Replace("Standard Unlit22", "Standard Unlit2");
}
return result;
}
}
}
namespace BalrondSledgeMajster
{
public class FxReplacment
{
private List<GameObject> allPrefabs;
private string projectName = "[BalrondSledgeMajster]";
public void setInstance(List<GameObject> gameObjects)
{
allPrefabs = gameObjects;
}
public void ReplaceOnObject(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
SpawnArea component = gameObject.GetComponent<SpawnArea>();
if ((Object)(object)component != (Object)null)
{
EffectList spawnEffects = component.m_spawnEffects;
if (spawnEffects != null)
{
findEffectsAndChange(spawnEffects.m_effectPrefabs);
}
}
Destructible component2 = gameObject.GetComponent<Destructible>();
if ((Object)(object)component2 != (Object)null)
{
EffectList hitEffect = component2.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = component2.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
Projectile component3 = gameObject.GetComponent<Projectile>();
if ((Object)(object)component3 != (Object)null)
{
EffectList hitEffects = component3.m_hitEffects;
if (hitEffects != null)
{
findEffectsAndChange(hitEffects.m_effectPrefabs);
}
EffectList hitWaterEffects = component3.m_hitWaterEffects;
if (hitWaterEffects != null)
{
findEffectsAndChange(hitWaterEffects.m_effectPrefabs);
}
EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
if (spawnOnHitEffects != null)
{
findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs);
}
}
}
public void ReplaceOnVegetation(GameObject gameObject)
{
Pickable component = gameObject.GetComponent<Pickable>();
if ((Object)(object)component != (Object)null)
{
fixPlant(component);
}
Destructible component2 = gameObject.GetComponent<Destructible>();
if ((Object)(object)component2 != (Object)null)
{
fixPDestructable(component2);
}
MineRock5 component3 = gameObject.GetComponent<MineRock5>();
if ((Object)(object)component3 != (Object)null)
{
fixMineRock5(component3);
}
MineRock component4 = gameObject.GetComponent<MineRock>();
if ((Object)(object)component4 != (Object)null)
{
fixMineRock(component4);
}
}
private void fixPlant(Pickable pickable)
{
EffectList pickEffector = pickable.m_pickEffector;
if (pickEffector != null)
{
findEffectsAndChange(pickEffector.m_effectPrefabs);
}
}
private void fixPDestructable(Destructible minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
private void fixMineRock5(MineRock5 minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
private void fixMineRock(MineRock minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
public void ReplaceOnMonster(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
Debug.LogWarning((object)(projectName + ":: GameObject not found"));
return;
}
Humanoid component = gameObject.GetComponent<Humanoid>();
if ((Object)(object)component == (Object)null)
{
Debug.LogWarning((object)(projectName + ":: GameObject not found"));
return;
}
EffectList dropEffects = component.m_dropEffects;
if (dropEffects != null)
{
findEffectsAndChange(dropEffects.m_effectPrefabs);
}
EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
if (backstabHitEffects != null)
{
findEffectsAndChange(backstabHitEffects.m_effectPrefabs);
}
EffectList consumeItemEffects = component.m_consumeItemEffects;
if (consumeItemEffects != null)
{
findEffectsAndChange(consumeItemEffects.m_effectPrefabs);
}
EffectList critHitEffects = ((Character)component).m_critHitEffects;
if (critHitEffects != null)
{
findEffectsAndChange(critHitEffects.m_effectPrefabs);
}
EffectList deathEffects = ((Character)component).m_deathEffects;
if (deathEffects != null)
{
findEffectsAndChange(deathEffects.m_effectPrefabs);
}
EffectList hitEffects = ((Character)component).m_hitEffects;
if (hitEffects != null)
{
findEffectsAndChange(hitEffects.m_effectPrefabs);
}
EffectList jumpEffects = ((Character)component).m_jumpEffects;
if (jumpEffects != null)
{
findEffectsAndChange(jumpEffects.m_effectPrefabs);
}
EffectList perfectBlockEffect = component.m_perfectBlockEffect;
if (perfectBlockEffect != null)
{
findEffectsAndChange(perfectBlockEffect.m_effectPrefabs);
}
EffectList pickupEffects = component.m_pickupEffects;
if (pickupEffects != null)
{
findEffectsAndChange(pickupEffects.m_effectPrefabs);
}
EffectList slideEffects = ((Character)component).m_slideEffects;
if (slideEffects != null)
{
findEffectsAndChange(slideEffects.m_effectPrefabs);
}
EffectList tarEffects = ((Character)component).m_tarEffects;
if (tarEffects != null)
{
findEffectsAndChange(tarEffects.m_effectPrefabs);
}
EffectList waterEffects = ((Character)component).m_waterEffects;
if (waterEffects != null)
{
findEffectsAndChange(waterEffects.m_effectPrefabs);
}
FootStep component2 = gameObject.GetComponent<FootStep>();
if (!((Object)(object)component2 != (Object)null))
{
return;
}
List<StepEffect> effects = component2.m_effects;
foreach (StepEffect item in effects)
{
GameObject[] effectPrefabs = item.m_effectPrefabs;
List<GameObject> list = new List<GameObject>();
list.AddRange(effectPrefabs);
for (int i = 0; i < list.Count; i++)
{
if ((Object)(object)list[i] != (Object)null)
{
string name = ((Object)list[i]).name;
GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
if (!((Object)(object)val == (Object)null))
{
list[i] = val;
}
}
}
}
}
public void ReplaceOnItem(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
ItemDrop component = gameObject.GetComponent<ItemDrop>();
if (!((Object)(object)component == (Object)null))
{
EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
if (hitTerrainEffect != null)
{
findEffectsAndChange(hitTerrainEffect.m_effectPrefabs);
}
EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect;
if (holdStartEffect != null)
{
findEffectsAndChange(holdStartEffect.m_effectPrefabs);
}
EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
if (trailStartEffect != null)
{
findEffectsAndChange(trailStartEffect.m_effectPrefabs);
}
EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect;
if (blockEffect != null)
{
findEffectsAndChange(blockEffect.m_effectPrefabs);
}
}
}
public void ReplaceFxOnPiece(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
Piece component = gameObject.GetComponent<Piece>();
if ((Object)(object)component != (Object)null)
{
EffectList placeEffect = component.m_placeEffect;
if (placeEffect != null)
{
findEffectsAndChange(placeEffect.m_effectPrefabs);
}
}
WearNTear component2 = gameObject.GetComponent<WearNTear>();
if ((Object)(object)component2 != (Object)null)
{
EffectList hitEffect = component2.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
}
}
private void findEffectsAndChange(EffectData[] effects)
{
if (effects == null || effects.Length == 0)
{
return;
}
foreach (EffectData val in effects)
{
if ((Object)(object)val.m_prefab != (Object)null)
{
string name = ((Object)val.m_prefab).name;
GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
if (!((Object)(object)val2 == (Object)null))
{
val.m_prefab = val2;
}
}
}
}
}
public class BuildPieceTargeting
{
private static string[] names = new string[0];
public void changePieceTargeting(List<GameObject> gameObjects)
{
List<GameObject> list = gameObjects.FindAll((GameObject x) => (Object)(object)x.GetComponent<WearNTear>() != (Object)null);
foreach (GameObject item in list)
{
Piece component = item.GetComponent<Piece>();
if ((Object)(object)component != (Object)null && names.Contains(((Object)item).name))
{
((StaticTarget)component).m_primaryTarget = true;
}
if ((Object)(object)component != (Object)null && shouldBePrimaryTarget(item))
{
((StaticTarget)component).m_primaryTarget = true;
}
setResistances(item);
}
}
private bool shouldBePrimaryTarget(GameObject gameObject)
{
if ((Object)(object)gameObject.GetComponent<Door>() != (Object)null)
{
return true;
}
if ((Object)(object)gameObject.GetComponent<CraftingStation>() != (Object)null)
{
return true;
}
if ((Object)(object)gameObject.GetComponent<StationExtension>() != (Object)null)
{
return true;
}
if ((Object)(object)gameObject.GetComponent<Container>() != (Object)null)
{
return false;
}
return false;
}
private void setResistances(GameObject gameObject)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
WearNTear component = gameObject.GetComponent<WearNTear>();
if ((Object)(object)component != (Object)null)
{
component.m_damages.m_chop = setChopDamageResistance(component);
component.m_damages.m_pickaxe = setPickaxeDamageResistance(component);
component.m_damages.m_fire = setFireDamageResistance(component);
}
}
private DamageModifier setChopDamageResistance(WearNTear wearNTear)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected I4, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
MaterialType materialType = wearNTear.m_materialType;
MaterialType val = materialType;
return (DamageModifier)((int)val switch
{
0 => 6,
3 => 2,
2 => 5,
1 => 1,
_ => 0,
});
}
private DamageModifier setPickaxeDamageResistance(WearNTear wearNTear)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected I4, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
MaterialType materialType = wearNTear.m_materialType;
MaterialType val = materialType;
return (DamageModifier)((int)val switch
{
0 => 0,
3 => 1,
2 => 2,
1 => 6,
_ => 0,
});
}
private DamageModifier setFireDamageResistance(WearNTear wearNTear)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected I4, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
MaterialType materialType = wearNTear.m_materialType;
MaterialType val = materialType;
return (DamageModifier)((int)val switch
{
0 => 6,
3 => 2,
2 => 0,
1 => 5,
_ => 0,
});
}
}
public class DatabaseAddMethods
{
public void AddItems(List<GameObject> items)
{
foreach (GameObject item in items)
{
AddItem(item);
}
}
public void AddRecipes(List<Recipe> recipes)
{
foreach (Recipe recipe in recipes)
{
AddRecipe(recipe);
}
}
public void AddStatuseffects(List<StatusEffect> statusEffects)
{
foreach (StatusEffect statusEffect in statusEffects)
{
AddStatus(statusEffect);
}
}
private bool IsObjectDBValid()
{
return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
}
private void AddStatus(StatusEffect status)
{
if (!IsObjectDBValid())
{
return;
}
if ((Object)(object)status != (Object)null)
{
if ((Object)(object)ObjectDB.instance.GetStatusEffect(((object)status).GetHashCode()) == (Object)null)
{
ObjectDB.instance.m_StatusEffects.Add(status);
}
}
else
{
Debug.LogError((object)("ZZZ_BalrondSledgeMajster: " + ((Object)status).name + " - Status not found"));
}
}
private void AddRecipe(Recipe recipe)
{
if (!IsObjectDBValid())
{
return;
}
if ((Object)(object)recipe != (Object)null)
{
if ((Object)(object)ObjectDB.instance.GetRecipe(recipe.m_item.m_itemData) == (Object)null)
{
ObjectDB.instance.m_recipes.Add(recipe);
}
}
else
{
Debug.LogError((object)("ZZZ_BalrondSledgeMajster: " + ((Object)recipe).name + " - Recipe not found"));
}
}
private void AddItem(GameObject newPrefab)
{
if (!IsObjectDBValid())
{
return;
}
ItemDrop component = newPrefab.GetComponent<ItemDrop>();
if ((Object)(object)component != (Object)null)
{
if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
{
ObjectDB.instance.m_items.Add(newPrefab);
Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
}
}
else
{
Debug.LogError((object)("ZZZ_BalrondSledgeMajster: " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
}
}
}
[BepInPlugin("balrond.astafaraios.BalrondSledgeMajster", "ZZZ_BalrondSledgeMajster", "1.0.2")]
public class Launch : BaseUnityPlugin
{
[HarmonyPatch(typeof(Game), "Awake")]
public static class Game_Awake_Path
{
public static void Prefix()
{
ZNetScene_Awake_Path.hasSpawned = false;
}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
public static class Object_CopyOtherDB_Path
{
public static void Postfix()
{
if (IsObjectDBValid())
{
}
}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
public static class ObjectDB_Awake_Path
{
public static void Postfix()
{
if (IsObjectDBValid())
{
}
}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
public static class ZNetScene_Awake_Path
{
public static bool hasSpawned;
public static void Prefix(ZNetScene __instance)
{
if ((Object)(object)__instance == (Object)null)
{
Debug.LogWarning((object)"ZZZ_BalrondSledgeMajster: No ZnetScene found");
}
else
{
if (hasSpawned)
{
return;
}
List<GameObject> list = __instance.m_prefabs.FindAll((GameObject x) => ((Object)x).name.Contains("Sledge"));
GameObject battleaxe = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Battleaxe");
foreach (GameObject item in list)
{
if (!((Object)item).name.Contains("Anchor"))
{
itemEdits.editSLedge(item, battleaxe);
}
}
hasSpawned = true;
}
}
}
private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondSledgeMajster");
public const string PluginGUID = "balrond.astafaraios.BalrondSledgeMajster";
public const string PluginName = "ZZZ_BalrondSledgeMajster";
public const string PluginVersion = "1.0.2";
public static ModResourceLoader modResourceLoader = new ModResourceLoader();
public static ItemEdits itemEdits = new ItemEdits();
public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();
public static BuildPieceTargeting pieceTargeting = new BuildPieceTargeting();
public static GameObject RootObject;
public static GameObject PrefabContainer;
private void Awake()
{
harmony.PatchAll();
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
public void createPrefabContainer()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
RootObject = new GameObject("_ValheimReforgedRoot");
Object.DontDestroyOnLoad((Object)(object)RootObject);
PrefabContainer = new GameObject("Prefabs");
PrefabContainer.transform.parent = RootObject.transform;
PrefabContainer.SetActive(false);
}
public static GameObject cloneMe(GameObject source, string name)
{
GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
((Object)val).name = name;
return val;
}
private static bool IsObjectDBValid()
{
return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
}
}
public class ModResourceLoader
{
public AssetBundle assetBundle;
public Material loxFace_Default;
public Material loxtBody_Default;
public Material loxFur_Default;
public Material loxFace_Albino;
public Material loxtBody_Albino;
public Material loxFur_Albino;
public Material loxFace_Black;
public Material loxtBody_Black;
public Material loxFur_Black;
public Material loxFace_Blond;
public Material loxtBody_Blond;
public Material loxFur_Blond;
public Material loxFace_DarkBrown;
public Material loxtBody_DarkBrown;
public Material loxFur_DarkBrown;
public Material loxFace_Ginger;
public Material loxtBody_Ginger;
public Material loxFur_Ginger;
public Material wolfBody_Default;
public Material wolfBody_Albino;
public Material wolfBody_Black;
public Material wolfBody_DarkBrown;
public Material wolfBody_Grey;
public Material neckBody_Default;
public Material neckBody_Albino;
public Material neckBody_Blue;
public Material neckBody_DarkBlue;
public Material neckBody_DarkGreen;
public Material hareBody_Default;
public Material hareBody_Albino;
public Material hareBody_Black;
public Material hareBody_DarkBlue;
public Material hareBody_Ginger;
public Material drakeBody_Default;
public Material drakeBody_DarkBlue;
public Material drakeBody_IceBlue;
public Material drakeBody_Purple;
public Material drakeBody_Red;
public Material serpentBody_Default;
public Material serpentBody_Albino;
public Material serpentBody_Black;
public Material serpentBody_Blue;
public Material serpentBody_Green;
public Material serpentBody_Red;
public ShaderReplacment shaderReplacment = new ShaderReplacment();
public void loadAssets()
{
assetBundle = GetAssetBundleFromResources("furrandomizer");
string text = "Assets/BalrondSledgeMajster/";
Material temp = assetBundle.LoadAsset<Material>(text + "Lox/Default/lox_face.mat");
CreateLoxMaterial(temp, text);
CreateWolfMaterial(temp, text);
CreateNeckMaterial(temp, text);
CreateHareMaterial(temp, text);
CreateDrakeMaterial(temp, text);
CreateSerpentMaterials(temp, text);
}
private void CreateLoxMaterial(Material temp, string mainPath)
{
loxFace_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Default/lox_body1.mat");
loxtBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Default/lox_fur1.mat");
loxFur_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_face.mat");
loxFace_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_body1.mat");
loxtBody_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Albino/lox_fur1.mat");
loxFur_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_face.mat");
loxFace_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_body1.mat");
loxtBody_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Black/lox_fur1.mat");
loxFur_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_face.mat");
loxFace_Blond = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_body1.mat");
loxtBody_Blond = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Blonde/lox_fur1.mat");
loxFur_Blond = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_face.mat");
loxFace_DarkBrown = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_body1.mat");
loxtBody_DarkBrown = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/DarkBrown/lox_fur1.mat");
loxFur_DarkBrown = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_face.mat");
loxFace_Ginger = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_body1.mat");
loxtBody_Ginger = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Lox/Ginger/lox_fur1.mat");
loxFur_Ginger = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private void CreateWolfMaterial(Material temp, string mainPath)
{
temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Default/wolfMat.mat");
wolfBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Albino/wolfMat.mat");
wolfBody_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Black/wolfMat.mat");
wolfBody_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/DarkBrown/wolfMat.mat");
wolfBody_DarkBrown = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Wolf/Grey/wolfMat.mat");
wolfBody_Grey = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private void CreateNeckMaterial(Material temp, string mainPath)
{
temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Default/neck1.mat");
neckBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Albino/neck1.mat");
neckBody_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/Blue/neck1.mat");
neckBody_Blue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/DarkBlue/neck1.mat");
neckBody_DarkBlue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Neck/DarkGreen/neck1.mat");
neckBody_DarkGreen = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private void CreateHareMaterial(Material temp, string mainPath)
{
temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Default/Hare_mat1.mat");
hareBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Albino/Hare_mat1.mat");
hareBody_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Black/Hare_mat1.mat");
hareBody_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/DarkBlue/Hare_mat1.mat");
hareBody_DarkBlue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Hare/Ginger/Hare_mat1.mat");
hareBody_Ginger = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private void CreateDrakeMaterial(Material temp, string mainPath)
{
temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Default/Hatchling_mountain_mat1.mat");
drakeBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/DarkBlue/Hatchling_mountain_mat1.mat");
drakeBody_DarkBlue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/IceBlue/Hatchling_mountain_mat1.mat");
drakeBody_IceBlue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Purple/Hatchling_mountain_mat1.mat");
drakeBody_Purple = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Drake/Red/Hatchling_mountain_mat1.mat");
drakeBody_Red = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private void CreateSerpentMaterials(Material temp, string mainPath)
{
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Default/SeaSerpent_mat1.mat");
serpentBody_Default = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Albino/SeaSerpent_mat1.mat");
serpentBody_Albino = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Black/SeaSerpent_mat1.mat");
serpentBody_Black = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Blue/SeaSerpent_mat1.mat");
serpentBody_Blue = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Green/SeaSerpent_mat1.mat");
serpentBody_Green = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
temp = assetBundle.LoadAsset<Material>(mainPath + "Serpent/Red/SeaSerpent_mat1.mat");
serpentBody_Red = shaderReplacment.setProperValue(temp, ((Object)temp.shader).name);
}
private AssetBundle GetAssetBundleFromResources(string filename)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
using Stream stream = executingAssembly.GetManifestResourceStream(name);
return AssetBundle.LoadFromStream(stream);
}
}
public class ItemEdits
{
private string[] itemEditNames = new string[14]
{
"draugr_sword", "draugr_bow", "draugr_axe", "skeleton_bow", "skeleton_mace", "skeleton_sword2", "skeleton_bow2", "skeleton_sword2", "imp_fireball_attack", "Ghost_attack",
"gd_king_shoot", "Greydwarf_shaman_attack", "GoblinKing_Beam", "GoblinShaman_attack_fireball"
};
public void editSLedge(GameObject sledge, GameObject battleaxe)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
if ((Object)(object)sledge == (Object)null)
{
Debug.LogWarning((object)"Sledge is null");
return;
}
ItemDrop component = sledge.GetComponent<ItemDrop>();
if ((Object)(object)component == (Object)null)
{
return;
}
Debug.Log((object)("Working with sledge: " + ((Object)sledge).name));
Attack val = component.m_itemData.m_shared.m_attack.Clone();
if (val == null)
{
return;
}
if ((int)val.m_attackType != 4)
{
Debug.Log((object)("Sledge Primary not standard skipping: " + ((Object)sledge).name));
return;
}
ItemDrop component2 = battleaxe.GetComponent<ItemDrop>();
if (!((Object)(object)component2 == (Object)null))
{
Attack val2 = component2.m_itemData.m_shared.m_attack.Clone();
if (val2 != null)
{
val2.m_hitEffect = component2.m_itemData.m_shared.m_hitEffect;
val2.m_hitTerrainEffect = component2.m_itemData.m_shared.m_hitTerrainEffect;
val2.m_startEffect = component2.m_itemData.m_shared.m_startEffect;
val2.m_trailStartEffect = component2.m_itemData.m_shared.m_trailStartEffect;
val2.m_triggerEffect = component2.m_itemData.m_shared.m_triggerEffect;
val.m_hitEffect = component.m_itemData.m_shared.m_hitEffect;
val.m_hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
val.m_startEffect = component.m_itemData.m_shared.m_startEffect;
val.m_trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
val.m_triggerEffect = component.m_itemData.m_shared.m_triggerEffect;
component.m_itemData.m_shared.m_hitEffect = null;
component.m_itemData.m_shared.m_hitTerrainEffect = null;
component.m_itemData.m_shared.m_startEffect = null;
component.m_itemData.m_shared.m_trailStartEffect = null;
component.m_itemData.m_shared.m_triggerEffect = null;
component.m_itemData.m_shared.m_attack = val2;
component.m_itemData.m_shared.m_secondaryAttack = val;
}
}
}
private GameObject FindItem(List<GameObject> list, string name)
{
GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
if ((Object)(object)val != (Object)null)
{
return val;
}
Debug.LogWarning((object)("ZZZ_BalrondSledgeMajster: Item Not Found: " + name));
return null;
}
public void editItems(List<GameObject> list)
{
string[] array = itemEditNames;
foreach (string text in array)
{
GameObject val = FindItem(list, text);
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Could not find: " + text));
}
else
{
CheckStats(val);
}
}
}
private void CheckStats(GameObject gameObject)
{
switch (((Object)gameObject).name)
{
case "draugr_sword":
editSpiritDamageStat(gameObject, 25);
break;
case "draugr_bow":
editSpiritDamageStat(gameObject, 15);
break;
case "draugr_axe":
editSpiritDamageStat(gameObject, 15);
break;
case "skeleton_bow":
case "skeleton_sword":
case "Ghost_attack":
editSpiritDamageStat(gameObject, 10);
break;
case "skeleton_bow2":
case "skeleton_mace":
case "skeleton_sword2":
case "gd_king_shoot":
case "Greydwarf_shaman_attack":
case "GoblinKing_Beam":
case "GoblinShaman_attack_fireball":
editSpiritDamageStat(gameObject, 20);
break;
case "imp_fireball_attack":
editSpiritDamageStat(gameObject, 10);
break;
}
}
private void editSpiritDamageStat(GameObject gameObject, int spiritDamage)
{
ItemDrop component = gameObject.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_damages.m_spirit = spiritDamage;
if (((Object)gameObject).name == "skeleton_mace" || ((Object)gameObject).name == "imp_fireball_attack")
{
component.m_itemData.m_shared.m_damages.m_blunt += spiritDamage;
}
}
private void editFoodStat(GameObject gameObject, int hp = -99, int stam = -99, int eitr = -99, int time = -99, int regen = -99)
{
ItemDrop component = gameObject.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_food = ((hp == -99) ? component.m_itemData.m_shared.m_food : ((float)hp));
component.m_itemData.m_shared.m_foodStamina = ((stam == -99) ? component.m_itemData.m_shared.m_foodStamina : ((float)stam));
component.m_itemData.m_shared.m_foodEitr = ((eitr == -99) ? component.m_itemData.m_shared.m_foodEitr : ((float)eitr));
component.m_itemData.m_shared.m_foodRegen = ((regen == -99) ? component.m_itemData.m_shared.m_foodRegen : ((float)regen));
component.m_itemData.m_shared.m_foodBurnTime = ((time == -99) ? component.m_itemData.m_shared.m_foodBurnTime : ((float)time));
}
}
}