Decompiled source of Zarkow Turret Defense v0.28.910

plugins\ZarkowTurretDefense.dll

Decompiled 2 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 HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using SimpleJson;
using UnityEngine;
using ZarkowTurretDefense.Models;
using ZarkowTurretDefense.Scripts;
using ZarkowTurretDefense.Services;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ZarkowTurretDefense")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Digital Software")]
[assembly: AssemblyProduct("ZarkowTurretDefense")]
[assembly: AssemblyCopyright("Copyright © 2023 Johan Munkestam/Digital Software")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.20.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.20.0")]
namespace ZarkowTurretDefense
{
	[BepInPlugin("com.digitalsoftware.zarkowturretdefense", "Zarkow's Turret Defense", "0.28.910")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class ZTurretDefense : BaseUnityPlugin
	{
		public const string PluginGUID = "com.digitalsoftware.zarkowturretdefense";

		public const string PluginName = "Zarkow's Turret Defense";

		public const string PluginVersion = "0.28.910";

		public static ConfigEntry<int> TurretVolume;

		public static ConfigEntry<int> TurretStyle;

		public static ConfigEntry<float> DamageModifier;

		public static ConfigEntry<float> CostModifier;

		public static ConfigEntry<bool> DisableTurretLight;

		public static ConfigEntry<bool> DisableDroneLight;

		public static ConfigEntry<bool> DisableBuildingpartsLight;

		public static ConfigEntry<bool> TurretsShouldFullyIgnorePlayers;

		public static ConfigEntry<bool> ShowHeightMapDebugLogEntries;

		public static ConfigEntry<bool> ShowObjectDestroyDebugLogEntries;

		private readonly Harmony _harmony = new Harmony("com.digitalsoftware.zarkowturretdefense");

		private readonly Dictionary<string, AssetBundle> _assetBundles = new Dictionary<string, AssetBundle>();

		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		private void Awake()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			TurretVolume = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Turret Volume", 100, new ConfigDescription("Custom Turret Volume", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			TurretStyle = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Turret Style", 0, new ConfigDescription("Turret Style (Not active yet)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 4), Array.Empty<object>()));
			DamageModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "Damage Modifier", 1f, new ConfigDescription("Difficulty: Optionally Modify Damage of Turrets", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>()));
			CostModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "Cost Modifier", 1f, new ConfigDescription("Difficulty: Optionally Modify the Material Cost of Turrets", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>()));
			TurretsShouldFullyIgnorePlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("BehaviorTweaks", "Turrets Should Fully Ignore Players", false, new ConfigDescription("Tweak: Turrets should no longer even look at players for targeting purpose", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			DisableTurretLight = ((BaseUnityPlugin)this).Config.Bind<bool>("PerformanceTweaks", "Disable Lights - Turrets", false, new ConfigDescription("Tweak: Disable Lights - Turrets", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			DisableDroneLight = ((BaseUnityPlugin)this).Config.Bind<bool>("PerformanceTweaks", "Disable Lights - Drones", false, new ConfigDescription("Tweak: Disable Lights - Drones", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			DisableBuildingpartsLight = ((BaseUnityPlugin)this).Config.Bind<bool>("PerformanceTweaks", "Disable Lights - Buildingparts", false, new ConfigDescription("Tweak: Disable Lights - Buildingparts", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			ShowHeightMapDebugLogEntries = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Show HeightMap Debug Log Entries", false, new ConfigDescription("Debug: Show HeightMap Warning and Info log lines", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			ShowObjectDestroyDebugLogEntries = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Show Object Destroy Debug Log Entries", false, new ConfigDescription("Debug: Show log lines when an object from the mod pack is de-loaded as player move out of range", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
			LoadAssetBundles();
			LoadLocalization("English");
			LoadLocalization("German");
			AddTurrets();
			AddBuildingParts();
			UnloadAssetBundles();
			_harmony.PatchAll();
			Logger.LogInfo((object)"### BETA 0.28.910 ### Zarkow's Turret Defense Loaded.");
		}

		private void LoadAssetBundles()
		{
			_assetBundles.Add("turrets", AssetUtils.LoadAssetBundleFromResources("turrets"));
		}

		private void UnloadAssetBundles()
		{
			foreach (KeyValuePair<string, AssetBundle> assetBundle in _assetBundles)
			{
				assetBundle.Value.Unload(false);
			}
		}

		private void LoadLocalization(string languageName)
		{
			Logger.LogInfo((object)("### Load Localization language " + languageName));
			string text = LoadLocalizationJsonFromResource("ZarkowTurretDefense.Assets.Localizations." + languageName + ".json");
			Localization.AddJsonFile(languageName, text);
		}

		public static string LoadLocalizationJsonFromResource(string resourceName)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			using StreamReader streamReader = new StreamReader(stream);
			return streamReader.ReadToEnd();
		}

		private void AddTurrets()
		{
			Logger.LogInfo((object)"### --- Added Turrets ---");
			List<TurretConfig> list = new List<TurretConfig>();
			list.AddRange(TurretConfigManager.LoadTurretConfigJsonFromResource("ZarkowTurretDefense.Assets.Configs.turretsconfigs.json"));
			list.ForEach(delegate(TurretConfig turretConfig)
			{
				if (turretConfig.enabled)
				{
					Logger.LogDebug((object)("### Get assetBundle for '" + turretConfig.bundleName + "'"));
					AssetBundle val = _assetBundles[turretConfig.bundleName];
					if ((Object)(object)val == (Object)null)
					{
						Logger.LogWarning((object)"### assetBundle is null");
					}
					else
					{
						Logger.LogDebug((object)("### Read asset from " + turretConfig.prefabPath));
						GameObject val2 = val.LoadAsset<GameObject>(turretConfig.prefabPath);
						if ((Object)(object)val2 == (Object)null)
						{
							Logger.LogFatal((object)("### Missing prefab " + turretConfig.prefabPath + " in bundle"));
						}
						else
						{
							Logger.LogDebug((object)"### Add component script to prefab based on type");
							TurretBase turretBase = (TurretType)Enum.Parse(typeof(TurretType), turretConfig.type, ignoreCase: true) switch
							{
								TurretType.SignalTurret => val2.AddComponent<SignalTurret>(), 
								TurretType.MineTurret => val2.AddComponent<MineTurret>(), 
								TurretType.LightGun => val2.AddComponent<LightGunTurret>(), 
								TurretType.Gun => val2.AddComponent<GunTurret>(), 
								TurretType.HeavyGun => val2.AddComponent<HeavyGunTurret>(), 
								TurretType.MissileGun => val2.AddComponent<MissileTurret>(), 
								TurretType.Drone => val2.AddComponent<DroneTurret>(), 
								TurretType.RepairDrone => val2.AddComponent<RepairDroneTurret>(), 
								TurretType.GatherDrone => val2.AddComponent<GatherDroneTurret>(), 
								TurretType.FishingDrone => val2.AddComponent<FishingDroneTurret>(), 
								TurretType.LoggerDrone => val2.AddComponent<LoggerDroneTurret>(), 
								TurretType.InertTurret => val2.AddComponent<InertTurret>(), 
								_ => val2.AddComponent<TurretBase>(), 
							};
							Logger.LogDebug((object)("### Init Turret Config '" + turretConfig.name + "'"));
							turretBase.Initialize(turretConfig);
							Logger.LogDebug((object)$"### Apply Config and Create CustomPiece '{turretBase}'");
							CustomPiece val3 = TurretConfig.Convert(val2, turretConfig);
							Logger.LogDebug((object)"### Add piece to PieceManager");
							PieceManager.Instance.AddPiece(val3);
							Logger.LogDebug((object)"### --- Turret Added ---");
						}
					}
				}
			});
		}

		private void AddBuildingParts()
		{
			Logger.LogInfo((object)"### --- Added BuildingParts ---");
			List<BuildingpartConfig> list = new List<BuildingpartConfig>();
			list.AddRange(BuildingpartConfigManager.LoadBuildingpartConfigJsonFromResource("ZarkowTurretDefense.Assets.Configs.buildingpartsconfigs.json"));
			list.ForEach(delegate(BuildingpartConfig buildingpartConfig)
			{
				if (buildingpartConfig.enabled)
				{
					Logger.LogDebug((object)("### Get assetBundle for '" + buildingpartConfig.bundleName + "'"));
					AssetBundle val = _assetBundles[buildingpartConfig.bundleName];
					if ((Object)(object)val == (Object)null)
					{
						Logger.LogWarning((object)"### assetBundle is null");
					}
					else
					{
						Logger.LogDebug((object)("### Read asset from " + buildingpartConfig.prefabPath));
						GameObject obj = val.LoadAsset<GameObject>(buildingpartConfig.prefabPath);
						Logger.LogDebug((object)"### Add component script to prefab based on type");
						_ = (BuildingpartType)Enum.Parse(typeof(BuildingpartType), buildingpartConfig.type, ignoreCase: true);
						BuildingpartBase buildingpartBase = obj.AddComponent<BuildingpartBase>();
						Logger.LogDebug((object)("### Init Buildingpart config '" + buildingpartConfig.name + "'"));
						buildingpartBase.Initialize(buildingpartConfig);
						Logger.LogDebug((object)$"### Apply Config and Create CustomPiece '{buildingpartBase}'");
						CustomPiece val2 = BuildingpartConfig.Convert(obj, buildingpartConfig);
						Logger.LogDebug((object)"### Add piece to PieceManager");
						PieceManager.Instance.AddPiece(val2);
						Logger.LogDebug((object)"### --- BuildingPart Added ---");
					}
				}
			});
		}
	}
}
namespace ZarkowTurretDefense.Services
{
	internal class BuildingpartConfigManager
	{
		public static List<BuildingpartConfig> LoadBuildingpartConfigJsonFromResource(string resourceName)
		{
			string text;
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
			{
				using StreamReader streamReader = new StreamReader(stream);
				text = streamReader.ReadToEnd();
			}
			return SimpleJson.DeserializeObject<List<BuildingpartConfig>>(text);
		}
	}
	internal class TurretConfigManager
	{
		public static List<TurretConfig> LoadTurretConfigJsonFromResource(string resourceName)
		{
			string text;
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
			{
				using StreamReader streamReader = new StreamReader(stream);
				text = streamReader.ReadToEnd();
			}
			return SimpleJson.DeserializeObject<List<TurretConfig>>(text);
		}
	}
}
namespace ZarkowTurretDefense.Scripts
{
	public class Barrel
	{
		public int Id;

		public GameObject ThisBarrelGameObject;

		public GameObject LaunchEffectGameObject;

		public GameObject LaunchAudioGameObject;

		public Barrel(int id, GameObject thisGameObject, GameObject launchEffectGameObject, GameObject launchAudioGameObject)
		{
			Id = id;
			ThisBarrelGameObject = thisGameObject;
			LaunchEffectGameObject = launchEffectGameObject;
			LaunchAudioGameObject = launchAudioGameObject;
		}
	}
	public class BuildingpartBase : MonoBehaviour
	{
		public float Range = 20f;

		public float MinimumRange;

		public BuildingpartType BuildingpartTypeOfThisBuildingpart;

		protected HitData _hitData;

		private readonly int _viewBlockMask = LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "terrain", "viewblock", "vehicle" });

		private readonly int _viewBlockMaskPlayersCharactersOnly = LayerMask.GetMask(new string[4] { "character", "character_net", "character_ghost", "character_noenv" });

		protected readonly int _rayMaskSolids = LayerMask.GetMask(new string[12]
		{
			"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox",
			"character_noenv", "vehicle"
		});

		protected DegreesSpecifier _aimResult;

		protected DegreesSpecifier _aimResultTempCalcHolder;

		protected RotationDefinitions _rotationDefinitions;

		protected RotationData _rotationData = new RotationData();

		protected ZNetView _zNetView;

		protected ZDO _zDataObject;

		protected NetDataObjectHandler _netDataObjectHandler;

		private bool _everSeenHeightmap;

		public bool IsOwner
		{
			get
			{
				if ((Object)(object)_zNetView == (Object)null || !_zNetView.IsOwner())
				{
					return false;
				}
				return true;
			}
		}

		private void Awake()
		{
			//IL_005c: 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)
			_zNetView = ((Component)this).GetComponent<ZNetView>();
			_zDataObject = _zNetView.GetZDO();
			_netDataObjectHandler = new NetDataObjectHandler(_zDataObject);
			RegisterRemoteProcedureCalls();
			GetBasicBodyPartsOfBuildingpart();
			GetSpecialBodyPartsOfBuildingpart();
			_aimResult = new DegreesSpecifier();
			_aimResultTempCalcHolder = new DegreesSpecifier();
			Heightmap val = Heightmap.FindHeightmap(((Component)this).transform.position);
			if (ZTurretDefense.ShowHeightMapDebugLogEntries.Value)
			{
				string message = string.Format("{0}.Awake() ({1}) -- Heightmap loaded: {2} ({3} heightmaps loaded), position: {4}{5}", BuildingpartTypeOfThisBuildingpart, ((Object)((Component)this).gameObject).name, (Object)(object)val != (Object)null, Heightmap.s_heightmaps.Count, ((Component)this).transform.position, _zNetView.m_distant ? "-- Flagged as distant" : "");
				if ((Object)(object)val == (Object)null)
				{
					AddWarningMsg(message);
				}
				else
				{
					AddLogInfo(message);
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				_everSeenHeightmap = true;
			}
		}

		protected virtual void RegisterRemoteProcedureCalls()
		{
		}

		protected virtual void GetBasicBodyPartsOfBuildingpart()
		{
			if (ZTurretDefense.DisableBuildingpartsLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(((Component)this).gameObject);
			}
		}

		protected virtual void GetSpecialBodyPartsOfBuildingpart()
		{
		}

		protected void AddLogMsg(string message)
		{
			Logger.LogMessage((object)$"{DateTime.Now:o} ### Buildingpart[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}");
		}

		protected void AddDebugMsg(string message)
		{
			Logger.LogDebug((object)$"{DateTime.Now:o} ### Buildingpart[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}");
		}

		protected void AddLogInfo(string message)
		{
			Logger.LogInfo((object)$"{DateTime.Now:o} ### Buildingpart[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}");
		}

		protected void AddWarningMsg(string message)
		{
			Logger.LogWarning((object)$"{DateTime.Now:o} ### Buildingpart[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}");
		}

		public void Initialize(BuildingpartConfig buildingpartConfig)
		{
			BuildingpartTypeOfThisBuildingpart = (BuildingpartType)Enum.Parse(typeof(BuildingpartType), buildingpartConfig.type, ignoreCase: true);
		}

		private void OnDestroy()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (ZTurretDefense.ShowObjectDestroyDebugLogEntries.Value)
			{
				AddLogInfo($"OnDestroy({((Object)((Component)this).gameObject).name}, {((Component)this).transform.position}) ");
			}
		}

		private void Update()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (!_everSeenHeightmap)
			{
				Heightmap val = Heightmap.FindHeightmap(((Component)this).transform.position);
				if ((Object)(object)val != (Object)null)
				{
					if (ZTurretDefense.ShowHeightMapDebugLogEntries.Value)
					{
						AddWarningMsg($"{BuildingpartTypeOfThisBuildingpart}.Update() -- Finally got it >> Heightmap.FindHeightmap{((Component)this).transform.position} return  map {((Object)val).GetInstanceID()}, distantLod: {val.IsDistantLod}, bounds: {val.m_bounds}, width: {val.m_width}");
					}
					((Component)this).gameObject.GetComponent<WearNTear>().Start();
					_everSeenHeightmap = true;
				}
			}
			if ((Object)(object)_zNetView == (Object)null || !_zNetView.IsOwner())
			{
				SyncTurretNetData();
				_netDataObjectHandler.ReceiveDone();
			}
		}

		protected virtual void SyncTurretNetData()
		{
			_ = _netDataObjectHandler.HasDataToRead;
		}
	}
	public class DegreesSpecifier
	{
		public float DegreesY { get; set; }

		public float DegreesX { get; set; }

		public float Distance { get; set; }
	}
	public class DroneTurret : TurretBase
	{
		protected GameObject _droneGameObject;

		protected GameObject _droneSensorGameObject;

		protected GameObject _droneTurn;

		protected GameObject _droneTilt;

		protected GameObject _droneAimPoint;

		protected RotationDefinitions _droneRotationDefinitions;

		protected DegreesSpecifier _droneAimResult;

		private readonly RotationData _droneRotationData = new RotationData();

		protected Target _droneTarget;

		protected readonly float _droneMaxSpeed = 10f;

		protected float _droneSpeed;

		protected TurretPatrolType _droneMode;

		protected readonly int _rayMaskDroneDownCheck = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });

		protected override void RegisterRemoteProcedureCalls()
		{
			_zNetView.Register<Vector3, Vector3>("ZTD_LaunchDroneCannonProjectile", (Action<long, Vector3, Vector3>)RPC_LaunchDroneCannonProjectile);
		}

		protected override void GetSpecialBodyPartsOfTurret()
		{
			_lightYellow = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Yellow)");
			_lightRed = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Red)");
			_lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)");
			_dirtImpactPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "DirtImpact");
			_droneGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "Drone");
			_droneSensorGameObject = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensor");
			if (ZTurretDefense.DisableDroneLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(_droneSensorGameObject);
			}
			_droneTurn = HelperLib.GetChildGameObject(_droneGameObject, "DroneTurn");
			_droneTilt = HelperLib.GetChildGameObject(_droneGameObject, "DroneTilt");
			_droneAimPoint = HelperLib.GetChildGameObject(_droneGameObject, "DroneAimPoint");
		}

		protected override void SetUpTurretSpecificData()
		{
			_rotationDefinitions.MaxRotationHorizontalLeft = 180f;
			_rotationDefinitions.MaxRotationHorizontalRight = 180f;
			_rotationDefinitions.MaxRotationVerticalUp = 0.1f;
			_rotationDefinitions.MaxRotationVerticalDown = 0.1f;
			_rotationDefinitions.RotationSpeed = 360f;
			_rotationDefinitions.AllowedAimDeviance = 180f;
			_droneRotationDefinitions.MaxRotationHorizontalLeft = 45f;
			_droneRotationDefinitions.MaxRotationHorizontalRight = 45f;
			_droneRotationDefinitions.MaxRotationVerticalUp = 5f;
			_droneRotationDefinitions.MaxRotationVerticalDown = 65f;
			_droneRotationDefinitions.RotationSpeed = 35f;
			_droneRotationDefinitions.AllowedAimDeviance = 25f;
			_droneAimResult = new DegreesSpecifier();
		}

		protected override void SyncTurretNetData()
		{
			//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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			if (_netDataObjectHandler.HasDataToRead)
			{
				base.SyncTurretNetData();
				_droneGameObject.transform.position = _netDataObjectHandler.Data.GetVec3("_droneGameObject.position", Vector3.zero);
				_droneGameObject.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_droneGameObject.rotation", Quaternion.identity);
				_droneTurn.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_droneTurn.rotation", Quaternion.identity);
				_droneTilt.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_droneTilt.rotation", Quaternion.identity);
				_droneSensorGameObject.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_droneSensorGameObject.rotation", Quaternion.identity);
			}
		}

		protected override void ControlAndMoveMissilesOrProjectilesOrDrones()
		{
			//IL_0043: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_0106: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			if (_droneTarget == null)
			{
				_droneTarget = _targetList.FirstOrDefault();
				if (_droneTarget != null)
				{
					_droneTarget.TimeToLive = 10f;
					UpdateDroneMode(TurretPatrolType.ScanTarget);
				}
			}
			if (_droneTarget == null)
			{
				Vector2 val = Random.insideUnitCircle * (PatrolCloseToTurret ? (Range * 0.1f) : Range);
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(((Component)this).transform.position.x + val.x, ((Component)this).transform.position.y + 250f, ((Component)this).transform.position.z + val.y);
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(new Ray(val2, Vector3.down), ref val3, 500f, _rayMaskDroneDownCheck))
				{
					float num = ((RaycastHit)(ref val3)).point.y + 5f;
					if (num < 35f)
					{
						num = 35f;
					}
					Vector3 location = default(Vector3);
					((Vector3)(ref location))..ctor(((RaycastHit)(ref val3)).point.x, num, ((RaycastHit)(ref val3)).point.z);
					Target droneTarget = new Target
					{
						Location = location,
						IsMoveOrder = true,
						TimeToLive = 15f
					};
					_droneTarget = droneTarget;
					UpdateDroneMode(TurretPatrolType.ScanTarget);
				}
			}
			if (_droneTarget == null)
			{
				return;
			}
			if (_droneTarget.TimeToLive > 0f)
			{
				_droneTarget.TimeToLive -= Time.deltaTime;
			}
			if (_droneTarget.IsMoveOrder)
			{
				if (MoveTowardsTargetDestination(_droneTarget) && _droneTarget.TimeToLive <= 0f)
				{
					_droneTarget = null;
				}
				else if (_targetList.Count > 0)
				{
					_droneTarget.TimeToLive = -999f;
				}
				SetDataToDataObject();
			}
			else if (_droneTarget.IsTargetWearAndTearOrder)
			{
				if (MoveAndHandleWearAndTear(_droneTarget))
				{
					_targetList.Remove(_droneTarget);
					_droneTarget = null;
				}
				SetDataToDataObject();
			}
			else if (_droneTarget.IsTargetLoggerOrder)
			{
				if (MoveAndHandleTreesAndLogsAndStubs(_droneTarget))
				{
					_targetList.Remove(_droneTarget);
					_droneTarget = null;
				}
				SetDataToDataObject();
			}
			else if (_droneTarget.IsGatherItemOrder)
			{
				if (MoveAndHandleGather(_droneTarget) || (!_droneTarget.OnGatheritemDropReturnTrip && _droneTarget.TimeToLive < 0f))
				{
					_targetList.Remove(_droneTarget);
					_droneTarget = null;
				}
				SetDataToDataObject();
			}
			else if ((Object)(object)_droneTarget.Character != (Object)null && _droneTarget.Character.GetHealth() <= 0f)
			{
				_droneTarget = null;
			}
			else
			{
				bool num2 = MoveAndAttackTarget(_droneTarget);
				SetDataToDataObject();
				if (num2)
				{
					_targetList.Remove(_droneTarget);
					_droneTarget = null;
				}
			}
		}

		private void SetDataToDataObject()
		{
			//IL_001b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			_netDataObjectHandler.Data.Set("_droneGameObject.position", _droneGameObject.transform.position);
			_netDataObjectHandler.Data.Set("_droneGameObject.rotation", _droneGameObject.transform.rotation);
			_netDataObjectHandler.Data.Set("_droneTurn.rotation", _droneTurn.transform.rotation);
			_netDataObjectHandler.Data.Set("_droneTilt.rotation", _droneTilt.transform.rotation);
			_netDataObjectHandler.Data.Set("_droneSensorGameObject.rotation", _droneSensorGameObject.transform.rotation);
		}

		private bool MoveTowardsTargetDestination(Target target)
		{
			//IL_0036: 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_00ca: 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_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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_0174: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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)
			if (target == null)
			{
				AddWarningMsg("DroneTurret.MoveTowardsTargetDestination() -- target is null");
				return true;
			}
			if ((Object)(object)_droneGameObject == (Object)null)
			{
				AddWarningMsg("DroneTurret.MoveTowardsTargetDestination() -- _droneGameObject is null");
				return true;
			}
			float num = Vector3.Distance(_droneGameObject.transform.position, target.Location);
			if (num > _droneSpeed + 0.1f)
			{
				_droneSpeed += Time.deltaTime * 3f;
				if (_droneSpeed > _droneMaxSpeed)
				{
					_droneSpeed = _droneMaxSpeed;
				}
			}
			else
			{
				_droneSpeed -= Time.deltaTime * 5f;
				if (_droneSpeed < 0f)
				{
					_droneSpeed = ((num > 0.45f) ? 0.25f : 0f);
				}
			}
			Vector3 val = target.Location - _droneGameObject.transform.position;
			((Vector3)(ref val)).Normalize();
			if (num > 5f)
			{
				Vector3 val2 = target.Location - _droneGameObject.transform.position;
				val2.y = 0f;
				_droneGameObject.transform.rotation = Quaternion.Slerp(_droneGameObject.transform.rotation, Quaternion.LookRotation(val2), 2.5f * Time.deltaTime);
			}
			Transform transform = _droneGameObject.transform;
			transform.position += val * _droneSpeed * Time.deltaTime;
			if (Vector3.Distance(_droneGameObject.transform.position, target.Location) < 0.5f)
			{
				target.TimeToLive -= Time.deltaTime;
				return true;
			}
			return false;
		}

		protected virtual bool MoveAndHandleWearAndTear(Target target)
		{
			AddWarningMsg($"DroneTurret.MoveAndHandleWearAndTear({target.GetHashCode()}, {target.WearAndTearPiece.m_piece.m_name}) -- Virtual, not implemented");
			return true;
		}

		protected virtual bool MoveAndHandleGather(Target target)
		{
			AddWarningMsg($"DroneTurret.MoveAndHandleGather({target.GetHashCode()}) -- Virtual, not implemented");
			return true;
		}

		protected virtual bool MoveAndHandleTreesAndLogsAndStubs(Target target)
		{
			AddWarningMsg($"DroneTurret.MoveAndHandleTreesAndLogs({target.GetHashCode()}) -- Virtual, not implemented");
			return true;
		}

		protected virtual float SetDroneMovementHeight(float heightIn)
		{
			return heightIn + (HealingTarget ? 2f : 4f);
		}

		private bool MoveAndAttackTarget(Target target)
		{
			//IL_0091: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_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_00c5: 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_0167: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target.Character == (Object)null)
			{
				return true;
			}
			if ((Object)(object)target.Character.m_collider == (Object)null)
			{
				AddWarningMsg($"{TurretTypeOfThisTurret}.MoveAndAttackTarget({target.GetHashCode()}, {target.Character.m_name} [{((Object)target.Character).GetInstanceID()}], {target.Character.GetHealth()} hp), lacks capsule collider...");
				return false;
			}
			Vector3 centerPoint = target.Character.GetCenterPoint();
			target.Location = new Vector3(centerPoint.x, SetDroneMovementHeight(centerPoint.y), centerPoint.z);
			float num = Vector3.Distance(_droneGameObject.transform.position, target.Location);
			if (num - DroneAttackRange > _droneSpeed - 1f)
			{
				_droneSpeed += Time.deltaTime * 3f;
				if (_droneSpeed > _droneMaxSpeed)
				{
					_droneSpeed = _droneMaxSpeed;
				}
			}
			else
			{
				_droneSpeed -= Time.deltaTime * 5f;
				if (_droneSpeed < 0f)
				{
					_droneSpeed = ((num > DroneAttackRange * 0.3f) ? 0.25f : 0f);
				}
			}
			Vector3 val = target.Location - _droneGameObject.transform.position;
			((Vector3)(ref val)).Normalize();
			if (num > 0.5f)
			{
				Vector3 val2 = target.Location - _droneGameObject.transform.position;
				val2.y = 0f;
				_droneGameObject.transform.rotation = Quaternion.Slerp(_droneGameObject.transform.rotation, Quaternion.LookRotation(val2), 2.5f * Time.deltaTime);
			}
			Transform transform = _droneGameObject.transform;
			transform.position += val * _droneSpeed * Time.deltaTime;
			bool flag = CanSeeCharacter(target.Character, _droneAimPoint);
			if (Vector3.Distance(_droneGameObject.transform.position, target.Location) < DroneAttackRange && flag)
			{
				UpdateDroneMode(TurretPatrolType.AttackTarget);
			}
			else
			{
				UpdateDroneMode(TurretPatrolType.ScanTarget);
			}
			if (_droneTarget.Character.GetHealth() <= 0f)
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
				return true;
			}
			if (HealingTarget && _droneTarget.Character.GetHealthPercentage() >= 1f)
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
				return true;
			}
			if (_droneTarget.TimeToLive <= 0f)
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
				return true;
			}
			return false;
		}

		protected override void UpdateShootingIntervalAndDetermineIfWeShouldShoot()
		{
			if (_nextShootDelayTimer > 0f)
			{
				_nextShootDelayTimer -= Time.deltaTime;
			}
			if (_droneMode != TurretPatrolType.AttackTarget)
			{
				return;
			}
			if (_droneTarget.IsGatherItemOrder && _droneTarget.OnGatheritemDropReturnTrip)
			{
				if (_nextShootDelayTimer <= 0f)
				{
					TriggerTurretFiring();
				}
				return;
			}
			_droneRotationData.DistanceRotY = _droneRotationData.CurrentRotationY - _droneAimResult.DegreesY;
			_droneRotationData.DistanceRotX = _droneRotationData.CurrentRotationX - _droneAimResult.DegreesX;
			if (_nextShootDelayTimer > 0f || Math.Abs(_droneRotationData.DistanceRotY) > _droneRotationDefinitions.AllowedAimDeviance || Math.Abs(_droneRotationData.DistanceRotX) > _droneRotationDefinitions.AllowedAimDeviance || !(_nextShootDelayTimer <= 0f) || (AmmoCount > 0 && _ammoInGun == 0))
			{
				return;
			}
			TriggerTurretFiring();
			if (AmmoCount > 0)
			{
				_ammoInGun--;
				if (_ammoInGun <= 0)
				{
					_reloadGunTimer = ReloadTime;
				}
			}
		}

		protected override void TriggerTurretFiring()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			_nextShootDelayTimer += FireInterval;
			if (_nextShootDelayTimer < FireInterval / 2f)
			{
				_nextShootDelayTimer = FireInterval / 2f;
			}
			LaunchProjectileAndRegisterHitPosition(_droneTilt.transform.rotation, _barrelList[0].ThisBarrelGameObject.transform.position);
		}

		protected override void LaunchProjectileAndRegisterHitPosition(Quaternion directionQuat, Vector3 barrelEdgePosition)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0099: 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_00a6: 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)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(new Ray(barrelEdgePosition, directionQuat * Vector3.forward), ref val, Range * 2f, _rayMaskSolids))
			{
				return;
			}
			if (_hitData == null)
			{
				AddWarningMsg("LaunchProjectileAndShowHitPosition() - _hitData is null");
				return;
			}
			Character component = ((Component)((Component)((RaycastHit)(ref val)).collider).transform.root).gameObject.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				if (HealingTarget)
				{
					component.Heal(HealingAmount, true);
				}
				else
				{
					HitData val2 = _hitData.Clone();
					val2.m_hitCollider = ((RaycastHit)(ref val)).collider;
					val2.m_point = ((RaycastHit)(ref val)).point;
					val2.m_dir = ((Quaternion)(ref directionQuat)).eulerAngles;
					ApplyDamageToCharacterHit(component, val2);
				}
			}
			_zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchDroneCannonProjectile", new object[2]
			{
				((RaycastHit)(ref val)).point,
				((RaycastHit)(ref val)).normal
			});
		}

		protected override void CleanTargetListAndUpdateAimInfo()
		{
			if (_targetList.Count > 0)
			{
				List<Target> list = new List<Target>();
				foreach (Target target in _targetList)
				{
					if ((Object)(object)target.Character != (Object)null && target.Character.GetHealth() <= 0f)
					{
						list.Add(target);
					}
				}
				foreach (Target item in list)
				{
					_targetList.Remove(item);
				}
			}
			if (_droneTarget == null)
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
			}
			else if (!UpdateAimInfoForCurrentTarget())
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
			}
		}

		protected void UpdateDroneMode(TurretPatrolType newMode)
		{
			if (newMode != _droneMode)
			{
				_droneMode = newMode;
			}
		}

		protected override bool UpdateAimInfoForCurrentTarget()
		{
			if (_droneTarget == null)
			{
				return false;
			}
			return HelperLib.UpdateAimInfoForCurrentTarget(_droneTarget, _droneAimPoint, _droneAimResult, _aimResultTempCalcHolder);
		}

		protected override void RotateTurretTowardsTarget()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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)
			HelperLib.RotateTurretTowardsTarget(_droneTurn, _droneTilt, _droneAimResult, _droneRotationDefinitions, _droneRotationData);
			_droneSensorGameObject.transform.rotation = _droneTilt.transform.rotation;
			_netDataObjectHandler.Data.Set("_droneTurn.rotation", _droneTurn.transform.rotation);
			_netDataObjectHandler.Data.Set("_droneTilt.rotation", _droneTilt.transform.rotation);
			_netDataObjectHandler.Data.Set("_droneSensorGameObject.rotation", _droneSensorGameObject.transform.rotation);
		}

		private void RPC_LaunchDroneCannonProjectile(long sender, Vector3 impactLocation, Vector3 impactNormal)
		{
			//IL_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			if (_barrelList != null && _barrelList.Count != 0)
			{
				Barrel barrel = _barrelList.FirstOrDefault();
				if (barrel == null)
				{
					AddWarningMsg("DroneTurret.RPC_LaunchDroneCannonProjectile: FAIL - no barrelObject found");
					return;
				}
				GameObject obj = Object.Instantiate<GameObject>(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false);
				obj.transform.SetParent((Transform)null);
				obj.SetActive(false);
				obj.SetActive(true);
				Object.Destroy((Object)(object)obj, 5f);
				GameObject obj2 = Object.Instantiate<GameObject>(barrel.LaunchAudioGameObject, barrel.ThisBarrelGameObject.transform, false);
				obj2.transform.SetParent((Transform)null);
				obj2.SetActive(false);
				obj2.SetActive(true);
				Object.Destroy((Object)(object)obj2, 1f);
				Quaternion rotation = default(Quaternion);
				((Quaternion)(ref rotation)).SetLookRotation(impactNormal);
				GameObject obj3 = Object.Instantiate<GameObject>(_dirtImpactPrefab, (Transform)null);
				obj3.transform.position = impactLocation;
				obj3.transform.rotation = rotation;
				obj3.SetActive(false);
				obj3.SetActive(true);
				Object.Destroy((Object)(object)obj3, 10f);
			}
		}
	}
	public class FishingDroneTurret : GatherDroneTurret
	{
		protected override float SetDroneMovementHeight(float heightIn)
		{
			if (_droneTarget.OnGatheritemDropReturnTrip)
			{
				return heightIn + 3f;
			}
			return 30.5f;
		}

		protected override void FindNewTarget()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			List<Target> list = new List<Target>();
			foreach (ItemDrop s_instance in ItemDrop.s_instances)
			{
				if ((Object)(object)s_instance == (Object)null)
				{
					continue;
				}
				if (!((Behaviour)s_instance).enabled)
				{
					AddDebugMsg("itemDrop, Target search: Item " + ((Object)s_instance).name + " is not enabled -- skipping");
				}
				else if (((Component)s_instance).gameObject.layer == 9)
				{
					float rangeToItemDrop = GetRangeToItemDrop(s_instance);
					if (!(rangeToItemDrop >= Range) && !(rangeToItemDrop <= MinimumRange) && (_droneTarget == null || !((Object)(object)_droneTarget.GatherItemDrop == (Object)(object)s_instance)) && !(((Component)s_instance).transform.position.y >= 30f) && rangeToItemDrop < num)
					{
						num = AddItemToTargetList(list, s_instance, rangeToItemDrop, MaximumNumberOfTrackedTargets);
					}
				}
			}
			if (list.Count > 0)
			{
				num = list[0].DistanceRating;
			}
			SetTargets(list, num);
			_updateTargetTimer += 5f;
		}
	}
	public class GatherDroneTurret : DroneTurret
	{
		protected readonly int _rayMaskGatherObjects = LayerMask.GetMask(new string[1] { "item" });

		private GameObject _droneCarryPoint;

		protected override void GetSpecialBodyPartsOfTurret()
		{
			_lightYellow = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Yellow)");
			_lightRed = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Red)");
			_lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)");
			_dirtImpactPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "DirtImpact");
			_droneGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "Drone");
			_droneSensorGameObject = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensor");
			if (ZTurretDefense.DisableDroneLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(_droneSensorGameObject);
			}
			_droneTurn = HelperLib.GetChildGameObject(_droneGameObject, "DroneTurn");
			_droneTilt = HelperLib.GetChildGameObject(_droneGameObject, "DroneTilt");
			_droneAimPoint = HelperLib.GetChildGameObject(_droneGameObject, "DroneAimPoint");
			_droneCarryPoint = HelperLib.GetChildGameObject(_droneGameObject, "DroneCarryPoint");
		}

		protected override void SetUpTurretSpecificData()
		{
			_rotationDefinitions.MaxRotationHorizontalLeft = 180f;
			_rotationDefinitions.MaxRotationHorizontalRight = 180f;
			_rotationDefinitions.MaxRotationVerticalUp = 0.1f;
			_rotationDefinitions.MaxRotationVerticalDown = 0.1f;
			_rotationDefinitions.RotationSpeed = 360f;
			_rotationDefinitions.AllowedAimDeviance = 180f;
			_droneRotationDefinitions.MaxRotationHorizontalLeft = 120f;
			_droneRotationDefinitions.MaxRotationHorizontalRight = 120f;
			_droneRotationDefinitions.MaxRotationVerticalUp = 1f;
			_droneRotationDefinitions.MaxRotationVerticalDown = 89.9f;
			_droneRotationDefinitions.RotationSpeed = 35f;
			_droneRotationDefinitions.AllowedAimDeviance = 5f;
			_droneAimResult = new DegreesSpecifier();
		}

		protected override float SetDroneMovementHeight(float heightIn)
		{
			return heightIn + 3f;
		}

		protected override bool MoveAndHandleGather(Target target)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0043: 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_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)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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)target.GatherItemDrop == (Object)null)
			{
				return true;
			}
			Vector3 val = ((!target.OnGatheritemDropReturnTrip) ? ((Component)target.GatherItemDrop).transform.position : ((Component)this).gameObject.transform.position);
			target.Location = new Vector3(val.x, SetDroneMovementHeight(val.y), val.z);
			float num = Vector3.Distance(_droneGameObject.transform.position, target.Location);
			if (num - DroneAttackRange > _droneSpeed - 1f)
			{
				_droneSpeed += Time.deltaTime * 3f;
				if (_droneSpeed > _droneMaxSpeed)
				{
					_droneSpeed = _droneMaxSpeed;
				}
			}
			else
			{
				_droneSpeed -= Time.deltaTime * 5f;
				if (_droneSpeed < 0f)
				{
					_droneSpeed = ((num > DroneAttackRange * 0.3f) ? 0.25f : 0f);
				}
			}
			Vector3 val2 = target.Location - _droneGameObject.transform.position;
			((Vector3)(ref val2)).Normalize();
			if (num > 0.5f)
			{
				Vector3 val3 = target.Location - _droneGameObject.transform.position;
				val3.y = 0f;
				_droneGameObject.transform.rotation = Quaternion.Slerp(_droneGameObject.transform.rotation, Quaternion.LookRotation(val3), 2.5f * Time.deltaTime);
			}
			Transform transform = _droneGameObject.transform;
			transform.position += val2 * _droneSpeed * Time.deltaTime;
			if (Vector3.Distance(_droneGameObject.transform.position, target.Location) < ((!target.OnGatheritemDropReturnTrip) ? DroneAttackRange : (DroneAttackRange * 1.2f)))
			{
				UpdateDroneMode(TurretPatrolType.AttackTarget);
			}
			else
			{
				UpdateDroneMode(TurretPatrolType.ScanTarget);
			}
			if (_droneTarget.OnGatheritemDropReturnTrip)
			{
				SyncItemToDrone(turnOffUsageOfGravity: false, turnOnUsageOfGravity: false);
				return false;
			}
			if (!_droneTarget.GatherItemDrop.CanPickup(false))
			{
				UpdateDroneMode(TurretPatrolType.NoTarget);
				return true;
			}
			if (_droneTarget.TimeToLive <= 0f)
			{
				AddDebugMsg($"{TurretTypeOfThisTurret}.MoveAndHandleGather - Pickup aborted - we ran out of time on Target {((Object)_droneTarget.GatherItemDrop).name}");
				UpdateDroneMode(TurretPatrolType.NoTarget);
				return true;
			}
			return false;
		}

		protected override void FindNewTarget()
		{
			float num = float.MaxValue;
			List<Target> list = new List<Target>();
			foreach (ItemDrop s_instance in ItemDrop.s_instances)
			{
				if ((Object)(object)s_instance == (Object)null)
				{
					continue;
				}
				if (!((Behaviour)s_instance).enabled)
				{
					AddDebugMsg("itemDrop, Target search: Item " + ((Object)s_instance).name + " is not enabled -- skipping");
				}
				else if (((Component)s_instance).gameObject.layer != 9)
				{
					float rangeToItemDrop = GetRangeToItemDrop(s_instance);
					if (!(rangeToItemDrop >= Range) && !(rangeToItemDrop <= MinimumRange) && (_droneTarget == null || !((Object)(object)_droneTarget.GatherItemDrop == (Object)(object)s_instance)) && rangeToItemDrop < num)
					{
						num = AddItemToTargetList(list, s_instance, rangeToItemDrop, MaximumNumberOfTrackedTargets);
					}
				}
			}
			if (list.Count > 0)
			{
				num = list[0].DistanceRating;
			}
			SetTargets(list, num);
			_updateTargetTimer += 5f;
		}

		protected float GetRangeToItemDrop(ItemDrop itemDrop)
		{
			//IL_0006: 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)
			return Vector3.Distance(((Component)itemDrop).transform.position, _turretAimPoint.transform.position);
		}

		protected float AddItemToTargetList(List<Target> newTargetList, ItemDrop item, float distanceRating, int maxTargets)
		{
			float num = float.MaxValue;
			if (newTargetList.Count > 0)
			{
				num = newTargetList[newTargetList.Count - 1].DistanceRating;
			}
			if (distanceRating >= num && newTargetList.Count >= MaximumNumberOfTrackedTargets)
			{
				return num;
			}
			int targetListIndexBasedOnDistance = GetTargetListIndexBasedOnDistance(newTargetList, distanceRating);
			if (targetListIndexBasedOnDistance > newTargetList.Count - 1)
			{
				if (newTargetList.Count < maxTargets)
				{
					newTargetList.Add(CreateGatherTarget(item, distanceRating));
					num = distanceRating;
				}
				return num;
			}
			newTargetList.Insert(targetListIndexBasedOnDistance, CreateGatherTarget(item, distanceRating));
			if (newTargetList.Count > maxTargets)
			{
				newTargetList.RemoveAt(maxTargets);
				num = newTargetList[newTargetList.Count - 1].DistanceRating;
			}
			return num;
		}

		protected Target CreateGatherTarget(ItemDrop item, float distanceRating)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			return new Target
			{
				Character = null,
				GatherItemDrop = item,
				IsGatherItemOrder = true,
				Location = ((Component)item).gameObject.transform.position,
				DistanceRating = distanceRating
			};
		}

		protected override bool UpdateAimInfoForCurrentTarget()
		{
			if (_droneTarget == null)
			{
				return false;
			}
			if ((Object)(object)_droneTarget.GatherItemDrop == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)_droneTarget.GatherItemDrop).gameObject == (Object)null)
			{
				return false;
			}
			return HelperLib.UpdateAimInfoForCurrentItemDropTarget(_droneTarget, _droneAimPoint, _droneAimResult, _aimResultTempCalcHolder);
		}

		protected override void LaunchProjectileAndRegisterHitPosition(Quaternion directionQuat, Vector3 barrelEdgePosition)
		{
			//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_004f: 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)
			if (!_droneTarget.OnGatheritemDropReturnTrip)
			{
				Vector3 position = ((Component)_droneTarget.GatherItemDrop).transform.position;
				_droneTarget.OnGatheritemDropReturnTrip = true;
				SyncItemToDrone(turnOffUsageOfGravity: true, turnOnUsageOfGravity: false);
				_zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchDroneCannonProjectile", new object[2]
				{
					position,
					Vector3.forward
				});
			}
			else
			{
				SyncItemToDrone(turnOffUsageOfGravity: false, turnOnUsageOfGravity: true);
				_droneTarget.GatherItemDrop = null;
			}
		}

		protected void SyncItemToDrone(bool turnOffUsageOfGravity, bool turnOnUsageOfGravity)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			Rigidbody component = ((Component)_droneTarget.GatherItemDrop).gameObject.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.MovePosition(_droneCarryPoint.transform.position);
				component.MoveRotation(_droneCarryPoint.transform.rotation);
				component.velocity = Vector3.zero;
				if (turnOffUsageOfGravity)
				{
					component.useGravity = false;
				}
				if (turnOnUsageOfGravity)
				{
					component.useGravity = true;
				}
			}
		}
	}
	public class GunTurret : TurretBase
	{
	}
	internal class HeavyGunTurret : TurretBase
	{
		private GameObject _projectilePrefabGameObject;

		private GameObject _projectileExplosionEffectPrefab;

		private GameObject _projectileExplosionEffectLightPrefab;

		private GameObject _projectileTrailGameObject;

		private readonly List<Projectile> _projectileList = new List<Projectile>();

		protected override void RegisterRemoteProcedureCalls()
		{
			_zNetView.Register<int, int>("ZTD_LaunchHeavyProjectile", (Action<long, int, int>)RPC_LaunchHeavyProjectile);
			_zNetView.Register<int, Vector3, Vector3, bool>("ZTD_DetonateHeavyProjectile", (Method<int, Vector3, Vector3, bool>)RPC_DetonateHeavyProjectile);
		}

		protected override void GetSpecialBodyPartsOfTurret()
		{
			_lightYellow = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Yellow)");
			_lightRed = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Red)");
			_lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)");
			if (ZTurretDefense.DisableTurretLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(_lightYellow);
				HelperLib.DisableLightsOnGameObjectAndChildren(_lightRed);
			}
			_projectilePrefabGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "ProjectilePrefab");
			_projectileExplosionEffectPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "ProjectileImpactEffect");
			_projectileExplosionEffectLightPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "ProjectileImpactEffectLight");
			_projectileTrailGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "Trail");
		}

		protected override void SetUpTurretSpecificData()
		{
			_rotationDefinitions.MaxRotationHorizontalLeft = 90f;
			_rotationDefinitions.MaxRotationHorizontalRight = 90f;
			_rotationDefinitions.MaxRotationVerticalUp = 35f;
			_rotationDefinitions.MaxRotationVerticalDown = 20f;
			_rotationDefinitions.RotationSpeed = 35f;
			_rotationDefinitions.AllowedAimDeviance = 5f;
			int num = 10;
			for (int i = 0; i < num; i++)
			{
				Projectile projectile = new Projectile
				{
					Id = i,
					ProjectileGameObject = Object.Instantiate<GameObject>(_projectilePrefabGameObject, ((Component)this).transform.root)
				};
				projectile.ProjectileGameObject.SetActive(false);
				_projectileList.Add(projectile);
			}
		}

		protected override void SwitchOwnershipHandling()
		{
			AddDebugMsg($"HeavyGunTurret.SwitchOwnershipHandling({base.IsOwner})");
			foreach (Projectile projectile in _projectileList)
			{
				projectile.OwnerHasActiveControl = false;
				if (projectile.AnnouncedAndVisible)
				{
					RemoveProjectileFromWorldAndDisposeTrail(projectile);
				}
			}
		}

		protected override void SyncTurretNetData()
		{
			//IL_0060: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!_netDataObjectHandler.HasDataToRead)
			{
				return;
			}
			base.SyncTurretNetData();
			foreach (Projectile projectile in _projectileList)
			{
				if (projectile.AnnouncedAndVisible)
				{
					projectile.ProjectileGameObject.transform.position = _netDataObjectHandler.Data.GetVec3($"projectile_{projectile.Id}.position", Vector3.zero);
					projectile.ProjectileGameObject.transform.rotation = _netDataObjectHandler.Data.GetQuaternion($"projectile_{projectile.Id}.rotation", Quaternion.identity);
				}
			}
		}

		protected override void TriggerTurretFiring()
		{
			if (_barrelList == null)
			{
				AddWarningMsg("HeavyGunTurret.TriggerTurretFiring() - _barrelList == null");
				return;
			}
			if (_nextBarrelIdToUse > _barrelList.Count)
			{
				AddWarningMsg($"HeavyGunTurret.TriggerTurretFiring() - if (_nextBarrelIdToUse > _barrelList.Count) : if ({_nextBarrelIdToUse} > {_barrelList.Count})");
				return;
			}
			_nextShootDelayTimer += FireInterval;
			if (_nextShootDelayTimer < FireInterval / 2f)
			{
				_nextShootDelayTimer = FireInterval / 2f;
			}
			Projectile nextAvailableProjectile = GetNextAvailableProjectile();
			if (nextAvailableProjectile == null)
			{
				AddWarningMsg($"HeavyGunTurret.TriggerTurretFiring() - No projectiles available, skipping (We have {_projectileList.Count} projectiles cached)");
			}
			if (nextAvailableProjectile != null)
			{
				nextAvailableProjectile.OwnerHasActiveControl = true;
				_zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchHeavyProjectile", new object[2] { _nextBarrelIdToUse, nextAvailableProjectile.Id });
			}
			_nextBarrelIdToUse++;
			if (_nextBarrelIdToUse >= _barrelList.Count)
			{
				_nextBarrelIdToUse = 0;
			}
		}

		private Projectile GetNextAvailableProjectile()
		{
			foreach (Projectile projectile in _projectileList)
			{
				if (!projectile.OwnerHasActiveControl)
				{
					return projectile;
				}
			}
			return null;
		}

		protected override void ControlAndMoveMissilesOrProjectilesOrDrones()
		{
			foreach (Projectile projectile in _projectileList)
			{
				if (projectile.OwnerHasActiveControl)
				{
					ControlAndMoveProjectile(projectile);
				}
			}
		}

		private void ControlAndMoveProjectile(Projectile projectile)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0042: 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_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_0068: 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_0079: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = projectile.ProjectileGameObject.transform.position;
			Transform transform = projectile.ProjectileGameObject.transform;
			transform.position += projectile.ProjectileGameObject.transform.forward * ProjectileVelocity * Time.deltaTime;
			float num = Vector3.Distance(position, projectile.ProjectileGameObject.transform.position);
			RaycastHit[] array = Physics.RaycastAll(new Ray(position, projectile.ProjectileGameObject.transform.forward), num, _rayMaskSolids);
			if (array.Length == 0 || !HandleProjectileHits(array, projectile))
			{
				SetDataToDataObject(projectile);
				if (Vector3.Distance(((Component)this).transform.position, projectile.ProjectileGameObject.transform.position) > Range * 5f)
				{
					DetonateProjectile(projectile, projectile.ProjectileGameObject.transform.position, destroyProjectile: true);
				}
			}
		}

		private bool HandleProjectileHits(RaycastHit[] hits, Projectile projectile)
		{
			//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_0146: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00bc: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: 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_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			List<RaycastHit> list = new List<RaycastHit>(hits);
			list.Sort((RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			foreach (RaycastHit item in list)
			{
				RaycastHit current = item;
				Character component = ((Component)((Component)((RaycastHit)(ref current)).collider).transform.root).gameObject.GetComponent<Character>();
				if ((Object)(object)component != (Object)null)
				{
					HitData val = _hitData.Clone();
					val.m_hitCollider = ((RaycastHit)(ref current)).collider;
					val.m_point = ((RaycastHit)(ref current)).point;
					Quaternion rotation = projectile.ProjectileGameObject.transform.rotation;
					val.m_dir = ((Quaternion)(ref rotation)).eulerAngles;
					ApplyDamageToCharacterHit(component, val);
					DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: false);
					continue;
				}
				float num = (_hitData.m_damage.m_blunt + _hitData.m_damage.m_pierce + _hitData.m_damage.m_fire) * 0.75f;
				HitData val2 = _hitData.Clone();
				val2.m_hitCollider = ((RaycastHit)(ref current)).collider;
				val2.m_point = ((RaycastHit)(ref current)).point;
				val2.m_damage.m_blunt = 0f;
				val2.m_damage.m_slash = 0f;
				val2.m_damage.m_pierce = 0f;
				val2.m_damage.m_chop = num;
				val2.m_damage.m_pickaxe = num * 0.5f;
				val2.m_damage.m_fire = 0f;
				val2.m_damage.m_frost = 0f;
				val2.m_damage.m_lightning = 0f;
				val2.m_damage.m_poison = 0f;
				val2.m_damage.m_spirit = 0f;
				val2.m_toolTier = 10;
				val2.m_pushForce = 0f;
				TreeBase component2 = ((Component)((RaycastHit)(ref current)).transform.root).gameObject.GetComponent<TreeBase>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.Damage(val2);
					DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: true);
					projectile.ProjectileGameObject.transform.position = ((RaycastHit)(ref current)).point;
					SetDataToDataObject(projectile);
					return true;
				}
				TreeLog component3 = ((Component)((RaycastHit)(ref current)).transform.root).gameObject.GetComponent<TreeLog>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.Damage(val2);
					DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: true);
					projectile.ProjectileGameObject.transform.position = ((RaycastHit)(ref current)).point;
					SetDataToDataObject(projectile);
					return true;
				}
				Destructible component4 = ((Component)((RaycastHit)(ref current)).transform.root).gameObject.GetComponent<Destructible>();
				if ((Object)(object)component4 != (Object)null)
				{
					component4.Damage(val2);
					DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: true);
					projectile.ProjectileGameObject.transform.position = ((RaycastHit)(ref current)).point;
					SetDataToDataObject(projectile);
					return true;
				}
				MineRock5 component5 = ((Component)((RaycastHit)(ref current)).transform.root).gameObject.GetComponent<MineRock5>();
				if ((Object)(object)component5 != (Object)null)
				{
					component5.Damage(val2);
					DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: true);
					projectile.ProjectileGameObject.transform.position = ((RaycastHit)(ref current)).point;
					SetDataToDataObject(projectile);
					return true;
				}
				DetonateProjectile(projectile, new Vector3(((RaycastHit)(ref current)).point.x, ((RaycastHit)(ref current)).point.y, ((RaycastHit)(ref current)).point.z), destroyProjectile: true);
				projectile.ProjectileGameObject.transform.position = ((RaycastHit)(ref current)).point;
				SetDataToDataObject(projectile);
				return true;
			}
			return false;
		}

		private void SetDataToDataObject(Projectile projectile)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			_netDataObjectHandler.Data.Set($"projectile_{projectile.Id}.position", projectile.ProjectileGameObject.transform.position);
			_netDataObjectHandler.Data.Set($"projectile_{projectile.Id}.rotation", projectile.ProjectileGameObject.transform.rotation);
		}

		private void DetonateProjectile(Projectile projectile, Vector3 impactLocation, bool destroyProjectile)
		{
			//IL_0030: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			if (destroyProjectile)
			{
				projectile.OwnerHasActiveControl = false;
			}
			_zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_DetonateHeavyProjectile", new object[4]
			{
				projectile.Id,
				impactLocation,
				Vector3.up,
				destroyProjectile
			});
			DamageAreaTargets(impactLocation, _rangedHitData, onlyDamageCharacters: false);
		}

		private void RPC_LaunchHeavyProjectile(long sender, int barrelId, int projectileId)
		{
			//IL_00c7: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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)
			if (_barrelList == null || barrelId + 1 > _barrelList.Count)
			{
				return;
			}
			Barrel barrel = _barrelList[barrelId];
			GameObject obj = Object.Instantiate<GameObject>(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false);
			obj.transform.SetParent((Transform)null);
			Object.Destroy((Object)(object)obj, 5f);
			obj.SetActive(true);
			GameObject obj2 = Object.Instantiate<GameObject>(barrel.LaunchAudioGameObject, barrel.ThisBarrelGameObject.transform, false);
			obj2.transform.SetParent((Transform)null);
			Object.Destroy((Object)(object)obj2, 5f);
			obj2.SetActive(true);
			Projectile projectileFromId = GetProjectileFromId(projectileId);
			if (projectileFromId == null)
			{
				AddWarningMsg($"HeavyGunTurret.RPC_LaunchHeavyProjectile: projectile is null, as it cannot be found from id {projectileId} -- aborting visual");
				return;
			}
			projectileFromId.ProjectileGameObject.transform.SetPositionAndRotation(barrel.ThisBarrelGameObject.transform.position, barrel.ThisBarrelGameObject.transform.rotation);
			projectileFromId.ProjectileGameObject.SetActive(false);
			projectileFromId.ProjectileGameObject.SetActive(true);
			projectileFromId.AnnouncedAndVisible = true;
			if ((Object)(object)_projectileTrailGameObject != (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(_projectileTrailGameObject, projectileFromId.ProjectileGameObject.transform.position, projectileFromId.ProjectileGameObject.transform.rotation, projectileFromId.ProjectileGameObject.transform);
				Trail trail = val.AddComponent<Trail>();
				trail.ParentGameObject = val;
				trail.InitLocationListAtStartLocation(projectileFromId.ProjectileGameObject.transform.position);
				projectileFromId.Trail = trail;
				projectileFromId.Trail.ParentGameObject.SetActive(true);
			}
		}

		private Projectile GetProjectileFromId(int id)
		{
			foreach (Projectile projectile in _projectileList)
			{
				if (id == projectile.Id)
				{
					return projectile;
				}
			}
			return null;
		}

		private void RPC_DetonateHeavyProjectile(long sender, int projectileId, Vector3 detonateLocation, Vector3 direction, bool destroyProjectile)
		{
			//IL_0015: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if (destroyProjectile)
			{
				Projectile projectileFromId = GetProjectileFromId(projectileId);
				RemoveProjectileFromWorldAndDisposeTrail(projectileFromId);
			}
			Quaternion rotation = default(Quaternion);
			((Quaternion)(ref rotation)).SetLookRotation(direction);
			GameObject obj = Object.Instantiate<GameObject>(_projectileExplosionEffectPrefab, (Transform)null);
			obj.transform.position = detonateLocation;
			obj.transform.rotation = rotation;
			obj.SetActive(false);
			obj.SetActive(true);
			Object.Destroy((Object)(object)obj, 5f);
			GameObject obj2 = Object.Instantiate<GameObject>(_projectileExplosionEffectLightPrefab, (Transform)null);
			obj2.transform.position = detonateLocation;
			obj2.transform.rotation = rotation;
			obj2.SetActive(false);
			obj2.SetActive(true);
			Object.Destroy((Object)(object)obj2, 0.6f);
		}

		private void RemoveProjectileFromWorldAndDisposeTrail(Projectile projectile)
		{
			projectile.ProjectileGameObject.SetActive(false);
			projectile.AnnouncedAndVisible = false;
			if ((Object)(object)projectile.Trail != (Object)null)
			{
				projectile.Trail.DisableTrail();
				projectile.Trail.ParentGameObject.transform.SetParent((Transform)null);
				Object.Destroy((Object)(object)projectile.Trail.ParentGameObject, 5f);
				projectile.Trail = null;
			}
		}
	}
	public enum TurretType
	{
		Gun,
		HeavyGun,
		SignalTurret,
		LightGun,
		MissileGun,
		MineTurret,
		Drone,
		RepairDrone,
		GatherDrone,
		FishingDrone,
		LoggerDrone,
		InertTurret
	}
	public enum BuildingpartType
	{
		Static
	}
	public static class HelperLib
	{
		public static GameObject GetChildGameObject(GameObject fromGameObject, string withName)
		{
			Transform[] componentsInChildren = ((Component)fromGameObject.transform).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name == withName)
				{
					return ((Component)val).gameObject;
				}
			}
			return null;
		}

		public static void DisableLightsOnGameObjectAndChildren(GameObject gameObjectRoot)
		{
			Light[] componentsInChildren = gameObjectRoot.GetComponentsInChildren<Light>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
		}

		public static bool UpdateAimInfoForCurrentTarget(Target primaryTarget, GameObject turretAimPoint, DegreesSpecifier aimResult, DegreesSpecifier aimResultTempCalcHolder)
		{
			//IL_0026: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0050: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)primaryTarget.Character == (Object)null)
			{
				return false;
			}
			Vector3 val = (primaryTarget.IsMoveOrder ? primaryTarget.Location : primaryTarget.Character.GetCenterPoint());
			Vector3 val2 = MathHelper.FirstOrderIntercept(turretAimPoint.transform.position, Vector3.zero, 1000f, val, primaryTarget.IsMoveOrder ? Vector3.zero : primaryTarget.Character.m_currentVel);
			aimResultTempCalcHolder.Distance = Vector3.Distance(turretAimPoint.transform.position, val);
			MathHelper.GetDegreesBetweenAimAndTarget(aimResultTempCalcHolder, turretAimPoint.transform, val2, null);
			aimResult.DegreesX = aimResultTempCalcHolder.DegreesX;
			aimResult.DegreesY = aimResultTempCalcHolder.DegreesY;
			aimResult.Distance = aimResultTempCalcHolder.Distance;
			if (!primaryTarget.IsMoveOrder)
			{
				primaryTarget.Location = val2;
			}
			return true;
		}

		public static bool UpdateAimInfoForCurrentPieceTarget(Target primaryTarget, GameObject droneAimPoint, DegreesSpecifier aimResult, DegreesSpecifier aimResultTempCalcHolder)
		{
			//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_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_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_0041: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			if ((Object)(object)primaryTarget.WearAndTearPiece == (Object)null)
			{
				return false;
			}
			Vector3 position = ((Component)primaryTarget.WearAndTearPiece).gameObject.transform.position;
			Vector3 val = MathHelper.FirstOrderIntercept(droneAimPoint.transform.position, Vector3.zero, 1000f, position, Vector3.zero);
			aimResultTempCalcHolder.Distance = Vector3.Distance(droneAimPoint.transform.position, position);
			MathHelper.GetDegreesBetweenAimAndTarget(aimResultTempCalcHolder, droneAimPoint.transform, val, null);
			aimResult.DegreesX = aimResultTempCalcHolder.DegreesX;
			aimResult.DegreesY = aimResultTempCalcHolder.DegreesY;
			aimResult.Distance = aimResultTempCalcHolder.Distance;
			if (!primaryTarget.IsMoveOrder)
			{
				primaryTarget.Location = val;
			}
			return true;
		}

		public static bool UpdateAimInfoForCurrentItemDropTarget(Target primaryTarget, GameObject droneAimPoint, DegreesSpecifier aimResult, DegreesSpecifier aimResultTempCalcHolder)
		{
			//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_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_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_0041: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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)
			if ((Object)(object)primaryTarget.GatherItemDrop == (Object)null)
			{
				return false;
			}
			Vector3 position = ((Component)primaryTarget.GatherItemDrop).gameObject.transform.position;
			Vector3 val = MathHelper.FirstOrderIntercept(droneAimPoint.transform.position, Vector3.zero, 1000f, position, Vector3.zero);
			aimResultTempCalcHolder.Distance = Vector3.Distance(droneAimPoint.transform.position, position);
			MathHelper.GetDegreesBetweenAimAndTarget(aimResultTempCalcHolder, droneAimPoint.transform, val, null);
			aimResult.DegreesX = aimResultTempCalcHolder.DegreesX;
			aimResult.DegreesY = aimResultTempCalcHolder.DegreesY;
			aimResult.Distance = aimResultTempCalcHolder.Distance;
			if (!primaryTarget.IsMoveOrder)
			{
				primaryTarget.Location = val;
			}
			return true;
		}

		public static bool UpdateAimInfoForCurrentTreeTarget(Target primaryTarget, GameObject droneAimPoint, DegreesSpecifier aimResult, DegreesSpecifier aimResultTempCalcHolder)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_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_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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)primaryTarget.LoggerTreeBaseTarget != (Object)null) ? ((Component)primaryTarget.LoggerTreeBaseTarget).gameObject.transform.position : (((Object)(object)primaryTarget.LoggerTreeLogTarget != (Object)null) ? ((Component)primaryTarget.LoggerTreeLogTarget).gameObject.transform.position : ((Component)primaryTarget.LoggerDestructibleTarget).gameObject.transform.position));
			val.y += (((Object)(object)primaryTarget.LoggerTreeBaseTarget != (Object)null) ? 1f : (((Object)(object)primaryTarget.LoggerTreeLogTarget != (Object)null) ? 0.2f : 0.15f));
			Vector3 val2 = MathHelper.FirstOrderIntercept(droneAimPoint.transform.position, Vector3.zero, 1000f, val, Vector3.zero);
			aimResultTempCalcHolder.Distance = Vector3.Distance(droneAimPoint.transform.position, val);
			MathHelper.GetDegreesBetweenAimAndTarget(aimResultTempCalcHolder, droneAimPoint.transform, val2, null);
			aimResult.DegreesX = aimResultTempCalcHolder.DegreesX;
			aimResult.DegreesY = aimResultTempCalcHolder.DegreesY;
			aimResult.Distance = aimResultTempCalcHolder.Distance;
			if (!primaryTarget.IsMoveOrder)
			{
				primaryTarget.Location = val2;
			}
			return true;
		}

		public static bool ValidateTargetAgainstRotateRestrictions(GameObject turretAimPoint, Vector3 targetVelocity, Character characterEvaluated, DegreesSpecifier aimResult, RotationDefinitions rotationDefinitions)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0023: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)characterEvaluated).transform.position;
			position = MathHelper.FirstOrderIntercept(turretAimPoint.transform.position, Vector3.zero, 1000f, position, targetVelocity);
			MathHelper.GetDegreesBetweenAimAndTarget(aimResult, turretAimPoint.transform, position, null);
			float allowedAimDeviance = rotationDefinitions.AllowedAimDeviance;
			if (rotationDefinitions.MaxRotationHorizontalLeft > 0f && 0f - rotationDefinitions.MaxRotationHorizontalLeft + (0f - allowedAimDeviance) > aimResult.DegreesY)
			{
				return false;
			}
			if (rotationDefinitions.MaxRotationHorizontalRight > 0f && rotationDefinitions.MaxRotationHorizontalRight + allowedAimDeviance < aimResult.DegreesY)
			{
				return false;
			}
			if (rotationDefinitions.MaxRotationVerticalUp > 0f && rotationDefinitions.MaxRotationVerticalUp + allowedAimDeviance < 0f - aimResult.DegreesX)
			{
				return false;
			}
			if (rotationDefinitions.MaxRotationVerticalDown > 0f && rotationDefinitions.MaxRotationVerticalDown + allowedAimDeviance < aimResult.DegreesX)
			{
				return false;
			}
			return true;
		}

		public static void RotateTurretTowardsTarget(GameObject turretTurn, GameObject turretTilt, DegreesSpecifier aimResult, RotationDefinitions rotationDefinitions, RotationData rotationData)
		{
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			rotationData.DistanceRotY = rotationData.CurrentRotationY - aimResult.DegreesY;
			if (Math.Abs(rotationData.DistanceRotY) > 1E-05f)
			{
				float num = rotationDefinitions.RotationSpeed * Time.deltaTime;
				if (num > Math.Abs(rotationData.DistanceRotY))
				{
					num = Math.Abs(rotationData.DistanceRotY);
				}
				if (rotationData.CurrentRotationY > aimResult.DegreesY)
				{
					rotationData.CurrentRotationY -= num;
					if (rotationDefinitions.MaxRotationHorizontalLeft > 0f && rotationData.CurrentRotationY < 0f - rotationDefinitions.MaxRotationHorizontalLeft)
					{
						rotationData.CurrentRotationY = 0f - rotationDefinitions.MaxRotationHorizontalLeft;
					}
					if (rotationData.CurrentRotationY < -180f)
					{
						rotationData.CurrentRotationY += 360f;
					}
				}
				else
				{
					rotationData.CurrentRotationY += num;
					if (rotationDefinitions.MaxRotationHorizontalRight > 0f && rotationData.CurrentRotationY > rotationDefinitions.MaxRotationHorizontalRight)
					{
						rotationData.CurrentRotationY = rotationDefinitions.MaxRotationHorizontalRight;
					}
					if (rotationData.CurrentRotationY > 180f)
					{
						rotationData.CurrentRotationY -= 360f;
					}
				}
				turretTurn.transform.localEulerAngles = new Vector3(0f, rotationData.CurrentRotationY, 0f);
			}
			rotationData.DistanceRotX = rotationData.CurrentRotationX - aimResult.DegreesX;
			if (!(Math.Abs(rotationData.DistanceRotX) > 0.001f))
			{
				return;
			}
			float num2 = rotationDefinitions.RotationSpeed * Time.deltaTime;
			if (num2 > Math.Abs(rotationData.DistanceRotX))
			{
				num2 = Math.Abs(rotationData.DistanceRotX);
			}
			if (rotationData.CurrentRotationX > aimResult.DegreesX)
			{
				rotationData.CurrentRotationX -= num2;
				if (rotationDefinitions.MaxRotationVerticalUp > 0f && rotationData.CurrentRotationX < 0f - rotationDefinitions.MaxRotationVerticalUp)
				{
					rotationData.CurrentRotationX = 0f - rotationDefinitions.MaxRotationVerticalUp;
				}
				if (rotationData.CurrentRotationX < -180f)
				{
					rotationData.CurrentRotationX += 360f;
				}
			}
			else
			{
				rotationData.CurrentRotationX += num2;
				if (rotationDefinitions.MaxRotationVerticalDown > 0f && rotationData.CurrentRotationX > rotationDefinitions.MaxRotationVerticalDown)
				{
					rotationData.CurrentRotationX = rotationDefinitions.MaxRotationVerticalDown;
				}
				if (rotationData.CurrentRotationX > 180f)
				{
					rotationData.CurrentRotationX -= 360f;
				}
			}
			turretTilt.transform.localEulerAngles = new Vector3(rotationData.CurrentRotationX, 0f, 0f);
		}

		public static void PrintOutObjectHierarchy(GameObject fromGameObject)
		{
			Logger.LogDebug((object)"### Turret: --------------------------------------------------------------------------");
			Logger.LogDebug((object)$"### Turret: >> Print hierarchy info for: {((Object)fromGameObject).name}, {((Object)fromGameObject).GetInstanceID()}");
			Transform[] componentsInChildren = ((Component)fromGameObject.transform).GetComponentsInChildren<Transform>(true);
			Transform[] array = componentsInChildren;
			foreach (Transform val in array)
			{
				Logger.LogDebug((object)$"### Turret: >> {((Object)val).name} - Active: {((Component)val).gameObject.activeInHierarchy}");
			}
			Logger.LogDebug((object)$"### Turret: >> Sum parts: {componentsInChildren.Length} --------------------------------------------------");
		}

		public static void PrintOutGameObjectInfo(GameObject fromGameObject)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			Logger.LogDebug((object)$"### Turret: >> Print info for: {((Object)fromGameObject).name}, {((Object)fromGameObject).GetInstanceID()}");
			Logger.LogDebug((object)$"### Turret: >> position: {fromGameObject.transform.position}");
			Logger.LogDebug((object)$"### Turret: >> localPosition: {fromGameObject.transform.localPosition}");
			Logger.LogDebug((object)$"### Turret: >> rotation: {fromGameObject.transform.eulerAngles}");
			Logger.LogDebug((object)$"### Turret: >> localRotation: {fromGameObject.transform.localEulerAngles}");
			Logger.LogDebug((object)$"### Turret: >> lossyScale: {fromGameObject.transform.lossyScale}");
			Logger.LogDebug((object)$"### Turret: >> localScale: {fromGameObject.transform.localScale}");
			Logger.LogDebug((object)"### Turret: >> ------------------------------------------------------------------------");
		}

		public static void PrintOutAimResult(DegreesSpecifier aimResult)
		{
			Logger.LogDebug((object)$"### Turret: >> Print info for aimResult: {aimResult.GetHashCode()}");
			Logger.LogDebug((object)$"### Turret: >> DegreesX: {aimResult.DegreesX}");
			Logger.LogDebug((object)$"### Turret: >> DegreesY: {aimResult.DegreesY}");
			Logger.LogDebug((object)$"### Turret: >> Distance: {aimResult.Distance}");
		}

		public static void PrintAllReflectionOfCharacter(Character character)
		{
			Logger.LogDebug((object)$"### Turret: >> Print info for Character: {character.m_name}, {((Object)character).GetInstanceID()}");
			PropertyInfo[] properties = ((object)character).GetType().GetProperties();
			Logger.LogDebug((object)$"### Turret: >> Properties: {properties.Length}");
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				object value = propertyInfo.GetValue(character, null);
				Logger.LogDebug((object)("### Turret:  --- >> : " + propertyInfo.Name + ", value: " + value));
			}
			FieldInfo[] fields = ((object)character).GetType().GetFields();
			Logger.LogDebug((object)$"### Turret: >> Fields: {fields.Length}");
			FieldInfo[] array2 = fields;
			foreach (FieldInfo fieldInfo in array2)
			{
				object value2 = fieldInfo.GetValue(character);
				Logger.LogDebug((object)("### Turret:  --- >> : " + fieldInfo.Name + ", value: " + value2));
			}
			MemberInfo[] members = ((object)character).GetType().GetMembers();
			Logger.LogDebug((object)$"### Turret: >> Members: {members.Length}");
			MemberInfo[] array3 = members;
			foreach (MemberInfo memberInfo in array3)
			{
				Logger.LogDebug((object)$"### Turret:  --- >> : {memberInfo.Name}, value: {memberInfo}");
			}
			Logger.LogDebug((object)"### Turret: >> ------------------------------------------------------------------------");
		}

		public static void PrintAllReflectionOfObject(object yourObject)
		{
			Logger.LogDebug((object)$"### Turret: >> Print info for Object: {yourObject}, {yourObject.GetHashCode()}");
			PropertyInfo[] properties = yourObject.GetType().GetProperties();
			Logger.LogDebug((object)$"### Turret: >> Properties: {properties.Length}");
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				object obj;
				try
				{
					obj = propertyInfo.GetValue(yourObject, null);
				}
				catch (Exception)
				{
					obj = "[NULL-EXCEPTION]";
				}
				Logger.LogDebug((object)("### Turret:  --- >> : " + propertyInfo.Name + ", value: " + obj));
			}
			FieldInfo[] fields = yourObject.GetType().GetFields();
			Logger.LogDebug((object)$"### Turret: >> Fields: {fields.Length}");
			FieldInfo[] array2 = fields;
			foreach (FieldInfo fieldInfo in array2)
			{
				object value = fieldInfo.GetValue(yourObject);
				Logger.LogDebug((object)("### Turret:  --- >> : " + fieldInfo.Name + ", value: " + value));
			}
			MemberInfo[] members = yourObject.GetType().GetMembers();
			Logger.LogDebug((object)$"### Turret: >> Members: {members.Length}");
			MemberInfo[] array3 = members;
			foreach (MemberInfo memberInfo in array3)
			{
				Logger.LogDebug((object)$"### Turret:  --- >> : {memberInfo.Name}, value: {memberInfo}");
			}
			Logger.LogDebug((object)"### Turret: >> ------------------------------------------------------------------------");
		}
	}
	public class InertTurret : TurretBase
	{
		protected override void GetSpecialBodyPartsOfTurret()
		{
			_lightYellow = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Yellow)");
			_lightRed = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Red)");
			_lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)");
			if (ZTurretDefense.DisableTurretLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(_lightYellow);
				HelperLib.DisableLightsOnGameObjectAndChildren(_lightRed);
			}
		}

		protected override void SetUpTurretSpecificData()
		{
			_rotationDefinitions.MaxRotationHorizontalLeft = 120f;
			_rotationDefinitions.MaxRotationHorizontalRight = 120f;
			_rotationDefinitions.MaxRotationVerticalUp = 65f;
			_rotationDefinitions.MaxRotationVerticalDown = 35f;
			_rotationDefinitions.RotationSpeed = 120f;
			_rotationDefinitions.AllowedAimDeviance = 45f;
		}

		protected override void TriggerTurretFiring()
		{
			_nextShootDelayTimer += FireInterval;
			if (_nextShootDelayTimer < FireInterval / 2f)
			{
				_nextShootDelayTimer = FireInterval / 2f;
			}
		}
	}
	public class LightGunTurret : TurretBase
	{
		protected override void SetUpTurretSpecificData()
		{
			_rotationDefinitions.MaxRotationHorizontalLeft = 120f;
			_rotationDefinitions.MaxRotationHorizontalRight = 120f;
			_rotationDefinitions.MaxRotationVerticalUp = 45f;
			_rotationDefinitions.MaxRotationVerticalDown = 25f;
			_rotationDefinitions.RotationSpeed = 50f;
			_rotationDefinitions.AllowedAimDeviance = 15f;
		}
	}
	public class LoggerDroneTurret : DroneTurret
	{
		private GameObject _droneWarningLight;

		protected override void GetSpecialBodyPartsOfTurret()
		{
			_lightYellow = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Yellow)");
			_lightRed = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Red)");
			_lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)");
			_dirtImpactPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "DirtImpact");
			_droneGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "Drone");
			_droneSensorGameObject = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensor");
			if (ZTurretDefense.DisableDroneLight.Value)
			{
				HelperLib.DisableLightsOnGameObjectAndChildren(_droneSensorGameObject);
			}
			_droneTurn = HelperLib.GetChildGameObject(_droneGameObject, "DroneTurn");
			_droneTilt = HelperLib.GetChildGameObject(_droneGameObject, "DroneTilt");
			_droneAimPoint = Hel