Decompiled source of ValheimSpaceMarineMod v3.0.2

ValheimSpaceMarineMod.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Valheim Space Marine Mod")]
[assembly: AssemblyFileVersion("3.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.0.0")]
[module: UnverifiableCode]
namespace ValheimSpaceMarineMod;

public static class BalanceConfig
{
	public static ConfigEntry<bool> BossGating;

	public static ConfigEntry<int> StartingRequisition;

	public static ConfigEntry<float> XpScale;

	public static ConfigEntry<float> DamageScale;

	public static ConfigEntry<float> BossDamageScale;

	public static ConfigEntry<bool> FriendlyFire;

	public static ConfigEntry<bool> InfiniteEitr;

	public static ConfigEntry<float> ArmorStatScale;

	public static ConfigEntry<int> AllyRequiredTier;

	public static ConfigEntry<float> AllyCooldown;

	public static ConfigEntry<float> AllyHealth;

	public static ConfigEntry<float> AllyLifetime;

	public static ConfigEntry<float> AllyEarlyPower;

	public static ConfigEntry<bool> ClampShawItems;

	public static ConfigEntry<bool> ClampShawRecipes;

	public static ConfigEntry<KeyCode> KeyArmor;

	public static ConfigEntry<KeyCode> KeyArmory;

	public static ConfigEntry<KeyCode> KeyCycleWeapon;

	public static ConfigEntry<KeyCode> KeyDropPod;

	public static void Bind(ConfigFile c)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Expected O, but got Unknown
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Expected O, but got Unknown
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Expected O, but got Unknown
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Expected O, but got Unknown
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Expected O, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Expected O, but got Unknown
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Expected O, but got Unknown
		BossGating = c.Bind<bool>("1. Progression", "BossGating", true, "Оружие, ранги брони и союзник открываются только после победы над боссами Вальхейма (Эйктюр, Древний, Костемас, Модер, Яглут, Королева). false = только очки реквизиции.");
		StartingRequisition = c.Bind<int>("1. Progression", "StartingRequisition", 40, new ConfigDescription("Очки реквизиции нового персонажа.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5000), Array.Empty<object>()));
		XpScale = c.Bind<float>("1. Progression", "XpScale", 1f, new ConfigDescription("Множитель получаемого опыта и очков реквизиции.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		DamageScale = c.Bind<float>("2. Combat", "DamageScale", 1f, new ConfigDescription("Общий множитель урона оружия 40k (1.0 = сбалансировано под ваниль).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
		BossDamageScale = c.Bind<float>("2. Combat", "BossDamageScale", 0.6f, new ConfigDescription("Множитель урона по боссам для оружия 40k (снарядов, огнемёта, вирусной бомбы).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
		FriendlyFire = c.Bind<bool>("2. Combat", "FriendlyFire", false, "false = оружие 40k не бьёт постройки игроков, прирученных животных, союзников и игроков без PvP.");
		InfiniteEitr = c.Bind<bool>("3. Armor", "InfiniteEitr", false, "true = как в версии 2.0: в силовой броне Eitr всегда 50.");
		ArmorStatScale = c.Bind<float>("3. Armor", "ArmorStatScale", 1f, new ConfigDescription("Множитель бонусов силовой брони (здоровье, броня, выносливость, регенерация).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
		AllyRequiredTier = c.Bind<int>("4. Ally", "RequiredTier", 0, new ConfigDescription("Тир, с которого доступен дроп-под с союзником (0 = сразу, 3 = после Костемаса).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 7), Array.Empty<object>()));
		AllyCooldown = c.Bind<float>("4. Ally", "CooldownSeconds", 600f, new ConfigDescription("Перезарядка вызова союзника, секунды.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 7200f), Array.Empty<object>()));
		AllyHealth = c.Bind<float>("4. Ally", "Health", 500f, new ConfigDescription("Здоровье союзника (в версии 2.0 было 1500).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 5000f), Array.Empty<object>()));
		AllyLifetime = c.Bind<float>("4. Ally", "LifetimeSeconds", 180f, new ConfigDescription("Через сколько секунд союзник уходит.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 3600f), Array.Empty<object>()));
		AllyEarlyPower = c.Bind<float>("4. Ally", "EarlyPower", 0.3f, new ConfigDescription("Сила союзника до первого босса (множитель здоровья и урона); растёт до 1.0 к тиру 3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
		ClampShawItems = c.Bind<bool>("5. Shawesomes items", "ClampItemStats", true, "Привести характеристики предметов Shawesomes_Warhammer40k к уровню ванильных тиров (урон, блок, броня, прочность, еда).");
		ClampShawRecipes = c.Bind<bool>("5. Shawesomes items", "ClampRecipes", true, "Если у предметов Shawesomes есть рецепты — заменить материалы на ванильные по тирам.");
		KeyArmor = c.Bind<KeyCode>("6. Keys", "ToggleArmor", (KeyCode)98, "Надеть/снять силовую броню.");
		KeyArmory = c.Bind<KeyCode>("6. Keys", "Armory", (KeyCode)118, "Открыть арсенал (также F8).");
		KeyCycleWeapon = c.Bind<KeyCode>("6. Keys", "CycleWeapon", (KeyCode)103, "Следующее оружие.");
		KeyDropPod = c.Bind<KeyCode>("6. Keys", "DropPod", (KeyCode)110, "Вызвать дроп-под с союзником.");
	}
}
public class FxFade : MonoBehaviour
{
	public float duration = 0.2f;

	public float startIntensity;

	public float startWidth;

	private float t;

	private Light light;

	private LineRenderer line;

	private void Awake()
	{
		light = ((Component)this).GetComponent<Light>();
		line = ((Component)this).GetComponent<LineRenderer>();
		if ((Object)(object)light != (Object)null)
		{
			startIntensity = light.intensity;
		}
		if ((Object)(object)line != (Object)null)
		{
			startWidth = line.startWidth;
		}
	}

	private void Update()
	{
		t += Time.deltaTime;
		float num = Mathf.Clamp01(1f - t / Mathf.Max(0.01f, duration));
		if ((Object)(object)light != (Object)null)
		{
			light.intensity = startIntensity * num;
		}
		if ((Object)(object)line != (Object)null)
		{
			line.startWidth = startWidth * num;
			line.endWidth = startWidth * num * 0.5f;
		}
		if (t >= duration)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public static class Fx
{
	private static Material mat;

	private static Texture2D soft;

	private static Material GetMat()
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mat != (Object)null)
		{
			return mat;
		}
		Shader val = null;
		string[] array = new string[7] { "Legacy Shaders/Particles/Additive", "Particles/Additive", "Mobile/Particles/Additive", "Particles/Standard Unlit", "Sprites/Default", "Unlit/Color", "Hidden/Internal-Colored" };
		for (int i = 0; i < array.Length; i++)
		{
			val = Shader.Find(array[i]);
			if ((Object)(object)val != (Object)null)
			{
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		mat = new Material(val);
		mat.mainTexture = (Texture)(object)SoftTex();
		if (mat.HasProperty("_TintColor"))
		{
			mat.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f, 0.5f));
		}
		mat.renderQueue = 3000;
		return mat;
	}

	private static Texture2D SoftTex()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)soft != (Object)null)
		{
			return soft;
		}
		int num = 32;
		soft = new Texture2D(num, num, (TextureFormat)4, false);
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num2 = ((float)j + 0.5f) / (float)num * 2f - 1f;
				float num3 = ((float)i + 0.5f) / (float)num * 2f - 1f;
				float num4 = Mathf.Clamp01(1f - Mathf.Sqrt(num2 * num2 + num3 * num3));
				num4 *= num4;
				soft.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
			}
		}
		soft.Apply();
		return soft;
	}

	public static void Flash(Vector3 pos, Color c, float range, float intensity, float time)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			GameObject val = new GameObject("WHFlash");
			val.transform.position = pos;
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = c;
			obj.range = range;
			obj.intensity = intensity;
			obj.shadows = (LightShadows)0;
			val.AddComponent<FxFade>().duration = time;
		}
		catch
		{
		}
	}

	public static void Burst(Vector3 pos, Vector3 dir, Color c, int count, float speed, float size, float life, float angle, float gravity)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Expected O, but got Unknown
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Material val = GetMat();
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("WHBurst");
				val2.SetActive(false);
				val2.transform.position = pos;
				if (((Vector3)(ref dir)).sqrMagnitude > 0.001f)
				{
					val2.transform.rotation = Quaternion.LookRotation(dir);
				}
				ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
				MainModule main = val3.main;
				((MainModule)(ref main)).duration = 0.5f;
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).playOnAwake = true;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.6f, life);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(speed * 0.4f, speed);
				((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.5f, size);
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(c);
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(gravity);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).maxParticles = Mathf.Max(8, count * 2);
				EmissionModule emission = val3.emission;
				((EmissionModule)(ref emission)).enabled = true;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
				{
					new Burst(0f, (short)count)
				});
				ShapeModule shape = val3.shape;
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
				((ShapeModule)(ref shape)).angle = angle;
				((ShapeModule)(ref shape)).radius = 0.05f;
				ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				Gradient val4 = new Gradient();
				val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(Color.white, 0f),
					new GradientColorKey(new Color(1f, 0.6f, 0.4f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(1f, 0f),
					new GradientAlphaKey(0f, 1f)
				});
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
				SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.1f));
				ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>();
				((Renderer)component).material = val;
				component.renderMode = (ParticleSystemRenderMode)0;
				val2.SetActive(true);
				Object.Destroy((Object)(object)val2, life + 1f);
			}
		}
		catch
		{
		}
	}

	public static void Stream(Vector3 pos, Vector3 dir, Color c, float rate, float speed, float size, float life, float angle, float duration)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Expected O, but got Unknown
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Material val = GetMat();
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("WHStream");
				val2.SetActive(false);
				val2.transform.position = pos;
				val2.transform.rotation = Quaternion.LookRotation(dir);
				ParticleSystem val3 = val2.AddComponent<ParticleSystem>();
				MainModule main = val3.main;
				((MainModule)(ref main)).duration = duration;
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).playOnAwake = true;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(life * 0.7f, life);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(speed * 0.6f, speed);
				((MainModule)(ref main)).startSize = new MinMaxCurve(size * 0.6f, size);
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(c);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				EmissionModule emission = val3.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
				ShapeModule shape = val3.shape;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
				((ShapeModule)(ref shape)).angle = angle;
				((ShapeModule)(ref shape)).radius = 0.1f;
				ColorOverLifetimeModule colorOverLifetime = val3.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				Gradient val4 = new Gradient();
				val4.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(Color.white, 0f),
					new GradientColorKey(new Color(1f, 0.25f, 0.1f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(0.9f, 0f),
					new GradientAlphaKey(0f, 1f)
				});
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val4);
				SizeOverLifetimeModule sizeOverLifetime = val3.sizeOverLifetime;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.4f, 1f, 1.6f));
				((Renderer)val2.GetComponent<ParticleSystemRenderer>()).material = val;
				val2.SetActive(true);
				Object.Destroy((Object)(object)val2, duration + life + 0.5f);
			}
		}
		catch
		{
		}
	}

	public static void Trail(GameObject go, Color c, float width, float time)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Material val = GetMat();
			if (!((Object)(object)val == (Object)null))
			{
				TrailRenderer obj = go.AddComponent<TrailRenderer>();
				((Renderer)obj).material = val;
				obj.time = time;
				obj.startWidth = width;
				obj.endWidth = 0f;
				obj.startColor = c;
				obj.endColor = new Color(c.r, c.g, c.b, 0f);
				obj.minVertexDistance = 0.1f;
				obj.alignment = (LineAlignment)0;
			}
		}
		catch
		{
		}
	}

	public static void Beam(Vector3 from, Vector3 to, Color c, float width, float time)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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)
		try
		{
			Material val = GetMat();
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("WHBeam");
				LineRenderer obj = val2.AddComponent<LineRenderer>();
				((Renderer)obj).material = val;
				obj.positionCount = 2;
				obj.SetPosition(0, from);
				obj.SetPosition(1, to);
				obj.startWidth = width;
				obj.endWidth = width * 0.5f;
				obj.startColor = c;
				obj.endColor = c;
				obj.useWorldSpace = true;
				val2.AddComponent<FxFade>().duration = time;
			}
		}
		catch
		{
		}
	}

	public static void Lightning(Vector3 pos, Color c, int arcs, float radius)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_003f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Material val = GetMat();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			for (int i = 0; i < arcs; i++)
			{
				GameObject val2 = new GameObject("WHArc");
				LineRenderer val3 = val2.AddComponent<LineRenderer>();
				((Renderer)val3).material = val;
				int num = (val3.positionCount = 6);
				Vector3 val4 = Random.onUnitSphere * radius;
				for (int j = 0; j < num; j++)
				{
					float num3 = (float)j / (float)(num - 1);
					val3.SetPosition(j, pos + val4 * (num3 * 2f - 1f) + Random.insideUnitSphere * radius * 0.25f);
				}
				val3.startWidth = 0.05f;
				val3.endWidth = 0.02f;
				val3.startColor = Color.white;
				val3.endColor = c;
				val3.useWorldSpace = true;
				val2.AddComponent<FxFade>().duration = 0.14f;
			}
		}
		catch
		{
		}
	}

	private static bool IsBolt(string id)
	{
		if (!id.Contains("bolt"))
		{
			return id == "shotgun";
		}
		return true;
	}

	public static void Muzzle(Vector3 pos, Vector3 dir, WeaponDef w)
	{
		//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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		Color fxColor = w.fxColor;
		float num = 1f;
		if (w.id == "lascannon" || w.id == "multimelta" || w.id == "plasmarifle")
		{
			num = 1.6f;
		}
		Flash(pos, fxColor, 9f * num, 5f * num, 0.08f);
		Burst(pos, dir, new Color(1f, 0.85f, 0.5f), 10, 7f * num, 0.18f * num, 0.18f, 18f, 0f);
		if (IsBolt(w.id))
		{
			Burst(pos - dir * 0.3f, Vector3.up + dir * -0.3f, new Color(1f, 0.7f, 0.2f), 3, 3f, 0.05f, 0.5f, 25f, 1f);
		}
	}

	public static void ProjectileStyle(GameObject go, WeaponDef w)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		string id = w.id;
		if (id == "lascannon")
		{
			Trail(go, new Color(1f, 0.15f, 0.2f), 0.3f, 0.18f);
		}
		else if (id == "multimelta")
		{
			Trail(go, new Color(1f, 0.5f, 0.1f), 0.35f, 0.25f);
		}
		else if (id.Contains("plasma"))
		{
			Trail(go, new Color(0.3f, 0.8f, 1f), 0.35f, 0.3f);
		}
		else if (id.Contains("needle"))
		{
			Trail(go, new Color(0.3f, 1f, 0.4f), 0.05f, 0.2f);
		}
		else
		{
			Trail(go, new Color(1f, 0.7f, 0.25f), 0.12f, 0.22f);
		}
	}

	public static void Explosion(Vector3 pos, WeaponDef w, float radius)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		string id = w.id;
		_ = w.fxColor;
		if (id.Contains("plasma"))
		{
			Flash(pos, new Color(0.4f, 0.85f, 1f), radius * 3f, 10f, 0.35f);
			Burst(pos, Vector3.up, new Color(0.5f, 0.9f, 1f), 8, 0.3f, radius * 1.1f, 0.35f, 180f, 0f);
			Burst(pos, Vector3.up, new Color(0.6f, 0.95f, 1f), 40, 9f, 0.15f, 0.6f, 180f, 0f);
			Lightning(pos, new Color(0.5f, 0.9f, 1f), 3, radius * 0.5f);
		}
		else if (id == "lascannon")
		{
			Flash(pos, new Color(1f, 0.2f, 0.3f), radius * 3f, 9f, 0.25f);
			Burst(pos, Vector3.up, new Color(1f, 0.3f, 0.4f), 5, 0.2f, radius, 0.25f, 180f, 0f);
			Burst(pos, Vector3.up, Color.white, 25, 12f, 0.1f, 0.4f, 60f, 0.3f);
		}
		else if (id == "multimelta")
		{
			Flash(pos, new Color(1f, 0.5f, 0.1f), radius * 3f, 9f, 0.4f);
			Burst(pos, Vector3.up, new Color(1f, 0.55f, 0.15f), 14, 3f, radius * 0.9f, 0.7f, 100f, -0.1f);
			Burst(pos, Vector3.up, new Color(1f, 0.9f, 0.5f), 30, 8f, 0.12f, 0.5f, 120f, 0.5f);
		}
		else if (id.Contains("needle"))
		{
			Burst(pos, Vector3.up, new Color(0.3f, 1f, 0.4f), 14, 2.5f, 0.35f, 0.7f, 120f, -0.1f);
			Flash(pos, new Color(0.3f, 1f, 0.4f), 4f, 2f, 0.12f);
		}
		else
		{
			Flash(pos, new Color(1f, 0.6f, 0.2f), radius * 3f, 8f, 0.18f);
			Burst(pos, Vector3.up, new Color(1f, 0.55f, 0.15f), 6, 0.6f, radius * 0.7f, 0.25f, 180f, 0f);
			Burst(pos, Vector3.up, new Color(1f, 0.85f, 0.4f), 18, 7f, 0.1f, 0.45f, 180f, 0.8f);
		}
	}

	public static void MeleeHit(Vector3 pos, Vector3 dir, WeaponDef w)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		string id = w.id;
		if (id.StartsWith("chain"))
		{
			Burst(pos, -dir + Vector3.up * 0.3f, new Color(1f, 0.8f, 0.3f), 22, 6f, 0.07f, 0.45f, 35f, 1f);
			Flash(pos, new Color(1f, 0.7f, 0.2f), 4f, 2.5f, 0.08f);
			return;
		}
		int num;
		switch (id)
		{
		case "combatknife":
			Burst(pos, -dir, new Color(1f, 0.9f, 0.7f), 6, 3f, 0.05f, 0.25f, 30f, 0.5f);
			return;
		case "crozius":
		case "relicblade":
		case "guardianspear":
			Flash(pos, new Color(1f, 0.9f, 0.4f), 6f, 4f, 0.18f);
			Burst(pos, Vector3.up, new Color(1f, 0.9f, 0.5f), 18, 4f, 0.12f, 0.5f, 180f, -0.1f);
			Lightning(pos, new Color(1f, 0.9f, 0.4f), 2, 0.6f);
			return;
		default:
			num = ((id == "powerfist") ? 1 : 0);
			break;
		case "thunderhammer":
			num = 1;
			break;
		}
		bool flag = (byte)num != 0;
		Flash(pos, new Color(0.4f, 0.8f, 1f), flag ? 9f : 6f, flag ? 7f : 4f, 0.18f);
		Lightning(pos, new Color(0.4f, 0.8f, 1f), flag ? 5 : 3, flag ? 1.2f : 0.7f);
		Burst(pos, Vector3.up, new Color(0.5f, 0.9f, 1f), flag ? 30 : 14, 6f, 0.1f, 0.4f, 180f, 0.3f);
	}
}
public class LifeEaterVirusController : MonoBehaviour
{
	public const float Radius = 15f;

	public Player owner;

	public float baseDamage = 100f;

	private float endTime;

	private float nextTick;

	private void Start()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Expected O, but got Unknown
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		endTime = Time.time + 15f;
		AudioSource.PlayClipAtPoint(SpaceMarineSound.BoltExplodeClip, ((Component)this).transform.position, 1.5f);
		Light obj = ((Component)this).gameObject.AddComponent<Light>();
		obj.type = (LightType)2;
		obj.color = new Color(0.1f, 1f, 0.2f);
		obj.range = 22f;
		obj.intensity = 6f;
		Fx.Burst(((Component)this).transform.position, Vector3.up, new Color(0.2f, 1f, 0.3f), 60, 14f, 1.4f, 1.2f, 180f, 0f);
		Fx.Stream(((Component)this).transform.position + Vector3.up * 0.5f, Vector3.up, new Color(0.25f, 1f, 0.35f), 40f, 2.5f, 2.2f, 2.5f, 80f, 14f);
		List<IDestructible> list = new List<IDestructible>();
		Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 15f);
		foreach (Collider val in array)
		{
			if (!Targeting.CanDamage((Component)(object)val, owner))
			{
				continue;
			}
			IDestructible componentInParent = ((Component)val).GetComponentInParent<IDestructible>();
			if (componentInParent != null && !list.Contains(componentInParent))
			{
				list.Add(componentInParent);
				float num = Targeting.DamageFactor((Component)(object)val);
				HitData val2 = new HitData();
				val2.m_point = ((Component)this).transform.position;
				val2.m_damage.m_poison = baseDamage * num;
				val2.m_damage.m_fire = baseDamage * 0.4f * num;
				val2.m_pushForce = 80f;
				if ((Object)(object)owner != (Object)null)
				{
					val2.SetAttacker((Character)(object)owner);
				}
				componentInParent.Damage(val2);
			}
		}
	}

	private void Update()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Expected O, but got Unknown
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		if (Time.time >= endTime)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		else
		{
			if (Time.time < nextTick)
			{
				return;
			}
			nextTick = Time.time + 1f;
			HashSet<Character> hashSet = new HashSet<Character>();
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 15f);
			foreach (Collider val in array)
			{
				Character componentInParent = ((Component)val).GetComponentInParent<Character>();
				if (!((Object)(object)componentInParent == (Object)null) && !hashSet.Contains(componentInParent) && Targeting.CanDamage((Component)(object)val, owner))
				{
					hashSet.Add(componentInParent);
					HitData val2 = new HitData();
					val2.m_damage.m_poison = baseDamage * 0.12f * Targeting.DamageFactor((Component)(object)val);
					val2.m_point = ((Component)this).transform.position;
					if ((Object)(object)owner != (Object)null)
					{
						val2.SetAttacker((Character)(object)owner);
					}
					componentInParent.Damage(val2);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "Damage")]
public static class Character_Damage_Patch
{
	[HarmonyPrefix]
	public static void Prefix(Character __instance, HitData hit)
	{
		if (hit != null && SpaceMarinePlugin.IsArmorActive && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)SpaceMarinePlugin.Progression == (Object)null) && (Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
		{
			((DamageTypes)(ref hit.m_damage)).Modify(SpaceMarinePlugin.Progression.GetCurrentDamageMultiplier());
		}
	}
}
[HarmonyPatch(typeof(Character), "Damage")]
public static class Character_Damage_Fx_Patch
{
	[HarmonyPrefix]
	public static void Prefix(Character __instance, HitData hit)
	{
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		if (hit == null)
		{
			return;
		}
		Character attacker = hit.GetAttacker();
		if ((Object)(object)attacker == (Object)null)
		{
			return;
		}
		AllyMarker component = ((Component)attacker).GetComponent<AllyMarker>();
		if ((Object)(object)component != (Object)null)
		{
			((DamageTypes)(ref hit.m_damage)).Modify(component.damageScale);
		}
		else if (!((Object)(object)attacker != (Object)(object)Player.m_localPlayer) && SpaceMarinePlugin.IsArmorActive && !((Object)(object)SpaceMarinePlugin.Progression == (Object)null))
		{
			WeaponDef weaponDef = WarhammerArmory.Get(SpaceMarinePlugin.Progression.data.activeWeaponId);
			if (weaponDef != null && !weaponDef.isRanged && !((Object)(object)__instance == (Object)null))
			{
				Fx.MeleeHit((hit.m_point != Vector3.zero) ? hit.m_point : (((Component)__instance).transform.position + Vector3.up), hit.m_dir, weaponDef);
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "OnDeath")]
public static class Character_OnDeath_Patch
{
	[HarmonyPostfix]
	public static void Postfix(Character __instance)
	{
		if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance == (Object)(object)Player.m_localPlayer) && !((Object)(object)SpaceMarinePlugin.Progression == (Object)null))
		{
			Character val = null;
			try
			{
				object? obj = AccessTools.Field(typeof(Character), "m_lastHit")?.GetValue(__instance);
				HitData val2 = (HitData)((obj is HitData) ? obj : null);
				val = ((val2 != null) ? val2.GetAttacker() : null);
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)(object)Player.m_localPlayer && !__instance.IsTamed())
			{
				SpaceMarinePlugin.Progression.OnEnemyKilled(__instance);
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "GetBodyArmor")]
public static class Player_GetBodyArmor_Patch
{
	[HarmonyPostfix]
	public static void Postfix(Player __instance, ref float __result)
	{
		if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && SpaceMarinePlugin.IsArmorActive && (Object)(object)SpaceMarinePlugin.Progression != (Object)null)
		{
			__result += SpaceMarinePlugin.Progression.GetCurrentArmorBonus();
		}
	}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class Player_GetTotalFoodValue_Patch
{
	[HarmonyPostfix]
	public static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
	{
		if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && SpaceMarinePlugin.IsArmorActive && (Object)(object)SpaceMarinePlugin.Progression != (Object)null)
		{
			hp += SpaceMarinePlugin.Progression.GetCurrentHealthBonus();
			stamina += SpaceMarinePlugin.Progression.GetCurrentStaminaBonus();
		}
	}
}
[HarmonyPatch(typeof(Player), "PlacePiece")]
public static class Player_PlacePiece_Patch
{
	[HarmonyPostfix]
	public static void Postfix(Piece piece)
	{
		if ((Object)(object)piece != (Object)null && (Object)(object)SpaceMarinePlugin.Progression != (Object)null)
		{
			SpaceMarinePlugin.Progression.OnBuilt();
		}
	}
}
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
public static class InventoryGui_DoCrafting_Patch
{
	[HarmonyPostfix]
	public static void Postfix()
	{
		if ((Object)(object)SpaceMarinePlugin.Progression != (Object)null)
		{
			SpaceMarinePlugin.Progression.OnCrafted();
		}
	}
}
[HarmonyPatch(typeof(Player), "TakeInput")]
public static class Player_TakeInput_Patch
{
	[HarmonyPrefix]
	public static bool Prefix(ref bool __result)
	{
		if ((Object)(object)SpaceMarinePlugin.ArmoryUI != (Object)null && SpaceMarinePlugin.ArmoryUI.IsWindowOpen)
		{
			__result = false;
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
public static class GameCamera_UpdateCamera_Patch
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		if ((Object)(object)SpaceMarinePlugin.ArmoryUI != (Object)null)
		{
			return !SpaceMarinePlugin.ArmoryUI.IsWindowOpen;
		}
		return true;
	}
}
[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
public static class GameCamera_UpdateMouseCapture_Patch
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		if ((Object)(object)SpaceMarinePlugin.ArmoryUI != (Object)null && SpaceMarinePlugin.ArmoryUI.IsWindowOpen)
		{
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
			return false;
		}
		return true;
	}
}
[Serializable]
public class ProgressionData
{
	public int dataVersion = 3;

	public string characterName = "";

	public int level = 1;

	public int currentXP;

	public int requisitionPoints = 40;

	public int armorRank = 1;

	public int bonusHealthLevel;

	public int bonusStaminaLevel;

	public int bonusArmorLevel;

	public int bonusRegenLevel;

	public int bonusDamageLevel;

	public List<string> unlockedWeapons = new List<string> { "combatknife", "needle_pistol" };

	public string activeWeaponId = "combatknife";

	public int totalKills;

	public int totalCrafts;
}
public class ProgressionGUI : MonoBehaviour
{
	public bool IsWindowOpen;

	private Rect windowRect;

	private int currentTab;

	private Vector2 weaponScroll = Vector2.zero;

	private bool isPosInit;

	private GUIStyle richLabel;

	private void CenterWindow()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp((float)Screen.width * 0.7f, 750f, 950f);
		float num2 = Mathf.Clamp((float)Screen.height * 0.78f, 520f, 780f);
		windowRect = new Rect(((float)Screen.width - num) / 2f, ((float)Screen.height - num2) / 2f, num, num2);
		isPosInit = true;
	}

	public void ToggleWindow(bool? force = null)
	{
		IsWindowOpen = (force.HasValue ? force.Value : (!IsWindowOpen));
		if (IsWindowOpen)
		{
			CenterWindow();
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
		}
		else
		{
			ZCursor.LockState = (CursorLockMode)1;
			ZCursor.Hide();
		}
	}

	private void Update()
	{
		if (IsWindowOpen)
		{
			ZCursor.LockState = (CursorLockMode)0;
			ZCursor.Show();
			if (Input.GetKeyDown((KeyCode)27))
			{
				ToggleWindow(false);
			}
		}
	}

	private void OnGUI()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Expected O, but got Unknown
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)SpaceMarinePlugin.Progression == (Object)null)
		{
			return;
		}
		if (richLabel == null)
		{
			richLabel = new GUIStyle(GUI.skin.label);
			richLabel.richText = true;
			richLabel.wordWrap = true;
		}
		if (SpaceMarinePlugin.IsArmorActive && !IsWindowOpen)
		{
			DrawTopHudBanner();
		}
		if (IsWindowOpen)
		{
			if (!isPosInit || ((Rect)(ref windowRect)).width < 100f)
			{
				CenterWindow();
			}
			((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 10f, Mathf.Max(10f, (float)Screen.width - ((Rect)(ref windowRect)).width - 10f));
			((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 10f, Mathf.Max(10f, (float)Screen.height - ((Rect)(ref windowRect)).height - 10f));
			GUI.color = Color.white;
			windowRect = GUI.Window(889900, windowRect, new WindowFunction(DrawMainWindow), "⚔ ВОЕННЫЙ АРСЕНАЛ & ПРОКАЧКА АСТАРТЕС  (v3.0, баланс Вальхейма)");
		}
	}

	private void DrawTopHudBanner()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		ProgressionData data = SpaceMarinePlugin.Progression.data;
		WeaponDef weaponDef = WarhammerArmory.Get(data.activeWeaponId);
		Rect val = new Rect((float)Screen.width / 2f - 380f, 10f, 760f, 32f);
		GUI.color = new Color(0.05f, 0.08f, 0.15f, 0.85f);
		GUI.Box(val, GUIContent.none);
		GUIStyle val2 = new GUIStyle(GUI.skin.label);
		val2.alignment = (TextAnchor)4;
		val2.fontSize = 12;
		val2.fontStyle = (FontStyle)1;
		val2.normal.textColor = new Color(1f, 0.85f, 0.2f);
		GUI.Label(val, "⚔ РАНГ: " + SpaceMarinePlugin.Progression.GetRankTitle(data.armorRank) + "  |  ОЧКИ: " + data.requisitionPoints + "  |  ОРУЖИЕ: " + weaponDef.name + "  [" + ((object)BalanceConfig.KeyArmory.Value/*cast due to .constrained prefix*/).ToString() + " — Арсенал] [" + ((object)BalanceConfig.KeyCycleWeapon.Value/*cast due to .constrained prefix*/).ToString() + " — Смена]", val2);
		GUI.color = Color.white;
	}

	private static void TabButton(ref int current, int index, string title)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		GUI.backgroundColor = (Color)((current == index) ? new Color(0.2f, 0.7f, 1f) : Color.grey);
		if (GUILayout.Button(title, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
		{
			current = index;
		}
	}

	private void DrawMainWindow(int id)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width - 40f, 25f));
		if (GUI.Button(new Rect(((Rect)(ref windowRect)).width - 32f, 4f, 28f, 20f), "✕"))
		{
			ToggleWindow(false);
		}
		WarhammerProgressionManager progression = SpaceMarinePlugin.Progression;
		ProgressionData data = progression.data;
		GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
		GUILayout.Space(6f);
		GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUIStyle val = new GUIStyle(GUI.skin.label);
		val.fontSize = 14;
		val.fontStyle = (FontStyle)1;
		val.normal.textColor = new Color(1f, 0.85f, 0.2f);
		GUILayout.Label("⚔ БОЕВОЙ УРОВЕНЬ: " + data.level + "   |   ОЧКИ РЕКВИЗИЦИИ: " + data.requisitionPoints + " ед.   |   " + data.characterName, val, Array.Empty<GUILayoutOption>());
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
		TabButton(ref currentTab, 0, "\ud83d\udee1\ufe0f СИЛОВАЯ БРОНЯ");
		TabButton(ref currentTab, 1, "⚔ АРСЕНАЛ (" + WarhammerArmory.Weapons.Count + " видов оружия)");
		TabButton(ref currentTab, 2, "\ud83d\udcca ФОРМУЛЯР И БОССЫ");
		GUI.backgroundColor = Color.white;
		GUILayout.EndHorizontal();
		GUILayout.Space(8f);
		if (currentTab == 0)
		{
			DrawArmorTab(progression, data);
		}
		else if (currentTab == 1)
		{
			DrawWeaponsTab(progression, data);
		}
		else
		{
			DrawStatsTab(progression, data);
		}
		GUILayout.EndVertical();
	}

	private void DrawArmorTab(WarhammerProgressionManager mgr, ProgressionData data)
	{
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.Label("<size=14><b>\ud83d\udee1\ufe0f Ранг Брони: <color=#FFD700>" + mgr.GetRankTitle(data.armorRank) + "</color> (Ранг " + data.armorRank + "/7)</b></size>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.Space(4f);
		GUILayout.Label("<b>Текущие эффекты:</b>  Броня: <b>+" + (int)mgr.GetCurrentArmorBonus() + "</b>  |  Макс. HP: <b>+" + (int)mgr.GetCurrentHealthBonus() + "</b>  |  Выносливость: <b>+" + (int)mgr.GetCurrentStaminaBonus() + "</b>\nПереносимый вес: <b>+" + (int)mgr.GetCurrentCarryBonus() + "</b>  |  Регенерация: <b>+" + mgr.GetCurrentRegenRate().ToString("F2") + " HP/сек</b>  |  Множитель урона: <b>x" + mgr.GetCurrentDamageMultiplier().ToString("F2") + "</b>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.Space(6f);
		if (data.armorRank < 7)
		{
			int rankUpgradeCost = mgr.GetRankUpgradeCost();
			int nextRankRequiredTier = mgr.GetNextRankRequiredTier();
			bool flag = Tiers.IsUnlocked(nextRankRequiredTier);
			bool flag2 = flag && data.requisitionPoints >= rankUpgradeCost;
			GUI.backgroundColor = (flag2 ? new Color(0.2f, 0.85f, 0.3f) : new Color(0.5f, 0.5f, 0.5f));
			string text = "★ ПОВЫСИТЬ РАНГ БРОНИ ДО: \"" + mgr.GetRankTitle(data.armorRank + 1) + "\" (" + rankUpgradeCost + " очков)";
			if (!flag)
			{
				text = text + "\n" + Tiers.LockReason(nextRankRequiredTier);
			}
			if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(flag ? 36f : 48f) }) && flag2)
			{
				data.requisitionPoints -= rankUpgradeCost;
				data.armorRank++;
				mgr.SaveProgress();
				Refresh();
			}
			GUI.backgroundColor = Color.white;
		}
		else
		{
			GUILayout.Label("<color=#FFD700><b>★ МАКСИМАЛЬНЫЙ РАНГ БРОНИ ДОСТИГНУТ (ПРИМАРХ)! ★</b></color>", richLabel, Array.Empty<GUILayoutOption>());
		}
		GUILayout.EndVertical();
		GUILayout.Space(8f);
		GUILayout.Label("<b>\ud83e\udde9 Точечная модернизация систем костюма:</b>", richLabel, Array.Empty<GUILayoutOption>());
		DrawUpgradeRow("\ud83e\ude78 Запас здоровья (+3 HP за уровень)", data.bonusHealthLevel, 10, 60 + data.bonusHealthLevel * 30, delegate
		{
			data.bonusHealthLevel++;
		});
		DrawUpgradeRow("⚡ Запас выносливости (+3 Stamina)", data.bonusStaminaLevel, 10, 50 + data.bonusStaminaLevel * 30, delegate
		{
			data.bonusStaminaLevel++;
		});
		DrawUpgradeRow("\ud83d\udee1\ufe0f Керамитовая броня (+2 Брони)", data.bonusArmorLevel, 10, 60 + data.bonusArmorLevel * 30, delegate
		{
			data.bonusArmorLevel++;
		});
		DrawUpgradeRow("\ud83e\ude79 Стимуляторы регенерации (+0.05 HP/сек)", data.bonusRegenLevel, 5, 80 + data.bonusRegenLevel * 50, delegate
		{
			data.bonusRegenLevel++;
		});
		DrawUpgradeRow("⚔ Усилитель сервоприводов (+2% урона)", data.bonusDamageLevel, 10, 100 + data.bonusDamageLevel * 60, delegate
		{
			data.bonusDamageLevel++;
		});
	}

	private void Refresh()
	{
		if (SpaceMarinePlugin.IsArmorActive && (Object)(object)Player.m_localPlayer != (Object)null)
		{
			SpaceMarinePlugin.RefreshPlayerStats(Player.m_localPlayer, healBoost: true);
		}
	}

	private void DrawUpgradeRow(string title, int level, int max, int cost, Action onUpgrade)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		ProgressionData data = SpaceMarinePlugin.Progression.data;
		GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.Label(title + " [Ур. " + level + "/" + max + "]", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		bool num = level >= max;
		bool flag = !num && data.requisitionPoints >= cost;
		GUI.backgroundColor = (flag ? new Color(0.2f, 0.85f, 0.3f) : new Color(0.5f, 0.5f, 0.5f));
		if (GUILayout.Button(num ? "МАКСИМУМ" : ("Прокачать (" + cost + " очков)"), (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(170f),
			GUILayout.Height(26f)
		}) && flag)
		{
			data.requisitionPoints -= cost;
			onUpgrade();
			SpaceMarinePlugin.Progression.SaveProgress();
			Refresh();
		}
		GUI.backgroundColor = Color.white;
		GUILayout.EndHorizontal();
	}

	private void DrawWeaponsTab(WarhammerProgressionManager mgr, ProgressionData data)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		weaponScroll = GUILayout.BeginScrollView(weaponScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
		foreach (WeaponDef weapon in WarhammerArmory.Weapons)
		{
			bool flag = data.unlockedWeapons.Contains(weapon.id);
			bool flag2 = data.activeWeaponId.Equals(weapon.id, StringComparison.OrdinalIgnoreCase);
			bool flag3 = Tiers.IsUnlocked(weapon.tier);
			GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			string text = (flag2 ? "#FFD700" : (flag ? "#00FFFF" : "#FFFFFF"));
			GUILayout.Label("<size=13><b><color=" + text + ">" + weapon.name + "</color></b></size> <color=#AAAAAA>[" + weapon.category + " · Тир " + weapon.tier + " · " + Tiers.BiomeNames[weapon.tier] + "]</color>", richLabel, Array.Empty<GUILayoutOption>());
			string text2 = ((weapon.isRanged && weapon.id != "virusbomb") ? ("  |  <color=#FF99CC>≈" + (int)(weapon.DisplayDamage() / Mathf.Max(0.1f, weapon.cooldown)) + " урона/сек</color>") : "");
			GUILayout.Label("<color=#FFCC00>Урон: " + (int)weapon.DisplayDamage() + "</color>  |  <color=#00FFCC>Выносливость: " + (int)weapon.staminaCost + "</color>" + text2 + "  |  <color=#CCCCCC>" + weapon.desc + "</color>", richLabel, Array.Empty<GUILayoutOption>());
			if (!flag3)
			{
				GUILayout.Label("<color=#FF8844>" + Tiers.LockReason(weapon.tier) + "</color>", richLabel, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.Space(10f);
			if (flag2)
			{
				GUI.backgroundColor = new Color(0.2f, 0.85f, 0.3f);
				GUILayout.Button("✔ ЭКИПИРОВАНО", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(135f),
					GUILayout.Height(38f)
				});
			}
			else if (flag)
			{
				GUI.backgroundColor = (flag3 ? new Color(0.2f, 0.65f, 0.95f) : new Color(0.5f, 0.5f, 0.5f));
				if (GUILayout.Button(flag3 ? "ЭКИПИРОВАТЬ" : "\ud83d\udd12 ЗАКРЫТО", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(135f),
					GUILayout.Height(38f)
				}) && flag3)
				{
					data.activeWeaponId = weapon.id;
					mgr.SaveProgress();
					SpaceMarinePlugin.Combat.ApplyEquippedWeaponModel(Player.m_localPlayer);
				}
			}
			else
			{
				bool flag4 = flag3 && data.requisitionPoints >= weapon.cost;
				GUI.backgroundColor = (flag4 ? new Color(1f, 0.75f, 0.1f) : new Color(0.5f, 0.5f, 0.5f));
				if (GUILayout.Button(flag3 ? ("КУПИТЬ (" + weapon.cost + " очков)") : ("\ud83d\udd12 " + weapon.cost + " очков"), (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(135f),
					GUILayout.Height(38f)
				}) && flag4)
				{
					data.requisitionPoints -= weapon.cost;
					data.unlockedWeapons.Add(weapon.id);
					data.activeWeaponId = weapon.id;
					mgr.SaveProgress();
					SpaceMarinePlugin.Combat.ApplyEquippedWeaponModel(Player.m_localPlayer);
				}
			}
			GUI.backgroundColor = Color.white;
			GUILayout.EndHorizontal();
			GUILayout.Space(2f);
		}
		GUILayout.EndScrollView();
	}

	private void DrawStatsTab(WarhammerProgressionManager mgr, ProgressionData data)
	{
		GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
		GUILayout.Label("<size=14><b>\ud83d\udcca Служебный Формуляр Астартес:</b></size>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.Space(8f);
		GUILayout.Label("• Боевой уровень: <b>" + data.level + "</b>   • Опыт (XP): <b>" + data.currentXP + "</b>   • Очков реквизиции: <b>" + data.requisitionPoints + "</b>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.Label("• Уничтожено врагов: <b>" + data.totalKills + "</b>   • Создано предметов: <b>" + data.totalCrafts + "</b>   • Оружия: <b>" + data.unlockedWeapons.Count + " / " + WarhammerArmory.Weapons.Count + "</b>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.Space(10f);
		GUILayout.Label("<b>\ud83c\udfc6 Прогресс по Вальхейму (открывает новые тиры):</b>", richLabel, Array.Empty<GUILayoutOption>());
		for (int i = 1; i < Tiers.RequiredKey.Length; i++)
		{
			string text = (Tiers.IsUnlocked(i) ? "<color=#66FF66>✔ открыт</color>" : "<color=#FF8844>\ud83d\udd12 закрыт</color>");
			GUILayout.Label("  Тир " + i + " — " + Tiers.BiomeNames[i] + ": победить " + Tiers.BossNames[i] + "   " + text, richLabel, Array.Empty<GUILayoutOption>());
		}
		if (!BalanceConfig.BossGating.Value)
		{
			GUILayout.Label("<color=#AAAAAA>(BossGating выключен в конфиге — все тиры доступны)</color>", richLabel, Array.Empty<GUILayoutOption>());
		}
		GUILayout.Space(12f);
		GUILayout.Label("<color=#FFD700><i>«Нет греха, кроме слабости. За Императора!»</i></color>", richLabel, Array.Empty<GUILayoutOption>());
		GUILayout.EndVertical();
	}
}
public static class ShawBalance
{
	private class Entry
	{
		public int Tier;

		public float TotalDamage;

		public float Block;

		public float Durability;

		public Entry(int tier, float dmg, float block, float dur)
		{
			Tier = tier;
			TotalDamage = dmg;
			Block = block;
			Durability = dur;
		}
	}

	private static readonly Dictionary<string, Entry> Items = new Dictionary<string, Entry>
	{
		{
			"shaw40kchainsword",
			new Entry(1, 50f, 40f, 500f)
		},
		{
			"shaw40kchainsword1",
			new Entry(1, 50f, 40f, 500f)
		},
		{
			"shaw40kchainaxe",
			new Entry(1, 52f, 30f, 500f)
		},
		{
			"shaw40kchainaxe1",
			new Entry(1, 52f, 30f, 500f)
		},
		{
			"shaw40kgspear",
			new Entry(2, 66f, 40f, 600f)
		},
		{
			"shaw40kgspear1",
			new Entry(2, 66f, 40f, 600f)
		},
		{
			"umaisword",
			new Entry(2, 60f, 40f, 500f)
		},
		{
			"umaisword2",
			new Entry(1, 45f, 30f, 400f)
		},
		{
			"umaibow",
			new Entry(2, 60f, 0f, 500f)
		},
		{
			"umaigun1",
			new Entry(1, 34f, 0f, 500f)
		},
		{
			"shaw40kflamer",
			new Entry(2, 14f, 0f, 500f)
		},
		{
			"shaw40kflamer1",
			new Entry(2, 14f, 0f, 500f)
		},
		{
			"titan_gun",
			new Entry(4, 120f, 0f, 500f)
		},
		{
			"titan_misiles",
			new Entry(4, 130f, 0f, 500f)
		}
	};

	private static readonly string[] ArmorPieces = new string[5] { "femautohelm", "femautochest", "femautolegs", "femautoback", "shawsangchest" };

	private static readonly string[][] TierMaterials = new string[8][]
	{
		new string[3] { "Wood:8", "Flint:4", "LeatherScraps:4" },
		new string[3] { "Bronze:6", "Wood:4", "Resin:4" },
		new string[3] { "Iron:8", "Wood:6", "Chain:1" },
		new string[3] { "Silver:8", "WolfPelt:2", "FineWood:6" },
		new string[3] { "BlackMetal:10", "LinenThread:6", "FineWood:6" },
		new string[3] { "Carapace:6", "YggdrasilWood:6", "Eitr:4" },
		new string[3] { "FlametalNew:10", "MoltenCore:4", "Blackwood:6" },
		new string[3] { "FlametalNew:10", "MoltenCore:4", "Blackwood:6" }
	};

	private const float MaxEffectHit = 90f;

	public static void Apply(ManualLogSource log)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		StringBuilder stringBuilder = new StringBuilder("[ShawBalance] Отчёт:\n");
		int num = 0;
		if (BalanceConfig.ClampShawItems.Value)
		{
			foreach (KeyValuePair<string, Entry> item in Items)
			{
				ItemDrop drop = GetDrop(item.Key);
				if (!((Object)(object)drop == (Object)null))
				{
					SharedData shared = drop.m_itemData.m_shared;
					float num2 = CombatTotal(shared.m_damages);
					if (item.Value.TotalDamage > 0f)
					{
						ScaleTo(ref shared.m_damages, item.Value.TotalDamage);
						shared.m_damagesPerLevel = default(DamageTypes);
					}
					if (item.Value.Block > 0f && shared.m_blockPower > item.Value.Block)
					{
						shared.m_blockPower = item.Value.Block;
					}
					else if (item.Value.Block <= 0f)
					{
						shared.m_blockPower = 0f;
					}
					shared.m_blockPowerPerLevel = 0f;
					shared.m_armor = 0f;
					shared.m_armorPerLevel = 0f;
					if (item.Value.Durability > 0f)
					{
						shared.m_maxDurability = Mathf.Min(shared.m_maxDurability, item.Value.Durability);
						shared.m_durabilityPerLevel = 0f;
					}
					if (shared.m_attack != null)
					{
						shared.m_attack.m_attackEitr = 0f;
					}
					num++;
					stringBuilder.AppendFormat("  {0,-22} T{1}  урон {2:0} → {3:0}\n", item.Key, item.Value.Tier, num2, CombatTotal(shared.m_damages));
				}
			}
			string[] armorPieces = ArmorPieces;
			foreach (string text in armorPieces)
			{
				ItemDrop drop2 = GetDrop(text);
				if (!((Object)(object)drop2 == (Object)null))
				{
					SharedData shared2 = drop2.m_itemData.m_shared;
					float armor = shared2.m_armor;
					shared2.m_armor = ((text == "shawsangchest") ? 14f : 0f);
					shared2.m_armorPerLevel = 0f;
					shared2.m_maxDurability = Mathf.Min(shared2.m_maxDurability, 600f);
					shared2.m_durabilityPerLevel = 0f;
					num++;
					stringBuilder.AppendFormat("  {0,-22} броня {1:0} → {2:0}\n", text, armor, shared2.m_armor);
				}
			}
			ItemDrop drop3 = GetDrop("DatGoodSHT");
			if ((Object)(object)drop3 != (Object)null)
			{
				SharedData shared3 = drop3.m_itemData.m_shared;
				stringBuilder.AppendFormat("  Senzu                  еда {0:0}/{1:0} burn {2:0}s regen {3:0}", shared3.m_food, shared3.m_foodStamina, shared3.m_foodBurnTime, shared3.m_foodRegen);
				shared3.m_food = 45f;
				shared3.m_foodStamina = 45f;
				shared3.m_foodEitr = 0f;
				shared3.m_foodBurnTime = 900f;
				shared3.m_foodRegen = 2f;
				stringBuilder.AppendLine(" → 45/45 burn 900s regen 2");
				num++;
			}
			num += ClampEffectPrefabs(stringBuilder);
		}
		if (BalanceConfig.ClampShawRecipes.Value)
		{
			num += ClampRecipes(stringBuilder);
		}
		if (num > 0)
		{
			log.LogInfo((object)stringBuilder.ToString().TrimEnd());
		}
	}

	private static ItemDrop GetDrop(string prefabName)
	{
		GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(prefabName) : null);
		if (!((Object)(object)val != (Object)null))
		{
			return null;
		}
		return val.GetComponent<ItemDrop>();
	}

	private static float CombatTotal(DamageTypes d)
	{
		//IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		return d.m_damage + d.m_blunt + d.m_slash + d.m_pierce + d.m_fire + d.m_frost + d.m_lightning + d.m_poison + d.m_spirit;
	}

	private static void ScaleTo(ref DamageTypes d, float target)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		float num = CombatTotal(d);
		if (num > 0f)
		{
			float num2 = target / num;
			d.m_damage *= num2;
			d.m_blunt *= num2;
			d.m_slash *= num2;
			d.m_pierce *= num2;
			d.m_fire *= num2;
			d.m_frost *= num2;
			d.m_lightning *= num2;
			d.m_poison *= num2;
			d.m_spirit *= num2;
		}
		d.m_chop = Mathf.Min(d.m_chop, target * 0.6f);
		d.m_pickaxe = Mathf.Min(d.m_pickaxe, target * 0.3f);
	}

	private static int ClampEffectPrefabs(StringBuilder report)
	{
		int num = 0;
		foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
		{
			bool flag = false;
			try
			{
				string[] allAssetNames = allLoadedAssetBundle.GetAllAssetNames();
				for (int i = 0; i < allAssetNames.Length; i++)
				{
					if (allAssetNames[i].IndexOf("shaw40k", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						flag = true;
						break;
					}
				}
			}
			catch
			{
				continue;
			}
			if (!flag)
			{
				continue;
			}
			GameObject[] array = allLoadedAssetBundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array)
			{
				Aoe[] componentsInChildren = val.GetComponentsInChildren<Aoe>(true);
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					if (ClampHit(ref componentsInChildren[j].m_damage))
					{
						num++;
					}
				}
				Projectile[] componentsInChildren2 = val.GetComponentsInChildren<Projectile>(true);
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					if (ClampHit(ref componentsInChildren2[j].m_damage))
					{
						num++;
					}
				}
			}
		}
		report.AppendFormat("  Снаряды/зоны эффектов Shawesomes: ограничено {0} (потолок {1:0} за попадание, рубка/добыча ≤ 60)\n", num, 90f);
		return num;
	}

	private static bool ClampHit(ref DamageTypes d)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		bool result = false;
		float num = CombatTotal(d);
		if (num > 90f)
		{
			float num2 = 90f / num;
			d.m_damage *= num2;
			d.m_blunt *= num2;
			d.m_slash *= num2;
			d.m_pierce *= num2;
			d.m_fire *= num2;
			d.m_frost *= num2;
			d.m_lightning *= num2;
			d.m_poison *= num2;
			d.m_spirit *= num2;
			result = true;
		}
		if (d.m_chop > 60f)
		{
			d.m_chop = 60f;
			result = true;
		}
		if (d.m_pickaxe > 60f)
		{
			d.m_pickaxe = 60f;
			result = true;
		}
		return result;
	}

	private static int ClampRecipes(StringBuilder report)
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Expected O, but got Unknown
		int num = 0;
		if ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_recipes == null)
		{
			return 0;
		}
		foreach (Recipe recipe in ObjectDB.instance.m_recipes)
		{
			if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null)
			{
				continue;
			}
			string name = ((Object)((Component)recipe.m_item).gameObject).name;
			if (!Items.TryGetValue(name, out var value))
			{
				continue;
			}
			List<Requirement> list = new List<Requirement>();
			string[] array = TierMaterials[Mathf.Clamp(value.Tier, 0, TierMaterials.Length - 1)];
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(':');
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(array2[0]);
				if (!((Object)(object)itemPrefab == (Object)null))
				{
					Requirement val = new Requirement();
					val.m_resItem = itemPrefab.GetComponent<ItemDrop>();
					val.m_amount = int.Parse(array2[1]);
					val.m_amountPerLevel = 0;
					list.Add(val);
				}
			}
			if (list.Count != 0)
			{
				recipe.m_resources = list.ToArray();
				recipe.m_minStationLevel = Mathf.Max(1, value.Tier);
				num++;
				report.AppendFormat("  рецепт {0}: ванильные материалы T{1}\n", name, value.Tier);
			}
		}
		return num;
	}
}
[BepInPlugin("com.antigravity.valheimspacemarine", "Valheim Space Marine Mod", "3.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AllyMarker : MonoBehaviour
{
	public float damageScale = 1f;
}
public class SpaceMarinePlugin : BaseUnityPlugin
{
	public const string GrantedMarker = "wh40k_granted";

	public static SpaceMarinePlugin Instance;

	public static bool IsArmorActive = false;

	public static WarhammerProgressionManager Progression;

	public static WarhammerCombatController Combat;

	public static ProgressionGUI ArmoryUI;

	public static readonly string[] MarineArmorPrefabs = new string[4] { "femautohelm", "femautochest", "femautolegs", "femautoback" };

	private static readonly string[] GrantedWeaponPrefabs = new string[6] { "shaw40kchainsword", "shaw40kchainaxe", "shaw40kgspear", "umaisword", "umaigun1", "shaw40kflamer" };

	private Harmony harmony;

	private Player lastPlayer;

	private float baseCarry = -1f;

	private float nextAllyTime;

	private int shawAppliedForDb = -1;

	private static MethodInfo updateFoodMethod;

	private void Awake()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		Instance = this;
		BalanceConfig.Bind(((BaseUnityPlugin)this).Config);
		Progression = ((Component)this).gameObject.AddComponent<WarhammerProgressionManager>();
		Combat = ((Component)this).gameObject.AddComponent<WarhammerCombatController>();
		ArmoryUI = ((Component)this).gameObject.AddComponent<ProgressionGUI>();
		try
		{
			harmony = new Harmony("com.antigravity.valheimspacemarine");
			harmony.PatchAll();
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Harmony patch error: " + ex));
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"=== Valheim Space Marine & Warhammer 40k Armory v3.0.0 (Valheim balance) initialized ===");
	}

	private void OnDestroy()
	{
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private void Update()
	{
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items != null && ObjectDB.instance.m_items.Count > 0 && shawAppliedForDb != ((Object)ObjectDB.instance).GetInstanceID())
		{
			shawAppliedForDb = ((Object)ObjectDB.instance).GetInstanceID();
			try
			{
				ShawBalance.Apply(((BaseUnityPlugin)this).Logger);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("ShawBalance: " + ex));
			}
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)(object)lastPlayer)
		{
			OnLocalPlayerChanged(localPlayer);
		}
		if ((Object)(object)localPlayer == (Object)null || Console.IsVisible() || ((Object)(object)Chat.instance != (Object)null && Chat.instance.IsChatDialogWindowVisible()))
		{
			return;
		}
		if (Input.GetKeyDown(BalanceConfig.KeyArmor.Value))
		{
			ToggleSpaceMarineMode(localPlayer);
		}
		if (Input.GetKeyDown(BalanceConfig.KeyArmory.Value) || Input.GetKeyDown((KeyCode)289))
		{
			ArmoryUI.ToggleWindow();
		}
		if (Input.GetKeyDown(BalanceConfig.KeyCycleWeapon.Value))
		{
			Combat.CycleNextOwnedWeapon();
		}
		if (Input.GetKeyDown(BalanceConfig.KeyDropPod.Value))
		{
			SummonSpaceMarineDropPod(localPlayer);
		}
		if (IsArmorActive)
		{
			localPlayer.m_maxCarryWeight = ((baseCarry > 0f) ? baseCarry : 300f) + Progression.GetCurrentCarryBonus();
			if (BalanceConfig.InfiniteEitr.Value && localPlayer.GetEitr() < 50f)
			{
				((Character)localPlayer).AddEitr(50f);
			}
			float currentRegenRate = Progression.GetCurrentRegenRate();
			if (currentRegenRate > 0f && ((Character)localPlayer).GetHealth() < ((Character)localPlayer).GetMaxHealth())
			{
				((Character)localPlayer).Heal(Time.deltaTime * currentRegenRate, false);
			}
		}
	}

	private void OnLocalPlayerChanged(Player player)
	{
		lastPlayer = player;
		IsArmorActive = false;
		baseCarry = -1f;
		if (!((Object)(object)player == (Object)null))
		{
			Progression.LoadFor(player.GetPlayerName());
			RemoveGrantedItems(player);
		}
	}

	public static void TriggerUpdateFood(Player player)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			if (updateFoodMethod == null)
			{
				updateFoodMethod = typeof(Player).GetMethod("UpdateFood", BindingFlags.Instance | BindingFlags.NonPublic);
			}
			if (updateFoodMethod != null)
			{
				updateFoodMethod.Invoke(player, new object[2] { 0f, true });
			}
		}
		catch
		{
		}
	}

	public static void RefreshPlayerStats(Player player, bool healBoost = false)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		try
		{
			if (IsArmorActive && (Object)(object)Progression != (Object)null)
			{
				if (Instance.baseCarry < 0f)
				{
					Instance.baseCarry = player.m_maxCarryWeight;
				}
				player.m_maxCarryWeight = Instance.baseCarry + Progression.GetCurrentCarryBonus();
				TriggerUpdateFood(player);
				if (healBoost)
				{
					((Character)player).Heal(Progression.GetCurrentHealthBonus(), false);
					((Character)player).AddStamina(Progression.GetCurrentStaminaBonus());
				}
			}
			else
			{
				if (Instance.baseCarry > 0f)
				{
					player.m_maxCarryWeight = Instance.baseCarry;
					Instance.baseCarry = -1f;
				}
				TriggerUpdateFood(player);
			}
		}
		catch (Exception ex)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)("RefreshPlayerStats error: " + ex.Message));
			}
		}
	}

	public static void ToggleSpaceMarineMode(Player player)
	{
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		IsArmorActive = !IsArmorActive;
		if (IsArmorActive)
		{
			Instance.baseCarry = player.m_maxCarryWeight;
			Equip40kGear(player);
			RefreshPlayerStats(player, healBoost: true);
			Combat.ApplyEquippedWeaponModel(player);
			string rankTitle = Progression.GetRankTitle(Progression.data.armorRank);
			string text = "<color=#FFD700>★ СИЛОВАЯ БРОНЯ АСТАРТЕС ЭКИПИРОВАНА! ★</color>\n";
			string text2 = "<color=#00FFFF>Ранг: " + rankTitle + " | Броня: +" + (int)Progression.GetCurrentArmorBonus() + " | Здоровье: +" + (int)Progression.GetCurrentHealthBonus() + " | Выносливость: +" + (int)Progression.GetCurrentStaminaBonus() + "</color>\n";
			string text3 = "<color=#FFFFFF>[" + ((object)BalanceConfig.KeyArmory.Value/*cast due to .constrained prefix*/).ToString() + "] Арсенал  [" + ((object)BalanceConfig.KeyCycleWeapon.Value/*cast due to .constrained prefix*/).ToString() + "] Оружие  [" + ((object)BalanceConfig.KeyArmor.Value/*cast due to .constrained prefix*/).ToString() + "] Снять</color>";
			MessageHud.instance.ShowMessage((MessageType)2, text + text2 + text3, 0, (Sprite)null, false, true);
		}
		else
		{
			Unequip40kGear(player);
			RefreshPlayerStats(player);
			MessageHud.instance.ShowMessage((MessageType)2, "Силовая броня снята.", 0, (Sprite)null, false, true);
		}
	}

	public static void Equip40kGear(Player player)
	{
		if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null || (Object)(object)ObjectDB.instance == (Object)null)
		{
			return;
		}
		string[] marineArmorPrefabs = MarineArmorPrefabs;
		foreach (string text in marineArmorPrefabs)
		{
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				continue;
			}
			ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
			if (!((Object)(object)component == (Object)null))
			{
				component.m_itemData.m_shared.m_armor = 0f;
				component.m_itemData.m_shared.m_armorPerLevel = 0f;
				component.m_itemData.m_shared.m_maxQuality = 1;
				ItemData val = GrantItem(player, itemPrefab, component);
				if (val != null)
				{
					((Humanoid)player).EquipItem(val, true);
				}
			}
		}
		Combat.ApplyEquippedWeaponModel(player);
	}

	public static ItemData GrantItem(Player player, GameObject prefab, ItemDrop drop)
	{
		Inventory inventory = ((Humanoid)player).GetInventory();
		ItemData item = inventory.GetItem(drop.m_itemData.m_shared.m_name, -1, false);
		if (item == null)
		{
			inventory.AddItem(prefab, 1);
			item = inventory.GetItem(drop.m_itemData.m_shared.m_name, -1, false);
			if (item != null && item.m_customData != null)
			{
				item.m_customData["wh40k_granted"] = "1";
			}
		}
		return item;
	}

	public static void Unequip40kGear(Player player)
	{
		RemoveGrantedItems(player);
	}

	public static void RemoveGrantedItems(Player player)
	{
		if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null)
		{
			return;
		}
		Inventory inventory = ((Humanoid)player).GetInventory();
		List<ItemData> list = new List<ItemData>();
		foreach (ItemData allItem in inventory.GetAllItems())
		{
			if (allItem.m_customData != null && allItem.m_customData.ContainsKey("wh40k_granted"))
			{
				list.Add(allItem);
			}
		}
		foreach (ItemData item in list)
		{
			((Humanoid)player).UnequipItem(item, false);
			inventory.RemoveItem(item);
		}
	}

	public static void SummonSpaceMarineDropPod(Player player)
	{
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		int value = BalanceConfig.AllyRequiredTier.Value;
		if (!Tiers.IsUnlocked(value))
		{
			MessageHud.instance.ShowMessage((MessageType)2, "<color=#FF4500>Дроп-под недоступен. " + Tiers.LockReason(value) + "</color>", 0, (Sprite)null, false, true);
		}
		else if (Time.time < Instance.nextAllyTime)
		{
			int num = Mathf.CeilToInt(Instance.nextAllyTime - Time.time);
			MessageHud.instance.ShowMessage((MessageType)2, "<color=#FF4500>Дроп-под перезаряжается: " + num + " с</color>", 0, (Sprite)null, false, true);
		}
		else
		{
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("Shaw_Ultra_Marine");
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			Instance.nextAllyTime = Time.time + BalanceConfig.AllyCooldown.Value;
			int num2 = 0;
			for (int i = 1; i < Tiers.RequiredKey.Length; i++)
			{
				if (Tiers.IsUnlocked(i))
				{
					num2 = i;
				}
			}
			float num3 = Mathf.Clamp01((float)num2 / 3f);
			float num4 = Mathf.Lerp(BalanceConfig.AllyEarlyPower.Value, 1f, num3);
			float seconds = BalanceConfig.AllyLifetime.Value * Mathf.Lerp(0.4f, 1f, num3);
			Vector3 val = ((Component)player).transform.position + ((Component)player).transform.forward * 4.5f;
			float y = default(float);
			if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val, ref y))
			{
				val.y = y;
			}
			else
			{
				val.y = ((Component)player).transform.position.y;
			}
			Quaternion val2 = Quaternion.Euler(0f, ((Component)player).transform.eulerAngles.y, 0f);
			GameObject val3 = Object.Instantiate<GameObject>(prefab, val, val2);
			val3.SetActive(true);
			Character component = val3.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_faction = (Faction)0;
				float num5 = BalanceConfig.AllyHealth.Value * num4;
				component.SetMaxHealth(num5);
				component.SetHealth(num5);
				val3.AddComponent<AllyMarker>().damageScale = num4;
				component.m_name = "Брат Астартес (Союзник)";
			}
			GameObject val4 = ZNetScene.instance.GetPrefab("droppod_open") ?? ZNetScene.instance.GetPrefab("spawn_drop_pod");
			if ((Object)(object)val4 != (Object)null)
			{
				Object.Destroy((Object)(object)Object.Instantiate<GameObject>(val4, val, val2), 25f);
			}
			((MonoBehaviour)Instance).StartCoroutine(Instance.DespawnAlly(val3, seconds));
			MessageHud.instance.ShowMessage((MessageType)2, "<color=#FFD700>★ ДРОП-ПОД КОСМОДЕСАНТА ПРИЗВАН С ОРБИТЫ! ★</color>", 0, (Sprite)null, false, true);
		}
	}

	private IEnumerator DespawnAlly(GameObject ally, float seconds)
	{
		yield return (object)new WaitForSeconds(seconds);
		if ((Object)(object)ally != (Object)null)
		{
			ZNetView component = ally.GetComponent<ZNetView>();
			if ((Object)(object)component != (Object)null && component.IsValid() && (Object)(object)ZNetScene.instance != (Object)null)
			{
				ZNetScene.instance.Destroy(ally);
			}
			else
			{
				Object.Destroy((Object)(object)ally);
			}
		}
	}
}
public static class SpaceMarineSound
{
	private static AudioClip bolterShot;

	private static AudioClip boltExplode;

	public static AudioClip BolterShotClip
	{
		get
		{
			if ((Object)(object)bolterShot == (Object)null)
			{
				bolterShot = Generate("BolterReport", 0.22f, 22f, 190f, 0.7f, 0.9f, 40000, 22f);
			}
			return bolterShot;
		}
	}

	public static AudioClip BoltExplodeClip
	{
		get
		{
			if ((Object)(object)boltExplode == (Object)null)
			{
				boltExplode = Generate("BoltDetonation", 0.8f, 6.5f, 130f, 0.75f, 0.8f, 40001, 4f);
			}
			return boltExplode;
		}
	}

	private static AudioClip Generate(string name, float seconds, float noiseDecay, float toneHz, float noiseGain, float toneGain, int seed, float toneDecay)
	{
		int num = 44100;
		int num2 = (int)((float)num * seconds);
		float[] array = new float[num2];
		Random random = new Random(seed);
		for (int i = 0; i < num2; i++)
		{
			float num3 = (float)i / (float)num;
			float num4 = (float)(random.NextDouble() * 2.0 - 1.0) * Mathf.Exp((0f - num3) * noiseDecay);
			float num5 = Mathf.Sin((float)Math.PI * toneHz * num3) * Mathf.Exp((0f - num3) * toneDecay);
			array[i] = Mathf.Clamp(num4 * noiseGain + num5 * toneGain, -1f, 1f);
		}
		AudioClip val = AudioClip.Create(name, num2, 1, num, false);
		MethodInfo method = typeof(AudioClip).GetMethod("SetData", new Type[2]
		{
			typeof(float[]),
			typeof(int)
		});
		if (method != null)
		{
			method.Invoke(val, new object[2] { array, 0 });
		}
		return val;
	}
}
public static class Targeting
{
	public static bool CanDamage(Component target, Player attacker)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target == (Object)null)
		{
			return false;
		}
		if (BalanceConfig.FriendlyFire.Value)
		{
			return !IsSelf(target, attacker);
		}
		if (IsSelf(target, attacker))
		{
			return false;
		}
		if ((Object)(object)target.GetComponentInParent<Piece>() != (Object)null)
		{
			return false;
		}
		Character componentInParent = target.GetComponentInParent<Character>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			if (componentInParent.IsTamed())
			{
				return false;
			}
			Player val = (Player)(object)((componentInParent is Player) ? componentInParent : null);
			if ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)attacker != (Object)null && ((Character)attacker).IsPVPEnabled())
				{
					return ((Character)val).IsPVPEnabled();
				}
				return false;
			}
			if ((int)componentInParent.GetFaction() == 0)
			{
				return false;
			}
		}
		return true;
	}

	private static bool IsSelf(Component target, Player attacker)
	{
		if ((Object)(object)attacker == (Object)null)
		{
			return false;
		}
		if (!((Object)(object)target.gameObject == (Object)(object)((Component)attacker).gameObject))
		{
			return target.transform.IsChildOf(((Component)attacker).transform);
		}
		return true;
	}

	public static float DamageFactor(Component target)
	{
		Character val = (((Object)(object)target != (Object)null) ? target.GetComponentInParent<Character>() : null);
		if ((Object)(object)val != (Object)null && val.IsBoss())
		{
			return BalanceConfig.BossDamageScale.Value;
		}
		return 1f;
	}
}
public static class Tiers
{
	public static readonly string[] BiomeNames = new string[8] { "Луга", "Чёрный лес", "Болота", "Горы", "Равнины", "Туманные земли", "Пепельные земли", "Глубокий Север" };

	public static readonly string[] RequiredKey = new string[8] { null, "defeated_eikthyr", "defeated_gdking", "defeated_bonemass", "defeated_dragon", "defeated_goblinking", "defeated_queen", "defeated_fader" };

	public static readonly string[] BossNames = new string[8] { "", "Эйктюра", "Древнего", "Костемаса", "Модер", "Яглута", "Королеву Роя", "Фейдера" };

	public static bool IsUnlocked(int tier)
	{
		if (tier <= 0 || !BalanceConfig.BossGating.Value)
		{
			return true;
		}
		tier = Math.Min(tier, RequiredKey.Length - 1);
		try
		{
			return (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGlobalKey(RequiredKey[tier]);
		}
		catch
		{
			return false;
		}
	}

	public static string LockReason(int tier)
	{
		if (IsUnlocked(tier))
		{
			return "";
		}
		tier = Math.Min(tier, BossNames.Length - 1);
		return "\ud83d\udd12 Победите " + BossNames[tier] + " (" + BiomeNames[tier] + ")";
	}
}
public class UniversalProjectile : MonoBehaviour
{
	private WeaponDef def;

	private Vector3 velocity;

	private Player owner;

	private float damage;

	private float life = 5f;

	private Vector3 prevPos;

	private Vector3 startPos;

	public void Initialize(WeaponDef def, Vector3 dir, Player source, float dmg)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_005f: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		this.def = def;
		owner = source;
		damage = dmg;
		float num = 140f;
		if (def.id.Contains("plasma"))
		{
			num = 110f;
		}
		velocity = ((Vector3)(ref dir)).normalized * num;
		prevPos = ((Component)this).transform.position;
		startPos = ((Component)this).transform.position;
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)1);
		obj.transform.SetParent(((Component)this).transform, false);
		obj.transform.localScale = (def.id.Contains("plasma") ? new Vector3(0.35f, 0.35f, 0.35f) : new Vector3(0.1f, 0.25f, 0.1f));
		obj.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
		Collider component = obj.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		Renderer component2 = obj.GetComponent<Renderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			Material val = new Material(Shader.Find("Standard") ?? Shader.Find("Diffuse"));
			val.color = def.fxColor;
			component2.material = val;
		}
		Light obj2 = ((Component)this).gameObject.AddComponent<Light>();
		obj2.type = (LightType)2;
		obj2.color = def.fxColor;
		obj2.range = 8f;
		obj2.intensity = 4f;
		AudioSource.PlayClipAtPoint(SpaceMarineSound.BolterShotClip, ((Component)this).transform.position, 0.9f);
		Fx.Muzzle(((Component)this).transform.position, dir, def);
		Fx.ProjectileStyle(((Component)this).gameObject, def);
	}

	private bool IsOwner(Collider c)
	{
		if ((Object)(object)owner != (Object)null)
		{
			if (!((Object)(object)((Component)c).gameObject == (Object)(object)((Component)owner).gameObject))
			{
				return ((Component)c).transform.IsChildOf(((Component)owner).transform);
			}
			return true;
		}
		return false;
	}

	private void Update()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		life -= Time.deltaTime;
		if (life <= 0f)
		{
			Detonate(((Component)this).transform.position);
			return;
		}
		Vector3 val = ((Component)this).transform.position + velocity * Time.deltaTime;
		((Component)this).transform.rotation = Quaternion.LookRotation(velocity);
		Vector3 val2 = val - prevPos;
		RaycastHit val3 = default(RaycastHit);
		if (Physics.Raycast(prevPos, ((Vector3)(ref val2)).normalized, ref val3, ((Vector3)(ref val2)).magnitude, -1, (QueryTriggerInteraction)1) && !IsOwner(((RaycastHit)(ref val3)).collider))
		{
			((Component)this).transform.position = ((RaycastHit)(ref val3)).point;
			Detonate(((RaycastHit)(ref val3)).point);
		}
		else
		{
			prevPos = ((Component)this).transform.position;
			((Component)this).transform.position = val;
		}
	}

	private float BlastRadius()
	{
		if (def.id.Contains("plasma"))
		{
			return 4f;
		}
		if (def.id.Contains("lascannon"))
		{
			return 3f;
		}
		if (def.id.Contains("multimelta"))
		{
			return 3f;
		}
		return 2.5f;
	}

	private void Detonate(Vector3 point)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown resul