using System;
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 BalrondHumanoidRandomizer.Monsters;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("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 BalrondHumanoidRandomizer
{
public class FxReplacment
{
private List<GameObject> allPrefabs;
private string projectName = "[BalrondHumanoidRandomizer]";
public void setInstance(List<GameObject> gameObjects)
{
allPrefabs = gameObjects;
}
public void ReplaceOnObject(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
SpawnArea component = gameObject.GetComponent<SpawnArea>();
if ((Object)(object)component != (Object)null)
{
EffectList spawnEffects = component.m_spawnEffects;
if (spawnEffects != null)
{
findEffectsAndChange(spawnEffects.m_effectPrefabs);
}
}
Destructible component2 = gameObject.GetComponent<Destructible>();
if ((Object)(object)component2 != (Object)null)
{
EffectList hitEffect = component2.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = component2.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
Projectile component3 = gameObject.GetComponent<Projectile>();
if ((Object)(object)component3 != (Object)null)
{
EffectList hitEffects = component3.m_hitEffects;
if (hitEffects != null)
{
findEffectsAndChange(hitEffects.m_effectPrefabs);
}
EffectList hitWaterEffects = component3.m_hitWaterEffects;
if (hitWaterEffects != null)
{
findEffectsAndChange(hitWaterEffects.m_effectPrefabs);
}
EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
if (spawnOnHitEffects != null)
{
findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs);
}
}
}
public void ReplaceOnVegetation(GameObject gameObject)
{
Pickable component = gameObject.GetComponent<Pickable>();
if ((Object)(object)component != (Object)null)
{
fixPlant(component);
}
Destructible component2 = gameObject.GetComponent<Destructible>();
if ((Object)(object)component2 != (Object)null)
{
fixPDestructable(component2);
}
MineRock5 component3 = gameObject.GetComponent<MineRock5>();
if ((Object)(object)component3 != (Object)null)
{
fixMineRock5(component3);
}
MineRock component4 = gameObject.GetComponent<MineRock>();
if ((Object)(object)component4 != (Object)null)
{
fixMineRock(component4);
}
}
private void fixPlant(Pickable pickable)
{
EffectList pickEffector = pickable.m_pickEffector;
if (pickEffector != null)
{
findEffectsAndChange(pickEffector.m_effectPrefabs);
}
}
private void fixPDestructable(Destructible minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
private void fixMineRock5(MineRock5 minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
private void fixMineRock(MineRock minerock5)
{
EffectList hitEffect = minerock5.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList destroyedEffect = minerock5.m_destroyedEffect;
if (destroyedEffect != null)
{
findEffectsAndChange(destroyedEffect.m_effectPrefabs);
}
}
public void ReplaceOnMonster(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
Debug.LogWarning((object)(projectName + ":: GameObject not found"));
return;
}
Humanoid component = gameObject.GetComponent<Humanoid>();
if ((Object)(object)component == (Object)null)
{
Debug.LogWarning((object)(projectName + ":: GameObject not found"));
return;
}
EffectList dropEffects = component.m_dropEffects;
if (dropEffects != null)
{
findEffectsAndChange(dropEffects.m_effectPrefabs);
}
EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
if (backstabHitEffects != null)
{
findEffectsAndChange(backstabHitEffects.m_effectPrefabs);
}
EffectList consumeItemEffects = component.m_consumeItemEffects;
if (consumeItemEffects != null)
{
findEffectsAndChange(consumeItemEffects.m_effectPrefabs);
}
EffectList critHitEffects = ((Character)component).m_critHitEffects;
if (critHitEffects != null)
{
findEffectsAndChange(critHitEffects.m_effectPrefabs);
}
EffectList deathEffects = ((Character)component).m_deathEffects;
if (deathEffects != null)
{
findEffectsAndChange(deathEffects.m_effectPrefabs);
}
EffectList hitEffects = ((Character)component).m_hitEffects;
if (hitEffects != null)
{
findEffectsAndChange(hitEffects.m_effectPrefabs);
}
EffectList jumpEffects = ((Character)component).m_jumpEffects;
if (jumpEffects != null)
{
findEffectsAndChange(jumpEffects.m_effectPrefabs);
}
EffectList perfectBlockEffect = component.m_perfectBlockEffect;
if (perfectBlockEffect != null)
{
findEffectsAndChange(perfectBlockEffect.m_effectPrefabs);
}
EffectList pickupEffects = component.m_pickupEffects;
if (pickupEffects != null)
{
findEffectsAndChange(pickupEffects.m_effectPrefabs);
}
EffectList slideEffects = ((Character)component).m_slideEffects;
if (slideEffects != null)
{
findEffectsAndChange(slideEffects.m_effectPrefabs);
}
EffectList tarEffects = ((Character)component).m_tarEffects;
if (tarEffects != null)
{
findEffectsAndChange(tarEffects.m_effectPrefabs);
}
EffectList waterEffects = ((Character)component).m_waterEffects;
if (waterEffects != null)
{
findEffectsAndChange(waterEffects.m_effectPrefabs);
}
FootStep component2 = gameObject.GetComponent<FootStep>();
if (!((Object)(object)component2 != (Object)null))
{
return;
}
List<StepEffect> effects = component2.m_effects;
foreach (StepEffect item in effects)
{
GameObject[] effectPrefabs = item.m_effectPrefabs;
List<GameObject> list = new List<GameObject>();
list.AddRange(effectPrefabs);
for (int i = 0; i < list.Count; i++)
{
if ((Object)(object)list[i] != (Object)null)
{
string name = ((Object)list[i]).name;
GameObject val = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
if (!((Object)(object)val == (Object)null))
{
list[i] = val;
}
}
}
}
}
public void ReplaceOnItem(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
ItemDrop component = gameObject.GetComponent<ItemDrop>();
if (!((Object)(object)component == (Object)null))
{
EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
if (hitTerrainEffect != null)
{
findEffectsAndChange(hitTerrainEffect.m_effectPrefabs);
}
EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect;
if (holdStartEffect != null)
{
findEffectsAndChange(holdStartEffect.m_effectPrefabs);
}
EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
if (trailStartEffect != null)
{
findEffectsAndChange(trailStartEffect.m_effectPrefabs);
}
EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect;
if (blockEffect != null)
{
findEffectsAndChange(blockEffect.m_effectPrefabs);
}
}
}
public void ReplaceFxOnPiece(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
Piece component = gameObject.GetComponent<Piece>();
if ((Object)(object)component != (Object)null)
{
EffectList placeEffect = component.m_placeEffect;
if (placeEffect != null)
{
findEffectsAndChange(placeEffect.m_effectPrefabs);
}
}
WearNTear component2 = gameObject.GetComponent<WearNTear>();
if ((Object)(object)component2 != (Object)null)
{
EffectList hitEffect = component2.m_hitEffect;
if (hitEffect != null)
{
findEffectsAndChange(hitEffect.m_effectPrefabs);
}
}
}
private void findEffectsAndChange(EffectData[] effects)
{
if (effects == null || effects.Length == 0)
{
return;
}
foreach (EffectData val in effects)
{
if ((Object)(object)val.m_prefab != (Object)null)
{
string name = ((Object)val.m_prefab).name;
GameObject val2 = allPrefabs.Find((GameObject x) => ((Object)x).name == name);
if (!((Object)(object)val2 == (Object)null))
{
val.m_prefab = val2;
}
}
}
}
}
public class ShaderReplacment
{
public static List<GameObject> prefabsToReplaceShader = new List<GameObject>();
public static List<Material> materialsInPrefabs = new List<Material>();
public string[] shaderlist = new string[49]
{
"Custom/AlphaParticle", "Custom/Blob", "Custom/Bonemass", "Custom/Clouds", "Custom/Creature", "Custom/Decal", "Custom/Distortion", "Custom/Flow", "Custom/FlowOpaque", "Custom/Grass",
"Custom/GuiScroll", "Custom/Heightmap", "Custom/icon", "Custom/InteriorSide", "Custom/LitGui", "Custom/LitParticles", "Custom/mapshader", "Custom/ParticleDecal", "Custom/Piece", "Custom/Player",
"Custom/Rug", "Custom/ShadowBlob", "Custom/SkyboxProcedural", "Custom/SkyObject", "Custom/StaticRock", "Custom/Tar", "Custom/Trilinearmap", "Custom/UI/BGBlur", "Custom/Vegetation", "Custom/Water",
"Custom/WaterBottom", "Custom/WaterMask", "Custom/Yggdrasil", "Custom/Yggdrasil/root", "Hidden/BlitCopyHDRTonemap", "Hidden/Dof/DepthOfFieldHdr", "Hidden/Dof/DX11Dof", "Hidden/Internal-Loading", "Hidden/Internal-UIRDefaultWorld", "Hidden/SimpleClear",
"Hidden/SunShaftsComposite", "Lux Lit Particles/ Bumped", "Lux Lit Particles/ Tess Bumped", "Particles/Standard Surface2", "Particles/Standard Unlit2", "Standard TwoSided", "ToonDeferredShading2017", "Unlit/DepthWrite", "Unlit/Lighting"
};
public static List<Shader> shaders = new List<Shader>();
private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>();
public static bool debug = true;
public static Shader findShader(string name)
{
Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
if (array.Length == 0)
{
Debug.LogWarning((object)"SHADER LIST IS EMPTY!");
return null;
}
if (debug)
{
}
return shaders.Find((Shader x) => ((Object)x).name == name);
}
public static Shader GetShaderByName(string name)
{
return shaders.Find((Shader x) => ((Object)x).name == name.Trim());
}
public static void debugShaderList(List<Shader> shadersRes)
{
foreach (Shader shadersRe in shadersRes)
{
Debug.LogWarning((object)("SHADER NAME IS: " + ((Object)shadersRe).name));
}
debug = false;
}
public static void Replace(GameObject gameObject)
{
prefabsToReplaceShader.Add(gameObject);
GetMaterialsInPrefab(gameObject);
}
public static void GetMaterialsInPrefab(GameObject gameObject)
{
Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material[] sharedMaterials = val.sharedMaterials;
if (sharedMaterials == null || sharedMaterials.Length == 0)
{
continue;
}
Material[] array2 = sharedMaterials;
foreach (Material val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
materialsInPrefabs.Add(val2);
}
}
}
}
public static void getMeShaders()
{
AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
AssetBundle[] array2 = array;
foreach (AssetBundle val in array2)
{
IEnumerable<Shader> enumerable3;
try
{
IEnumerable<Shader> enumerable2;
if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
{
IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
enumerable2 = enumerable;
}
else
{
enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
where (Object)(object)shader != (Object)null
select shader;
}
enumerable3 = enumerable2;
}
catch (Exception)
{
continue;
}
if (enumerable3 == null)
{
continue;
}
foreach (Shader item in enumerable3)
{
CachedShaders.Add(item);
}
}
}
public static void runMaterialFix()
{
getMeShaders();
shaders.AddRange(CachedShaders);
foreach (Material materialsInPrefab in materialsInPrefabs)
{
Shader shader = materialsInPrefab.shader;
if (!((Object)(object)shader == (Object)null))
{
string name = ((Object)shader).name;
if (!(name == "Standard") && name.Contains("Balrond"))
{
setProperValue(materialsInPrefab, name);
}
}
}
}
private static void setProperValue(Material material, string shaderName)
{
string name = shaderName.Replace("Balrond", "Custom");
name = checkNaming(name);
Shader shaderByName = GetShaderByName(name);
if (!((Object)(object)shaderByName == (Object)null))
{
material.shader = shaderByName;
}
}
private static string checkNaming(string name)
{
string result = name;
if (name.Contains("Bumped"))
{
result = name.Replace("Custom", "Lux Lit Particles");
}
if (name.Contains("Tess Bumped"))
{
result = name.Replace("Custom", "Lux Lit Particles");
}
if (name.Contains("Standard Surface"))
{
result = name.Replace("Custom", "Particles");
result = result.Replace("Standard Surface2", "Standard Surface");
}
if (name.Contains("Standard Unlit"))
{
result = name.Replace("Custom", "Particles");
result = result.Replace("Standard Unlit", "Standard Unlit2");
result = result.Replace("Standard Unlit22", "Standard Unlit2");
}
return result;
}
}
public class StatusEffectBuilder
{
public List<StatusEffect> statusEffects = new List<StatusEffect>();
public void setShieldStatus(SE_LevelShield statusEffect, Sprite icon)
{
((StatusEffect)statusEffect).m_icon = icon;
((StatusEffect)statusEffect).m_ttl = 40f;
((Object)statusEffect).name = "SE_LevelShield";
((StatusEffect)statusEffect).m_name = "Shield_MonsterRandomizer";
((StatusEffect)statusEffect).m_tooltip = "You been shielded";
((StatusEffect)statusEffect).m_activationAnimation = "";
statusEffects.Add((StatusEffect)(object)statusEffect);
}
public void setBleedingStatus(SE_bleed statusEffect, Sprite icon)
{
((StatusEffect)statusEffect).m_icon = icon;
((StatusEffect)statusEffect).m_ttl = 60f;
((StatusEffect)statusEffect).m_tooltip = "You been slashed open. Any more cuts will hurt more";
((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
statusEffects.Add((StatusEffect)(object)statusEffect);
}
public void setPiercedStatus(SE_pierced statusEffect, Sprite icon)
{
((StatusEffect)statusEffect).m_icon = icon;
((StatusEffect)statusEffect).m_ttl = 60f;
((StatusEffect)statusEffect).m_tooltip = "You been pierced. Another stab like that will be more fatal";
((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
statusEffects.Add((StatusEffect)(object)statusEffect);
}
public void setCrushedStatus(SE_crushed statusEffect, Sprite icon)
{
((StatusEffect)statusEffect).m_icon = icon;
((StatusEffect)statusEffect).m_ttl = 60f;
((StatusEffect)statusEffect).m_tooltip = "Your bone was crushed. Another blunt hit will be fatal";
((StatusEffect)statusEffect).m_activationAnimation = "encumbered";
statusEffects.Add((StatusEffect)(object)statusEffect);
}
public void setBadgaesStatus(StatusEffect statusEffect, Sprite icon)
{
SE_Bandages sE_Bandages = (SE_Bandages)(object)statusEffect;
((StatusEffect)sE_Bandages).m_icon = icon;
((StatusEffect)sE_Bandages).m_name = "First Aid";
((StatusEffect)sE_Bandages).m_category = "bandages";
((Object)sE_Bandages).name = "Bandages";
((StatusEffect)sE_Bandages).m_ttl = 120f;
((StatusEffect)sE_Bandages).m_tooltip = "Applied first aid. This will help mend the pain";
((SE_Stats)sE_Bandages).m_healthOverTimeInterval = 5f;
((SE_Stats)sE_Bandages).m_healthOverTimeDuration = ((StatusEffect)sE_Bandages).m_ttl;
((SE_Stats)sE_Bandages).m_healthOverTimeTickHP = 3f;
((StatusEffect)sE_Bandages).m_activationAnimation = "equipping";
statusEffects.Add((StatusEffect)(object)sE_Bandages);
}
public StatusEffect cloneShield(StatusEffect shield, int absorb, string name)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
SE_Shield val = (SE_Shield)shield.Clone();
val.m_absorbDamage = absorb;
((StatusEffect)val).m_name = name;
((Object)val).name = name;
return (StatusEffect)(object)val;
}
public static void setupVisualsForStatus(StatusEffect statusEffect, List<GameObject> list)
{
if ((Object)(object)statusEffect == (Object)null)
{
Debug.LogWarning((object)"Status Effect is null!");
return;
}
switch (statusEffect.m_name)
{
case "Bleeding":
{
SE_bleed sE_bleed = (SE_bleed)(object)statusEffect;
break;
}
case "Crushed":
{
SE_crushed sE_crushed = (SE_crushed)(object)statusEffect;
break;
}
case "Pierced":
{
SE_pierced sE_pierced = (SE_pierced)(object)statusEffect;
break;
}
case "Shield_MonsterRandomizer":
{
List<EffectData> list2 = new List<EffectData>();
SE_LevelShield sE_LevelShield = (SE_LevelShield)(object)statusEffect;
list2.Add(createEffectData(list, "fx_GoblinShieldBreak", attach: false, "", scale: true));
list2.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
sE_LevelShield.m_breakEffects.m_effectPrefabs = list2.ToArray();
List<EffectData> list3 = new List<EffectData>();
list3.Add(createEffectData(list, "fx_GoblinShieldHit"));
list3.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
sE_LevelShield.m_hitEffects.m_effectPrefabs = list3.ToArray();
List<EffectData> list4 = new List<EffectData>();
list4.Add(createEffectData(list, "vfx_GoblinShield", attach: true, "", scale: true));
list4.RemoveAll((EffectData x) => (Object)(object)x.m_prefab == (Object)null);
((StatusEffect)sE_LevelShield).m_startEffects.m_effectPrefabs = list4.ToArray();
break;
}
}
}
private static EffectData createEffectData(List<GameObject> list, string name, bool attach = false, string attachName = "", bool scale = false)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
EffectData val = new EffectData();
val.m_variant = -1;
val.m_prefab = FindEffect(list, name);
val.m_enabled = true;
val.m_attach = attach;
val.m_scale = scale;
val.m_childTransform = attachName;
return val;
}
private static GameObject FindEffect(List<GameObject> list, string name)
{
GameObject val = list.Find((GameObject x) => ((Object)x).name == name);
if ((Object)(object)val != (Object)null)
{
return val;
}
return null;
}
}
public class BaseLevelEffectSetupValue
{
public float scale = 1.1f;
public float saturation = 0.5f;
public float hue = -0.1f;
public float value = -0.1f;
public LevelSetup setup = null;
public GameObject enabledObject = null;
public GameObject enabledObjectLevel2 = null;
public GameObject enabledObjectLevel3 = null;
public bool setEmmisive = false;
public Color emissive = Color.white;
public float sumValue = 0.05f;
public void getSetup(LevelEffects levelEffects)
{
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)levelEffects == (Object)null)
{
return;
}
int num = 0;
if (levelEffects.m_levelSetups != null && levelEffects.m_levelSetups.Count > 0)
{
num = levelEffects.m_levelSetups.Count;
setup = levelEffects.m_levelSetups.Last();
}
if (num != 0 && setup != null)
{
scale = setup.m_scale;
saturation = setup.m_saturation;
hue = setup.m_hue;
value = setup.m_value;
enabledObject = setup.m_enableObject;
emissive = setup.m_emissiveColor;
setEmmisive = setup.m_setEmissiveColor;
enabledObjectLevel2 = enabledObject;
enabledObjectLevel3 = enabledObject;
}
else
{
setValues(num, levelEffects);
}
if ((Object)(object)levelEffects.m_character != (Object)null)
{
if (((Object)((Component)levelEffects.m_character).gameObject).name == "Deer")
{
EditDeer(levelEffects);
}
if (((Object)((Component)levelEffects.m_character).gameObject).name == "Boar")
{
EditBoar(levelEffects);
}
}
}
private void EditDeer(LevelEffects levelEffects)
{
GameObject enableObject = levelEffects.m_levelSetups[0].m_enableObject;
GameObject enableObject2 = levelEffects.m_levelSetups[1].m_enableObject;
enabledObjectLevel2 = enableObject;
enabledObjectLevel3 = enableObject2;
Transform parent = enableObject.transform.parent;
GameObject enableObject3 = (enabledObject = ((Component)parent.Find("Antler1")).gameObject);
levelEffects.m_levelSetups[0].m_enableObject = enableObject3;
levelEffects.m_levelSetups[1].m_enableObject = enableObject3;
}
private void EditBoar(LevelEffects gameObject)
{
}
private void setValues(int levels, LevelEffects levelEffects)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
float y = ((Component)levelEffects).transform.localScale.y;
if (levels == 0)
{
scale = y;
saturation = 0f;
hue = 0f;
value = 0f;
}
if (levels == 1)
{
scale = y + 0.05f;
saturation = 0.5f;
hue = -0.05f;
value = -0.05f;
}
if (levels == 2)
{
scale = y + 0.1f;
saturation = 0.5f;
hue = -0.1f;
value = -0.1f;
}
}
}
public class HumanoidExtend : MonoBehaviour
{
private MonsterAI monster;
private Humanoid humanoid;
private ZNetView m_nview;
private bool itemStolen = false;
private int growthAmount = 1;
private int maxLevel = 7;
private int currentLevel;
public bool canSteal = false;
public bool levelingEnabled = true;
public bool expOnKillEnabled = true;
public bool bossLeveling = false;
public int chanceToSteal = 25;
public int currentGrowth = 0;
public int growthToLevel = 40000;
public int expForKill = 500;
public GameObject levelUpEffect;
public GameObject stealEffect;
public ItemData stolenItem = null;
public bool toggleReset = false;
private SphereCollider collider;
private void Awake()
{
humanoid = ((Component)this).GetComponent<Humanoid>();
monster = ((Component)this).GetComponent<MonsterAI>();
m_nview = ((Component)this).GetComponent<ZNetView>();
currentLevel = ((Character)humanoid).GetLevel();
if (!((BaseAI)monster).m_character.IsTamed())
{
collider = ((Component)monster).gameObject.AddComponent<SphereCollider>();
collider.radius = 3f;
((Collider)collider).isTrigger = true;
}
m_nview.Register<string, int>("Steal", (Action<long, string, int>)RPC_StolenItem);
if (((Character)humanoid).IsBoss() && bossLeveling && !levelingEnabled)
{
levelingEnabled = false;
bossLeveling = false;
}
Character character = ((BaseAI)monster).m_character;
character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, (Action)delegate
{
detectKill(((Component)monster).transform);
});
Character character2 = ((BaseAI)monster).m_character;
character2.m_onDeath = (Action)Delegate.Combine(character2.m_onDeath, (Action)delegate
{
DropStolen();
});
setMaxExpToLevel();
((MonoBehaviour)this).InvokeRepeating("CheckLeveling", 1f, 1f);
}
private void CheckTamed()
{
if (((BaseAI)monster).m_character.IsTamed())
{
Object.DestroyImmediate((Object)(object)collider);
}
}
private void CheckLeveling()
{
ResetLevel();
CheckTamed();
if (((Component)this).gameObject.activeInHierarchy)
{
if (levelingEnabled)
{
currentGrowth += growthAmount;
}
if (currentGrowth >= growthToLevel && currentLevel < maxLevel)
{
TransferExpOnLevel();
setMaxExpToLevel();
monsterLevelUp();
}
}
}
private void TransferExpOnLevel()
{
if (currentGrowth > growthToLevel)
{
int num = currentGrowth - growthToLevel;
if (num > 0)
{
currentGrowth += num;
}
}
else
{
currentGrowth = 0;
}
}
private void setMaxExpToLevel()
{
growthToLevel *= currentLevel;
}
private void monsterLevelUp()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
currentLevel++;
if ((Object)(object)levelUpEffect != (Object)null && ((Character)humanoid).GetLevel() < currentLevel)
{
Object.Instantiate<GameObject>(levelUpEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null);
}
if (((Character)humanoid).GetLevel() < currentLevel)
{
((Character)humanoid).SetLevel(currentLevel);
((Character)humanoid).RPC_Heal((long)((Object)humanoid).GetInstanceID(), ((Character)humanoid).GetMaxHealth(), false);
}
}
public void detectKill(Transform transform)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (!expOnKillEnabled)
{
return;
}
Collider[] array = Physics.OverlapSphere(transform.position, 3f, LayerMask.GetMask(new string[1] { "character" }));
Collider[] array2 = array;
HumanoidExtend humanoidExtend = default(HumanoidExtend);
foreach (Collider val in array2)
{
if (((Component)val).TryGetComponent<HumanoidExtend>(ref humanoidExtend))
{
Humanoid component = ((Component)humanoidExtend).GetComponent<Humanoid>();
if (((Character)component).m_faction != ((Character)humanoid).m_faction)
{
addExpToFound(humanoidExtend);
}
}
}
}
private void ResetLevel()
{
if (toggleReset)
{
((Character)humanoid).SetLevel(1);
toggleReset = false;
}
}
private void addExpToFound(HumanoidExtend humanoidExtend)
{
humanoidExtend.currentGrowth += expForKill;
}
private void OnCollisionEnter(Collision collision)
{
int num = Random.Range(1, 100);
Player val = default(Player);
if (!itemStolen && num <= 33 && canSteal && collision.gameObject.TryGetComponent<Player>(ref val) && ((Character)val).m_nview.IsValid())
{
CustomSteal(monster, val);
itemStolen = true;
}
}
private void CustomSteal(MonsterAI monster, Player player)
{
Inventory inventory = ((Humanoid)player).GetInventory();
FindItemToSteal(inventory, player);
}
private void FindItemToSteal(Inventory inventory, Player player)
{
List<ItemData> allItems = inventory.GetAllItems();
List<ItemData> list = allItems.FindAll((ItemData x) => (!x.m_equipped && x.m_quality == 1 && x.m_variant == 0 && !x.IsWeapon()) || ((Object)x.m_dropPrefab).name.Contains("Torch"));
if (list.Count > 0)
{
int index = Random.Range(0, list.Count() - 1);
GameObject dropPrefab = list[index].m_dropPrefab;
string name = list[index].m_shared.m_name;
Debug.Log((object)("STOLEN ITEM: " + ((Object)dropPrefab).name));
((Character)player).Message((MessageType)2, name + " was stolen!", 0, (Sprite)null);
stolenItem = list[index];
inventory.RemoveItem(list[index]);
m_nview.InvokeRPC("Steal", new object[2]
{
((Object)list[index].m_dropPrefab).name,
list[index].m_stack
});
}
else
{
Debug.Log((object)"There was nothing to steal");
}
}
private void RPC_StolenItem(long sender, string name, int amount)
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
ItemDrop component = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == name).GetComponent<ItemDrop>();
stolenItem = component.m_itemData.Clone();
stolenItem.m_stack = amount;
if ((Object)(object)stealEffect != (Object)null)
{
Object.Instantiate<GameObject>(stealEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null);
}
}
public void CustomDoorInteract(Transform character, Door door)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)character).transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
bool flag = Vector3.Dot(((Component)this).transform.forward, normalized) < 0f;
door.m_nview.InvokeRPC("UseDoor", new object[2]
{
((Object)((Component)humanoid).GetComponent<ZNetView>()).GetInstanceID(),
flag
});
}
private void DropStolen()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (canSteal && itemStolen && stolenItem != null)
{
Object.Instantiate<GameObject>(stolenItem.m_dropPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null).GetComponent<ItemDrop>().m_itemData.m_stack = stolenItem.m_stack;
}
}
}
[Serializable]
public class HumanoidRandomizer : MonoBehaviour
{
private ZNetView m_zview;
private MonsterAI m_monsterAI;
private Humanoid m_humanoid;
private VisEquipment m_visEquipment;
public string newName;
public bool isNameSet = false;
public List<ItemSet> itemSets;
public string m_itemSetName = "";
public string m_itemSetSimplified = "";
public int m_weaponStance = 0;
private Animator m_animator;
public RuntimeAnimatorController sourceAnimator;
public Biome spawnBiome = (Biome)1;
private void Awake()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
if (!validatePrefab())
{
Debug.LogWarning((object)("I should not be randomized: " + ((Object)((Component)this).gameObject).name));
return;
}
m_zview = ((Component)this).GetComponent<ZNetView>();
m_monsterAI = ((Component)this).GetComponent<MonsterAI>();
m_humanoid = ((Component)this).GetComponent<Humanoid>();
m_animator = ((Character)m_humanoid).m_animator;
m_visEquipment = ((Component)this).GetComponent<VisEquipment>();
newName = ((Character)m_humanoid).m_name;
spawnBiome = GetBiome();
if ((Object)(object)m_visEquipment == (Object)null || (Object)(object)m_animator == (Object)null || (Object)(object)m_humanoid == (Object)null || (Object)(object)m_monsterAI == (Object)null || (Object)(object)m_zview == (Object)null)
{
Debug.LogWarning((object)("[HUMANOID RANDOMIZER]Incomplete requirments for: " + ((Object)((Component)this).gameObject).name));
if ((Object)(object)m_visEquipment == (Object)null)
{
Debug.LogWarning((object)"missing: VisEquipment script");
}
if ((Object)(object)m_animator == (Object)null)
{
Debug.LogWarning((object)"missing: animator");
}
if ((Object)(object)m_humanoid == (Object)null)
{
Debug.LogWarning((object)"missing: Humanoid script");
}
if ((Object)(object)m_monsterAI == (Object)null)
{
Debug.LogWarning((object)"missing: MonsterAi script");
}
if ((Object)(object)m_zview == (Object)null)
{
Debug.LogWarning((object)"missing: ZnetView script");
}
}
else
{
if (itemSets == null || itemSets.Count == 0)
{
setupItemSets();
}
setAnimatorControler();
bool @bool = m_zview.m_zdo.GetBool("humanoidRandomizerActive", false);
PickRandomSet(@bool);
setWeaponState(m_itemSetName);
m_monsterAI.m_minAttackInterval = 2f;
clearMissingFiles();
}
}
private void clearMissingFiles()
{
List<GameObject> list = new List<GameObject>();
GameObject[] defaultItems = m_humanoid.m_defaultItems;
foreach (GameObject val in defaultItems)
{
if ((Object)(object)val != (Object)null)
{
list.Add(val);
}
}
m_humanoid.m_defaultItems = list.ToArray();
List<GameObject> list2 = new List<GameObject>();
GameObject[] randomArmor = m_humanoid.m_randomArmor;
foreach (GameObject val2 in randomArmor)
{
if ((Object)(object)val2 != (Object)null)
{
list2.Add(val2);
}
}
m_humanoid.m_defaultItems = list2.ToArray();
List<GameObject> list3 = new List<GameObject>();
GameObject[] randomShield = m_humanoid.m_randomShield;
foreach (GameObject val3 in randomShield)
{
if ((Object)(object)val3 != (Object)null)
{
list3.Add(val3);
}
}
m_humanoid.m_defaultItems = list3.ToArray();
}
private void setupItemSets()
{
switch (editZnetName(((Object)this).name))
{
case "Skeleton":
itemSets = VariantTypeCheck.itemSetsSkeleton;
break;
case "Skeleton_NoArcher":
itemSets = VariantTypeCheck.itemSetsSkeletonNoArcher;
break;
case "Skeleton_Poison":
itemSets = VariantTypeCheck.itemSetsSkeletonPoison;
break;
case "Draugr":
itemSets = VariantTypeCheck.itemSetsDraugr;
break;
case "Draugr_Elite":
itemSets = VariantTypeCheck.itemSetsDraugrElite;
break;
case "Draugr_Ranged":
itemSets = VariantTypeCheck.itemSetsDraugrRanged;
break;
case "Goblin":
itemSets = VariantTypeCheck.itemSetsGoblin;
break;
case "GoblinArcher":
itemSets = VariantTypeCheck.itemSetsGoblinArcher;
break;
case "GoblinShaman":
itemSets = VariantTypeCheck.itemSetsGoblinShaman;
break;
}
}
private bool validatePrefab()
{
string[] array = new string[9] { "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman" };
bool flag = false;
string[] array2 = array;
foreach (string value in array2)
{
if (((Object)((Component)this).gameObject).name.Contains(value))
{
flag = true;
break;
}
}
if (!flag)
{
return false;
}
string name = ((Object)((Component)this).gameObject).name;
name = editZnetName(name);
return array.Contains(name);
}
private string editZnetName(string name)
{
name = name.Replace("(Clone)", "");
int num = name.IndexOf("(");
if (num >= 0)
{
name = name.Substring(0, num);
}
return name.Trim();
}
private void setAnimatorControler()
{
Animator componentInChildren = ((Component)this).gameObject.GetComponentInChildren<Animator>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.runtimeAnimatorController = sourceAnimator;
}
else
{
m_animator.runtimeAnimatorController = sourceAnimator;
}
}
private void PickRandomSet(bool chosen = false)
{
string setName = "";
if (chosen)
{
setName = m_zview.m_zdo.GetString("humanoidRandomizerSetName", "");
}
while (setName == "" || setName == null)
{
setName = getWeightedSetName();
}
if (setName == "" || setName == null)
{
Debug.LogWarning((object)"No item set found");
return;
}
ItemSet val;
for (val = itemSets.Find((ItemSet x) => x.m_name == setName); val == null; val = itemSets.Find((ItemSet x) => x.m_name == setName))
{
setName = getWeightedSetName();
}
m_zview.m_zdo.Set("humanoidRandomizerSetName", setName);
m_itemSetName = setName;
m_itemSetSimplified = setName;
List<ItemSet> list = new List<ItemSet>();
list.Add(val);
m_humanoid.m_randomSets = list.ToArray();
m_zview.m_zdo.Set("humanoidRandomizerActive", true);
}
private bool CheckBiome(Biome m_biome)
{
//IL_0006: 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_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
return (Heightmap.FindBiome(((Component)this).transform.position) & m_biome) > 0;
}
private Biome GetBiome()
{
//IL_0006: 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)
return Heightmap.FindBiome(((Component)this).transform.position);
}
private string getWeightedSetName()
{
int num = Random.Range(1, 100);
List<string> list = new List<string>();
while (list.Count == 0)
{
list = new List<string>();
foreach (KeyValuePair<string, int> weight in VariantTypeCheck.weights)
{
int id = VariantTypeCheck.biome[weight.Key];
if (IsCorrectBiome(id, editZnetName(((Object)this).name)) && weight.Value > num)
{
list.Add(weight.Key);
}
}
if (list.Count == 0)
{
num = Random.Range(1, 100);
}
}
int index = Random.Range(0, list.Count - 1);
return list[index];
}
private bool IsCorrectBiome(int id, string name)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Invalid comparison between Unknown and I4
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Invalid comparison between Unknown and I4
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Invalid comparison between Unknown and I4
if (name == "Skeleton" || name == "Skeleton_NoArcher" || name == "Skeleton_Poison")
{
switch (id)
{
case 1:
return true;
case 2:
if ((int)spawnBiome != 1)
{
return true;
}
break;
}
if (id == 3 && (int)spawnBiome != 1 && (int)spawnBiome != 8)
{
return true;
}
return false;
}
return true;
}
private int weightedRoll()
{
return Random.Range(0, itemSets.Count - 1);
}
private void setMonsterName()
{
if (((Character)m_humanoid).m_name != prototyepname() + " " + m_itemSetSimplified)
{
newName = prototyepname() + " " + m_itemSetSimplified;
((Character)m_humanoid).m_name = newName;
}
}
private string prototyepname()
{
GameObject val = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == editZnetName(((Object)((Component)this).gameObject).name));
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"Original not found");
return ((Character)m_humanoid).m_name;
}
string result = ((Character)val.GetComponent<Humanoid>()).m_name;
if (((Object)((Component)this).gameObject).name == "Skeleton_Poison")
{
result = "Rancid";
}
return result;
}
private string simplifyName(string setName)
{
if (m_itemSetName.Contains("Guardian"))
{
return "Guardian";
}
if (m_itemSetName.Contains("Marauder"))
{
return "Marauder";
}
if (m_itemSetName.Contains("Warrior"))
{
return "Warrior";
}
return setName;
}
private void setWeaponState(string setName)
{
m_animator.SetFloat("weaponStance", 0f);
switch (setName)
{
case "Sailor":
case "Bonebreaker":
case "Frozenhammer":
case "Splasher":
m_animator.SetFloat("weaponStance", 3f);
break;
case "Swordmaster":
case "Blackblade":
case "Soulcalibur":
m_animator.SetFloat("weaponStance", 2f);
break;
case "Executioner":
case "Reaper":
case "Reaver":
m_animator.SetFloat("weaponStance", 1f);
break;
case "Arbalist":
m_animator.SetFloat("weaponStance", 4f);
break;
case "Stabber":
case "Thief":
case "Assassin":
case "Savage":
case "Corsair":
case "Lightbringer":
m_animator.SetFloat("weaponStance", 5f);
break;
default:
m_animator.SetFloat("weaponStance", 0f);
break;
}
}
public void AddArmorPieces()
{
if (((Character)m_humanoid).m_level == 1 || (((Object)((Component)this).gameObject).name != "Goblin(Clone)" && ((Object)((Component)this).gameObject).name != "GoblinArcher(Clone)") || ((Character)m_humanoid).m_level == 1)
{
return;
}
List<GameObject> list = new List<GameObject>();
list.AddRange(m_humanoid.m_randomSets[0].m_items);
GameObject helmet = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinHelmet");
GameObject arms = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinArmband");
GameObject sholders = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinShoulders");
GameObject boots = ObjectDB.instance.m_items.Find((GameObject x) => ((Object)x).name == "GoblinLegband");
switch (((Character)m_humanoid).m_level)
{
case 2:
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
{
list.Add(arms);
}
break;
case 3:
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
{
list.Add(arms);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
{
list.Add(boots);
}
break;
case 4:
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
{
list.Add(arms);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
{
list.Add(boots);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null)
{
list.Add(helmet);
}
break;
case 5:
case 6:
case 7:
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)arms).name) == (Object)null)
{
list.Add(arms);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)boots).name) == (Object)null)
{
list.Add(boots);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)helmet).name) == (Object)null)
{
list.Add(helmet);
}
if ((Object)(object)list.Find((GameObject x) => ((Object)x).name == ((Object)sholders).name) == (Object)null)
{
list.Add(sholders);
}
break;
}
m_humanoid.m_randomSets[0].m_items = list.ToArray();
}
}
public class LevelEffectGenerator
{
private BaseLevelEffectSetupValue baseLevelEffectSetupValue = new BaseLevelEffectSetupValue();
public void CreateVisuals(LevelEffects levelEffects)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
baseLevelEffectSetupValue.getSetup(levelEffects);
int num = 0;
if (levelEffects.m_levelSetups != null)
{
num = levelEffects.m_levelSetups.Count;
}
int num2 = 6 - num;
for (int i = 0; i < num2; i++)
{
LevelSetup item = createSetup(baseLevelEffectSetupValue.scale, baseLevelEffectSetupValue.saturation, baseLevelEffectSetupValue.hue, baseLevelEffectSetupValue.value, baseLevelEffectSetupValue.setEmmisive, baseLevelEffectSetupValue.emissive, baseLevelEffectSetupValue.sumValue * (float)(i + 1), num2, i + 1);
levelEffects.m_levelSetups.Add(item);
}
}
public LevelEffects CreateLevelEffectAt(Transform visual, SkinnedMeshRenderer meshRenderer)
{
if ((Object)(object)meshRenderer == (Object)null)
{
return null;
}
if ((Object)(object)meshRenderer != (Object)null)
{
LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
val.m_mainRender = (Renderer)(object)meshRenderer;
val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
return val;
}
return null;
}
public LevelEffects CreateLevelEffectComponent(Transform visual)
{
SkinnedMeshRenderer[] componentsInChildren = ((Component)visual).GetComponentsInChildren<SkinnedMeshRenderer>();
if (componentsInChildren.Length > 1)
{
return null;
}
if (componentsInChildren.Length == 1)
{
LevelEffects val = ((Component)visual).gameObject.AddComponent<LevelEffects>();
val.m_mainRender = (Renderer)(object)componentsInChildren[0];
val.m_character = (Character)(object)((Component)visual.parent).gameObject.GetComponent<Humanoid>();
return val;
}
return null;
}
private LevelSetup createSetup(float scale, float saturation, float hue, float value, bool isEmmisive, Color emission, float changeValue, int maxAmount, int lvl)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
LevelSetup val = new LevelSetup();
val.m_scale = scale;
val.m_saturation = saturation + changeValue;
val.m_hue = hue + changeValue;
val.m_value = value + changeValue;
val.m_enableObject = pickEnabledObject(maxAmount, lvl);
val.m_setEmissiveColor = isEmmisive;
val.m_emissiveColor = new Color(emission.r + changeValue, emission.g + changeValue, emission.b + changeValue, emission.a);
return val;
}
private GameObject pickEnabledObject(int maxAmount, int lvl)
{
if (maxAmount == 6)
{
if (lvl > 4)
{
return baseLevelEffectSetupValue.enabledObjectLevel3;
}
if (lvl > 2)
{
return baseLevelEffectSetupValue.enabledObjectLevel2;
}
}
if (maxAmount == 3)
{
if (lvl > 3)
{
return baseLevelEffectSetupValue.enabledObjectLevel3;
}
if (lvl > 2)
{
return baseLevelEffectSetupValue.enabledObjectLevel2;
}
}
if (maxAmount < 3)
{
switch (lvl)
{
case 2:
return baseLevelEffectSetupValue.enabledObjectLevel3;
case 1:
return baseLevelEffectSetupValue.enabledObjectLevel2;
}
}
return baseLevelEffectSetupValue.enabledObject;
}
}
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.m_StatusEffects.Find((StatusEffect x) => ((Object)x).name == ((Object)status).name) == (Object)null)
{
ObjectDB.instance.m_StatusEffects.Add(status);
}
}
else
{
Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)status).name + " - Status not found"));
}
}
private void AddRecipe(Recipe recipe)
{
if (!IsObjectDBValid())
{
return;
}
if ((Object)(object)recipe != (Object)null)
{
if ((Object)(object)ObjectDB.instance.GetRecipe(recipe.m_item.m_itemData) == (Object)null)
{
ObjectDB.instance.m_recipes.Add(recipe);
}
}
else
{
Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)recipe).name + " - Recipe not found"));
}
}
private void AddItem(GameObject newPrefab)
{
if (!IsObjectDBValid())
{
return;
}
ItemDrop component = newPrefab.GetComponent<ItemDrop>();
if ((Object)(object)component != (Object)null)
{
if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
{
ObjectDB.instance.m_items.Add(newPrefab);
Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
}
}
else
{
Debug.LogError((object)("BalrondHumanoidRandomizer: " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
}
}
}
[BepInPlugin("balrond.astafaraios.BalrondHumanoidRandomizer", "BalrondHumanoidRandomizer", "1.4.0")]
public class Launch : BaseUnityPlugin
{
[HarmonyPatch(typeof(Game), "Awake")]
public static class Game_Awake_Path
{
public static void Prefix()
{
hasSpawned = false;
SetupNewHudElements();
}
}
[HarmonyPatch(typeof(MonsterAI), "Awake")]
public static class MonsterAI_Path
{
public static void Postfix(MonsterAI __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject == (Object)null) && (((Object)((Component)__instance).gameObject).name.Contains("Variant") || (Object)(object)((Component)__instance).gameObject.GetComponent<HumanoidRandomizer>() != (Object)null))
{
__instance.m_minAttackInterval = 2.5f;
}
}
}
[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
public static class Object_CopyOtherDB_Path
{
public static void Postfix()
{
if (!IsObjectDBValid())
{
return;
}
try
{
StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && ((Object)x).name == "Spirit");
if ((Object)(object)val != (Object)null && modResourceLoader != null)
{
val.m_icon = modResourceLoader.spiritBurnIcon;
}
itemEdits.editItems(ObjectDB.instance.m_items);
databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
databaseAddMethods.AddRecipes(modResourceLoader.recipes);
databaseAddMethods.AddItems(modResourceLoader.attackList);
databaseAddMethods.AddItems(modResourceLoader.visualList);
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: Object_CopyOtherDB_Path failed\n" + ex));
}
}
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
public static class ObjectDB_Awake_Path
{
public static bool hasSpawned;
public static void Postfix()
{
if (!IsObjectDBValid())
{
return;
}
try
{
StatusEffect val = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && ((Object)x).name == "Spirit");
if ((Object)(object)val != (Object)null && modResourceLoader != null)
{
val.m_icon = modResourceLoader.spiritBurnIcon;
}
itemEdits.editItems(ObjectDB.instance.m_items);
databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
databaseAddMethods.AddRecipes(modResourceLoader.recipes);
databaseAddMethods.AddItems(modResourceLoader.attackList);
databaseAddMethods.AddItems(modResourceLoader.visualList);
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: ObjectDB_Awake_Path failed\n" + ex));
}
}
}
[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
public static class CharacterDrop_GenerateDropList_Path
{
public static void Prefix(CharacterDrop __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.m_character == (Object)null) && __instance.m_character.GetLevel() >= 4)
{
__instance.m_character.SetLevel(4);
}
}
}
[HarmonyPatch(typeof(ZNetScene), "Awake")]
public static class ZNetScene_Awake_Path
{
public static void Prefix(ZNetScene __instance)
{
if ((Object)(object)__instance == (Object)null)
{
Debug.LogWarning((object)"BalrondHumanoidRandomizer: No ZnetScene found");
return;
}
try
{
modResourceLoader.AddPrefabsToZnetScene(__instance);
if (hasSpawned)
{
return;
}
pieceTargeting.changePieceTargeting(__instance.m_prefabs);
itemSetBuilder.setup(__instance.m_prefabs);
itemSetBuilder.fixAllReferences();
GameObject val = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton");
GameObject val2 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_NoArcher");
GameObject val3 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Skeleton_Poison");
GameObject val4 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr");
GameObject val5 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr_Ranged");
GameObject val6 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Draugr_Elite");
GameObject val7 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Goblin");
GameObject val8 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "GoblinArcher");
GameObject val9 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "GoblinShaman");
if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_StatusEffects != null)
{
StatusEffect val10 = ObjectDB.instance.m_StatusEffects.Find((StatusEffect x) => (Object)(object)x != (Object)null && x.m_name == "Shield_MonsterRandomizer");
if ((Object)(object)val10 != (Object)null)
{
StatusEffectBuilder.setupVisualsForStatus(val10, __instance.m_prefabs);
}
}
if ((Object)(object)val != (Object)null)
{
itemSetBuilder.CreateItemSets(val, modResourceLoader.animatorController);
}
if ((Object)(object)val2 != (Object)null)
{
itemSetBuilder.CreateItemSets(val2, modResourceLoader.animatorController);
}
if ((Object)(object)val3 != (Object)null)
{
itemSetBuilder.CreateItemSets(val3, modResourceLoader.animatorController);
}
if ((Object)(object)val4 != (Object)null)
{
itemSetBuilder.CreateItemSets(val4, modResourceLoader.animatorControllerDraugr);
}
if ((Object)(object)val5 != (Object)null)
{
itemSetBuilder.CreateItemSets(val5, modResourceLoader.animatorControllerDraugr);
}
if ((Object)(object)val6 != (Object)null)
{
itemSetBuilder.CreateItemSets(val6, modResourceLoader.animatorControllerDraugr);
}
if ((Object)(object)val7 != (Object)null)
{
itemSetBuilder.CreateItemSets(val7, modResourceLoader.animatorController);
}
if ((Object)(object)val8 != (Object)null)
{
itemSetBuilder.CreateItemSets(val8, modResourceLoader.animatorController);
}
if ((Object)(object)val9 != (Object)null)
{
itemSetBuilder.CreateItemSets(val9, modResourceLoader.animatorController);
}
addPrefabList(itemSetBuilder.prefabs, __instance.m_prefabs);
monsterManager.setupMonsterList(__instance.m_prefabs);
monsterManager.changeMonsterResistance();
monsterManager.setupSpawners(__instance.m_prefabs);
GameObject val11 = __instance.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == "Player");
if ((Object)(object)val11 != (Object)null)
{
setPlayerResistance(val11);
}
if (!((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsDedicated())
{
ShaderReplacment.runMaterialFix();
hasSpawned = true;
}
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: ZNetScene_Awake_Path failed\n" + ex));
}
}
}
[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
public static class EnemyHudUpdateHudsPatch
{
public static void Prefix(EnemyHud __instance)
{
if ((Object)(object)__instance == (Object)null || __instance.m_huds == null)
{
return;
}
if (!modDetected)
{
string key = "org.bepinex.plugins.creaturelevelcontrol";
if (Chainloader.PluginInfos.ContainsKey(key))
{
Debug.Log((object)"BalrondHumanoidRandomizer: CLLC mod assembly detected. Disabling inbuild star display");
CLLCdetected = true;
}
string key2 = "MidnightsFX.StarLevelSystem";
if (Chainloader.PluginInfos.ContainsKey(key2))
{
Debug.Log((object)"BalrondHumanoidRandomizer: StarLevelSystem mod assembly detected. Disabling inbuild star display");
StarLevelSystemDetected = true;
}
modDetected = true;
}
if (CLLCdetected || StarLevelSystemDetected)
{
return;
}
foreach (KeyValuePair<Character, HudData> hud in __instance.m_huds)
{
HudData value = hud.Value;
Character val = value?.m_character;
if (value == null || (Object)(object)val == (Object)null || (!val.IsPlayer() && !val.IsBoss() && !value.m_isMount && value.m_hoverTimer >= __instance.m_hoverShowDuration))
{
continue;
}
if ((Object)(object)value.m_gui != (Object)null)
{
value.m_gui.SetActive(true);
}
int level = val.GetLevel();
if (level >= 2)
{
bool flag = val.IsBoss();
if (!CLLCdetected && !StarLevelSystemDetected && ((flag && level <= 7) || (!flag && level >= 4 && level <= 7)))
{
SetUiStarElement(value, level, flag);
}
if (!StarLevelSystemDetected && ((flag && level <= 7) || level <= 7))
{
SetUiStarElement(value, level, flag);
}
}
}
}
}
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public static class RPC_DamagePatch
{
public static int chanceForBlunt = 1;
public static int chanceForPierce = 1;
public static int chanceForSLash = 1;
public static void Prefix(Character __instance, ref HitData hit)
{
if (hit == null)
{
return;
}
Character attacker = hit.GetAttacker();
Humanoid val = (Humanoid)(object)((attacker is Humanoid) ? attacker : null);
if ((Object)(object)val == (Object)null || ((Character)val).IsPlayer())
{
return;
}
try
{
HitData val2 = HumanoidRandomizerDamageModificator.modifyOutput(((Component)val).gameObject, hit);
if (val2 != null)
{
hit = val2;
}
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: RPC_DamagePatch failed\n" + ex));
}
}
}
private readonly Harmony harmony = new Harmony("balrond.astafaraios.BalrondHumanoidRandomizer");
public const string PluginGUID = "balrond.astafaraios.BalrondHumanoidRandomizer";
public const string PluginName = "BalrondHumanoidRandomizer";
public const string PluginVersion = "1.4.0";
public static ModResourceLoader modResourceLoader = new ModResourceLoader();
public static ItemEdits itemEdits = new ItemEdits();
public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();
public static MonsterManager monsterManager = new MonsterManager();
public static BuildPieceTargeting pieceTargeting = new BuildPieceTargeting();
public static AttachBuilder attachBuilder = new AttachBuilder();
public static ItemSetBuilder itemSetBuilder = new ItemSetBuilder();
public static HumanoidRandomizerDamageModificator HumanoidRandomizerDamageModificator = new HumanoidRandomizerDamageModificator();
public static GameObject RootObject;
public static GameObject PrefabContainer;
public static GameObject rightHand;
public static GameObject leftHand;
public static bool hasSpawned = false;
private static readonly string MainSceneName = "main";
private static readonly string GuiPath = "_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBase";
private static readonly string GuiBossPath = "_GameMain/LoadingGUI/PixelFix/IngameGui/EnemyHud/HudRoot/HudBaseBoss";
public static GameObject gui;
public static GameObject gui2;
public static bool CLLCdetected = false;
public static bool modDetected = false;
public static bool StarLevelSystemDetected = false;
public static string[] validNames = new string[10] { "Skeleton_NoArcher", "Skeleton_Poison", "Skeleton", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Goblin", "GoblinArcher", "GoblinShaman", "Surtling" };
private void Awake()
{
try
{
createPrefabContainer();
if (modResourceLoader != null)
{
modResourceLoader.loadAssets();
rightHand = modResourceLoader.rightHand;
leftHand = modResourceLoader.leftHand;
}
if (HumanoidRandomizerDamageModificator != null)
{
HumanoidRandomizerDamageModificator.setup();
}
if (attachBuilder != null)
{
attachBuilder.createPrefabContainer();
}
VariantTypeCheck.weights = VariantTypeCheck.setupChances();
VariantTypeCheck.setBiomeRestriction();
harmony.PatchAll();
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: Awake failed\n" + ex));
}
}
private void OnDestroy()
{
try
{
harmony.UnpatchSelf();
}
catch (Exception ex)
{
Debug.LogError((object)("BalrondHumanoidRandomizer: OnDestroy failed\n" + ex));
}
}
public void createPrefabContainer()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
if ((Object)(object)RootObject == (Object)null)
{
RootObject = GameObject.Find("_ValheimReforgedRoot");
}
if ((Object)(object)RootObject == (Object)null)
{
RootObject = new GameObject("_ValheimReforgedRoot");
Object.DontDestroyOnLoad((Object)(object)RootObject);
}
if ((Object)(object)PrefabContainer == (Object)null)
{
Transform val = RootObject.transform.Find("Prefabs");
if ((Object)(object)val != (Object)null)
{
PrefabContainer = ((Component)val).gameObject;
return;
}
PrefabContainer = new GameObject("Prefabs");
PrefabContainer.transform.SetParent(RootObject.transform, false);
PrefabContainer.SetActive(false);
}
}
public static GameObject cloneMe(GameObject source, string name = "")
{
if ((Object)(object)source == (Object)null)
{
Debug.LogWarning((object)"BalrondHumanoidRandomizer: cloneMe source is null");
return null;
}
if ((Object)(object)PrefabContainer == (Object)null)
{
Debug.LogWarning((object)"BalrondHumanoidRandomizer: PrefabContainer is null");
return null;
}
GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("BalrondHumanoidRandomizer: Failed to clone " + ((Object)source).name));
return null;
}
((Object)val).name = ((!string.IsNullOrEmpty(name)) ? name : ((Object)source).name);
return val;
}
private static bool IsObjectDBValid()
{
return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null && ObjectDB.instance.m_recipes != null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
}
public static void SetupNewHudElements()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != MainSceneName)
{
return;
}
if ((Object)(object)gui == (Object)null)
{
gui = GameObject.Find(GuiPath);
}
if ((Object)(object)gui2 == (Object)null)
{
gui2 = GameObject.Find(GuiBossPath);
}
if (modResourceLoader == null)
{
Debug.LogWarning((object)"Resource loader is empty!");
return;
}
SetupHud(gui, delegate
{
modResourceLoader.LoadNewStars();
}, (GameObject[])(object)new GameObject[4] { modResourceLoader.lvl4, modResourceLoader.lvl5, modResourceLoader.lvl6, modResourceLoader.lvl7 }, "I did not load the UI", default(Vector3));
SetupHud(gui2, delegate
{
modResourceLoader.LoadNewBossStars();
}, (GameObject[])(object)new GameObject[6] { modResourceLoader.lvl2boss, modResourceLoader.lvl3boss, modResourceLoader.lvl4boss, modResourceLoader.lvl5boss, modResourceLoader.lvl6boss, modResourceLoader.lvl7boss }, "I did not load the BOSS UI", default(Vector3));
}
private static void SetupHud(GameObject hud, Action loadAction, GameObject[] elements, string warning, Vector3 offset)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)hud == (Object)null)
{
Debug.LogWarning((object)warning);
return;
}
if (elements == null || elements.Length == 0)
{
Debug.LogWarning((object)"BalrondHumanoidRandomizer: SetupHud elements array is empty");
return;
}
if ((Object)(object)elements[0] == (Object)null)
{
loadAction?.Invoke();
}
foreach (GameObject val in elements)
{
if (!((Object)(object)val == (Object)null))
{
if (offset.x != 0f || offset.y != 0f || offset.z != 0f)
{
Transform transform = hud.transform;
transform.position += offset;
}
else
{
val.transform.SetParent(hud.transform, false);
}
}
}
}
public static void addStatusToAttackField(GameObject gameObject, StatusEffect statusEffect)
{
if (!((Object)(object)gameObject == (Object)null) && !((Object)(object)statusEffect == (Object)null))
{
ItemDrop component = gameObject.GetComponent<ItemDrop>();
if (!((Object)(object)component == (Object)null) && component.m_itemData != null && component.m_itemData.m_shared != null)
{
component.m_itemData.m_shared.m_equipStatusEffect = statusEffect;
}
}
}
public static void addPrefabList(List<GameObject> newList, List<GameObject> znetScene)
{
if (newList == null || znetScene == null)
{
return;
}
foreach (GameObject prefab in newList)
{
if ((Object)(object)prefab != (Object)null && znetScene.FindAll((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == ((Object)prefab).name).Count == 0)
{
znetScene.Add(prefab);
}
}
}
public List<GameObject> GeneratePrefabs(GameObject gameObject)
{
List<GameObject> list = new List<GameObject>();
if ((Object)(object)gameObject == (Object)null)
{
Debug.LogWarning((object)"BalrondHumanoidRandomizer: GeneratePrefabs gameObject is null");
return list;
}
HumanoidRandomizer component = gameObject.GetComponent<HumanoidRandomizer>();
if ((Object)(object)component == (Object)null || component.itemSets == null)
{
Debug.LogWarning((object)("BalrondHumanoidRandomizer: GeneratePrefabs no HumanoidRandomizer/itemSets on " + ((Object)gameObject).name));
return list;
}
List<ItemSet> itemSets = component.itemSets;
foreach (ItemSet item in itemSets)
{
if (item == null)
{
continue;
}
GameObject val = cloneMe(gameObject, ((Object)gameObject).name + "_Variant_" + item.m_name);
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Unable to clone: " + ((Object)gameObject).name));
continue;
}
Humanoid component2 = val.GetComponent<Humanoid>();
if ((Object)(object)component2 == (Object)null)
{
Debug.LogWarning((object)("BalrondHumanoidRandomizer: No Humanoid on cloned variant " + ((Object)val).name));
continue;
}
component2.m_defaultItems = item.m_items;
HumanoidRandomizer component3 = val.GetComponent<HumanoidRandomizer>();
if ((Object)(object)component3 != (Object)null)
{
Object.Destroy((Object)(object)component3);
}
if ((Object)(object)((Character)component2).m_animator != (Object)null)
{
switch (item.m_name)
{
case "Bonebreaker":
((Character)component2).m_animator.SetFloat("weaponStance", 3f);
break;
case "Swordmaster":
((Character)component2).m_animator.SetFloat("weaponStance", 2f);
break;
case "Executioner":
((Character)component2).m_animator.SetFloat("weaponStance", 1f);
break;
case "Arbalist":
((Character)component2).m_animator.SetFloat("weaponStance", 4f);
break;
case "Assassin":
case "Savage":
((Character)component2).m_animator.SetFloat("weaponStance", 5f);
break;
default:
((Character)component2).m_animator.SetFloat("weaponStance", 0f);
break;
}
}
list.Add(val);
}
Debug.LogWarning((object)("Generated variants: " + list.Count));
return list;
}
public static void prepareSurtling(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
return;
}
VisEquipment val = gameObject.GetComponent<VisEquipment>();
if ((Object)(object)val == (Object)null)
{
val = gameObject.AddComponent<VisEquipment>();
}
Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
Transform[] array = componentsInChildren;
foreach (Transform val2 in array)
{
if (!((Object)(object)val2 == (Object)null))
{
if ("mixamorig:RightHand" == ((Object)val2).name && (Object)(object)rightHand != (Object)null)
{
rightHand.transform.SetParent(val2, false);
}
if ("mixamorig:LeftHand" == ((Object)val2).name && (Object)(object)leftHand != (Object)null)
{
leftHand.transform.SetParent(val2, false);
}
}
}
if ((Object)(object)rightHand != (Object)null)
{
val.m_rightHand = rightHand.transform;
}
if ((Object)(object)leftHand != (Object)null)
{
val.m_leftHand = leftHand.transform;
}
}
public static void setPlayerResistance(GameObject player)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player == (Object)null))
{
Humanoid component = player.GetComponent<Humanoid>();
if (!((Object)(object)component == (Object)null))
{
((Character)component).m_damageModifiers.m_spirit = (DamageModifier)0;
}
}
}
private static void SetUiStarElement(HudData hudData, int level, bool isBoss)
{
if (hudData == null)
{
return;
}
Transform val = ((!isBoss) ? (((Object)(object)hudData.m_level2 != (Object)null) ? ((Component)hudData.m_level2).transform : null) : (((Object)(object)hudData.m_healthFast != (Object)null) ? ((Component)hudData.m_healthFast).transform : null));
if (!((Object)(object)val == (Object)null))
{
string text = (isBoss ? ("level_" + level + "_boss") : ("level_" + level));
Transform val2 = ((!isBoss) ? (((Object)(object)val.parent != (Object)null) ? val.parent.Find(text) : null) : (((Object)(object)val.parent != (Object)null && (Object)(object)val.parent.parent != (Object)null) ? val.parent.parent.Find(text) : null));
if ((Object)(object)val2 == (Object)null)
{
Debug.LogWarning((object)("[StarUI] Cannot find object: " + text));
return;
}
GameObject gameObject = ((Component)val2).gameObject;
gameObject.SetActive(true);
CopyTransform(val, gameObject.transform);
}
}
private static void CopyTransform(Transform source, Transform target)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null))
{
target.position = source.position;
target.localPosition = source.localPosition;
target.rotation = source.rotation;
}
}
}
public class ModResourceLoader
{
public AssetBundle assetBundle;
public List<Recipe> recipes = new List<Recipe>();
public List<StatusEffect> statusEffects = new List<StatusEffect>();
public Sprite spiritBurnIcon = null;
public StatusEffectBuilder statusEffectBuilder = new StatusEffectBuilder();
public List<GameObject> attackList = new List<GameObject>();
public List<GameObject> visualList = new List<GameObject>();
public List<GameObject> otherList = new List<GameObject>();
public FxReplacment fxReplacment = null;
public GameObject lvl4;
public GameObject lvl5;
public GameObject lvl6;
public GameObject lvl7;
public GameObject lvl2boss;
public GameObject lvl3boss;
public GameObject lvl4boss;
public GameObject lvl5boss;
public GameObject lvl6boss;
public GameObject lvl7boss;
public Sprite newLogo = null;
public RuntimeAnimatorController animatorController = null;
public RuntimeAnimatorController animatorControllerDraugr = null;
public GameObject rightHand;
public GameObject leftHand;
private const string BasePath = "Assets/BalrondNPC/UI/";
public void loadAssets()
{
assetBundle = GetAssetBundleFromResources("monsterrandomizer");
string text = "Assets/BalrondNPC/";
spiritBurnIcon = assetBundle.LoadAsset<Sprite>(text + "spiritburn1.png");
animatorController = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoid_randomizer.controller");
animatorControllerDraugr = assetBundle.LoadAsset<RuntimeAnimatorController>(text + "humanoidDraugr_randomizer.controller");
rightHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/RightHand_Attach_bal.prefab");
leftHand = assetBundle.LoadAsset<GameObject>(text + "Visuals/LeftHand_Attach_bal.prefab");
LoadNewStars();
LoadNewBossStars();
LoadAttacks(text);
LoadVisuals(text);
LoadOther(text);
prepareOtherEffects(text);
}
private bool EnsureAssetBundleLoaded()
{
if ((Object)(object)assetBundle == (Object)null)
{
Debug.LogWarning((object)"Asset bundle not loaded!");
assetBundle = GetAssetBundleFromResources("monsterrandomizer");
return false;
}
return true;
}
public void LoadNewStars()
{
lvl4 = LoadPrefabIfNull(lvl4, "level_4.prefab");
lvl5 = LoadPrefabIfNull(lvl5, "level_5.prefab");
lvl6 = LoadPrefabIfNull(lvl6, "level_6.prefab");
lvl7 = LoadPrefabIfNull(lvl7, "level_7.prefab");
}
public void LoadNewBossStars()
{
lvl2boss = LoadPrefabIfNull(lvl2boss, "level_2_boss.prefab");
lvl3boss = LoadPrefabIfNull(lvl3boss, "level_3_boss.prefab");
lvl4boss = LoadPrefabIfNull(lvl4boss, "level_4_boss.prefab");
lvl5boss = LoadPrefabIfNull(lvl5boss, "level_5_boss.prefab");
lvl6boss = LoadPrefabIfNull(lvl6boss, "level_6_boss.prefab");
lvl7boss = LoadPrefabIfNull(lvl7boss, "level_7_boss.prefab");
}
private GameObject LoadPrefabIfNull(GameObject current, string prefabName)
{
if ((Object)(object)current != (Object)null)
{
return current;
}
if ((Object)(object)assetBundle == (Object)null)
{
Debug.LogWarning((object)("AssetBundle is missing. Cannot load: " + prefabName));
return null;
}
GameObject val = assetBundle.LoadAsset<GameObject>("Assets/BalrondNPC/UI/" + prefabName);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("Could not load prefab: " + prefabName));
return null;
}
GameObject val2 = Launch.cloneMe(val);
val2.SetActive(false);
return val2;
}
public void AddPrefabsToZnetScene(ZNetScene zNetScene)
{
foreach (GameObject gm in attackList)
{
GameObject val = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm).name);
if ((Object)(object)val == (Object)null)
{
zNetScene.m_prefabs.Add(gm);
}
else
{
Debug.LogWarning((object)("Object exists: " + ((Object)gm).name));
}
}
foreach (GameObject gm2 in visualList)
{
GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm2).name);
if ((Object)(object)val2 == (Object)null)
{
zNetScene.m_prefabs.Add(gm2);
}
else
{
Debug.LogWarning((object)("Object exists: " + ((Object)gm2).name));
}
}
foreach (GameObject gm3 in otherList)
{
GameObject val3 = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == ((Object)gm3).name);
if ((Object)(object)val3 == (Object)null)
{
zNetScene.m_prefabs.Add(gm3);
}
else
{
Debug.LogWarning((object)("Object exists: " + ((Object)gm3).name));
}
}
zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
}
public void LoadAttacks(string mainPath)
{
string[] array = new string[43]
{
"attack_kick_unarmed_bal", "dual_pierce_bal", "dual_pierce_slash_bal", "dual_slashBLUNT_bal", "dual_slashSLASH_bal", "fireball_bal", "frostbolt_bal", "left_blade_bal", "left_blunt_bal", "left_special_bal",
"poisonbolt_bal", "right_blade_bal", "right_blunt_bal", "right_special_bal", "spiritbolt_bal", "thunderbolt_bal", "twoHand_Pierce_bal", "twoHand_slam_bal", "twoHand_slash_bal", "twoHand_spin_bal",
"twoHand_swing_bal", "twoHand_sword_bal", "twoHand_uppercutBlunt_bal", "twoHand_uppercutPierce_bal", "twoHand_uppercutSlash_bal", "left_specialBlunt_bal", "right_specialBlunt_bal", "twoHand_slamBlunt_bal", "twoHand_spinBlunt_bal", "twoHand_swingBlunt_bal",
"attack_punch_bal", "shield_slam_bal", "arbalest_shoot_bal", "spear_throw_bal", "cast_protect_caster_bal", "cast_protect_guardian_bal", "heal_base_bal", "heal_draugr_bal", "heal_goblin_bal", "poison_spray_bal",
"fire_spray_bal", "spirit_spray_bal", "firebomb_bal"
};
string[] array2 = array;
foreach (string text in array2)
{
GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Attacks/" + text + ".prefab");
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Could not find file with name: " + text));
continue;
}
ShaderReplacment.Replace(val);
val.SetActive(true);
attackList.Add(val);
}
}
public void LoadVisuals(string mainPath)
{
string[] array = new string[64]
{
"base_arbalest_bal", "base_axe_left_bal", "base_axe_right_bal", "base_bastard_bal", "base_battleaxe_bal", "base_knife_left_bal", "base_knife_right_bal", "base_mace_left_bal", "base_mace_right_bal", "base_sledge_bal",
"base_spear_bal", "base_sword_left_bal", "base_sword_right_bal", "dual_dagger_base_bal", "spellhand_left_fire_bal", "spellhand_left_ice_bal", "spellhand_left_poison_bal", "spellhand_left_spirit_bal", "spellhand_left_thunder_bal", "spellhand_right_fire_bal",
"spellhand_right_ice_bal", "spellhand_right_poison_bal", "spellhand_right_spirit_bal", "spellhand_right_thunder_bal", "spellhand_left_mage_bal", "spellhand_right_mage_bal", "dual_dagger_kick_bal", "base_torch_bal", "dual_claws_attack_bal", "dual_claws_kick_bal",
"dual_claws_pierce_bal", "dual_dagger_slash_bal", "base_saber_left_bal", "base_saber_right_bal", "base_anchor_bal", "base_staff_left_bal", "base_staff_right_bal", "base_sledge_frost_bal", "base_sledge_poison_bal", "base_curse_axe_left_bal",
"base_curse_axe_right_bal", "base_bastard_poison_bal", "base_bastard_spirit_bal", "base_battleaxe_poison_bal", "base_mace_frost_bal", "base_mace_left_frost_bal", "draugr_bow_base_bal", "draugr_bow_fire_bal", "draugr_bow_frost_bal", "draugr_bow_poison_bal",
"draugr_bow_spirit_bal", "skeleton_bow_base_bal", "skeleton_bow_fire_bal", "skeleton_bow_frost_bal", "skeleton_bow_poison_bal", "skeleton_bow_spirit_bal", "goblin_bow_base_bal", "goblin_bow_fire_bal", "goblin_bow_frost_bal", "goblin_bow_poison_bal",
"goblin_bow_spirit_bal", "base_harpoon_bal", "base_torch_right_bal", "base_battleaxe_spirit_bal"
};
string[] array2 = array;
foreach (string text in array2)
{
GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Visuals/" + text + ".prefab");
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Could not find file with name: " + text));
continue;
}
ShaderReplacment.Replace(val);
visualList.Add(val);
}
}
public void LoadOther(string mainPath)
{
string[] array = new string[36]
{
"fx_firebomb_hit", "bloodbolt_projectile", "fireball_projectile", "flamewave_ground_projectile 1", "frostbolt_projectile", "poisonbolt_projectile", "shadowbolt_projectile", "spiritbolt_projectile", "summon_projectile_skeleton", "thunderbolt_projectile",
"vfx_poisonbolt_explosion", "vfx_bloodbolt_explosion", "vfx_fireball_explosion", "vfx_frostbolt_explosion", "vfx_shadowbolt_explosion", "vfx_spiritbolt_explosion", "vfx_thunderbolt_explosion", "Protect_caster", "Protect_guardian", "spear_projectile",
"projectile_anchorNPC", "projectile_harpoonNPC", "heal_aoe", "spray_aoe_poison", "spray_aoe_fire", "spray_aoe_spirit", "firebomb_aoe", "firebomb_projectile", "vfx_spray_fire", "vfx_spray_poison",
"vfx_spray_spirit", "enemyArrowFire", "enemyArrowFrost", "enemyArrowNormal", "enemyArrowPoison", "enemyArrowSpirt"
};
string[] array2 = array;
foreach (string text in array2)
{
GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + "Projectile/" + text + ".prefab");
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Could not find file with name: " + text));
continue;
}
ShaderReplacment.Replace(val);
otherList.Add(val);
}
}
public void FixAllFx(FxReplacment fxReplacment)
{
this.fxReplacment = fxReplacment;
fixItemFX();
fixVisualFX();
fixOtherFX();
}
private void fixItemFX()
{
foreach (GameObject attack in attackList)
{
fxReplacment.ReplaceOnItem(attack);
}
}
private void fixVisualFX()
{
foreach (GameObject visual in visualList)
{
fxReplacment.ReplaceOnItem(visual);
}
}
private void fixOtherFX()
{
foreach (GameObject other in otherList)
{
fxReplacment.ReplaceOnObject(other);
}
}
private void prepareOtherEffects(string mainPath)
{
SE_bleed statusEffect = ScriptableObject.CreateInstance<SE_bleed>();
statusEffectBuilder.setBleedingStatus(statusEffect, assetBundle.LoadAsset<Sprite>(mainPath + "bleeding_Status_ico1.png"));
SE_LevelShield statusEffect2 = ScriptableObject.CreateInstance<SE_LevelShield>();
statusEffectBuilder.setShieldStatus(statusEffect2, assetBundle.LoadAsset<Sprite>(mainPath + "shieldMonster.png"));
SE_pierced statusEffect3 = ScriptableObject.CreateInstance<SE_pierced>();
statusEffectBuilder.setPiercedStatus(statusEffect3, assetBundle.LoadAsset<Sprite>(mainPath + "pierced_Status_ico1.png"));
SE_crushed statusEffect4 = ScriptableObject.CreateInstance<SE_crushed>();
statusEffectBuilder.setCrushedStatus(statusEffect4, assetBundle.LoadAsset<Sprite>(mainPath + "crushed_Status_ico1.png"));
statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_base.asset"));
statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_draugr.asset"));
statusEffects.Add(assetBundle.LoadAsset<StatusEffect>(mainPath + "status/heal_goblin.asset"));
statusEffects.AddRange(statusEffectBuilder.statusEffects);
}
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 MonsterManager
{
private GameObject levelEffects = null;
private GameObject stealEffect = null;
private LevelEffectGenerator levelEffectGenerator = new LevelEffectGenerator();
private List<GameObject> monsters;
private List<GameObject> list;
private string[] names = new string[0];
private string[] thiefName = new string[14]
{
"Greyling", "Greydwarf", "Greydwarf_Elite", "Draugr", "Draugr_Elite", "Draugr_Ranged", "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", "Forsaken",
"GoblinBrute", "GoblinArcher", "Goblin", "GoblinShaman"
};
public void SetVfx(GameObject levelEffects, GameObject stealEffect)
{
this.levelEffects = levelEffects;
this.stealEffect = stealEffect;
}
public void setupMonsterList(List<GameObject> list)
{
if (list == null)
{
Debug.LogWarning((object)"I DID NOT FOUND PREFAB LIST!");
return;
}
this.list = list;
monsters = list.FindAll((GameObject x) => (Object)(object)x.GetComponent<MonsterAI>() != (Object)null);
}
public void changeMonsterResistance()
{
if (monsters == null)
{
Debug.LogWarning((object)"I DID NOT FOUND ANY MONSTERS!");
return;
}
foreach (GameObject monster in monsters)
{
Humanoid component = monster.GetComponent<Humanoid>();
SetupLevelVisual(monster);
if ((Object)(object)component != (Object)null)
{
changeResistanceForException(component);
}
}
changeMonsterDrops();
}
private void setupHumanoidExtended(GameObject gameObject)
{
HumanoidExtend humanoidExtend = gameObject.AddComponent<HumanoidExtend>();
humanoidExtend.levelingEnabled = true;
humanoidExtend.levelUpEffect = levelEffects;
humanoidExtend.stealEffect = stealEffect;
if (thiefName.Contains(((Object)gameObject).name))
{
humanoidExtend.canSteal = true;
}
}
private void SetupLevelVisual(GameObject gameObject)
{
Transform visual = gameObject.transform.Find("Visual");
LevelEffects val = gameObject.GetComponentInChildren<LevelEffects>();
bool flag = true;
string[] source = new string[15]
{
"Lox", "Wraith", "TentaRoot", "TheHive", "Hatchling", "GoblinKing", "Eikthyr", "Bonemass", "Frog", "Haugbui",
"Greydwarf_Mystic", "Varsvin", "Varsvin_Brute", "Varsvin_Hunter", "SeekerQueen"
};
if (((Object)gameObject).name == "TheHive" || ((Object)gameObject).name == "Haugbui" || ((Object)gameObject).name == "Greydwarf_Mystic")
{
return;
}
if (source.Contains(((Object)gameObject).name))
{
Transform val2 = null;
switch (((Object)gameObject).name)
{
case "Lox":
val2 = gameObject.transform.Find("Visual/offset/Body");
break;
case "Wraith":
val2 = gameObject.transform.Find("Visual/wraith/wraith");
break;
case "TentaRoot":
val2 = gameObject.transform.Find("Visual/Tentaroots/Cube.001");
break;
case "Hatchling":
val2 = gameObject.transform.Find("Visual/Hatchling_mountain/Hatchling");
break;
case "GoblinKing":
val2 = gameObject.transform.Find("Visual/Yagluth");
break;
case "Eikthyr":
val2 = gameObject.transform.Find("Visual/Deer");
break;
case "Bonemass":
val2 = gameObject.transform.Find("Visual/model/bonemass");
break;
case "Varsvin":
case "Varsvin_Brute":
case "Varsvin_Hunter":
val2 = gameObject.transform.Find("Visual/Body");
break;
case "Frog":
val2 = gameObject.transform.Find("Visual/Frog2_mesh");
break;
case "Haugbui":
val2 = gameObject.transform.Find("Visual/Frog2_mesh");
break;
case "Greydwarf_Mystic":
val2 = gameObject.transform.Find("Visual/Frog2_mesh");
break;
case "SeekerQueen":
val2 = gameObject.transform.Find("Visual/Cube");
break;
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
val = levelEffectGenerator.CreateLevelEffectAt(visual, ((Component)val2).GetComponent<SkinnedMeshRenderer>());
}
else if (flag && (Object)(object)val == (Object)null)
{
val = levelEffectGenerator.CreateLevelEffectComponent(visual);
}
if ((Object)(object)val != (Object)null)
{
levelEffectGenerator.CreateVisuals(val);
}
}
private void editMonsterHealth(GameObject gameObject, int health)
{
Humanoid component = gameObject.GetComponent<Humanoid>();
((Character)component).m_health = health;
}
private void changeSpiritResistance(Humanoid humanoid)
{
//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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected I4, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
Faction faction = ((Character)humanoid).m_faction;
Faction val = faction;
switch (val - 1)
{
case 0:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
break;
case 1:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)1;
break;
case 5:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
break;
case 2:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)2;
break;
case 3:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)2;
break;
case 6:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)0;
break;
case 4:
((Character)humanoid).m_damageModifiers.m_spirit = (DamageModifier)5;
break;
}
}
private void changeResistanceForException(Humanoid humanoid)
{
changeSpiritResistance(humanoid);
}
public void setupSpawners(List<GameObject> list)
{
GameObject val = list.Find((GameObject x) => ((Object)x).name == "BonePileSpawner");
GameObject val2 = list.Find((GameObject x) => ((Object)x).name == "Spawner_DraugrPile");
GameObject val3 = list.Find((GameObject x) => ((Object)x).name == "Spawner_GreydwarfNest");
SpawnArea component = val.GetComponent<SpawnArea>();
if (component.m_farRadius != 1001f)
{
AddMonsterToSpawner(component, "Skeleton_Poison", 2, 0.6f);
AddMonsterToSpawner(component, "Ghost", 2, 0.6f);
}
SpawnArea component2 = val2.GetComponent<SpawnArea>();
if (component2.m_farRadius != 1001f)
{
AddMonsterToSpawner(component2, "Wraith", 2, 0.5f);
AddMonsterToSpawner(component2, "Draugr_Elite", 2, 3f);
AddMonsterToSpawner(component2, "Ghost", 2, 4f);
}
SpawnArea component3 = val3.GetComponent<SpawnArea>();
if (component3.m_farRadius != 1001f)
{
AddMonsterToSpawner(component3, "Greyling", 3, 4f);
}
changeSpawners(val);
changeSpawners(val2);
changeSpawners(val3, 6);
}
private void AddMonsterToSpawner(SpawnArea spawnArea, string prefabName, int maxLevel, float chance)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
SpawnData val = new SpawnData();
val.m_maxLevel = maxLevel;
val.m_weight = chance;
val.m_minLevel = 1;
val.m_prefab = list.Find((GameObject x) => ((Object)x).name == prefabName);
spawnArea.m_prefabs.Add(val);
}
private DropData prepareDrop(GameObject item, int min, int max, float chance)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid