Decompiled source of GsiXDynamicShield v1.1.7

GsiX.DynamicShield.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DynamicShield;
using GsiXHelper;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DynamicShield")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GsiX.DynamicShield")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
public class DynamicEffect : MonoBehaviour
{
	public float effectInterval = Time.time;

	public int effectIconPos;

	public float effectIconDelay = 0.1f;

	public bool hasDynamicEffect;

	private int statusEffectHash = DynamicDefault.DynShieldUmbrella_Hash;

	private List<StatusEffect> playerSEList = new List<StatusEffect>();

	public void Awake()
	{
		if (!Player.IsPlacementGhost(((Component)this).gameObject))
		{
			((MonoBehaviour)this).InvokeRepeating("SlowUpdate", 0f, 0.22f);
		}
	}

	public void SlowUpdate()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		if (((Character)Player.m_localPlayer).m_seman.HaveStatusEffect(statusEffectHash))
		{
			hasDynamicEffect = true;
			foreach (StatusEffect statusEffect in ((Character)Player.m_localPlayer).m_seman.m_statusEffects)
			{
				if (statusEffect.m_name == "$se_rested_name")
				{
					statusEffect.m_time = 0f;
				}
				if (statusEffect.m_name == "$se_wet_name" || statusEffect.m_name == "$se_burning_name" || statusEffect.m_name == "$se_frost_name" || statusEffect.m_name == "$se_lightning_name" || statusEffect.m_name == "$se_poison_name" || statusEffect.m_name == "$se_lightning_name")
				{
					playerSEList.Add(statusEffect);
				}
			}
			if (playerSEList.Count() <= 0)
			{
				return;
			}
			foreach (StatusEffect playerSE in playerSEList)
			{
				((Character)Player.m_localPlayer).m_seman.RemoveStatusEffect(playerSE, false);
			}
			playerSEList.Clear();
		}
		else
		{
			hasDynamicEffect = false;
		}
	}
}
public class DynamicEnemy : MonoBehaviour
{
	public DynamicTower m_dTower;

	public int GeneratorCost;

	public bool rangedEnable;

	public float rangedInterval;

	public int rangedTargetTotal;

	public int rangedCost;

	public bool showActivity;

	public bool miniAoeEnable;

	public float miniAoeDamage;

	public float miniAoeInterval;

	public int miniAoeTotalTarget;

	public int miniAoeCost;

	private int carI;

	private Character slowUpdateEnemy;

	private List<Character> slowUpdateExclude = new List<Character>();

	private List<Character> slowUpdateAoeExclude = new List<Character>();

	private Collider aimCollider;

	public void Awake()
	{
		if (Player.IsPlacementGhost(((Component)this).gameObject))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicEnemy Awake");
		}
		m_dTower = ((Component)this).GetComponent<DynamicTower>();
		if ((Object)(object)m_dTower.m_nview != (Object)null && m_dTower.m_nview.GetZDO() != null)
		{
			((MonoBehaviour)this).InvokeRepeating("FindTarget", 0f, rangedInterval);
			m_dTower.m_nview.Register<ZDOID>("RPC_AttackMiniAoe", (Action<long, ZDOID>)RPC_AttackMiniAoe);
			if (showActivity)
			{
				GH.DWarn(" DynamicEnemy Register");
			}
		}
	}

	public void Update()
	{
	}

	private void FindTarget()
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: 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_016a: 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)
		if ((Object)(object)m_dTower == (Object)null || !m_dTower.IsShieldOwner())
		{
			return;
		}
		if (rangedEnable && m_dTower.IsEnoughtFuel(GeneratorCost + rangedCost))
		{
			if (showActivity)
			{
				GH.DWarn(" DynamicEnemy Trigger");
			}
			for (carI = 0; carI < rangedTargetTotal; carI++)
			{
				slowUpdateEnemy = DynamicAmmo.GetEnemyInRange(new Vector3(((Component)m_dTower.m_shield).transform.position.x, ((Component)m_dTower.m_shield).transform.position.y + DynamicTower.fixedHeight * DynamicTower.shieldScale, ((Component)m_dTower.m_shield).transform.position.z), m_dTower.m_shield.m_radius, slowUpdateExclude, 1f);
				if ((Object)(object)slowUpdateEnemy == (Object)null)
				{
					break;
				}
				if ((Object)(object)slowUpdateEnemy != (Object)null && (Object)(object)slowUpdateEnemy.m_nview != (Object)null)
				{
					switch (Random.Range(0, 3))
					{
					case 0:
						Target(((Component)slowUpdateEnemy).gameObject, slowUpdateEnemy.GetZDOID(), DynamicAmmo.AmmoType.Light);
						break;
					case 1:
						Target(((Component)slowUpdateEnemy).gameObject, slowUpdateEnemy.GetZDOID(), DynamicAmmo.AmmoType.Sham);
						break;
					case 2:
						Target(((Component)slowUpdateEnemy).gameObject, slowUpdateEnemy.GetZDOID(), DynamicAmmo.AmmoType.Rads);
						break;
					}
				}
			}
			if (slowUpdateExclude.Count() > 0)
			{
				slowUpdateExclude.Clear();
			}
		}
		if (!miniAoeEnable || !m_dTower.IsEnoughtFuel(GeneratorCost + miniAoeCost) || !GH.IsTimeElpase(m_dTower.m_nview, ZDOVars.s_growStart, miniAoeInterval))
		{
			return;
		}
		GH.SetZDOsTime(m_dTower.m_nview, ZDOVars.s_growStart);
		int num = 0;
		for (int i = 0; i < miniAoeTotalTarget; i++)
		{
			slowUpdateEnemy = DynamicAmmo.GetEnemyInRange(new Vector3(((Component)m_dTower.m_shield).transform.position.x, ((Component)m_dTower.m_shield).transform.position.y + DynamicTower.fixedHeight * DynamicTower.shieldScale, ((Component)m_dTower.m_shield).transform.position.z), m_dTower.m_shield.m_radius, slowUpdateAoeExclude, 1f);
			if ((Object)(object)slowUpdateEnemy == (Object)null)
			{
				break;
			}
			InvokeMiniAoe(slowUpdateEnemy);
			num++;
		}
		if (num > 0)
		{
			m_dTower.InvokeUseFuel(miniAoeCost, 4, num);
		}
		slowUpdateAoeExclude.Clear();
		void Target(GameObject enemy, ZDOID targetZDOID, DynamicAmmo.AmmoType type)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			DynamicAmmo.ShootProjectile(m_dTower.m_shield, m_dTower, targetZDOID, enemy, type);
			m_dTower.InvokeUseFuel(rangedCost, 4, 1);
		}
	}

	private HitData CreateHitData(float damage, HitType hitType, Vector3 pos, Vector3 dir)
	{
		//IL_0000: 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)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		return new HitData
		{
			m_damage = 
			{
				m_damage = damage
			},
			m_point = pos,
			m_dir = dir,
			m_hitType = hitType,
			m_toolTier = 4
		};
	}

	private void ShieldAOEEffect(Transform baseparent)
	{
		//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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = baseparent.position;
		position.y += 0.5f;
		Quaternion rotation = baseparent.rotation;
		CreateDynamicEffect(DynamicAmmo.animeMiniAoe, position, rotation, baseparent);
	}

	private void ShieldPlayerEffect(Transform baseparent, float zOffsets, float incDegree, float maxDegree)
	{
		//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_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = baseparent.position;
		position.y += zOffsets;
		Quaternion rotation = baseparent.rotation;
		rotation *= Quaternion.Euler(90f, 0f, 0f);
		CreateDynamicEffect(DynamicAmmo.animeDomehit, position, rotation, baseparent);
		float num = 0f;
		Quaternion val = baseparent.rotation;
		for (; num < maxDegree; num += incDegree)
		{
			val *= Quaternion.Euler(0f, num, 0f);
			CreateDynamicEffect(DynamicAmmo.animeDomehit, position, val, baseparent);
		}
	}

	private void CreateDynamicEffect(GameObject effectData, Vector3 pos, Quaternion rot, Transform baseparent, float scale = 1f)
	{
		//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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)effectData == (Object)null)
		{
			GH.DWarn("[Update] Try to create null effectData");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(effectData, pos, rot);
		if ((Object)(object)val == (Object)null)
		{
			GH.DWarn("[Update] Try to Instantiate object but return null");
		}
		else
		{
			val.transform.localScale = baseparent.localScale * scale;
		}
	}

	private void InvokeMiniAoe(Character badguy)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		m_dTower.m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_AttackMiniAoe", new object[1] { badguy.GetZDOID() });
	}

	private void RPC_AttackMiniAoe(long sender, ZDOID zdoid)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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)
		GameObject val = ZNetScene.instance.FindInstance(zdoid);
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		Character component = val.GetComponent<Character>();
		if ((Object)(object)component != (Object)null)
		{
			Drawrays(m_dTower.m_shield, component, 1f);
			if (m_dTower.m_nview.IsOwner())
			{
				component.Damage(CreateHitData(miniAoeDamage, (HitType)20, ((Component)component).transform.position, ((Component)component).transform.forward));
				ShieldAOEEffect(((Component)component).transform);
				ShieldPlayerEffect(((Component)m_dTower.m_shield).transform, 7f, 45f, 180f);
			}
		}
	}

	private void Drawrays(ShieldGenerator from, Character to, float raylife, bool random = true)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: 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_010d: 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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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_012d: 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_013a: 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_0044: 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_004e: 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_0085: 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_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: 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_0169: 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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: 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_018d: 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_0193: 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_01ae: 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)
		Vector3 val = ((Component)from).transform.position + Vector3.up * DynamicTower.fixedHeight * DynamicTower.shieldScale;
		if (random)
		{
			Vector3 val2 = Vector2.op_Implicit(Random.insideUnitCircle * (m_dTower.domeScale + 0.5f));
			val.x += val2.x;
			val.y += Random.Range(0f, 0.4f);
			val.z += val2.y;
		}
		Vector3 val3 = GetCenterAim(((Component)to).gameObject, ((Component)to).transform.position) + Vector3.up * 0.5f;
		float num = Vector3.Distance(val, val3);
		float num2 = num / 30f;
		float num3 = 0f;
		float num4 = 0f;
		Vector3 val4 = (val3 - val) / 3f;
		Vector3 val5 = val + val4 + Vector3.up * num / 3f;
		Vector3 val6 = val5 + val4 + Vector3.up * num / 3f;
		List<Vector3> list = new List<Vector3> { val };
		while (num3 < num)
		{
			num3 += num2;
			num4 = num3 / num;
			Vector3 val7 = Vector3.Lerp(val, val5, num4);
			Vector3 val8 = Vector3.Lerp(val5, val6, num4);
			Vector3 val9 = Vector3.Lerp(val6, val3, num4);
			Vector3 val10 = Vector3.Lerp(val7, val8, num4);
			Vector3 val11 = Vector3.Lerp(val8, val9, num4);
			list.Add(Vector3.Lerp(val10, val11, num4));
		}
		Color red = Color.red;
		GH.DrawRayLine(list, 0.07f, raylife, red);
	}

	private Vector3 GetCenterAim(GameObject target, Vector3 oldAimCenter)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		aimCollider = target.GetComponent<Collider>();
		if ((Object)(object)aimCollider != (Object)null)
		{
			Bounds bounds = aimCollider.bounds;
			return ((Bounds)(ref bounds)).center;
		}
		return oldAimCenter;
	}
}
public class DynamicFriendly : MonoBehaviour
{
	public DynamicTower m_dTower;

	public int GeneratorCost;

	public bool damagePlayer;

	public bool damageTamed;

	public bool showActivity;

	public bool regenPlayer;

	public float regenInterval;

	public float regenPlayerHP;

	public float regenPlayerStam;

	public bool regenTamed;

	public float regenTamedHP;

	public int regenCost;

	public int regenPieceNum;

	public bool regenPlayerPiece;

	public int cleanupNum;

	public float claenLifespan;

	public bool cleanFish;

	public bool claenInTar;

	public int cleanCost;

	public List<string> itemDestroyList;

	public List<string> itemIgnoreList;

	private int cleanCount;

	private List<string> clientDestroylistbuff = new List<string>();

	private List<string> clientignorelistbuff = new List<string>();

	private Fish fishbuff;

	private string ignoreNameBuff1;

	private string ignoreNameBuff2;

	private DynamicFriendly dynFriendly;

	private bool canPickup;

	private float pickupSpeed = 30f;

	private Vector3 autoPickup_Auto1;

	private Vector3 autoPickup_Auto2;

	private FloatingTerrainDummy floatingTerrainDummy;

	[NonSerialized]
	public Dictionary<ItemDrop, float> autoPickupList = new Dictionary<ItemDrop, float>();

	[NonSerialized]
	public Dictionary<ItemDrop, float> autoPickupBuff = new Dictionary<ItemDrop, float>();

	public void Awake()
	{
		if (Player.IsPlacementGhost(((Component)this).gameObject))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicFriendly Awake");
		}
		m_dTower = ((Component)this).GetComponent<DynamicTower>();
		if ((Object)(object)m_dTower.m_nview != (Object)null && m_dTower.m_nview.GetZDO() != null)
		{
			((MonoBehaviour)this).InvokeRepeating("FindTarget", 0f, regenInterval);
			if (showActivity)
			{
				GH.DWarn(" DynamicFriendly Register");
			}
		}
	}

	public void FixedUpdate()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		UpdatePickUp(((Component)m_dTower.m_shield).transform.position, Time.time, Time.fixedDeltaTime);
	}

	private void FindTarget()
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)m_dTower == (Object)null || !m_dTower.IsShieldOwner() || !m_dTower.IsEnoughtFuel(GeneratorCost + regenCost))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicFriendly Trigger");
		}
		foreach (Character s_character in Character.s_characters)
		{
			if ((Object)(object)s_character == (Object)null || (Object)(object)s_character.m_nview == (Object)null || s_character.IsDead() || IsOutsideShield(((Component)s_character).gameObject))
			{
				continue;
			}
			if (s_character.IsPlayer())
			{
				if ((!damagePlayer && regenPlayer && s_character.GetHealthPercentage() < 1f) || s_character.GetStaminaPercentage() < 1f)
				{
					DynamicFriendlyHealChars(s_character);
				}
			}
			else if (s_character.IsTamed() && (int)s_character.m_faction == 0 && !damageTamed && regenTamed && s_character.GetHealthPercentage() < 1f)
			{
				DynamicFriendlyHealTamed(s_character);
			}
		}
		if (regenPieceNum > 0)
		{
			cleanCount = 0;
			foreach (WearNTear s_allInstance in WearNTear.s_allInstances)
			{
				if (cleanCount >= regenPieceNum)
				{
					break;
				}
				if (!((Object)(object)s_allInstance == (Object)null) && !((Object)(object)s_allInstance.m_piece == (Object)null) && !(s_allInstance.m_healthPercentage >= 0.99f) && !IsOutsideShield(((Component)s_allInstance).gameObject) && (!regenPlayerPiece || s_allInstance.m_piece.IsPlacedByPlayer()) && !((Object)(object)s_allInstance.m_nview == (Object)null))
				{
					DynamicFriendlyRepair(s_allInstance);
					cleanCount++;
				}
			}
		}
		if (cleanupNum <= 0)
		{
			return;
		}
		cleanCount = 0;
		foreach (ItemDrop s_instance in ItemDrop.s_instances)
		{
			if (cleanCount >= cleanupNum)
			{
				break;
			}
			if ((Object)(object)s_instance == (Object)null || (Object)(object)s_instance.m_nview == (Object)null || !s_instance.m_nview.IsValid() || IsOutsideShield(((Component)s_instance).gameObject) || s_instance.GetTimeSinceSpawned() < (double)claenLifespan || (!claenInTar && s_instance.InTar()))
			{
				continue;
			}
			if (!s_instance.m_nview.IsOwner())
			{
				s_instance.m_nview.ClaimOwnership();
			}
			else
			{
				if (FindItemIgnore(s_instance))
				{
					continue;
				}
				if (FindItemDestroy(s_instance))
				{
					cleanCount++;
					DynamicFriendlyDestroy(s_instance);
					continue;
				}
				canPickup = true;
				foreach (ShieldGenerator instance in ShieldGenerator.m_instances)
				{
					dynFriendly = ((Component)instance).GetComponent<DynamicFriendly>();
					if ((Object)(object)dynFriendly != (Object)null && (dynFriendly.autoPickupList.ContainsKey(s_instance) || dynFriendly.autoPickupBuff.ContainsKey(s_instance)))
					{
						canPickup = false;
						break;
					}
				}
				if (canPickup)
				{
					s_instance.m_autoPickup = false;
					s_instance.m_itemData.m_shared.m_weight = 0f;
					autoPickupList.Add(s_instance, Time.time);
					cleanCount++;
				}
			}
		}
		bool FindItemDestroy(ItemDrop droppedItem)
		{
			clientDestroylistbuff = itemDestroyList;
			if (DynamicRPC.ClientDestroyListBuffer.Count() > 0)
			{
				clientDestroylistbuff = DynamicRPC.ClientDestroyListBuffer;
			}
			ignoreNameBuff1 = ((Object)droppedItem).name.Replace("(Clone)", "").ToLower();
			foreach (string item in clientDestroylistbuff)
			{
				if (ignoreNameBuff1.Contains(item.ToLower()))
				{
					return true;
				}
			}
			return false;
		}
		bool FindItemIgnore(ItemDrop droppedItem)
		{
			clientignorelistbuff = itemIgnoreList;
			if (DynamicRPC.ClientIgnoreListBuffer.Count() > 0)
			{
				clientignorelistbuff = DynamicRPC.ClientIgnoreListBuffer;
			}
			ignoreNameBuff2 = ((Object)droppedItem).name.Replace("(Clone)", "").ToLower();
			foreach (string item2 in clientignorelistbuff)
			{
				if (ignoreNameBuff2.Contains(item2.ToLower()))
				{
					if (item2.Contains("fish") && !cleanFish)
					{
						fishbuff = ((Component)droppedItem).GetComponent<Fish>();
						if ((Object)(object)fishbuff == (Object)null || !fishbuff.IsOutOfWater() || fishbuff.IsHooked())
						{
							continue;
						}
					}
					return true;
				}
			}
			return false;
		}
	}

	private void DynamicFriendlyHealChars(Character friendly)
	{
		if (friendly.GetHealthPercentage() < 1f)
		{
			friendly.Heal(regenPlayerHP, true);
		}
		if (friendly.GetStaminaPercentage() < 1f)
		{
			friendly.AddStamina(regenPlayerStam);
		}
		ShieldPlayerEffect(((Component)friendly).transform, 1f, 90f, 180f);
		m_dTower.InvokeUseFuel(regenCost, 0, 1);
	}

	private void DynamicFriendlyHealTamed(Character friendly)
	{
		friendly.Heal(regenTamedHP, true);
		ShieldPlayerEffect(((Component)friendly).transform, 1f, 90f, 180f);
		m_dTower.InvokeUseFuel(regenCost, 0, 1);
	}

	private void DynamicFriendlyRepair(WearNTear piece)
	{
		piece.Repair();
		ShieldOtherEffect(((Component)piece).transform);
		m_dTower.InvokeUseFuel(regenCost, 1, 1);
		if ((Object)(object)Player.m_localPlayer != (Object)null && !IsOutsideShield(((Component)Player.m_localPlayer).gameObject))
		{
			((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("[DynamicShield] $msg_repaired", new string[1] { piece.m_piece.m_name }), 0, (Sprite)null);
		}
	}

	private void UpdatePickUp(Vector3 basePos, float currenTime, float dt)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0034: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		if (!m_dTower.IsShieldOwner() || autoPickupList.Count <= 0)
		{
			return;
		}
		basePos += Vector3.up * DynamicTower.fixedHeight * DynamicTower.shieldScale;
		foreach (KeyValuePair<ItemDrop, float> autoPickup in autoPickupList)
		{
			if ((Object)(object)autoPickup.Key != (Object)null && Vector3.Distance(basePos, ((Component)autoPickup.Key).transform.position) > 1.5f && currenTime - autoPickup.Value < 5f)
			{
				AutoPickup(autoPickup.Key, basePos, dt);
			}
			else
			{
				autoPickupBuff.Add(autoPickup.Key, autoPickup.Value);
			}
		}
		if (autoPickupBuff.Count <= 0)
		{
			return;
		}
		foreach (KeyValuePair<ItemDrop, float> item in autoPickupBuff)
		{
			autoPickupList.Remove(item.Key);
			if ((Object)(object)item.Key != (Object)null)
			{
				DynamicFriendlyPickup(item.Key);
			}
		}
		autoPickupBuff.Clear();
	}

	public void AutoPickup(ItemDrop item, Vector3 basePos, float dt)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_000b: 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_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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_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_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		basePos += Vector3.up;
		if (!item.CanPickup(true))
		{
			item.RequestOwn();
			return;
		}
		autoPickup_Auto1 = Vector3.Normalize(basePos - ((Component)item).transform.position);
		autoPickup_Auto2 = autoPickup_Auto1 * pickupSpeed * dt;
		Transform transform = ((Component)item).transform;
		transform.position += autoPickup_Auto2;
		floatingTerrainDummy = ((Component)item).GetComponent<FloatingTerrainDummy>();
		if ((Object)(object)floatingTerrainDummy != (Object)null)
		{
			Transform transform2 = ((Component)floatingTerrainDummy).transform;
			transform2.position += autoPickup_Auto2;
		}
	}

	private void DynamicFriendlyPickup(ItemDrop item)
	{
		item.Load();
		if (PickupItem(item))
		{
			ShieldOtherEffect(((Component)item).transform);
			m_dTower.InvokeUseFuel(cleanCost, 2, 1);
			if ((Object)(object)Player.m_localPlayer != (Object)null && !IsOutsideShield(((Component)Player.m_localPlayer).gameObject))
			{
				((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("[DynamicShield] Pickup " + item.m_itemData.m_shared.m_name), 0, (Sprite)null);
			}
		}
		bool PickupItem(ItemDrop droppedItem)
		{
			if (droppedItem.CanPickup(false) && m_dTower.m_container.m_inventory.AddItem(droppedItem.m_itemData))
			{
				EggGrow component = ((Component)droppedItem).GetComponent<EggGrow>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				if (m_dTower.m_nview.GetZDO() == null)
				{
					Object.Destroy((Object)(object)((Component)droppedItem).gameObject);
				}
				else
				{
					ZNetScene.instance.Destroy(((Component)droppedItem).gameObject);
				}
				if (m_dTower.m_container.m_inventory.GetEmptySlots() <= 2)
				{
					GH.MoveAllToCrate(m_dTower.m_container);
				}
				m_dTower.m_container.Save();
				return true;
			}
			return false;
		}
	}

	private void DynamicFriendlyDestroy(ItemDrop item)
	{
		ShieldOtherEffect(((Component)item).transform);
		m_dTower.InvokeUseFuel(cleanCost, 3, 1);
		if ((Object)(object)Player.m_localPlayer != (Object)null && !IsOutsideShield(((Component)Player.m_localPlayer).gameObject))
		{
			((Character)Player.m_localPlayer).Message((MessageType)1, Localization.instance.Localize("[DynamicShield] Cleaned " + item.m_itemData.m_shared.m_name), 0, (Sprite)null);
		}
		item.m_nview.Destroy();
	}

	private void ShieldPlayerEffect(Transform baseparent, float zOffsets, float incDegree, float maxDegree)
	{
		//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_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = baseparent.position;
		position.y += zOffsets;
		Quaternion rotation = baseparent.rotation;
		rotation *= Quaternion.Euler(90f, 0f, 0f);
		CreateDynamicEffect(DynamicAmmo.animeDomehit, position, rotation, baseparent);
		float num = 0f;
		Quaternion val = baseparent.rotation;
		for (; num < maxDegree; num += incDegree)
		{
			val *= Quaternion.Euler(0f, num, 0f);
			CreateDynamicEffect(DynamicAmmo.animeDomehit, position, val, baseparent);
		}
	}

	private bool IsOutsideShield(GameObject pointB)
	{
		//IL_0010: 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)
		return Vector3.Distance(((Component)m_dTower.m_shield).transform.position, pointB.transform.position) > m_dTower.m_shield.m_radius;
	}

	private void ShieldOtherEffect(Transform baseparent)
	{
		//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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		Vector3 position = baseparent.position;
		Quaternion rotation = baseparent.rotation;
		CreateDynamicEffect(DynamicAmmo.animeRefuel, position, rotation, baseparent);
	}

	private void CreateDynamicEffect(GameObject effectData, Vector3 pos, Quaternion rot, Transform baseparent, float scale = 1f)
	{
		//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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)effectData == (Object)null)
		{
			GH.DWarn("[UpdateEnemyThink] Try to create null effectData");
			return;
		}
		GameObject val = Object.Instantiate<GameObject>(effectData, pos, rot);
		if ((Object)(object)val == (Object)null)
		{
			GH.DWarn("[UpdateEnemyThink] Try to Instantiate object but return null");
		}
		else
		{
			val.transform.localScale = baseparent.localScale * scale;
		}
	}
}
public class DynamicMisc : MonoBehaviour
{
	public DynamicTower m_dTower;

	public int GeneratorCost;

	public bool miscEnable;

	public float miscUpdateInterval;

	public int miscTotal;

	public int miscUseCost;

	public int miscNumber;

	public bool miscTreeLog;

	public bool miscPickable;

	public bool miscBush;

	public bool miscRock;

	public bool miscStump;

	public bool miscSeagal;

	public bool showActivity;

	private List<GameObject> m_miscTarget = new List<GameObject>();

	private List<ZDOID> m_miscTarget2 = new List<ZDOID>();

	private bool m_miscCanTarget;

	private int tree;

	private int pick;

	private int seagul;

	private int statphy;

	private int radiusMult = 1;

	private float radiusApply;

	private Collider[] hitColliders;

	public void Awake()
	{
		if (Player.IsPlacementGhost(((Component)this).gameObject))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicMisc Awake");
		}
		m_dTower = ((Component)this).GetComponent<DynamicTower>();
		m_miscTarget.Clear();
		m_miscTarget2.Clear();
		if ((Object)(object)m_dTower.m_nview != (Object)null && m_dTower.m_nview.GetZDO() != null)
		{
			((MonoBehaviour)this).InvokeRepeating("FindTarget", 0f, miscUpdateInterval);
			((MonoBehaviour)this).InvokeRepeating("ShootTarget", 0f, 0.22f);
			m_dTower.m_nview.Register<int>("RPC_IncrementDynamicStats", (Action<long, int>)RPC_IncrementDynamicStats);
			if (showActivity)
			{
				GH.DWarn(" DynamicMisc Register");
			}
		}
	}

	private void FindTarget()
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05af: Unknown result type (might be due to invalid IL or missing references)
		//IL_0555: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)m_dTower == (Object)null || !m_dTower.IsShieldOwner() || !miscEnable || !m_dTower.IsEnoughtFuel(GeneratorCost + miscUseCost))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicMisc Trigger");
		}
		tree = 0;
		pick = 0;
		seagul = 0;
		statphy = 0;
		radiusApply = m_dTower.m_shield.m_radius / 3f * (float)radiusMult;
		radiusMult++;
		if (radiusMult > 3)
		{
			radiusMult = 1;
		}
		hitColliders = Physics.OverlapSphere(((Component)m_dTower.m_shield).transform.position, radiusApply);
		Collider[] array = hitColliders;
		foreach (Collider val in array)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			if (tree >= miscTotal && pick >= miscTotal && seagul >= miscTotal && statphy >= miscTotal)
			{
				break;
			}
			if (miscTreeLog)
			{
				TreeLog componentInParent = ((Component)val).GetComponentInParent<TreeLog>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					if (tree < miscTotal && (Object)(object)componentInParent.m_nview != (Object)null)
					{
						ReloadAmmo(((Component)componentInParent).gameObject, componentInParent.m_nview.GetZDO().m_uid);
						tree++;
					}
					continue;
				}
			}
			if (miscPickable)
			{
				Pickable componentInParent2 = ((Component)val).GetComponentInParent<Pickable>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					if (pick < miscTotal && (Object)(object)componentInParent2.m_nview != (Object)null && componentInParent2.m_nview.IsValid() && !componentInParent2.m_picked && componentInParent2.CanBePicked())
					{
						componentInParent2.m_nview.InvokeRPC("RPC_Pick", Array.Empty<object>());
						pick++;
						m_dTower.InvokeUseFuel(0, 5, 1);
					}
					continue;
				}
				PickableItem componentInParent3 = ((Component)val).GetComponentInParent<PickableItem>();
				if ((Object)(object)componentInParent3 != (Object)null)
				{
					if (pick < miscTotal && (Object)(object)componentInParent3.m_nview != (Object)null && componentInParent3.m_nview.IsValid() && !componentInParent3.m_picked)
					{
						componentInParent3.m_nview.InvokeRPC("Pick", Array.Empty<object>());
						pick++;
						m_dTower.InvokeUseFuel(0, 5, 1);
					}
					continue;
				}
				Beehive componentInParent4 = ((Component)val).GetComponentInParent<Beehive>();
				if ((Object)(object)componentInParent4 != (Object)null)
				{
					if (pick < miscTotal && (Object)(object)componentInParent4.m_nview != (Object)null && componentInParent4.m_nview.IsValid() && componentInParent4.GetHoneyLevel() >= 10)
					{
						componentInParent4.m_nview.InvokeRPC("RPC_Extract", Array.Empty<object>());
						InvokeIncrementStats((PlayerStatType)76);
						pick++;
						m_dTower.InvokeUseFuel(0, 5, 1);
					}
					continue;
				}
				SapCollector componentInParent5 = ((Component)val).GetComponentInParent<SapCollector>();
				if ((Object)(object)componentInParent5 != (Object)null)
				{
					if (pick < miscTotal && (Object)(object)componentInParent5.m_nview != (Object)null && componentInParent5.m_nview.IsValid() && componentInParent5.GetLevel() >= 10)
					{
						componentInParent5.m_nview.InvokeRPC("RPC_Extract", Array.Empty<object>());
						InvokeIncrementStats((PlayerStatType)77);
						pick++;
						m_dTower.InvokeUseFuel(0, 5, 1);
					}
					continue;
				}
			}
			if (miscSeagal)
			{
				RandomFlyingBird componentInParent6 = ((Component)val).GetComponentInParent<RandomFlyingBird>();
				if ((Object)(object)componentInParent6 != (Object)null)
				{
					if (seagul < miscTotal && ((Object)componentInParent6).name.StartsWith("Seagal") && (Object)(object)componentInParent6.m_nview != (Object)null && GH.TerrainCheck(((Component)componentInParent6).transform.position, -0.1f))
					{
						ReloadAmmo(((Component)componentInParent6).gameObject, componentInParent6.m_nview.GetZDO().m_uid);
						seagul++;
					}
					continue;
				}
			}
			if ((!miscStump && !miscRock && !miscBush) || statphy >= miscTotal)
			{
				continue;
			}
			StaticPhysics componentInParent7 = ((Component)val).GetComponentInParent<StaticPhysics>();
			Destructible componentInParent8 = ((Component)val).GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent7 != (Object)null && (Object)(object)componentInParent8 != (Object)null && (Object)(object)componentInParent7.m_nview != (Object)null)
			{
				m_miscCanTarget = false;
				if (((Object)componentInParent7).name.Contains("Stub") || ((Object)componentInParent7).name.Contains("Stump"))
				{
					m_miscCanTarget = miscStump;
				}
				else if (((Object)componentInParent7).name.StartsWith("Rock") && GH.TerrainCheck(((Component)componentInParent7).transform.position))
				{
					m_miscCanTarget = miscRock;
				}
				else if (((Object)componentInParent7).name.StartsWith("Bush"))
				{
					m_miscCanTarget = miscBush;
				}
				if (m_miscCanTarget)
				{
					ReloadAmmo(((Component)componentInParent7).gameObject, componentInParent7.m_nview.GetZDO().m_uid);
					statphy++;
				}
			}
		}
	}

	private void ReloadAmmo(GameObject target, ZDOID zdoid)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 3; i++)
		{
			m_miscTarget.Add(target);
			m_miscTarget2.Add(zdoid);
		}
		m_dTower.InvokeUseFuel(miscUseCost, 5, 1);
	}

	private void InvokeIncrementStats(PlayerStatType statType)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected I4, but got Unknown
		m_dTower.m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_IncrementDynamicStats", new object[1] { (int)statType });
	}

	private void RPC_IncrementDynamicStats(long sender, int statsType)
	{
		//IL_0030: 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)
		if ((Object)(object)ZNet.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && !ZNet.instance.IsServer() && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)m_dTower.m_shield).transform.position) <= m_dTower.m_shield.m_radius)
		{
			Game.instance.IncrementPlayerStat((PlayerStatType)statsType, 1f);
		}
	}

	private void ShootTarget()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: 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)
		if (m_dTower.IsShieldOwner() && m_miscTarget.Count > 0)
		{
			GameObject val = m_miscTarget.First();
			m_miscTarget.Remove(val);
			ZDOID val2 = m_miscTarget2.First();
			m_miscTarget2.Remove(val2);
			if ((Object)(object)val != (Object)null)
			{
				DynamicAmmo.ShootProjectile(m_dTower.m_shield, m_dTower, val2, val, DynamicAmmo.AmmoType.Ice);
			}
		}
	}
}
public class DynamicAmmo : MonoBehaviour
{
	public enum AmmoType
	{
		Ice,
		Light,
		Sham,
		Rads,
		len
	}

	public ZDOID targetZDOID;

	public ShieldGenerator m_tower;

	public Projectile m_projectile;

	public ZNetView m_nview;

	public GameObject m_target;

	public Character m_targetBff;

	public int retry;

	public bool hasHeight;

	public float m_ttl = 10f;

	public float turnRate = 180f;

	public Vector3 pointA;

	public Vector3 pointB;

	public Vector3 posAmmo;

	public Vector3 posBff;

	public Vector3 posNow;

	public Vector3 posOld = Vector3.zero;

	public Vector3 vecFwd;

	public List<Vector3> rayPoint = new List<Vector3>();

	private float deltaTime;

	private Collider aimCollider;

	public static float m_speed1 = 20f;

	public static float m_speed2 = 15f;

	public static float m_speed3 = 10f;

	private static GameObject projectileBuff;

	public static GameObject projectileIce;

	public static GameObject projectileLight;

	public static GameObject projectileSham;

	public static GameObject projectileRads;

	public static string[] projectileName_Dynamic = new string[4] { "DynamicIce", "DynamicLightning", "DynamicSham", "DynamicRad" };

	public static string[] projectileName_Vanilla = new string[4] { "staff_iceshard_projectile", "staff_lightning_projectile", "GoblinShaman_projectile_fireball", "radiation" };

	public static GameObject animeMiniAoe;

	public static GameObject animeRefuel;

	public static GameObject animeDomehit;

	public static float projectileDamage;

	public static float iceshardFrost;

	public static float lightningLight;

	public static float fireballFire;

	public static float radiatonSpirit;

	public static bool seeThruWall;

	public static bool canHitStructure;

	public static bool canHitPlayer;

	public static bool canHitTameable;

	public static bool canHitWild;

	public static bool canHitBoss;

	public static bool showDebugRay;

	private static Vector3 endPos = default(Vector3);

	private TreeBase hitTreeBase;

	private Projectile hitProjectile;

	private WearNTear hitWearTear;

	private Collider[] hitColliders;

	public void Awake()
	{
		m_nview = ((Component)this).GetComponent<ZNetView>();
		m_projectile = ((Component)this).GetComponent<Projectile>();
		if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null)
		{
			((MonoBehaviour)this).InvokeRepeating("SlowUpdate", 0f, 1f);
			((MonoBehaviour)this).InvokeRepeating("UpdateTarget", 0f, 0.22f);
			m_nview.Register("RPC_IncrementDynamicAmmoSkill", (Action<long>)RPC_IncrementDynamicAmmoSkill);
		}
	}

	public void FixedUpdate()
	{
		//IL_00ab: 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_00b5: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: 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_00d2: 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_016c: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)m_nview == (Object)null || !m_nview.IsOwner())
		{
			return;
		}
		if ((Object)(object)m_target == (Object)null && retry <= 2)
		{
			retry++;
			if ((Object)(object)m_tower != (Object)null)
			{
				m_targetBff = GetEnemyInRange(pointA, m_tower.m_radius, new List<Character>());
				if ((Object)(object)m_targetBff != (Object)null)
				{
					m_target = ((Component)m_targetBff).gameObject;
				}
			}
		}
		if ((Object)(object)m_target != (Object)null)
		{
			posBff = GetCenterAim(m_target, posBff);
		}
		else if (!hasHeight)
		{
			hasHeight = true;
			posBff.y = GH.GetTerrainHeight(posBff);
		}
		pointB = posBff;
		posAmmo = ((Component)m_projectile).transform.position;
		posNow = GetVecForward(pointA, posAmmo, pointB, 0.5f, out vecFwd);
		m_projectile.m_vel = Vector3.RotateTowards(m_projectile.m_vel, vecFwd, turnRate * Time.deltaTime * ((float)Math.PI / 180f), 0f);
		if (showDebugRay)
		{
			if (Vector3.Distance(posNow, posOld) > 0.5f)
			{
				posOld = posNow;
				rayPoint.Add(posOld);
			}
			GH.DrawRayLine(rayPoint, 0.05f, 0.1f, Color.red);
		}
	}

	public void InvokeIncrementAmmoSkill()
	{
		m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_IncrementDynamicAmmoSkill", Array.Empty<object>());
	}

	public void RPC_IncrementDynamicAmmoSkill(long sender)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00b3: Invalid comparison between Unknown and I4
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: 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_0173: 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)
		if ((Object)(object)Player.m_localPlayer == (Object)null || !(Vector3.Distance(((Component)m_tower).transform.position, ((Component)Player.m_localPlayer).transform.position) <= m_tower.m_radius))
		{
			return;
		}
		float raiseSkillAmount = m_projectile.m_raiseSkillAmount;
		string text = "";
		SkillType val = (SkillType)0;
		if (((Character)Player.m_localPlayer).GetSkillFactor(m_projectile.m_skill) < 1f)
		{
			val = (SkillType)10;
			text = "Blood +";
		}
		else if (((Character)Player.m_localPlayer).GetSkillFactor((SkillType)9) < 1f)
		{
			val = (SkillType)9;
			text = "Element +";
		}
		else
		{
			val = (SkillType)999;
			text = "++ All Skills ++";
		}
		if ((int)val != 0)
		{
			if ((int)val == 999)
			{
				AddSkills((SkillType)1, raiseSkillAmount);
				AddSkills((SkillType)2, raiseSkillAmount);
				AddSkills((SkillType)3, raiseSkillAmount);
				AddSkills((SkillType)4, raiseSkillAmount);
				AddSkills((SkillType)6, raiseSkillAmount);
				AddSkills((SkillType)7, raiseSkillAmount);
				AddSkills((SkillType)8, raiseSkillAmount);
				AddSkills((SkillType)11, raiseSkillAmount);
				AddSkills((SkillType)12, raiseSkillAmount);
				AddSkills((SkillType)13, raiseSkillAmount);
				AddSkills((SkillType)14, raiseSkillAmount);
				AddSkills((SkillType)100, raiseSkillAmount);
				AddSkills((SkillType)101, raiseSkillAmount);
				AddSkills((SkillType)102, raiseSkillAmount);
				AddSkills((SkillType)103, raiseSkillAmount);
				AddSkills((SkillType)104, raiseSkillAmount);
				AddSkills((SkillType)110, raiseSkillAmount);
			}
			else
			{
				AddSkills(val, raiseSkillAmount);
			}
			Vector3 position = ((Component)Player.m_localPlayer).transform.position;
			position.y += 1.2f;
			float num = 1f;
			((Character)Player.m_localPlayer).m_seman.ModifyRaiseSkill(val, ref num);
			text += num * raiseSkillAmount;
			DynamicText.instance.ShowText(DynamicText.TextType.Skill, position, text);
		}
		static void AddSkills(SkillType addskilltype, float skillamount)
		{
			//IL_0005: 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)
			if (((Character)Player.m_localPlayer).GetSkillFactor(addskilltype) < 1f)
			{
				((Character)Player.m_localPlayer).RaiseSkill(addskilltype, skillamount);
			}
		}
	}

	public void SetStartPoint(Vector3 start)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		pointA = start;
		posAmmo = start;
		posOld = start;
		rayPoint.Add(start);
	}

	private Vector3 GetVecForward(Vector3 start, Vector3 ammo, Vector3 end, float targetOffsets, out Vector3 fwd)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//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)
		//IL_0048: 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_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)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0069: 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_0078: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_009a: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: 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_00fe: 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_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		if (DistanceVector2(ammo, end) < 5f)
		{
			fwd = end - ammo;
			return end;
		}
		float num = DistanceVector2(start, end);
		float num2 = DistanceVector2(start, ammo) + targetOffsets;
		Vector3 val = (end - start) / 3f;
		Vector3 val2 = start + val + Vector3.up * 15f;
		Vector3 val3 = val2 + val + Vector3.up * 15f;
		if (num2 <= num)
		{
			deltaTime = num2 / num;
		}
		Vector3 val4 = Vector3.Lerp(start, val2, deltaTime);
		Vector3 val5 = Vector3.Lerp(val2, val3, deltaTime);
		Vector3 val6 = Vector3.Lerp(val3, end, deltaTime);
		Vector3 val7 = Vector3.Lerp(val4, val5, deltaTime);
		Vector3 val8 = Vector3.Lerp(val5, val6, deltaTime);
		Vector3 val9 = Vector3.Lerp(val7, val8, deltaTime) + Vector3.up * 7f;
		fwd = val9 - ammo;
		return val9;
	}

	private float DistanceVector2(Vector3 startt, Vector3 endd)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = startt;
		val.y = endd.y;
		return Vector3.Distance(val, endd);
	}

	private Vector3 GetCenterAim(GameObject target, Vector3 oldAimCenter)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		aimCollider = target.GetComponent<Collider>();
		if ((Object)(object)aimCollider != (Object)null)
		{
			Bounds bounds = aimCollider.bounds;
			return ((Bounds)(ref bounds)).center;
		}
		return oldAimCenter;
	}

	public static Character GetEnemyInRange(Vector3 basePos, float range, List<Character> excludList, float targetHeight = 0f)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_0087: 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_00a3: 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_00ad: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		foreach (Character s_character in Character.s_characters)
		{
			if (excludList.Contains(s_character) || (Object)(object)s_character == (Object)null || Vector3.Distance(((Component)s_character).transform.position, basePos) > range || (Object)(object)((Component)s_character).GetComponent<Growup>() != (Object)null || (s_character.IsBoss() && !canHitBoss))
			{
				continue;
			}
			if (!seeThruWall)
			{
				endPos = new Vector3(((Component)s_character).transform.position.x, ((Component)s_character).transform.position.y + targetHeight, ((Component)s_character).transform.position.z);
				if (GH.RaycastIsBlocked(basePos, endPos))
				{
					continue;
				}
			}
			if (!canHitPlayer && (int)s_character.m_faction == 0)
			{
				continue;
			}
			if ((Object)(object)((Component)s_character).GetComponent<Tameable>() != (Object)null)
			{
				if (s_character.IsTamed())
				{
					if (!canHitTameable)
					{
						continue;
					}
				}
				else if (!canHitWild)
				{
					continue;
				}
			}
			if (!s_character.IsDead())
			{
				excludList.Add(s_character);
				return s_character;
			}
		}
		return null;
	}

	public static void ShootProjectile(ShieldGenerator tower, DynamicTower dyntower, ZDOID zdoid, GameObject victim, AmmoType ammotype)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_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_00c9: 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_00ec: 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_00fe: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: 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_013c: 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_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: 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_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		projectileBuff = GetAmmoFromType(ammotype);
		if ((Object)(object)tower == (Object)null || (Object)(object)dyntower == (Object)null || (Object)(object)victim == (Object)null || (Object)(object)projectileBuff == (Object)null)
		{
			return;
		}
		Vector3 val = GetTowerShootPos(addoffsets: true);
		Vector3 val2 = val;
		val2.y += 1f;
		Vector3 val3 = val2 - val;
		Quaternion val4 = Quaternion.LookRotation(val3, Vector3.up);
		GameObject val5 = Object.Instantiate<GameObject>(projectileBuff, val, val4);
		if ((Object)(object)val5 == (Object)null)
		{
			return;
		}
		Projectile component = val5.GetComponent<Projectile>();
		DynamicAmmo component2 = val5.GetComponent<DynamicAmmo>();
		if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
		{
			Object.Destroy((Object)(object)val5);
			return;
		}
		component2.targetZDOID = zdoid;
		component2.m_tower = tower;
		component2.m_target = victim;
		component2.pointB = victim.transform.position;
		component2.posBff = victim.transform.position;
		component2.SetStartPoint(val);
		float num = Vector3.Distance(component2.pointA, component2.pointB);
		if (num <= 5f)
		{
			component.m_vel = ((Vector3)(ref val3)).normalized * m_speed3;
		}
		else if (num <= 10f)
		{
			component.m_vel = ((Vector3)(ref val3)).normalized * m_speed2;
		}
		else
		{
			component.m_vel = ((Vector3)(ref val3)).normalized * m_speed1;
		}
		HitData val6 = new HitData();
		((DamageTypes)(ref val6.m_damage)).Add(GetDamageType(ammotype), 1);
		val6.m_pushForce = 3f;
		val6.m_backstabBonus = 3f;
		val6.m_dodgeable = false;
		val6.m_blockable = false;
		val6.m_ranged = true;
		val6.m_skill = (SkillType)10;
		val6.m_skillRaiseAmount = (Game.m_worldLevel + 1) * 2;
		val6.m_hitType = (HitType)19;
		val6.m_healthReturn = 10f;
		val6.m_toolTier = 4;
		val6.m_itemWorldLevel = 0;
		val6.m_staggerMultiplier = 3f;
		component.m_damage = val6.m_damage;
		component.m_originalHitData = val6;
		component.m_stayTTL = 0f;
		component.m_gravity = 0f;
		component.m_stayAfterHitStatic = false;
		component.m_stayAfterHitDynamic = false;
		component.m_skill = val6.m_skill;
		component.m_raiseSkillAmount = val6.m_skillRaiseAmount;
		Rigidbody component3 = ((Component)component).GetComponent<Rigidbody>();
		if ((Object)(object)component3 != (Object)null)
		{
			component3.mass = 0f;
		}
		Piece component4 = ((Component)tower).GetComponent<Piece>();
		if ((Object)(object)component4 != (Object)null)
		{
			long creator = component4.GetCreator();
			component.m_owner = (Character)(object)Player.GetPlayer(creator);
			if ((Object)(object)component.m_owner != (Object)null)
			{
				val6.m_attacker = component.m_owner.GetZDOID();
			}
		}
		if ((Object)(object)component.m_owner == (Object)null)
		{
			component.m_owner = (Character)(object)Player.GetPlayer(tower.m_nview.GetZDO().GetOwner());
			if ((Object)(object)component.m_owner != (Object)null)
			{
				val6.m_attacker = component.m_owner.GetZDOID();
			}
		}
		IProjectile component5 = val5.GetComponent<IProjectile>();
		if (component5 != null)
		{
			component5.Setup(component.m_owner, component.m_vel, 0f, val6, (ItemData)null, (ItemData)null);
		}
		static GameObject GetAmmoFromType(AmmoType type)
		{
			GameObject val8 = null;
			switch (type)
			{
			case AmmoType.Ice:
				val8 = projectileIce;
				if ((Object)(object)val8 == (Object)null)
				{
					GH.DWarn(" projectileIce == null");
				}
				break;
			case AmmoType.Light:
				val8 = projectileLight;
				if ((Object)(object)val8 == (Object)null)
				{
					GH.DWarn(" projectileLight == null");
				}
				break;
			case AmmoType.Sham:
				val8 = projectileSham;
				if ((Object)(object)val8 == (Object)null)
				{
					GH.DWarn(" projectileSham == null");
				}
				break;
			case AmmoType.Rads:
				val8 = projectileRads;
				if ((Object)(object)val8 == (Object)null)
				{
					GH.DWarn(" projectileRads == null");
				}
				break;
			default:
				val8 = null;
				GH.DWarn(" Attempt to fetch unknown projectile type");
				break;
			}
			return val8;
		}
		static DamageTypes GetDamageType(AmmoType type)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes result = default(DamageTypes);
			switch (type)
			{
			case AmmoType.Ice:
				result.m_damage = projectileDamage;
				result.m_blunt = 50f;
				result.m_slash = 50f;
				result.m_pierce = 50f;
				result.m_chop = 50f;
				result.m_pickaxe = 50f;
				break;
			case AmmoType.Light:
				result.m_damage = projectileDamage;
				result.m_lightning = lightningLight;
				result.m_poison = 3f;
				break;
			case AmmoType.Sham:
				result.m_damage = projectileDamage;
				result.m_fire = fireballFire;
				result.m_poison = 3f;
				break;
			case AmmoType.Rads:
				result.m_damage = projectileDamage;
				result.m_spirit = radiatonSpirit;
				result.m_poison = 3f;
				break;
			}
			return result;
		}
		Vector3 GetTowerShootPos(bool addoffsets = false)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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)
			Vector3 val7 = ((Component)tower).transform.position;
			val7.y += DynamicTower.fixedHeight + 0.5f;
			if ((Object)(object)dyntower != (Object)null)
			{
				if (addoffsets)
				{
					val7 += dyntower.shootOffsets[dyntower.offsets];
					dyntower.offsets++;
					if (dyntower.offsets >= dyntower.shootOffsets.Length)
					{
						dyntower.offsets = 0;
					}
				}
			}
			else
			{
				val7 += Random.onUnitSphere * 1.5f;
			}
			return val7;
		}
	}

	public static bool IsAmmo(string name)
	{
		if (name.StartsWith(projectileName_Dynamic[0]) || name.StartsWith(projectileName_Dynamic[1]) || name.StartsWith(projectileName_Dynamic[2]) || name.StartsWith(projectileName_Dynamic[3]))
		{
			return true;
		}
		return false;
	}

	public bool IsHitPiecesNStatic(Collider projectileCollider, GameObject hitObject)
	{
		hitTreeBase = hitObject.GetComponent<TreeBase>();
		if ((Object)(object)hitTreeBase != (Object)null)
		{
			IgnoreAllCollider(projectileCollider, hitObject);
			return true;
		}
		hitProjectile = hitObject.GetComponent<Projectile>();
		if ((Object)(object)hitProjectile != (Object)null)
		{
			IgnoreAllCollider(projectileCollider, hitObject);
			return true;
		}
		hitWearTear = hitObject.GetComponent<WearNTear>();
		if ((Object)(object)hitWearTear != (Object)null && !canHitStructure)
		{
			IgnoreAllCollider(projectileCollider, hitObject);
			return true;
		}
		return false;
		void IgnoreAllCollider(Collider baseCollider, GameObject go)
		{
			hitColliders = go.GetComponentsInChildren<Collider>(true);
			if (hitColliders.Length != 0)
			{
				Collider[] array = hitColliders;
				foreach (Collider val in array)
				{
					Physics.IgnoreCollision(baseCollider, val);
				}
			}
		}
	}

	public bool IsHitCharacter(Collider projectileCollider, Character character)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((Component)character).GetComponent<Tameable>() != (Object)null)
		{
			if (character.m_tamed)
			{
				if (!canHitTameable)
				{
					Physics.IgnoreCollision(projectileCollider, ((Component)character).gameObject.GetComponent<Collider>());
					return true;
				}
			}
			else if (!canHitWild)
			{
				Physics.IgnoreCollision(projectileCollider, ((Component)character).gameObject.GetComponent<Collider>());
				return true;
			}
		}
		else if ((int)character.m_faction == 0 && character.IsPlayer())
		{
			if (!canHitPlayer)
			{
				Physics.IgnoreCollision(projectileCollider, ((Component)character).gameObject.GetComponent<Collider>());
				return true;
			}
		}
		else if (character.IsBoss() && !canHitBoss)
		{
			Physics.IgnoreCollision(projectileCollider, ((Component)character).gameObject.GetComponent<Collider>());
			return true;
		}
		return false;
	}
}
public class DynamicText : MonoBehaviour
{
	public enum TextType
	{
		Heal,
		Repair,
		Pickup,
		Destroy,
		Enemy,
		Misc,
		AOE,
		Skill
	}

	public class WorldTextInstance
	{
		public Vector3 m_worldPos;

		public GameObject m_gui;

		public float m_timer;

		public TMP_Text m_textField;
	}

	public static DynamicText m_instance;

	public float m_textDuration = 1.5f;

	public float m_maxTextDistance = 30f;

	public int m_largeFontSize = 16;

	public int m_smallFontSize = 8;

	public float m_smallFontDistance = 10f;

	public GameObject m_worldTextBase;

	public List<WorldTextInstance> m_worldTexts = new List<WorldTextInstance>();

	public DamageText m_body;

	private float alpha = 0.5f;

	public static DynamicText instance => m_instance;

	public void Awake()
	{
		m_instance = this;
		m_body = ((Component)this).GetComponent<DamageText>();
		m_worldTextBase = DamageText.instance.m_worldTextBase;
		ZRoutedRpc.instance.Register<ZPackage>("RPC_DamageText", (Action<long, ZPackage>)RPC_DamageText);
	}

	public void LateUpdate()
	{
		UpdateWorldTexts(Time.deltaTime);
	}

	public void UpdateWorldTexts(float dt)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		WorldTextInstance worldTextInstance = null;
		Camera mainCamera = Utils.GetMainCamera();
		foreach (WorldTextInstance worldText in m_worldTexts)
		{
			worldText.m_timer += dt;
			if (worldText.m_timer > m_textDuration && worldTextInstance == null)
			{
				worldTextInstance = worldText;
			}
			worldText.m_worldPos.y += dt;
			float num = Mathf.Clamp01(worldText.m_timer / m_textDuration);
			Color color = ((Graphic)worldText.m_textField).color;
			color.a = 1f - Mathf.Pow(num, 3f);
			((Graphic)worldText.m_textField).color = color;
			Vector3 val = Utils.WorldToScreenPointScaled(mainCamera, worldText.m_worldPos);
			if (val.x < 0f || val.x > (float)Screen.width || val.y < 0f || val.y > (float)Screen.height || val.z < 0f)
			{
				worldText.m_gui.SetActive(false);
				continue;
			}
			worldText.m_gui.SetActive(true);
			worldText.m_gui.transform.position = val;
		}
		if (worldTextInstance != null)
		{
			Object.Destroy((Object)(object)worldTextInstance.m_gui);
			m_worldTexts.Remove(worldTextInstance);
		}
	}

	public void AddInworldText(TextType type, Vector3 pos, float distance, string num, bool mySelf)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_007b: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		if (m_worldTexts.Count <= 200)
		{
			WorldTextInstance worldTextInstance = new WorldTextInstance();
			worldTextInstance.m_worldPos = pos + Random.insideUnitSphere * 0.5f;
			worldTextInstance.m_gui = Object.Instantiate<GameObject>(m_worldTextBase, ((Component)this).transform);
			worldTextInstance.m_textField = worldTextInstance.m_gui.GetComponent<TMP_Text>();
			worldTextInstance.m_timer = 0f;
			m_worldTexts.Add(worldTextInstance);
			string text = "";
			Color color = Color.white;
			GetColorNText(type, ref text, ref color);
			worldTextInstance.m_textField.text = text + num;
			((Graphic)worldTextInstance.m_textField).color = color;
			if (distance > m_smallFontDistance)
			{
				worldTextInstance.m_textField.fontSize = m_smallFontSize;
			}
			else
			{
				worldTextInstance.m_textField.fontSize = m_largeFontSize;
			}
		}
	}

	private void GetColorNText(TextType texttype, ref string text, ref Color color)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_00a3: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: 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_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: 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)
		text = "";
		color = Color.white;
		switch (texttype)
		{
		case TextType.Heal:
			color = new Color(0f, 1f, 0f, alpha);
			text = "Heal ";
			break;
		case TextType.Repair:
			color = new Color(0.4f, 1f, 0.4f, alpha);
			text = "Repair ";
			break;
		case TextType.Pickup:
			color = new Color(0f, 1f, 1f, alpha);
			text = "Pickup ";
			break;
		case TextType.Destroy:
			color = new Color(1f, 0.5f, 0.5f, alpha);
			text = "Destroy ";
			break;
		case TextType.Enemy:
			color = new Color(1f, 0.62f, 0.31f, alpha);
			text = "Enemy ";
			break;
		case TextType.Misc:
			color = new Color(1f, 1f, 0.7f, alpha);
			text = "Misc ";
			break;
		case TextType.AOE:
			color = new Color(1f, 0f, 0f, alpha);
			text = "AOE ";
			break;
		case TextType.Skill:
			color = Color.yellow;
			text = "";
			break;
		default:
			color = Color.white;
			break;
		}
	}

	public void ShowText(TextType type, Vector3 pos, string num, bool player = false)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		ZPackage val = new ZPackage();
		val.Write((int)type);
		val.Write(pos);
		val.Write(num);
		val.Write(player);
		ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_DamageText", new object[1] { val });
	}

	public void RPC_DamageText(long sender, ZPackage pkg)
	{
		//IL_001d: 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_0038: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		Camera mainCamera = Utils.GetMainCamera();
		if (Object.op_Implicit((Object)(object)mainCamera) && !Hud.IsUserHidden())
		{
			TextType type = (TextType)pkg.ReadInt();
			Vector3 val = pkg.ReadVector3();
			string num = pkg.ReadString();
			bool flag = pkg.ReadBool();
			float num2 = Vector3.Distance(((Component)mainCamera).transform.position, val);
			if (!(num2 > m_maxTextDistance))
			{
				bool mySelf = flag && sender == ZNet.GetUID();
				AddInworldText(type, val, num2, num, mySelf);
			}
		}
	}
}
public class DynamicTower : MonoBehaviour
{
	public ShieldGenerator m_shield;

	public ZNetView m_nview;

	public Container m_container;

	public bool showActivity;

	public int generatorCost;

	private Transform fakeDome1;

	private Transform fakeDome2;

	private Transform[] fakeWisps;

	public int Frag;

	public int Chrd = 1;

	public int Fuel = 2;

	private bool isDropContent;

	public float[] fuelAmount = new float[3] { -1f, -1f, -1f };

	public string[] fuelName = new string[3] { "BoneFragments", "CharredBone", "None" };

	private int wispNum;

	private int maxWisp = 10;

	private int ringNum;

	private int maxRing = 5;

	private float ringRad;

	private float ringOff;

	private Color ringColor = new Color(0.313f, 1f, 1f, 0.3f);

	private float particlePosition = 4f;

	private float particleDirection = 1f;

	private float triggerTime = 10f;

	public float domeScale;

	private bool triggerIsUsed;

	private Vector3 fixedPoint = new Vector3(0f, fixedHeight, 0f);

	public int offsets;

	public Vector3[] shootOffsets = (Vector3[])(object)new Vector3[5]
	{
		new Vector3(0f, 0f, 0f),
		new Vector3(0f, 0f, 1f),
		new Vector3(1f, 0f, 1f),
		new Vector3(1f, 0f, -1f),
		new Vector3(-1f, 0f, 1f)
	};

	public static GameObject DynamicGoblin;

	public static GameObject DynamicStaff;

	public static GameObject DynamicWisp;

	public static string[] fakeName_Goblin = new string[2] { "vfx_DynamicGoblinShield", "vfx_GoblinShield" };

	public static string[] fakeName_Staff = new string[2] { "vfx_DynamicStaffShield", "vfx_StaffShield" };

	public static string[] fakeName_Wisp = new string[2] { "DynamicWisp", "LuredWisp" };

	public static float shieldScale = 1.5f;

	public static float fixedHeight = 6.7f;

	private string zdoCount;

	private int healCount;

	private int repairCount;

	private int pickupCount;

	private int destroyCount;

	private int enemyCount;

	private int miscCount;

	private int aoeCount;

	public void Awake()
	{
		if (Player.IsPlacementGhost(((Component)this).gameObject))
		{
			return;
		}
		if (showActivity)
		{
			GH.DWarn(" DynamicTrigger Awake");
		}
		m_shield = ((Component)this).GetComponent<ShieldGenerator>();
		m_nview = ((Component)this).GetComponent<ZNetView>();
		m_container = ((Component)this).GetComponent<Container>();
		fuelAmount[Fuel] = -1f;
		isDropContent = false;
		if (!((Object)(object)m_nview != (Object)null) || m_nview.GetZDO() == null)
		{
			return;
		}
		((MonoBehaviour)this).InvokeRepeating("ApplyShieldEffect", 0f, 0.5f);
		m_nview.Register<string, int>("RPC_AddDynamicFuel", (Action<long, string, int>)RPC_AddDynamicFuel);
		m_nview.Register<int, int, int>("RPC_UseDynamicFuel", (Action<long, int, int, int>)RPC_UseDynamicFuel);
		m_nview.Register<int>("RPC_UseDynamicAoe", (Action<long, int>)RPC_UseDynamicAoe);
		if ((Object)(object)m_shield != (Object)null)
		{
			EffectData[] effectPrefabs = m_shield.m_fuelAddedEffects.m_effectPrefabs;
			foreach (EffectData val in effectPrefabs)
			{
				if (val != null && (Object)(object)val.m_prefab != (Object)null && ((Object)val.m_prefab).name == "sfx_kiln_addore")
				{
					val.m_prefab.SetActive(false);
					break;
				}
			}
		}
		((MonoBehaviour)this).InvokeRepeating("DynamicSlowUpdate", 0f, 1f);
		if (m_nview.IsOwner())
		{
			RemoveAllWisp();
		}
	}

	public void Update()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		if (!IsShieldValid())
		{
			return;
		}
		if (ringNum > 0)
		{
			ringRad = 1.8f;
			ringOff = -1f;
			for (int i = 0; i < ringNum; i++)
			{
				GH.DrawRayCircle(((Component)m_shield).transform.position, 0.1f, ringRad, (fixedHeight + ringOff) * shieldScale, ringColor);
				ringRad -= 0.3f;
				ringOff -= 0.5f;
			}
		}
		if (fuelAmount[Fuel] > 0f)
		{
			GH.ShowHaloRing(m_shield, "DynamicParticle_Ring1", 2f, 1.4f, ref particlePosition, ref particleDirection);
			GH.FollowLeadHaloRing(m_shield, "DynamicParticle_Ring2", 1.2f, particlePosition - 0.5f);
			GH.FollowLeadHaloRing(m_shield, "DynamicParticle_Ring3", 1f, particlePosition - 1f);
			GH.FollowLeadHaloRing(m_shield, "DynamicParticle_Ring4", 0.8f, particlePosition - 1.5f);
		}
		if (m_nview.IsOwner())
		{
			domeScale = Mathf.Max(fuelAmount[Fuel] / (float)m_shield.m_maxFuel, 0.1f);
			FindandSet(fakeName_Goblin[0] + "(Clone)", domeScale, 0.5f * domeScale);
			FindandSet(fakeName_Staff[0] + "(Clone)", domeScale);
		}
		void FindandSet(string fxname, float set, float rad = 0f)
		{
			fakeDome1 = ((Component)m_shield).transform.Find(fxname);
			if ((Object)(object)fakeDome1 != (Object)null)
			{
				UpdateLocalPosition(((Component)fakeDome1).gameObject, set, rad);
			}
		}
	}

	public void DynamicSlowUpdate()
	{
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		if (!IsShieldValid())
		{
			return;
		}
		if (fuelAmount[Fuel] == -1f)
		{
			LoadFuel();
			LoadCounter();
			fakeDome2 = ((Component)m_shield).transform.Find(fakeName_Goblin[0] + "(Clone)");
			if ((Object)(object)fakeDome2 != (Object)null)
			{
				ZNetScene.instance.Destroy(((Component)fakeDome2).gameObject);
			}
			fakeDome2 = ((Component)m_shield).transform.Find(fakeName_Staff[0] + "(Clone)");
			if ((Object)(object)fakeDome2 != (Object)null)
			{
				ZNetScene.instance.Destroy(((Component)fakeDome2).gameObject);
			}
			return;
		}
		if (triggerIsUsed && GH.IsTimeElpase(m_nview, ZDOVars.s_lastTime, triggerTime))
		{
			triggerIsUsed = false;
		}
		ringNum = CountRingNumber();
		if (!m_nview.IsOwner() || isDropContent)
		{
			return;
		}
		fakeDome2 = ((Component)m_shield).transform.Find(fakeName_Goblin[0] + "(Clone)");
		if ((Object)(object)fakeDome2 == (Object)null)
		{
			CreateDome(DynamicGoblin);
		}
		fakeDome2 = ((Component)m_shield).transform.Find(fakeName_Staff[0] + "(Clone)");
		if ((Object)(object)fakeDome2 == (Object)null)
		{
			CreateDome(DynamicStaff);
		}
		fakeWisps = FindChildren(((Component)m_shield).transform, fakeName_Wisp[0] + "(Clone)");
		wispNum = GetWispNumber();
		if (wispNum < fakeWisps.Length)
		{
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				Transform val = ((Component)m_shield).transform.Find(fakeName_Wisp[0] + "(Clone)");
				if ((Object)(object)val != (Object)null)
				{
					ZNetScene.instance.Destroy(((Component)val).gameObject);
				}
			}
		}
		else
		{
			if (wispNum <= fakeWisps.Length || !((Object)(object)ZNetScene.instance != (Object)null))
			{
				return;
			}
			Vector3 val2 = ((Component)m_shield).transform.position + Vector3.up * fixedHeight * shieldScale;
			GameObject val3 = Object.Instantiate<GameObject>(DynamicWisp, val2, Quaternion.identity);
			if ((Object)(object)val3 != (Object)null)
			{
				val3.transform.SetParent(((Component)m_shield).transform, true);
				val3.transform.localPosition = new Vector3(0f, fixedHeight * shieldScale, 0f);
				LuredWisp component = val3.GetComponent<LuredWisp>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_despawnTimer = 3f;
					component.m_targetPoint = val2;
					component.m_despawnInDaylight = false;
				}
				else
				{
					ZNetScene.instance.Destroy(val3);
				}
			}
		}
		int CountRingNumber()
		{
			return (int)Mathf.Ceil(Mathf.Lerp(0f, (float)maxRing, fuelAmount[Fuel] / (float)m_shield.m_maxFuel));
		}
		int GetWispNumber()
		{
			return (int)Mathf.Ceil(Mathf.Lerp(0f, (float)maxWisp, fuelAmount[Fuel] / (float)m_shield.m_maxFuel));
		}
	}

	private Transform[] FindChildren(Transform transform, string name)
	{
		return (from t in ((Component)transform).GetComponentsInChildren<Transform>()
			where ((Object)t).name == name
			select t).ToArray();
	}

	private void RemoveAllWisp()
	{
		if ((Object)(object)ZNetScene.instance == (Object)null)
		{
			return;
		}
		Transform[] array = FindChildren(((Component)m_shield).transform, fakeName_Wisp[0] + "(Clone)");
		if (array.Length != 0)
		{
			for (int i = 0; i < array.Length; i++)
			{
				ZNetScene.instance.Destroy(((Component)array[i]).gameObject);
			}
		}
	}

	private GameObject CreateDome(GameObject fxobj, float addRadius = 0f)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)m_shield).transform.position + Vector3.up * fixedHeight * shieldScale;
		GameObject val2 = Object.Instantiate<GameObject>(fxobj, val, ((Component)m_shield).transform.rotation);
		if ((Object)(object)val2 != (Object)null)
		{
			val2.transform.SetParent(((Component)m_shield).transform, true);
			UpdateLocalPosition(val2, 0.1f, addRadius);
			return val2;
		}
		return null;
	}

	private void UpdateLocalPosition(GameObject vfxobj, float innerRad, float addRadius = 0f)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)vfxobj != (Object)null)
		{
			vfxobj.transform.localScale = new Vector3(innerRad + addRadius, innerRad + addRadius, innerRad + addRadius);
			vfxobj.transform.localPosition = new Vector3(0f, fixedHeight, 0f);
		}
	}

	public void InvokeUseAoe(int cost)
	{
		triggerIsUsed = true;
		m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_UseDynamicAoe", new object[1] { cost });
	}

	private void RPC_UseDynamicAoe(long sender, int amount)
	{
		triggerIsUsed = true;
		RPC_UseDynamicFuel(0L, amount, 6, 1);
		if ((Object)(object)m_nview != (Object)null && m_nview.IsOwner())
		{
			GH.SetZDOsTime(m_nview, ZDOVars.s_lastTime);
		}
	}

	public void InvokeAddFuel(string fuelname, int amount = 1)
	{
		m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_AddDynamicFuel", new object[2] { fuelname, amount });
	}

	private void RPC_AddDynamicFuel(long sender, string fuelname, int amount)
	{
		//IL_0098: 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)
		if (fuelname.StartsWith(fuelName[Frag]))
		{
			fuelAmount[Frag] += amount;
		}
		else if (fuelname.StartsWith(fuelName[Chrd]))
		{
			fuelAmount[Chrd] += amount;
		}
		fuelAmount[Fuel] = fuelAmount[Frag] + fuelAmount[Chrd];
		m_shield.m_fuelAddedEffects.Create(((Component)m_shield).transform.position, ((Component)m_shield).transform.rotation, ((Component)m_shield).transform, 1f, -1);
		SetFuel();
	}

	public void InvokeUseFuel(int cost, int DynType, int hitCount)
	{
		m_nview.InvokeRPC(ZRoutedRpc.Everybody, "RPC_UseDynamicFuel", new object[3] { cost, DynType, hitCount });
	}

	private void RPC_UseDynamicFuel(long sender, int amount, int type, int hitNum)
	{
		if (fuelAmount[Frag] > 0f)
		{
			fuelAmount[Frag] = Mathf.Max(fuelAmount[Frag] - (float)amount, 0f);
		}
		else if (fuelAmount[Chrd] > 0f)
		{
			fuelAmount[Chrd] = Mathf.Max(fuelAmount[Chrd] - (float)amount, 0f);
		}
		fuelAmount[Fuel] = fuelAmount[Frag] + fuelAmount[Chrd];
		SetFuel();
		for (int i = 0; i < hitNum; i++)
		{
			ShowHitCount((DynamicText.TextType)type);
		}
	}

	private void SetFuel()
	{
		if ((Object)(object)m_nview != (Object)null && m_nview.IsOwner())
		{
			m_nview.GetZDO().Set(ZDOVars.s_stamina, Mathf.Max(fuelAmount[Frag], 0f));
			m_nview.GetZDO().Set(ZDOVars.s_health, Mathf.Max(fuelAmount[Chrd], 0f));
			m_nview.GetZDO().Set(ZDOVars.s_fuel, Mathf.Max(fuelAmount[Fuel], 0f));
		}
	}

	public void DropOnDestroy(Container crate, GameObject cargeCrate)
	{
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		if (((Object)(object)ZNetScene.instance == (Object)null && (Object)(object)m_shield == (Object)null) || (Object)(object)m_nview == (Object)null)
		{
			return;
		}
		isDropContent = true;
		if (!m_nview.IsOwner())
		{
			return;
		}
		Transform val = ((Component)m_shield).transform.Find(fakeName_Goblin[0] + "(Clone)");
		if ((Object)(object)val != (Object)null)
		{
			ZNetScene.instance.Destroy(((Component)val).gameObject);
		}
		val = ((Component)m_shield).transform.Find(fakeName_Staff[0] + "(Clone)");
		if ((Object)(object)val != (Object)null)
		{