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-2026 Johan Munkestam/Digital Software")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.2.0.1020")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.1020")] namespace ZarkowTurretDefense { [BepInPlugin("com.digitalsoftware.zarkowturretdefense", "Zarkow's Turret Defense", "1.3.1050")] [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 = "1.3.1050"; public static ConfigEntry TurretVolume; public static ConfigEntry TurretStyle; public static ConfigEntry DamageModifier; public static ConfigEntry CostModifier; public static ConfigEntry DisableTurretLight; public static ConfigEntry DisableDroneLight; public static ConfigEntry DisableBuildingpartsLight; public static ConfigEntry TurretsShouldFullyIgnorePlayers; public static ConfigEntry ShowHeightMapDebugLogEntries; public static ConfigEntry ShowObjectDestroyDebugLogEntries; private readonly Harmony _harmony = new Harmony("com.digitalsoftware.zarkowturretdefense"); private readonly Dictionary _assetBundles = new Dictionary(); 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("General", "Turret Volume", 100, new ConfigDescription("Custom Turret Volume", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); TurretStyle = ((BaseUnityPlugin)this).Config.Bind("General", "Turret Style", 0, new ConfigDescription("Turret Style (Not active yet)", (AcceptableValueBase)(object)new AcceptableValueRange(0, 4), Array.Empty())); DamageModifier = ((BaseUnityPlugin)this).Config.Bind("Difficulty", "Damage Modifier", 1f, new ConfigDescription("Difficulty: Optionally Modify Damage of Turrets", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); CostModifier = ((BaseUnityPlugin)this).Config.Bind("Difficulty", "Cost Modifier", 1f, new ConfigDescription("Difficulty: Optionally Modify the Material Cost of Turrets", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 100f), Array.Empty())); TurretsShouldFullyIgnorePlayers = ((BaseUnityPlugin)this).Config.Bind("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(false, true), Array.Empty())); DisableTurretLight = ((BaseUnityPlugin)this).Config.Bind("PerformanceTweaks", "Disable Lights - Turrets", false, new ConfigDescription("Tweak: Disable Lights - Turrets", (AcceptableValueBase)(object)new AcceptableValueRange(false, true), Array.Empty())); DisableDroneLight = ((BaseUnityPlugin)this).Config.Bind("PerformanceTweaks", "Disable Lights - Drones", false, new ConfigDescription("Tweak: Disable Lights - Drones", (AcceptableValueBase)(object)new AcceptableValueRange(false, true), Array.Empty())); DisableBuildingpartsLight = ((BaseUnityPlugin)this).Config.Bind("PerformanceTweaks", "Disable Lights - Buildingparts", false, new ConfigDescription("Tweak: Disable Lights - Buildingparts", (AcceptableValueBase)(object)new AcceptableValueRange(false, true), Array.Empty())); ShowHeightMapDebugLogEntries = ((BaseUnityPlugin)this).Config.Bind("Debug", "Show HeightMap Debug Log Entries", false, new ConfigDescription("Debug: Show HeightMap Warning and Info log lines", (AcceptableValueBase)(object)new AcceptableValueRange(false, true), Array.Empty())); ShowObjectDestroyDebugLogEntries = ((BaseUnityPlugin)this).Config.Bind("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(false, true), Array.Empty())); LoadAssetBundles(); LoadLocalization("English"); LoadLocalization("German"); AddTurrets(); AddBuildingParts(); UnloadAssetBundles(); _harmony.PatchAll(); Logger.LogInfo((object)"### RELEASE 1.3.1050 ### Zarkow's Turret Defense Loaded."); } private void LoadAssetBundles() { _assetBundles.Add("turrets", AssetUtils.LoadAssetBundleFromResources("turrets")); } private void UnloadAssetBundles() { foreach (KeyValuePair 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 list = new List(); 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(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(), TurretType.MineTurret => val2.AddComponent(), TurretType.LightGun => val2.AddComponent(), TurretType.Gun => val2.AddComponent(), TurretType.HeavyGun => val2.AddComponent(), TurretType.AdvancedGun => val2.AddComponent(), TurretType.MissileGun => val2.AddComponent(), TurretType.Drone => val2.AddComponent(), TurretType.RepairDrone => val2.AddComponent(), TurretType.GatherDrone => val2.AddComponent(), TurretType.FishingDrone => val2.AddComponent(), TurretType.LoggerDrone => val2.AddComponent(), TurretType.InertTurret => val2.AddComponent(), _ => val2.AddComponent(), }; 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 list = new List(); 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 val2 = val.LoadAsset(buildingpartConfig.prefabPath); Logger.LogDebug((object)"### Add component script to prefab based on type"); BuildingpartBase buildingpartBase = (((BuildingpartType)Enum.Parse(typeof(BuildingpartType), buildingpartConfig.type, ignoreCase: true) != BuildingpartType.HoverCart) ? val2.AddComponent() : val2.AddComponent()); Logger.LogDebug((object)("### Init Buildingpart config '" + buildingpartConfig.name + "'")); buildingpartBase.Initialize(buildingpartConfig); Logger.LogDebug((object)$"### Apply Config and Create CustomPiece '{buildingpartBase}'"); CustomPiece val3 = BuildingpartConfig.Convert(val2, buildingpartConfig); Logger.LogDebug((object)"### Add piece to PieceManager"); PieceManager.Instance.AddPiece(val3); Logger.LogDebug((object)"### --- BuildingPart Added ---"); } } }); } } } namespace ZarkowTurretDefense.Services { internal class BuildingpartConfigManager { public static List LoadBuildingpartConfigJsonFromResource(string resourceName) { string text; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { using StreamReader streamReader = new StreamReader(stream); text = streamReader.ReadToEnd(); } return SimpleJson.DeserializeObject>(text); } } internal class TurretConfigManager { public static List LoadTurretConfigJsonFromResource(string resourceName) { string text; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) { using StreamReader streamReader = new StreamReader(stream); text = streamReader.ReadToEnd(); } return SimpleJson.DeserializeObject>(text); } } } namespace ZarkowTurretDefense.Scripts { internal class AdvancedGunTurret : TurretBase { private GameObject _projectilePrefabGameObject; private GameObject _projectileExplosionEffectPrefab; private GameObject _projectileExplosionEffectLightPrefab; private readonly List _projectileList = new List(); protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_LaunchAdvancedProjectile", (Action)RPC_LaunchAdvancedProjectile); _zNetView.Register("ZTD_DetonateAdvancedProjectile", (Method)RPC_DetonateAdvancedProjectile); } 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"); } protected override void SetUpTurretSpecificData() { _rotationDefinitions.MaxRotationHorizontalLeft = 90f; _rotationDefinitions.MaxRotationHorizontalRight = 90f; _rotationDefinitions.MaxRotationVerticalUp = 15f; _rotationDefinitions.MaxRotationVerticalDown = 20f; _rotationDefinitions.RotationSpeed = 60f; _rotationDefinitions.AllowedAimDeviance = 15f; int num = 50; for (int i = 0; i < num; i++) { Projectile projectile = new Projectile { Id = i, ProjectileGameObject = Object.Instantiate(_projectilePrefabGameObject, ((Component)this).transform.root) }; projectile.ProjectileGameObject.SetActive(false); _projectileList.Add(projectile); } } protected override void SwitchOwnershipHandling() { AddDebugMsg($"AdvancedGunTurret.SwitchOwnershipHandling({base.IsOwner})"); foreach (Projectile projectile in _projectileList) { projectile.OwnerHasActiveControl = false; if (projectile.AnnouncedAndVisible) { RemoveProjectileFromWorld(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 bool UpdateAimInfoForCurrentTarget() { return HelperLib.UpdateAimInfoForCurrentTarget(_targetList[0], _turretAimPoint, _aimResult, _aimResultTempCalcHolder, ProjectileVelocity); } protected override void TriggerTurretFiring() { if (_barrelList == null) { AddWarningMsg("AdvancedGunTurret.TriggerTurretFiring() - _barrelList == null"); return; } if (_nextBarrelIdToUse > _barrelList.Count) { AddWarningMsg($"AdvancedGunTurret.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($"AdvancedGunTurret.TriggerTurretFiring() - No projectiles available, skipping (We have {_projectileList.Count} projectiles cached)"); } if (nextAvailableProjectile != null) { nextAvailableProjectile.OwnerHasActiveControl = true; _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchAdvancedProjectile", 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_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) List list = new List(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(); 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 * 0.35f; val2.m_damage.m_pickaxe = num * 0.35f; val2.m_damage.m_fire = num; 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(); 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(); 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(); 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(); 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_DetonateAdvancedProjectile", new object[4] { projectile.Id, impactLocation, Vector3.up, destroyProjectile }); DamageAreaTargets(impactLocation, _rangedHitData, onlyDamageCharacters: false); } private void RPC_LaunchAdvancedProjectile(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) if (_barrelList != null && barrelId + 1 <= _barrelList.Count) { Barrel barrel = _barrelList[barrelId]; GameObject obj = Object.Instantiate(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false); obj.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj, 5f); obj.SetActive(true); GameObject obj2 = Object.Instantiate(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($"AdvancedGunTurret.RPC_LaunchAdvancedProjectile: 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; } } private Projectile GetProjectileFromId(int id) { foreach (Projectile projectile in _projectileList) { if (id == projectile.Id) { return projectile; } } return null; } private void RPC_DetonateAdvancedProjectile(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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (destroyProjectile) { Projectile projectileFromId = GetProjectileFromId(projectileId); RemoveProjectileFromWorld(projectileFromId); } Quaternion rotation = default(Quaternion); ((Quaternion)(ref rotation)).SetLookRotation(direction); GameObject obj = Object.Instantiate(_projectileExplosionEffectPrefab, (Transform)null); obj.transform.position = detonateLocation; obj.transform.rotation = rotation; obj.SetActive(false); obj.SetActive(true); Object.Destroy((Object)(object)obj, 5f); if ((Object)(object)_projectileExplosionEffectLightPrefab != (Object)null) { GameObject obj2 = Object.Instantiate(_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 RemoveProjectileFromWorld(Projectile projectile) { projectile.ProjectileGameObject.SetActive(false); projectile.AnnouncedAndVisible = false; } } 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(); _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().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 GameObject _droneLight; 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 = TurretPatrolType.ScanTarget; protected readonly int _rayMaskDroneDownCheck = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); protected int _inactivityToRestCounter = 3; protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_LaunchDroneCannonProjectile", (Action)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"); _droneLight = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensorLight"); } 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (_droneTarget == null) { _droneTarget = _targetList.FirstOrDefault(); if (_droneTarget != null) { _inactivityToRestCounter = 3; if (_droneTarget.TimeToLive <= 0f) { _droneTarget.TimeToLive = 10f; } UpdateDroneMode(TurretPatrolType.ScanTarget); } } if (_droneTarget == null && _inactivityToRestCounter > 0) { if (PatrolCloseToTurret && _inactivityToRestCounter > 0) { _inactivityToRestCounter--; } 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.NoTarget); } } else if (_droneTarget == null && _inactivityToRestCounter == 0) { Target droneTarget2 = new Target { Location = new Vector3(_turretAimPoint.transform.position.x, _turretAimPoint.transform.position.y + 2f, _turretAimPoint.transform.position.z), IsMoveOrder = true, TimeToLive = 10f }; _droneTarget = droneTarget2; UpdateDroneMode(TurretPatrolType.NoTarget); _inactivityToRestCounter--; } else if (_droneTarget == null && _inactivityToRestCounter == -1) { Target droneTarget3 = new Target { Location = new Vector3(_turretAimPoint.transform.position.x, _turretAimPoint.transform.position.y, _turretAimPoint.transform.position.z), IsMoveOrder = true, TimeToLive = 10f }; _droneTarget = droneTarget3; UpdateDroneMode(TurretPatrolType.NoTarget); _inactivityToRestCounter--; } 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(); 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 list = new List(); 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) { return; } _droneMode = newMode; if (_droneMode == TurretPatrolType.AttackTarget || _droneMode == TurretPatrolType.ScanTarget) { if ((Object)(object)_droneLight != (Object)null) { _droneLight.SetActive(true); } } else if ((Object)(object)_droneLight != (Object)null) { _droneLight.SetActive(false); } } 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(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(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(_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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; List list = new List(); 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 ((int)s_instance.m_itemData.m_shared.m_itemType == 21) { 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; private GameObject _droneDropOffAimPoint; private Container _container; protected override void GetSpecialBodyPartsOfTurret() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) _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"); _droneDropOffAimPoint = HelperLib.GetChildGameObject(((Component)this).gameObject, "DropoffAimPoint"); if ((Object)(object)_droneDropOffAimPoint == (Object)null) { AddLogInfo("UNEXPECTED: _droneDropOffAimPoint is null -- fixing"); _droneDropOffAimPoint = new GameObject(); _droneDropOffAimPoint.transform.SetParent(((Component)this).gameObject.transform); _droneDropOffAimPoint.transform.localPosition = new Vector3(0f, 0.5f, -4f); } _droneLight = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensorLight"); } 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(); _container = ((Component)((Component)this).transform).GetComponent(); } protected override float SetDroneMovementHeight(float heightIn) { return heightIn + 3f; } protected override bool MoveAndHandleGather(Target target) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_00b5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target.GatherItemDrop == (Object)null) { return true; } if (!target.OnGatherItemDropReturnTrip) { if ((Object)(object)target.RigidBody == (Object)null) { AddLogInfo("Rigidbody missing on target, skipping it."); return true; } if (target.RigidBody.isKinematic) { return true; } if ((Object)(object)((Component)target.GatherItemDrop).transform == (Object)null) { AddLogInfo("target.GatherItemDrop.transform == null"); } if ((Object)(object)_droneDropOffAimPoint == (Object)null) { AddLogInfo("_droneDropOffAimPoint == null"); } if ((Object)(object)_droneDropOffAimPoint.transform == (Object)null) { AddLogInfo("_droneDropOffAimPoint.transform == null"); } if (Vector3.Distance(((Component)target.GatherItemDrop).transform.position, _droneDropOffAimPoint.transform.position) <= MinimumRange) { return true; } } Vector3 val = ((!target.OnGatherItemDropReturnTrip) ? ((Component)target.GatherItemDrop).transform.position : _droneDropOffAimPoint.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 if (!target.OnGatherItemDropReturnTrip) { UpdateDroneMode(TurretPatrolType.ScanTarget); } else { UpdateDroneMode(TurretPatrolType.NoTarget); } if (_droneTarget.OnGatherItemDropReturnTrip) { SyncItemToDrone(_droneTarget.RigidBody, turnOffUsageOfGravity: true, turnOnUsageOfGravity: false); return false; } if (!_droneTarget.GatherItemDrop.CanPickup(false)) { UpdateDroneMode(TurretPatrolType.NoTarget); return true; } if (_droneTarget.TimeToLive <= 0f) { UpdateDroneMode(TurretPatrolType.NoTarget); return true; } return false; } protected override void FindNewTarget() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 float num = float.MaxValue; List list = new List(); List s_instances = ItemDrop.s_instances; List inventory = _container.GetInventory().m_inventory; foreach (ItemDrop item in s_instances) { if (!((Object)(object)item == (Object)null) && ((Behaviour)item).enabled && (int)item.m_itemData.m_shared.m_itemType != 21 && !IsItemInExclusionList(item, inventory)) { float rangeToItemDrop = GetRangeToItemDrop(item); if (!(rangeToItemDrop >= Range) && !(rangeToItemDrop <= MinimumRange) && IsWithinDirection(item) && (_droneTarget == null || !((Object)(object)_droneTarget.GatherItemDrop == (Object)(object)item)) && rangeToItemDrop < num) { num = AddItemToTargetList(list, item, rangeToItemDrop, MaximumNumberOfTrackedTargets); } } } if (list.Count > 0) { num = list[0].DistanceRating; } SetTargets(list, num); _updateTargetTimer += 5f; } private bool IsWithinDirection(ItemDrop item) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_004f: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(60f * ((float)Math.PI / 180f)); Vector3 val = ((Component)item).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < Mathf.Epsilon) { return false; } ((Vector3)(ref val)).Normalize(); if (Vector3.Dot(((Component)this).transform.forward, val) >= num) { return true; } return false; } private bool IsItemInExclusionList(ItemDrop item, List exclusionList) { foreach (ItemData exclusion in exclusionList) { if (item.m_itemData.m_shared.m_name == exclusion.m_shared.m_name) { return true; } } return false; } 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 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, RigidBody = ((Component)item).gameObject.GetComponent() }; } 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!_droneTarget.OnGatherItemDropReturnTrip) { Vector3 position = ((Component)_droneTarget.GatherItemDrop).transform.position; _droneTarget.OnGatherItemDropReturnTrip = true; SyncItemToDrone(_droneTarget.RigidBody, turnOffUsageOfGravity: true, turnOnUsageOfGravity: false); _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchDroneCannonProjectile", new object[2] { position, Vector3.forward }); UpdateDroneMode(TurretPatrolType.NoTarget); } else { SyncItemToDrone(_droneTarget.RigidBody, turnOffUsageOfGravity: false, turnOnUsageOfGravity: true); _droneTarget.GatherItemDrop = null; } } protected void SyncItemToDrone(Rigidbody targetRigidBody, bool turnOffUsageOfGravity, bool turnOnUsageOfGravity) { //IL_0015: 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) if ((Object)(object)targetRigidBody != (Object)null) { targetRigidBody.MovePosition(_droneCarryPoint.transform.position); targetRigidBody.MoveRotation(_droneCarryPoint.transform.rotation); if (turnOffUsageOfGravity) { targetRigidBody.isKinematic = true; } if (turnOnUsageOfGravity) { targetRigidBody.isKinematic = false; } } } } public class GunTurret : TurretBase { } internal class HeavyGunTurret : TurretBase { private GameObject _projectilePrefabGameObject; private GameObject _projectileExplosionEffectPrefab; private GameObject _projectileExplosionEffectLightPrefab; private GameObject _projectileTrailGameObject; private readonly List _projectileList = new List(); protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_LaunchHeavyProjectile", (Action)RPC_LaunchHeavyProjectile); _zNetView.Register("ZTD_DetonateHeavyProjectile", (Method)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(_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 bool UpdateAimInfoForCurrentTarget() { return HelperLib.UpdateAimInfoForCurrentTarget(_targetList[0], _turretAimPoint, _aimResult, _aimResultTempCalcHolder, ProjectileVelocity); } 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 list = new List(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(); 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(); 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(); 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(); 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(); 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(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false); obj.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj, 5f); obj.SetActive(true); GameObject obj2 = Object.Instantiate(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(_projectileTrailGameObject, projectileFromId.ProjectileGameObject.transform.position, projectileFromId.ProjectileGameObject.transform.rotation, projectileFromId.ProjectileGameObject.transform); Trail trail = val.AddComponent(); 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(_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(_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, AdvancedGun, SignalTurret, LightGun, MissileGun, MineTurret, Drone, RepairDrone, GatherDrone, FishingDrone, LoggerDrone, InertTurret } public enum BuildingpartType { Static, HoverCart } public static class HelperLib { public static GameObject GetChildGameObject(GameObject fromGameObject, string withName) { Transform[] componentsInChildren = ((Component)fromGameObject.transform).GetComponentsInChildren(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(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, float projectileSpeed = 1000f) { //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_003e: 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_004d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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, projectileSpeed, 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(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 HoverCart : BuildingpartBase { protected Rigidbody _rigidBodyHoverCart; protected GameObject _partEngineRightFront; protected GameObject _partEngineLeftFront; protected GameObject _partEngineRightMid; protected GameObject _partEngineLeftMid; protected GameObject _partEngineRightRear; protected GameObject _partEngineLeftRear; protected LineRenderer _partEngineRightFrontLineRenderer; protected LineRenderer _partEngineLeftFrontLineRenderer; protected LineRenderer _partEngineRightMidLineRenderer; protected LineRenderer _partEngineLeftMidLineRenderer; protected LineRenderer _partEngineRightRearLineRenderer; protected LineRenderer _partEngineLeftRearLineRenderer; protected float hoverHeight = 3f; protected float springStrength = 80f; protected float damping = 12f; protected float maxLiftPerPoint = 100f; protected float uprightTorque = 20f; protected float uprightDamping = 5f; private bool _everSeenHeightmap; 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(); _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 override void RegisterRemoteProcedureCalls() { } protected override void GetSpecialBodyPartsOfBuildingpart() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) _rigidBodyHoverCart = ((Component)this).gameObject.GetComponent(); _rigidBodyHoverCart.centerOfMass = new Vector3(0f, -0.5f, 0f); _rigidBodyHoverCart.linearDamping = 1f; _rigidBodyHoverCart.angularDamping = 2f; _partEngineRightFront = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineRightFront"); _partEngineRightFrontLineRenderer = _partEngineRightFront.GetComponent(); _partEngineLeftFront = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineLeftFront"); _partEngineLeftFrontLineRenderer = _partEngineLeftFront.GetComponent(); _partEngineRightMid = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineRightMid"); _partEngineRightMidLineRenderer = _partEngineRightMid.GetComponent(); _partEngineLeftMid = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineLeftMid"); _partEngineLeftMidLineRenderer = _partEngineLeftMid.GetComponent(); _partEngineRightRear = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineRightRear"); _partEngineRightRearLineRenderer = _partEngineRightRear.GetComponent(); _partEngineLeftRear = HelperLib.GetChildGameObject(((Component)this).gameObject, "EngineLeftRear"); _partEngineLeftRearLineRenderer = _partEngineLeftRear.GetComponent(); } 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().Start(); _everSeenHeightmap = true; } } if (!((Object)(object)_zNetView == (Object)null) && _zNetView.IsOwner()) { _ = Time.deltaTime; _ = 0f; } } private void FixedUpdate() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (_everSeenHeightmap && !((Object)(object)_zNetView == (Object)null) && _zNetView.IsOwner() && Time.deltaTime != 0f) { AddLogInfo($"---- {_rigidBodyHoverCart.linearVelocity}"); GenerateForceDependingOnDistanceToGround(_partEngineRightFront, _partEngineRightFrontLineRenderer); GenerateForceDependingOnDistanceToGround(_partEngineLeftFront, _partEngineLeftFrontLineRenderer); GenerateForceDependingOnDistanceToGround(_partEngineRightRear, _partEngineRightRearLineRenderer); GenerateForceDependingOnDistanceToGround(_partEngineLeftRear, _partEngineLeftRearLineRenderer); ApplyUprightStabilization(); } } private void GenerateForceDependingOnDistanceToGround(GameObject gameObject, LineRenderer engineLineRender) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 1.1f; RaycastHit val = default(RaycastHit); if (Physics.Raycast(new Ray(gameObject.transform.position, Vector3.down), ref val, num2, _rayMaskSolids)) { if (!(Vector3.Dot(((RaycastHit)(ref val)).normal, Vector3.up) < 0.6f)) { float num3 = hoverHeight - ((RaycastHit)(ref val)).distance; float num4 = Vector3.Dot(_rigidBodyHoverCart.GetPointVelocity(gameObject.transform.position), Vector3.up); float num5 = num3 * springStrength; float num6 = (0f - num4) * damping; Mathf.Clamp(num5 + num6, 0f, maxLiftPerPoint); _ = ((RaycastHit)(ref val)).point; float num7 = ((RaycastHit)(ref val)).distance; if (num7 < 0.1f) { num7 = 0.1f; } num = (1f - Mathf.InverseLerp(0.1f, num2, num7)) * 20f; if ((Object)(object)engineLineRender != (Object)null) { engineLineRender.SetPosition(0, gameObject.transform.position); engineLineRender.SetPosition(1, ((RaycastHit)(ref val)).point); } Vector3 val2 = Vector3.up * num; _rigidBodyHoverCart.AddForceAtPosition(val2, gameObject.transform.position, (ForceMode)5); } } else if ((Object)(object)engineLineRender != (Object)null) { engineLineRender.SetPosition(0, gameObject.transform.position); engineLineRender.SetPosition(1, gameObject.transform.position); } } private void ApplyUprightStabilization() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(((Component)this).transform.up, Vector3.up); ((Component)this).transform.InverseTransformDirection(_rigidBodyHoverCart.angularVelocity); Vector3 val2 = val * uprightTorque - _rigidBodyHoverCart.angularVelocity * uprightDamping; _rigidBodyHoverCart.AddTorque(val2, (ForceMode)5); } } 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 = HelperLib.GetChildGameObject(_droneGameObject, "DroneAimPoint"); _droneWarningLight = HelperLib.GetChildGameObject(_droneGameObject, "DroneWarningLight"); _droneLight = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensorLight"); } 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 = 90f; _droneRotationDefinitions.MaxRotationHorizontalRight = 90f; _droneRotationDefinitions.MaxRotationVerticalUp = 1f; _droneRotationDefinitions.MaxRotationVerticalDown = 89.9f; _droneRotationDefinitions.RotationSpeed = 35f; _droneRotationDefinitions.AllowedAimDeviance = 5f; _droneAimResult = new DegreesSpecifier(); } protected override float SetDroneMovementHeight(float heightIn) { return heightIn + 5f; } protected override bool MoveAndHandleTreesAndLogsAndStubs(Target target) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01da: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: 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_02fd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target.LoggerTreeBaseTarget == (Object)null && (Object)(object)target.LoggerTreeLogTarget == (Object)null && (Object)(object)target.LoggerDestructibleTarget == (Object)null) { return true; } Vector3 val = (((Object)(object)target.LoggerTreeBaseTarget != (Object)null) ? ((Component)target.LoggerTreeBaseTarget).gameObject.transform.position : (((Object)(object)target.LoggerTreeLogTarget != (Object)null) ? ((Component)target.LoggerTreeLogTarget).gameObject.transform.position : ((Component)target.LoggerDestructibleTarget).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) < DroneAttackRange) { UpdateDroneMode(TurretPatrolType.AttackTarget); } else { UpdateDroneMode(TurretPatrolType.ScanTarget); } if ((((Object)(object)target.LoggerTreeBaseTarget != (Object)null) ? target.LoggerTreeBaseTarget.m_health : (((Object)(object)target.LoggerTreeLogTarget != (Object)null) ? target.LoggerTreeLogTarget.m_health : target.LoggerDestructibleTarget.m_health)) <= 0f) { UpdateDroneMode(TurretPatrolType.NoTarget); return true; } if (target.TimeToLive <= 0f) { UpdateDroneMode(TurretPatrolType.NoTarget); Target droneTarget = new Target { Location = new Vector3(_turretAimPoint.transform.position.x, _turretAimPoint.transform.position.y + 2f, _turretAimPoint.transform.position.z), IsMoveOrder = true, TimeToLive = 10f }; _droneTarget = droneTarget; return false; } return false; } protected override void FindNewTarget() { //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Invalid comparison between Unknown and I4 float num = float.MaxValue; List list = new List(); foreach (TreeBase item in new List(Object.FindObjectsOfType())) { if ((Object)(object)item == (Object)null || item.m_health <= 0f) { continue; } float rangeToTreeOrLogOrDestructible = GetRangeToTreeOrLogOrDestructible(((Component)item).gameObject, _turretAimPoint); if (!(rangeToTreeOrLogOrDestructible > Range * 1.05f)) { rangeToTreeOrLogOrDestructible += GetRangeToTreeOrLogOrDestructible(((Component)item).gameObject, _droneGameObject) * 0.5f; if (rangeToTreeOrLogOrDestructible < num) { num = AddTreeOrLogOrDestructibleToTargetList(list, item, null, null, rangeToTreeOrLogOrDestructible, MaximumNumberOfTrackedTargets); } } } foreach (TreeLog item2 in new List(Object.FindObjectsOfType())) { if ((Object)(object)item2 == (Object)null || item2.m_health <= 0f) { continue; } float rangeToTreeOrLogOrDestructible2 = GetRangeToTreeOrLogOrDestructible(((Component)item2).gameObject, _turretAimPoint); if (!(rangeToTreeOrLogOrDestructible2 > Range * 1.1f)) { rangeToTreeOrLogOrDestructible2 += GetRangeToTreeOrLogOrDestructible(((Component)item2).gameObject, _droneGameObject) * 0.5f; if (rangeToTreeOrLogOrDestructible2 < num) { num = AddTreeOrLogOrDestructibleToTargetList(list, null, item2, null, rangeToTreeOrLogOrDestructible2, MaximumNumberOfTrackedTargets); } } } foreach (Destructible item3 in new List(Object.FindObjectsOfType())) { if ((Object)(object)item3 == (Object)null || item3.m_health <= 0f || (int)item3.m_destructibleType != 2 || (Object)(object)((Component)((Component)item3).transform.root).GetComponent() != (Object)null) { continue; } float rangeToTreeOrLogOrDestructible3 = GetRangeToTreeOrLogOrDestructible(((Component)item3).gameObject, _turretAimPoint); if (!(rangeToTreeOrLogOrDestructible3 > Range * 1.05f)) { rangeToTreeOrLogOrDestructible3 += GetRangeToTreeOrLogOrDestructible(((Component)item3).gameObject, _droneGameObject) * 0.5f; if (rangeToTreeOrLogOrDestructible3 < num) { num = AddTreeOrLogOrDestructibleToTargetList(list, null, null, item3, rangeToTreeOrLogOrDestructible3, MaximumNumberOfTrackedTargets); } } } if (list.Count > 0) { num = list[0].DistanceRating; if (!((Object)(object)list[0].LoggerTreeBaseTarget != (Object)null)) { if (!((Object)(object)list[0].LoggerTreeLogTarget != (Object)null)) { _ = ((Object)list[0].LoggerDestructibleTarget).name; } else { _ = ((Object)list[0].LoggerTreeLogTarget).name; } } else { _ = ((Object)list[0].LoggerTreeBaseTarget).name; } } SetTargets(list, num); _updateTargetTimer += 20f; } private float GetRangeToTreeOrLogOrDestructible(GameObject treeOrLogOrDestructible, GameObject compareGameObject) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(treeOrLogOrDestructible.transform.position, compareGameObject.transform.position); } private float AddTreeOrLogOrDestructibleToTargetList(List newTargetList, TreeBase treeBase, TreeLog treeLog, Destructible destructible, 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(CreateTreeAndLogOrDestructibleTarget(treeBase, treeLog, destructible, distanceRating)); num = distanceRating; } return num; } newTargetList.Insert(targetListIndexBasedOnDistance, CreateTreeAndLogOrDestructibleTarget(treeBase, treeLog, destructible, distanceRating)); if (newTargetList.Count > maxTargets) { newTargetList.RemoveAt(maxTargets); num = newTargetList[newTargetList.Count - 1].DistanceRating; } return num; } private Target CreateTreeAndLogOrDestructibleTarget(TreeBase tree, TreeLog log, Destructible destructible, float distanceRating) { //IL_0058: 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) GameObject val = (((Object)(object)tree != (Object)null) ? ((Component)tree).gameObject : (((Object)(object)log != (Object)null) ? ((Component)log).gameObject : ((Component)destructible).gameObject)); return new Target { Character = null, IsTargetLoggerOrder = true, LoggerTreeBaseTarget = tree, LoggerTreeLogTarget = log, LoggerDestructibleTarget = destructible, Location = val.transform.position, DistanceRating = distanceRating, TimeToLive = 40f }; } protected override bool UpdateAimInfoForCurrentTarget() { if (_droneTarget == null) { return false; } if ((Object)(object)_droneTarget.LoggerTreeBaseTarget == (Object)null && (Object)(object)_droneTarget.LoggerTreeLogTarget == (Object)null && (Object)(object)_droneTarget.LoggerDestructibleTarget == (Object)null) { return false; } if ((Object)(object)_droneTarget.LoggerTreeBaseTarget != (Object)null && (Object)(object)((Component)_droneTarget.LoggerTreeBaseTarget).gameObject == (Object)null) { return false; } if ((Object)(object)_droneTarget.LoggerTreeLogTarget != (Object)null && (Object)(object)((Component)_droneTarget.LoggerTreeLogTarget).gameObject == (Object)null) { return false; } if ((Object)(object)_droneTarget.LoggerDestructibleTarget != (Object)null && (Object)(object)((Component)_droneTarget.LoggerDestructibleTarget).gameObject == (Object)null) { return false; } return HelperLib.UpdateAimInfoForCurrentTreeTarget(_droneTarget, _droneAimPoint, _droneAimResult, _aimResultTempCalcHolder); } 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_0197: 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_00cd: Invalid comparison between Unknown and I4 //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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("LoggerDroneTurret.LaunchProjectileAndShowHitPosition() - _hitData is null"); return; } TreeBase component = ((Component)((Component)((RaycastHit)(ref val)).collider).transform.root).gameObject.GetComponent(); TreeLog val2 = (((Object)(object)component == (Object)null) ? ((Component)((Component)((RaycastHit)(ref val)).collider).transform.root).gameObject.GetComponent() : null); Destructible val3 = (((Object)(object)val2 == (Object)null) ? ((Component)((Component)((RaycastHit)(ref val)).collider).transform.root).GetComponent() : null); if ((Object)(object)component != (Object)null || (Object)(object)val2 != (Object)null || ((Object)(object)val3 != (Object)null && (int)val3.m_destructibleType == 2)) { if ((((Object)(object)component != (Object)null) ? component.m_health : (((Object)(object)val2 != (Object)null) ? val2.m_health : val3.m_health)) > 0f) { HitData val4 = _hitData.Clone(); val4.m_hitCollider = ((RaycastHit)(ref val)).collider; val4.m_point = ((RaycastHit)(ref val)).point; val4.m_dir = ((Quaternion)(ref directionQuat)).eulerAngles; val4.m_toolTier = 10; val4.m_pushForce = 0f; val4.m_staggerMultiplier = 0f; if ((Object)(object)component != (Object)null) { component.Damage(val4); } else if ((Object)(object)val2 != (Object)null) { val2.Damage(val4); } else { val3.Damage(val4); } } } else { Collider[] array = Physics.OverlapSphere(((RaycastHit)(ref val)).point, 1f, _rayMaskTreesAndRock); foreach (Collider val5 in array) { HitData val6 = _hitData.Clone(); val6.m_hitCollider = val5; val6.m_point = (val5.providesContacts ? val5.ClosestPoint(((RaycastHit)(ref val)).point) : val5.ClosestPointOnBounds(((RaycastHit)(ref val)).point)); val6.m_dir = ((Quaternion)(ref directionQuat)).eulerAngles; val6.m_damage.m_chop *= 0.5f; val6.m_damage.m_pickaxe *= 0.5f; val6.m_toolTier = 10; val6.m_pushForce = 0f; val6.m_staggerMultiplier = 0f; Destructible component2 = ((Component)((Component)val5).transform.root).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.Damage(val6); continue; } MineRock5 component3 = ((Component)((Component)val5).transform.root).gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.Damage(val6); } } } _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchDroneCannonProjectile", new object[2] { ((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal }); } private void FixedUpdate() { _droneWarningLight.transform.Rotate(0f, 5f, 0f); } } public struct RotationDefinitions { public float MaxRotationHorizontalLeft; public float MaxRotationHorizontalRight; public float MaxRotationVerticalUp; public float MaxRotationVerticalDown; public float RotationSpeed; public float AllowedAimDeviance; } public static class MathHelper { public static int MultiplyWithFloatWithFloor(int inAmount, float multiple, int floor) { int num = (int)Math.Round((float)inAmount * multiple, MidpointRounding.AwayFromZero); if (num < floor) { num = floor; } return num; } public static double NthRoot(double A, int N) { return Math.Pow(A, 1.0 / (double)N); } public static void GetDegreesBetweenAimAndTarget(DegreesSpecifier aimResult, Transform aimTransform, Vector3 targetLocation, Transform debug) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = aimTransform.rotation; aimTransform.LookAt(targetLocation, Vector3.up); Quaternion localRotation = aimTransform.localRotation; float num = ((Quaternion)(ref localRotation)).eulerAngles.y; if (num > 180f) { num -= 360f; } if (num < -180f) { num += 360f; } aimResult.DegreesY = num; localRotation = aimTransform.localRotation; float num2 = ((Quaternion)(ref localRotation)).eulerAngles.x; if (num2 > 180f) { num2 -= 360f; } if (num2 < -180f) { num2 += 360f; } aimResult.DegreesX = num2; if ((Object)(object)debug != (Object)null) { debug.rotation = aimTransform.rotation; } aimTransform.rotation = rotation; } public static Vector3 FirstOrderIntercept(Vector3 shooterPosition, Vector3 shooterVelocity, float shotSpeed, Vector3 targetPosition, Vector3 targetVelocity) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 targetRelativePosition = targetPosition - shooterPosition; Vector3 val = targetVelocity - shooterVelocity; float num = FirstOrderInterceptTime(shotSpeed, targetRelativePosition, val); return targetPosition + num * val; } public static float FirstOrderInterceptTime(float shotSpeed, Vector3 targetRelativePosition, Vector3 targetRelativeVelocity) { //IL_004f: 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_0036: 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) float sqrMagnitude = ((Vector3)(ref targetRelativeVelocity)).sqrMagnitude; if (sqrMagnitude < 0.001f) { return 0f; } float num = sqrMagnitude - shotSpeed * shotSpeed; if (Mathf.Abs(num) < 0.001f) { return Mathf.Max((0f - ((Vector3)(ref targetRelativePosition)).sqrMagnitude) / (2f * Vector3.Dot(targetRelativeVelocity, targetRelativePosition)), 0f); } float num2 = 2f * Vector3.Dot(targetRelativeVelocity, targetRelativePosition); float sqrMagnitude2 = ((Vector3)(ref targetRelativePosition)).sqrMagnitude; float num3 = num2 * num2 - 4f * num * sqrMagnitude2; if (num3 > 0f) { float num4 = (0f - num2 + Mathf.Sqrt(num3)) / (2f * num); float num5 = (0f - num2 - Mathf.Sqrt(num3)) / (2f * num); if (num4 > 0f) { if (num5 > 0f) { return Mathf.Min(num4, num5); } return num4; } return Mathf.Max(num5, 0f); } if (num3 < 0f) { return 0f; } return Mathf.Max((0f - num2) / (2f * num), 0f); } public static Rect GetBoundingBoxOnScreen(Bounds bounds, Camera camera) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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) //IL_026f: 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_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: 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_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0353: 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_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref bounds)).center; Vector3 size = ((Bounds)(ref bounds)).size; Vector3[] array = (Vector3[])(object)new Vector3[8] { center + Vector3.right * size.x / 2f + Vector3.up * size.y / 2f + Vector3.forward * size.z / 2f, center + Vector3.right * size.x / 2f + Vector3.up * size.y / 2f - Vector3.forward * size.z / 2f, center + Vector3.right * size.x / 2f - Vector3.up * size.y / 2f + Vector3.forward * size.z / 2f, center + Vector3.right * size.x / 2f - Vector3.up * size.y / 2f - Vector3.forward * size.z / 2f, center - Vector3.right * size.x / 2f + Vector3.up * size.y / 2f + Vector3.forward * size.z / 2f, center - Vector3.right * size.x / 2f + Vector3.up * size.y / 2f - Vector3.forward * size.z / 2f, center - Vector3.right * size.x / 2f - Vector3.up * size.y / 2f + Vector3.forward * size.z / 2f, center - Vector3.right * size.x / 2f - Vector3.up * size.y / 2f - Vector3.forward * size.z / 2f }; Rect result = Rect.MinMaxRect(float.MaxValue, float.MaxValue, float.MinValue, float.MinValue); for (int i = 0; i < array.Length; i++) { Vector3 val = camera.WorldToScreenPoint(array[i]); if (val.x < ((Rect)(ref result)).xMin) { ((Rect)(ref result)).xMin = val.x; } if (val.y < ((Rect)(ref result)).yMin) { ((Rect)(ref result)).yMin = val.y; } if (val.x > ((Rect)(ref result)).xMax) { ((Rect)(ref result)).xMax = val.x; } if (val.y > ((Rect)(ref result)).yMax) { ((Rect)(ref result)).yMax = val.y; } } return result; } } public class MineTurret : TurretBase { private GameObject _mineLaunchEffect; private GameObject _mineTriggerEffect; protected override void GetSpecialBodyPartsOfTurret() { _mineLaunchEffect = HelperLib.GetChildGameObject(((Component)this).gameObject, "MineLaunchEffect"); _mineTriggerEffect = HelperLib.GetChildGameObject(((Component)this).gameObject, "MineTriggerEffect"); } protected override void SetUpTurretSpecificData() { _rotationDefinitions.MaxRotationHorizontalLeft = 180f; _rotationDefinitions.MaxRotationHorizontalRight = 180f; _rotationDefinitions.MaxRotationVerticalUp = 90f; _rotationDefinitions.MaxRotationVerticalDown = 85f; _rotationDefinitions.RotationSpeed = 360f; _rotationDefinitions.AllowedAimDeviance = 45f; } protected override void TriggerTurretFiring() { //IL_0041: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) _nextShootDelayTimer += FireInterval; if (_nextShootDelayTimer < FireInterval / 2f) { _nextShootDelayTimer = FireInterval / 2f; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y + 0.5f, ((Component)this).transform.position.z); _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_FireMine", new object[1] { val }); DamageAreaTargets(val, _rangedHitData, onlyDamageCharacters: true); } protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_FireMine", (Action)RPC_FireMine); } private void RPC_FireMine(long sender, Vector3 startLocation) { //IL_001d: 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_006c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(_mineLaunchEffect, (Transform)null); obj.transform.position = _turretTilt.transform.position; obj.transform.rotation = _turretTilt.transform.rotation; obj.SetActive(false); obj.SetActive(true); Object.Destroy((Object)(object)obj, 3f); GameObject obj2 = Object.Instantiate(_mineTriggerEffect, (Transform)null); obj2.transform.position = startLocation; obj2.SetActive(false); obj2.SetActive(true); Object.Destroy((Object)(object)obj2, 10f); } } public class Missile { public int Id; public GameObject MissileGameObject; public Target Target; public float TimeLivedLeft; public bool ActiveInGame; public bool ActiveInFlight; public Trail Trail; public bool TargetingActive => TimeLivedLeft > 0f; public void RegisterMissileAndAddTarget(Target target) { if (!target.IsMoveOrder) { target.MissilesSharingThisTarget.Add(this); } Target = target; } public void DeRegisterMissileAndRemoveTarget() { if (Target == null) { Logger.LogDebug((object)$"### Missile -- Target is NULL - most likely killed already (Id: {Id})"); return; } if (!Target.IsMoveOrder) { Target.MissilesSharingThisTarget.Remove(this); } Target = null; } } public class MissileTurret : TurretBase { private GameObject _missilePrefabGameObject; private GameObject _missileExplosionEffectPrefab; private GameObject _missileExplosionEffectLightPrefab; private GameObject _missileTrailGameObject; private readonly List _missileList = new List(); protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_LaunchMissile", (Action)RPC_LaunchMissile); _zNetView.Register("ZTD_DetonateMissile", (Action)RPC_DetonateMissile); } protected override void GetSpecialBodyPartsOfTurret() { _lightLaser = HelperLib.GetChildGameObject(((Component)this).gameObject, "Light (Laser)"); _missilePrefabGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "MissilePrefab"); _missileExplosionEffectPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "MissileImpactEffect"); _missileExplosionEffectLightPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "MissileImpactEffectLight"); _missileTrailGameObject = HelperLib.GetChildGameObject(((Component)this).gameObject, "Trail"); } protected override void SetUpTurretSpecificData() { _rotationDefinitions.MaxRotationHorizontalLeft = 120f; _rotationDefinitions.MaxRotationHorizontalRight = 120f; _rotationDefinitions.MaxRotationVerticalUp = 60f; _rotationDefinitions.MaxRotationVerticalDown = 30f; _rotationDefinitions.RotationSpeed = 100f; _rotationDefinitions.AllowedAimDeviance = 40f; foreach (Barrel barrel in _barrelList) { Missile missile = new Missile { Id = barrel.Id, MissileGameObject = Object.Instantiate(_missilePrefabGameObject, ((Component)this).transform.root) }; missile.MissileGameObject.SetActive(false); _missileList.Add(missile); } } protected override void SyncTurretNetData() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!_netDataObjectHandler.HasDataToRead) { return; } base.SyncTurretNetData(); foreach (Missile missile in _missileList) { if (missile.ActiveInFlight && missile.ActiveInGame) { missile.MissileGameObject.transform.position = _netDataObjectHandler.Data.GetVec3($"missile_{missile.Id}.position", Vector3.zero); missile.MissileGameObject.transform.rotation = _netDataObjectHandler.Data.GetQuaternion($"missile_{missile.Id}.rotation", Quaternion.identity); } } } protected override void TriggerTurretFiring() { if (_barrelList == null) { AddWarningMsg("MissileTurret.TriggerTurretFiring() - _barrelList == null"); return; } if (_nextBarrelIdToUse > _barrelList.Count) { AddWarningMsg($"MissileTurret.TriggerTurretFiring() - if (_nextBarrelIdToUse > _barrelList.Count) : if ({_nextBarrelIdToUse} > {_barrelList.Count})"); return; } if (AmmoCount > 0) { if (_ammoInGun == 0) { return; } _nextBarrelIdToUse = AmmoCount - _ammoInGun; } if (_missileList.Count > 1) { _nextShootDelayTimer += FireInterval; if (_nextShootDelayTimer < FireInterval / 2f) { _nextShootDelayTimer = FireInterval / 2f; } } else { _nextShootDelayTimer = float.MaxValue; } Missile missile = _missileList[_nextBarrelIdToUse]; if (!missile.ActiveInGame || !missile.ActiveInFlight) { missile.ActiveInFlight = true; missile.TimeLivedLeft = 16f; _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchMissile", new object[1] { _nextBarrelIdToUse }); } } protected override void ControlAndMoveMissilesOrProjectilesOrDrones() { foreach (Missile missile in _missileList) { ControlAndMoveMissile(missile); } } private void ControlAndMoveMissile(Missile missile) { //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: 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_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) if (!missile.ActiveInFlight || !missile.ActiveInGame) { return; } missile.TimeLivedLeft -= Time.deltaTime; if (missile.Target != null) { if (!missile.Target.IsMoveOrder) { if (missile.Target.Character.GetHealth() <= 0f || ((Object)missile.Target.Character).GetInstanceID() == 0) { Target target = new Target { Location = missile.Target.Location, IsMoveOrder = true, TimeToLive = 0.25f + Random.value * 0.5f }; missile.DeRegisterMissileAndRemoveTarget(); missile.RegisterMissileAndAddTarget(target); } } else if (missile.Target.TimeToLive > 0f) { missile.Target.TimeToLive -= Time.deltaTime; if (missile.Target.TimeToLive <= 0f) { missile.DeRegisterMissileAndRemoveTarget(); } } } if (missile.Target == null && missile.TargetingActive) { GetTargetForMissile(missile); if (missile.Target == null) { float num = missile.MissileGameObject.transform.position.x + Random.value * 10f - 5f; float num2 = missile.MissileGameObject.transform.position.y + Random.value * 4f + 6f; float num3 = missile.MissileGameObject.transform.position.z + Random.value * 10f - 5f; Target target2 = new Target { Location = new Vector3(num, num2, num3), IsMoveOrder = true, TimeToLive = 0.5f + (Random.value + 2f) }; missile.RegisterMissileAndAddTarget(target2); } } if (missile.Target != null) { Vector3 val = missile.Target.Location; bool flag = true; if ((Object)(object)missile.Target.Character != (Object)null && missile.Target.Character.GetHealth() > 0f) { Vector3 centerPoint = missile.Target.Character.GetCenterPoint(); val = MathHelper.FirstOrderIntercept(missile.MissileGameObject.transform.position, Vector3.zero, 0f, centerPoint, missile.Target.Character.m_currentVel); missile.Target.Location = val; flag = missile.Target.Character.IsFlying(); } if (Vector3.Distance(missile.MissileGameObject.transform.position, val) >= 20f && !flag) { val.y += 12f; } Vector3 val2 = val - missile.MissileGameObject.transform.position; Vector3 val3 = Vector3.RotateTowards(missile.MissileGameObject.transform.forward, val2, MissileTurnRate * Time.deltaTime, 0f); missile.MissileGameObject.transform.rotation = Quaternion.LookRotation(val3); } Vector3 position = missile.MissileGameObject.transform.position; Transform transform = missile.MissileGameObject.transform; transform.position += missile.MissileGameObject.transform.forward * MissileVelocity * Time.deltaTime; float num4 = Vector3.Distance(position, missile.MissileGameObject.transform.position); RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(new Ray(position, missile.MissileGameObject.transform.forward), ref val4, num4, _rayMaskSolids)) { missile.MissileGameObject.transform.position = ((RaycastHit)(ref val4)).point; SetDataToDataObject(missile); HitData val5 = _hitData.Clone(); val5.m_hitCollider = ((RaycastHit)(ref val4)).collider; val5.m_point = ((RaycastHit)(ref val4)).point; Quaternion rotation = missile.MissileGameObject.transform.rotation; val5.m_dir = ((Quaternion)(ref rotation)).eulerAngles; Character component = ((Component)((Component)((RaycastHit)(ref val4)).collider).transform.root).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { ApplyDamageToCharacterHit(component, val5); } DetonateMissile(missile, new Vector3(((RaycastHit)(ref val4)).point.x, ((RaycastHit)(ref val4)).point.y + 1f, ((RaycastHit)(ref val4)).point.z)); } else { SetDataToDataObject(missile); if (Vector3.Distance(((Component)this).transform.position, missile.MissileGameObject.transform.position) > Range * 1.5f) { DetonateMissile(missile, missile.MissileGameObject.transform.position); } } } private void SetDataToDataObject(Missile missile) { //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($"missile_{missile.Id}.position", missile.MissileGameObject.transform.position); _netDataObjectHandler.Data.Set($"missile_{missile.Id}.rotation", missile.MissileGameObject.transform.rotation); } private void GetTargetForMissile(Missile missile) { if (_targetList.Count == 0) { return; } int num = 0; Target targetWithDefinedTrackingMissiles; do { targetWithDefinedTrackingMissiles = GetTargetWithDefinedTrackingMissiles(num); num++; if (num > AmmoCount + 2) { return; } } while (targetWithDefinedTrackingMissiles == null); missile.RegisterMissileAndAddTarget(targetWithDefinedTrackingMissiles); } private Target GetTargetWithDefinedTrackingMissiles(int numberOfTrackingMissiles) { foreach (Target target in _targetList) { if (!target.Character.IsPlayer() && target.MissilesSharingThisTarget.Count <= numberOfTrackingMissiles) { return target; } } return null; } private void DetonateMissile(Missile missile, Vector3 impactLocation) { //IL_004d: 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_0067: Unknown result type (might be due to invalid IL or missing references) missile.ActiveInFlight = false; missile.DeRegisterMissileAndRemoveTarget(); if (_missileList.Count == 1) { _nextShootDelayTimer = FireInterval; } _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_DetonateMissile", new object[3] { missile.Id, impactLocation, Vector3.up }); DamageAreaTargets(impactLocation, _rangedHitData, onlyDamageCharacters: false); } private void RPC_LaunchMissile(long sender, int missileId) { //IL_00c2: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) if (_barrelList != null && missileId + 1 <= _barrelList.Count && missileId + 1 <= _missileList.Count) { Barrel barrel = _barrelList[missileId]; GameObject obj = Object.Instantiate(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false); obj.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj, 5f); obj.SetActive(true); GameObject obj2 = Object.Instantiate(barrel.LaunchAudioGameObject, barrel.ThisBarrelGameObject.transform, false); obj2.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj2, 5f); obj2.SetActive(true); Missile missile = _missileList[missileId]; missile.MissileGameObject.transform.SetPositionAndRotation(barrel.ThisBarrelGameObject.transform.position, barrel.ThisBarrelGameObject.transform.rotation); missile.MissileGameObject.SetActive(false); missile.MissileGameObject.SetActive(true); missile.ActiveInGame = true; if ((Object)(object)_missileTrailGameObject != (Object)null) { GameObject val = Object.Instantiate(_missileTrailGameObject, missile.MissileGameObject.transform.position, missile.MissileGameObject.transform.rotation, missile.MissileGameObject.transform); Trail trail = val.AddComponent(); trail.ParentGameObject = val; trail.InitLocationListAtStartLocation(missile.MissileGameObject.transform.position); missile.Trail = trail; missile.Trail.ParentGameObject.SetActive(true); } } } private void RPC_DetonateMissile(long sender, int missileId, Vector3 detonateLocation, Vector3 direction) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_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) Missile missile = _missileList[missileId]; missile.MissileGameObject.SetActive(false); missile.ActiveInGame = false; if ((Object)(object)missile.Trail != (Object)null) { missile.Trail.DisableTrail(); missile.Trail.ParentGameObject.transform.SetParent((Transform)null); Object.Destroy((Object)(object)missile.Trail.ParentGameObject, 5f); missile.Trail = null; } Quaternion rotation = default(Quaternion); ((Quaternion)(ref rotation)).SetLookRotation(direction); GameObject obj = Object.Instantiate(_missileExplosionEffectPrefab, (Transform)null); obj.transform.position = detonateLocation; obj.transform.rotation = rotation; obj.SetActive(false); obj.SetActive(true); Object.Destroy((Object)(object)obj, 10f); GameObject obj2 = Object.Instantiate(_missileExplosionEffectLightPrefab, (Transform)null); obj2.transform.position = detonateLocation; obj2.transform.rotation = rotation; obj2.SetActive(false); obj2.SetActive(true); Object.Destroy((Object)(object)obj2, 0.6f); } } public class NetDataObjectHandler { private readonly ZDO _zDataObject; private uint _dataRevision; public bool HasDataToRead { get { if (_zDataObject != null) { return _dataRevision != _zDataObject.DataRevision; } return false; } } public ZDO Data => _zDataObject; public NetDataObjectHandler(ZDO zDataObject) { _zDataObject = zDataObject; _dataRevision = 1u; } public void ReceiveDone() { if (_zDataObject == null) { _dataRevision = 0u; } else { _dataRevision = _zDataObject.DataRevision; } } } public class Projectile { public int Id; public GameObject ProjectileGameObject; public bool AnnouncedAndVisible; public bool OwnerHasActiveControl; public Trail Trail; } public class RepairDroneTurret : DroneTurret { protected readonly int _rayMaskRepairDroneSolids = LayerMask.GetMask(new string[3] { "piece", "piece_nonsolid", "vehicle" }); 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, "RepairDetonation"); _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"); _droneLight = HelperLib.GetChildGameObject(_droneGameObject, "DroneSensorLight"); } 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 = 90f; _droneRotationDefinitions.MaxRotationHorizontalRight = 90f; _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 MoveAndHandleWearAndTear(Target target) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target.WearAndTearPiece == (Object)null) { AddDebugMsg($"RepairDroneTurret.MoveAndHandleWearAndTear({target.GetHashCode()}, target.WearAndTearPiece == null -- piece might already be destroyed, skip target"); return true; } Vector3 position = ((Component)target.WearAndTearPiece).gameObject.transform.position; target.Location = new Vector3(position.x, SetDroneMovementHeight(position.y), position.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; if (Vector3.Distance(_droneGameObject.transform.position, target.Location) < DroneAttackRange) { UpdateDroneMode(TurretPatrolType.AttackTarget); } else { UpdateDroneMode(TurretPatrolType.ScanTarget); } if (_droneTarget.WearAndTearPiece.GetHealthPercentage() <= 0f) { AddDebugMsg("RepairDroneTurret.MoveAndHandleWearAndTear - Target " + ((Object)_droneTarget.WearAndTearPiece.m_piece).name + " is Destroyed"); UpdateDroneMode(TurretPatrolType.NoTarget); return true; } if (RepairTarget && _droneTarget.WearAndTearPiece.GetHealthPercentage() >= 1f) { UpdateDroneMode(TurretPatrolType.NoTarget); return true; } if (_droneTarget.TimeToLive <= 0f) { UpdateDroneMode(TurretPatrolType.NoTarget); return true; } return false; } protected override void FindNewTarget() { float num = float.MaxValue; List list = new List(); if (OnlyPlayerForTargeting) { SetTargets(list, num); return; } foreach (WearNTear allInstance in WearNTear.GetAllInstances()) { if ((Object)(object)allInstance == (Object)null) { continue; } if (allInstance.GetHealthPercentage() <= 0f) { AddDebugMsg("WearAndTearPiece, Target search: Character " + ((Object)allInstance).name + ", is DESTROYED -- skipping"); continue; } float rangeToWearAndTearPiece = GetRangeToWearAndTearPiece(allInstance); if (!(rangeToWearAndTearPiece > Range * 1.5f) && (!RepairTarget || !(allInstance.GetHealthPercentage() >= 0.9f))) { rangeToWearAndTearPiece = ((!(rangeToWearAndTearPiece < MinimumRange)) ? (rangeToWearAndTearPiece * allInstance.GetHealthPercentage()) : (Range * 2f + rangeToWearAndTearPiece)); if (rangeToWearAndTearPiece < num) { num = AddWearAndTearPieceToTargetList(list, allInstance, rangeToWearAndTearPiece, MaximumNumberOfTrackedTargets); } } } if (list.Count > 0) { num = list[0].DistanceRating; } SetTargets(list, num); _updateTargetTimer += 10f; } private float GetRangeToWearAndTearPiece(WearNTear wearAndTearPiece) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(((Component)wearAndTearPiece).gameObject.transform.position, _turretAimPoint.transform.position); } private float AddWearAndTearPieceToTargetList(List newTargetList, WearNTear wearAndTear, 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(CreateWearAndTearTarget(wearAndTear, distanceRating)); num = distanceRating; } return num; } newTargetList.Insert(targetListIndexBasedOnDistance, CreateWearAndTearTarget(wearAndTear, distanceRating)); if (newTargetList.Count > maxTargets) { newTargetList.RemoveAt(maxTargets); num = newTargetList[newTargetList.Count - 1].DistanceRating; } return num; } private Target CreateWearAndTearTarget(WearNTear wearAndTear, 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, WearAndTearPiece = wearAndTear, IsTargetWearAndTearOrder = true, Location = ((Component)wearAndTear).gameObject.transform.position, DistanceRating = distanceRating }; } protected override bool UpdateAimInfoForCurrentTarget() { if (_droneTarget == null) { return false; } if ((Object)(object)_droneTarget.WearAndTearPiece == (Object)null) { return false; } if ((Object)(object)((Component)_droneTarget.WearAndTearPiece).gameObject == (Object)null) { return false; } return HelperLib.UpdateAimInfoForCurrentPieceTarget(_droneTarget, _droneAimPoint, _droneAimResult, _aimResultTempCalcHolder); } 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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 val = barrelEdgePosition; val += directionQuat * Vector3.forward * (DroneAttackRange * 1f); Collider[] array = Physics.OverlapSphere(val, 2.5f, _rayMaskRepairDroneSolids); if (array.Length == 0) { return; } Collider[] array2 = array; for (int i = 0; i < array2.Length; i++) { WearNTear component = ((Component)((Component)array2[i]).transform.root).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null) && !(component.GetHealthPercentage() >= 1f)) { component.Repair(); } } _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_LaunchDroneCannonProjectile", new object[2] { val, Vector3.forward }); } } public class RotationData { public float CurrentRotationY; public float CurrentRotationX; public float DistanceRotY; public float DistanceRotX; } public class SignalTurret : TurretBase { protected GameObject _signalFlare; protected GameObject _signalLaunchEffect; protected override void GetSpecialBodyPartsOfTurret() { _signalFlare = HelperLib.GetChildGameObject(((Component)this).gameObject, "LightFlareEffect"); _signalLaunchEffect = HelperLib.GetChildGameObject(((Component)this).gameObject, "SignalTurretLaunchEffect"); } protected override void SetUpTurretSpecificData() { _rotationDefinitions.MaxRotationHorizontalLeft = 180f; _rotationDefinitions.MaxRotationHorizontalRight = 180f; _rotationDefinitions.MaxRotationVerticalUp = 90f; _rotationDefinitions.MaxRotationVerticalDown = 85f; _rotationDefinitions.RotationSpeed = 360f; _rotationDefinitions.AllowedAimDeviance = 45f; } protected override void TriggerTurretFiring() { //IL_0041: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) _nextShootDelayTimer += FireInterval; if (_nextShootDelayTimer < FireInterval / 2f) { _nextShootDelayTimer = FireInterval / 2f; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y + 15f, ((Component)this).transform.position.z); _zNetView.InvokeRPC(ZNetView.Everybody, "ZTD_FireSignalFlare", new object[1] { val }); } protected override void RegisterRemoteProcedureCalls() { _zNetView.Register("ZTD_FireSignalFlare", (Action)RPC_FireSignalFlare); } private void RPC_FireSignalFlare(long sender, Vector3 startLocation) { //IL_001d: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) GameObject obj = Object.Instantiate(_signalLaunchEffect, (Transform)null); obj.transform.position = _turretTilt.transform.position; obj.transform.rotation = _turretTilt.transform.rotation; obj.SetActive(false); obj.SetActive(true); Object.Destroy((Object)(object)obj, 3f); GameObject obj2 = Object.Instantiate(_signalFlare, (Transform)null); obj2.transform.position = startLocation; obj2.SetActive(false); obj2.SetActive(true); obj2.GetComponent().AddForce(Vector3.down * 25f); Object.Destroy((Object)(object)obj2, 19f); } } public class Target { public Character Character; public Vector3 Location; public float DistanceRating; public bool IsMoveOrder; public bool IsTargetWearAndTearOrder; public WearNTear WearAndTearPiece; public bool IsGatherItemOrder; public ItemDrop GatherItemDrop; public bool OnGatherItemDropReturnTrip; public Rigidbody RigidBody; public bool IsTargetLoggerOrder; public TreeBase LoggerTreeBaseTarget; public TreeLog LoggerTreeLogTarget; public Destructible LoggerDestructibleTarget; public float TimeToLive; public List MissilesSharingThisTarget = new List(); } public class Trail : MonoBehaviour { private readonly float _intervalTime = 0.05f; public GameObject ParentGameObject; private LineRenderer _lineRenderer; private readonly List _listLocations; private readonly int _maxPoints = 30; private float _intervalTimerCounter; private Transform _transform; private bool _enabled; public Trail() { _listLocations = new List(); } private void Awake() { _lineRenderer = ((Component)((Component)this).transform).GetComponentInChildren(); if ((Object)(object)_lineRenderer == (Object)null) { Logger.LogDebug((object)$"{DateTime.Now:o} ### Trail[{((Object)((Component)this).gameObject).GetInstanceID()}]: No LineRenderer found"); return; } _transform = ((Component)this).transform; _intervalTimerCounter = 0f; _enabled = true; } public void InitLocationListAtStartLocation(Vector3 startLocation) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) _listLocations.Clear(); for (int i = 0; i < _maxPoints - 1; i++) { _listLocations.Add(startLocation); } } private void Update() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (_enabled) { _intervalTimerCounter -= Time.deltaTime; if (_intervalTimerCounter <= 0f) { AddLocationPoint(_transform.position); _intervalTimerCounter += _intervalTime; } } } public void AddLocationPoint(Vector3 location) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _listLocations.Add(location); CountOutLines(); } private void CountOutLines() { if (_listLocations.Count > _maxPoints) { _listLocations.RemoveAt(0); } _lineRenderer.positionCount = _listLocations.Count; _lineRenderer.SetPositions(_listLocations.ToArray()); } public void DisableTrail() { _enabled = true; } } public class ProjectileParticle : MonoBehaviour { public HitData HitData; public TurretBase SourceTurret; private void OnParticleCollision(GameObject other) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) Character val = default(Character); if (other.TryGetComponent(ref val) && SourceTurret.IsOwner && (int)val.GetFaction() != 0 && !val.IsTamed() && !val.IsDead()) { val.Damage(HitData); } } } public class TurretBase : MonoBehaviour { public enum TurretPatrolType { NoTarget, ScanTarget, AttackTarget } public float Range = 20f; public float MinimumRange; public float DroneAttackRange; public float FireInterval = 1f; public float ReloadTime; public int AmmoCount; public int MaximumNumberOfTrackedTargets; public bool MustHaveLineOfSightToTrack; public bool IgnorePlayerForTargeting; public bool OnlyPlayerForTargeting; public bool IgnoreThatTargetIsBehindCover; public float MissileTurnRate; public float MissileVelocity; public float ProjectileVelocity; public float Damage; public float BluntDamage; public float SlashDamage; public float PierceDamage; public float ChopDamage; public float PickaxeDamage; public float FireDamage; public float FrostDamage; public float LightningDamage; public float PoisonDamage; public float SpiritDamage; public float DamageRadius; public float RangedDamage; public float RangedBluntDamage; public float RangedSlashDamage; public float RangedPierceDamage; public float RangedChopDamage; public float RangedPickaxeDamage; public float RangedFireDamage; public float RangedFrostDamage; public float RangedLightningDamage; public float RangedPoisonDamage; public float RangedSpiritDamage; public bool UniformDamageThroughDamageRadius; public bool HealingTarget; public float HealingAmount; public bool RepairTarget; public bool PatrolCloseToTurret; public TurretType TurretTypeOfThisTurret; protected HitData _hitData; protected HitData _rangedHitData; private readonly float _targetUpdateInterval = 0.4f; 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 readonly int _rayMaskTrees = LayerMask.GetMask(new string[2] { "Default", "Default_small" }); protected readonly int _rayMaskTreesAndRock = LayerMask.GetMask(new string[3] { "Default", "Default_small", "static_solid" }); protected readonly int _rayMaskCharacterDamageArea = LayerMask.GetMask(new string[2] { "character", "character_noenv" }); protected readonly int _rayMaskExplosionArea = LayerMask.GetMask(new string[5] { "character", "character_noenv", "Default", "Default_small", "static_solid" }); protected List _targetList = new List(); protected float _updateTargetTimer; protected float _nextShootDelayTimer; protected float _reloadGunTimer; protected int _ammoInGun; protected List _barrelList = new List(); protected int _nextBarrelIdToUse; private AudioSource[] _audioSources; protected GameObject _turretTurn; protected GameObject _turretTilt; protected GameObject _turretAimPoint; protected TurretPatrolType _turretMode; protected GameObject _lightYellow; protected GameObject _lightRed; protected GameObject _lightLaser; protected GameObject _dirtImpactPrefab; protected DegreesSpecifier _aimResult; protected DegreesSpecifier _aimResultTempCalcHolder; protected RotationDefinitions _rotationDefinitions; protected RotationData _rotationData = new RotationData(); protected ZNetView _zNetView; protected ZDO _zDataObject; protected NetDataObjectHandler _netDataObjectHandler; protected bool _wasOwnerLastFrame; private bool _everSeenHeightmap; public bool IsOwner { get { if ((Object)(object)_zNetView == (Object)null) { return false; } return _zNetView.IsOwner(); } } private void Awake() { //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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Expected O, but got Unknown //IL_03c2: Unknown result type (might be due to invalid IL or missing references) _audioSources = ((Component)this).GetComponentsInChildren(true); AudioSource[] audioSources = _audioSources; for (int i = 0; i < audioSources.Length; i++) { audioSources[i].outputAudioMixerGroup = AudioMan.instance.m_ambientMixer; } SetVolume(); ZTurretDefense.TurretVolume.SettingChanged += SetVolume; _zNetView = ((Component)this).GetComponent(); _zDataObject = _zNetView.GetZDO(); _netDataObjectHandler = new NetDataObjectHandler(_zDataObject); RegisterRemoteProcedureCalls(); _hitData = new HitData { m_damage = new DamageTypes { m_damage = Damage * ZTurretDefense.DamageModifier.Value, m_blunt = BluntDamage * ZTurretDefense.DamageModifier.Value, m_slash = SlashDamage * ZTurretDefense.DamageModifier.Value, m_pierce = PierceDamage * ZTurretDefense.DamageModifier.Value, m_chop = ChopDamage * ZTurretDefense.DamageModifier.Value, m_pickaxe = PickaxeDamage * ZTurretDefense.DamageModifier.Value, m_fire = FireDamage * ZTurretDefense.DamageModifier.Value, m_frost = FrostDamage * ZTurretDefense.DamageModifier.Value, m_lightning = LightningDamage * ZTurretDefense.DamageModifier.Value, m_poison = PoisonDamage * ZTurretDefense.DamageModifier.Value, m_spirit = SpiritDamage * ZTurretDefense.DamageModifier.Value }, m_ranged = true, m_staggerMultiplier = 1.2f }; if (DamageRadius > 0f) { _rangedHitData = new HitData { m_damage = new DamageTypes { m_damage = RangedDamage * ZTurretDefense.DamageModifier.Value, m_blunt = RangedBluntDamage * ZTurretDefense.DamageModifier.Value, m_slash = RangedSlashDamage * ZTurretDefense.DamageModifier.Value, m_pierce = RangedPierceDamage * ZTurretDefense.DamageModifier.Value, m_chop = RangedChopDamage * ZTurretDefense.DamageModifier.Value, m_pickaxe = RangedPickaxeDamage * ZTurretDefense.DamageModifier.Value, m_fire = RangedFireDamage * ZTurretDefense.DamageModifier.Value, m_frost = RangedFrostDamage * ZTurretDefense.DamageModifier.Value, m_lightning = RangedLightningDamage * ZTurretDefense.DamageModifier.Value, m_poison = RangedPoisonDamage * ZTurretDefense.DamageModifier.Value, m_spirit = RangedSpiritDamage * ZTurretDefense.DamageModifier.Value }, m_ranged = true, m_staggerMultiplier = 5f }; } GetBasicBodyPartsOfTurret(); GetSpecialBodyPartsOfTurret(); _barrelList = FindBarrels(); _aimResult = new DegreesSpecifier(); _aimResultTempCalcHolder = new DegreesSpecifier(); SetUpTurretSpecificData(); _updateTargetTimer = Random.Range(0f, _targetUpdateInterval); _ammoInGun = AmmoCount; 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}", TurretTypeOfThisTurret, ((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() { _zNetView.Register("ZTD_FireTurretGun", (Action)RPC_FireTurretGun); } protected virtual void GetBasicBodyPartsOfTurret() { _turretTurn = HelperLib.GetChildGameObject(((Component)this).gameObject, "TurretTurn"); _turretTilt = HelperLib.GetChildGameObject(((Component)this).gameObject, "TurretTilt"); _turretAimPoint = HelperLib.GetChildGameObject(((Component)this).gameObject, "AimPoint"); } protected virtual 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); } _dirtImpactPrefab = HelperLib.GetChildGameObject(((Component)this).gameObject, "DirtImpact"); } protected virtual void SetUpTurretSpecificData() { _rotationDefinitions.MaxRotationHorizontalLeft = 120f; _rotationDefinitions.MaxRotationHorizontalRight = 120f; _rotationDefinitions.MaxRotationVerticalUp = 65f; _rotationDefinitions.MaxRotationVerticalDown = 50f; _rotationDefinitions.RotationSpeed = 130f; _rotationDefinitions.AllowedAimDeviance = 10f; } protected void AddLogMsg(string message) { Logger.LogMessage((object)$"{DateTime.Now:o} ### Turret[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}"); } protected void AddDebugMsg(string message) { Logger.LogDebug((object)$"{DateTime.Now:o} ### Turret[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}"); } protected void AddLogInfo(string message) { Logger.LogInfo((object)$"{DateTime.Now:o} ### Turret[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}"); } protected void AddWarningMsg(string message) { Logger.LogWarning((object)$"{DateTime.Now:o} ### Turret[{((Object)((Component)this).gameObject).GetInstanceID()}]: {message}"); } private List FindBarrels() { int num = 0; List list = new List(); GameObject val; do { num++; val = FindBarrelGameObjectById(num); if ((Object)(object)val != (Object)null) { list.Add(TurnGameObjectIntoBarrel(num - 1, val)); } } while ((Object)(object)val != (Object)null); return list; } private GameObject FindBarrelGameObjectById(int id) { return HelperLib.GetChildGameObject(((Component)this).gameObject, $"LaunchPosition{id}"); } private Barrel TurnGameObjectIntoBarrel(int id, GameObject gameObject) { GameObject childGameObject = HelperLib.GetChildGameObject(gameObject, "LaunchEffect"); GameObject childGameObject2 = HelperLib.GetChildGameObject(gameObject, "LaunchAudio"); return new Barrel(id, gameObject, childGameObject, childGameObject2); } public void Initialize(TurretConfig turretConfig) { TurretTypeOfThisTurret = (TurretType)Enum.Parse(typeof(TurretType), turretConfig.type, ignoreCase: true); Range = turretConfig.range; MinimumRange = turretConfig.minimumRange; DroneAttackRange = turretConfig.droneAttackRange; FireInterval = turretConfig.fireInterval; ReloadTime = turretConfig.reloadTime; AmmoCount = turretConfig.ammoCount; MaximumNumberOfTrackedTargets = turretConfig.maximumNumberOfTrackedTargets; MustHaveLineOfSightToTrack = turretConfig.mustHaveLineOfSightToTrack; IgnorePlayerForTargeting = turretConfig.ignorePlayerForTargeting; OnlyPlayerForTargeting = turretConfig.onlyPlayerForTargeting; IgnoreThatTargetIsBehindCover = turretConfig.ignoreThatTargetIsBehindCover; MissileTurnRate = turretConfig.missileTurnRate; MissileVelocity = turretConfig.missileVelocity; ProjectileVelocity = turretConfig.projectileVelocity; Damage = turretConfig.damage; BluntDamage = turretConfig.bluntDamage; PierceDamage = turretConfig.pierceDamage; ChopDamage = turretConfig.chopDamage; PickaxeDamage = turretConfig.pickaxeDamage; FireDamage = turretConfig.fireDamage; FrostDamage = turretConfig.frostDamage; LightningDamage = turretConfig.lightningDamage; PoisonDamage = turretConfig.poisonDamage; SpiritDamage = turretConfig.spiritDamage; DamageRadius = turretConfig.damageRadius; RangedDamage = turretConfig.rangedDamage; RangedBluntDamage = turretConfig.rangedBluntDamage; RangedPierceDamage = turretConfig.rangedPierceDamage; RangedChopDamage = turretConfig.rangedChopDamage; RangedPickaxeDamage = turretConfig.rangedPickaxeDamage; RangedFireDamage = turretConfig.rangedFireDamage; RangedFrostDamage = turretConfig.rangedFrostDamage; RangedLightningDamage = turretConfig.rangedLightningDamage; RangedPoisonDamage = turretConfig.rangedPoisonDamage; RangedSpiritDamage = turretConfig.rangedSpiritDamage; UniformDamageThroughDamageRadius = turretConfig.uniformDamageThroughDamageRadius; HealingTarget = turretConfig.healingTarget; HealingAmount = turretConfig.healingAmount; RepairTarget = turretConfig.repairTarget; PatrolCloseToTurret = turretConfig.patrolCloseToTurret; } private void SetVolume(object sender, EventArgs e) { SetVolume(); } private void SetVolume() { AudioSource[] audioSources = _audioSources; for (int i = 0; i < audioSources.Length; i++) { audioSources[i].volume = (float)ZTurretDefense.TurretVolume.Value / 100f; } } 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}) "); } if (_audioSources != null) { ZTurretDefense.TurretVolume.SettingChanged -= SetVolume; } } 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($"{TurretTypeOfThisTurret}.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().Start(); _everSeenHeightmap = true; } } if (_wasOwnerLastFrame != IsOwner) { SwitchOwnershipHandling(); _wasOwnerLastFrame = IsOwner; } if (!IsOwner) { SyncTurretNetData(); _netDataObjectHandler.ReceiveDone(); } else { if (Time.deltaTime == 0f) { return; } _updateTargetTimer -= Time.deltaTime; if (AmmoCount > 0 && _reloadGunTimer > 0f) { _reloadGunTimer -= Time.deltaTime; if (_reloadGunTimer <= 0f) { _ammoInGun = AmmoCount; } } ControlAndMoveMissilesOrProjectilesOrDrones(); if (_updateTargetTimer < 0f) { FindNewTarget(); _updateTargetTimer += _targetUpdateInterval; } CleanTargetListAndUpdateAimInfo(); if (_turretMode == TurretPatrolType.NoTarget) { _aimResult.DegreesY = 0f; _aimResult.DegreesX = 0f; _aimResult.Distance = 0f; } RotateTurretTowardsTarget(); UpdateShootingIntervalAndDetermineIfWeShouldShoot(); } } protected virtual void SwitchOwnershipHandling() { } protected virtual void SyncTurretNetData() { //IL_0037: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (_netDataObjectHandler.HasDataToRead) { if ((Object)(object)_turretTurn != (Object)null) { _turretTurn.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_turretTurn", Quaternion.identity); } if ((Object)(object)_turretTilt != (Object)null) { _turretTilt.transform.rotation = _netDataObjectHandler.Data.GetQuaternion("_turretTilt", Quaternion.identity); } if ((Object)(object)_lightYellow != (Object)null) { _lightYellow.SetActive(_netDataObjectHandler.Data.GetBool("_lightYellow.SetActive", false)); } if ((Object)(object)_lightRed != (Object)null) { _lightRed.SetActive(_netDataObjectHandler.Data.GetBool("_lightRed.SetActive", false)); } if ((Object)(object)_lightLaser != (Object)null) { _lightLaser.SetActive(_netDataObjectHandler.Data.GetBool("_lightLaser.SetActive", false)); } } } protected virtual void CleanTargetListAndUpdateAimInfo() { if (_targetList.Count <= 0) { return; } List list = new List(); 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 (_targetList.Count == 0) { SetTargets(null, float.MaxValue); } else if (!UpdateAimInfoForCurrentTarget()) { SetTargets(null, float.MaxValue); } } protected virtual bool UpdateAimInfoForCurrentTarget() { return HelperLib.UpdateAimInfoForCurrentTarget(_targetList[0], _turretAimPoint, _aimResult, _aimResultTempCalcHolder); } protected virtual void RotateTurretTowardsTarget() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) HelperLib.RotateTurretTowardsTarget(_turretTurn, _turretTilt, _aimResult, _rotationDefinitions, _rotationData); _netDataObjectHandler.Data.Set("_turretTurn", _turretTurn.transform.rotation); _netDataObjectHandler.Data.Set("_turretTilt", _turretTilt.transform.rotation); } protected virtual void UpdateShootingIntervalAndDetermineIfWeShouldShoot() { if (_nextShootDelayTimer > 0f) { _nextShootDelayTimer -= Time.deltaTime; } if (_turretMode != TurretPatrolType.AttackTarget) { return; } _rotationData.DistanceRotY = _rotationData.CurrentRotationY - _aimResult.DegreesY; _rotationData.DistanceRotX = _rotationData.CurrentRotationX - _aimResult.DegreesX; if (_nextShootDelayTimer > 0f || Math.Abs(_rotationData.DistanceRotY) > _rotationDefinitions.AllowedAimDeviance || Math.Abs(_rotationData.DistanceRotX) > _rotationDefinitions.AllowedAimDeviance || !(_nextShootDelayTimer <= 0f) || (AmmoCount > 0 && _ammoInGun == 0)) { return; } TriggerTurretFiring(); if (AmmoCount > 0) { _ammoInGun--; if (_ammoInGun <= 0) { _reloadGunTimer = ReloadTime; } } } protected virtual void TriggerTurretFiring() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (_barrelList == null) { AddWarningMsg("TurretBase.TriggerTurretFiring() - _barrelList == null"); return; } if (_nextBarrelIdToUse > _barrelList.Count) { AddWarningMsg($"TurretBase.TriggerTurretFiring() - if (_nextBarrelIdToUse > _barrelList.Count) : if ({_nextBarrelIdToUse} > {_barrelList.Count})"); return; } _nextShootDelayTimer += FireInterval; if (_nextShootDelayTimer < FireInterval / 2f) { _nextShootDelayTimer = FireInterval / 2f; } LaunchProjectileAndRegisterHitPosition(_turretTilt.transform.rotation, _barrelList[_nextBarrelIdToUse].ThisBarrelGameObject.transform.position); _nextBarrelIdToUse++; if (_nextBarrelIdToUse >= _barrelList.Count) { _nextBarrelIdToUse = 0; } } protected void SetTargets(List newTargetList, float primaryTargetDistanceValue) { if (newTargetList == null) { _targetList.Clear(); } else { _targetList.Clear(); _targetList = newTargetList; } if (_targetList.Count == 0) { UpdateMode(TurretPatrolType.NoTarget); } else if (primaryTargetDistanceValue <= Range) { UpdateMode(TurretPatrolType.AttackTarget); } else { UpdateMode(TurretPatrolType.ScanTarget); } } protected virtual void UpdateMode(TurretPatrolType newMode) { if (newMode == _turretMode) { return; } _turretMode = newMode; bool flag = false; bool flag2 = false; if (_turretMode == TurretPatrolType.ScanTarget) { flag = true; } else if (_turretMode == TurretPatrolType.AttackTarget) { flag2 = true; } if (flag2) { if ((Object)(object)_lightRed != (Object)null) { _lightRed.SetActive(true); } if ((Object)(object)_lightLaser != (Object)null) { _lightLaser.SetActive(true); } } else { if ((Object)(object)_lightRed != (Object)null) { _lightRed.SetActive(false); } if ((Object)(object)_lightLaser != (Object)null) { _lightLaser.SetActive(false); } } if (flag) { if ((Object)(object)_lightYellow != (Object)null) { _lightYellow.SetActive(true); } } else if ((Object)(object)_lightYellow != (Object)null) { _lightYellow.SetActive(false); } _netDataObjectHandler.Data.Set("_lightYellow.SetActive", (Object)(object)_lightYellow != (Object)null && _lightYellow.activeSelf); _netDataObjectHandler.Data.Set("_lightRed.SetActive", (Object)(object)_lightRed != (Object)null && _lightRed.activeSelf); _netDataObjectHandler.Data.Set("_lightLaser.SetActive", (Object)(object)_lightLaser != (Object)null && _lightLaser.activeSelf); } protected virtual void FindNewTarget() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Invalid comparison between Unknown and I4 //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Invalid comparison between Unknown and I4 //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Invalid comparison between Unknown and I4 //IL_01f9: 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_01d7: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; List list = new List(); foreach (Character allCharacter in Character.GetAllCharacters()) { if ((Object)(object)allCharacter == (Object)null || allCharacter.GetHealth() <= 0f || (int)allCharacter.GetFaction() == 12) { continue; } float num2 = GetRangeToCharacter(allCharacter); if (num2 > Range * 1.5f) { continue; } if (num2 < MinimumRange) { num2 = Range * 2f + num2; } if ((OnlyPlayerForTargeting && HealingTarget && (int)allCharacter.GetFaction() != 0 && !allCharacter.IsTamed()) || (HealingTarget && allCharacter.GetHealthPercentage() >= 1f) || ((int)allCharacter.GetFaction() == 10 && (Object)(object)allCharacter.GetBaseAI() != (Object)null && !allCharacter.GetBaseAI().IsAlerted()) || (int)allCharacter.GetFaction() == 1) { continue; } if (allCharacter.IsTamed()) { if (!HealingTarget) { continue; } } else if ((Object)(object)allCharacter.GetBaseAI() != (Object)null && (Object)(object)allCharacter.GetBaseAI().m_tamable != (Object)null) { if (!allCharacter.GetBaseAI().IsAlerted()) { continue; } if (allCharacter.GetBaseAI().m_tamable.GetTameness() > 10) { num2 = Range * 5f + num2; } } if ((int)allCharacter.GetFaction() == 2) { if (allCharacter.m_name.Equals("$enemy_deer")) { continue; } if ((Object)(object)allCharacter.GetBaseAI() != (Object)null && !allCharacter.GetBaseAI().IsAlerted()) { num2 *= 2f; } } if (!IgnoreThatTargetIsBehindCover) { if (!CanSeeCharacter(allCharacter, _turretAimPoint)) { num2 = Range * 3f + num2; if (MustHaveLineOfSightToTrack) { continue; } } else if ((int)allCharacter.GetFaction() != 0 && CharacterBehindPlayers(allCharacter)) { num2 = Range * 2f + num2; } } if ((int)allCharacter.GetFaction() == 0) { if (IgnorePlayerForTargeting || (!HealingTarget && ZTurretDefense.TurretsShouldFullyIgnorePlayers.Value) || (!OnlyPlayerForTargeting && num2 >= Range * 0.5f)) { continue; } if (!OnlyPlayerForTargeting) { num2 = Range * 10f + num2; } } if (HelperLib.ValidateTargetAgainstRotateRestrictions(_turretAimPoint, allCharacter.m_currentVel, allCharacter, _aimResultTempCalcHolder, _rotationDefinitions) && num2 < num) { num = AddCharacterToTargetList(list, allCharacter, num2, MaximumNumberOfTrackedTargets); } } if (list.Count > 0) { num = list[0].DistanceRating; } SetTargets(list, num); } private float AddCharacterToTargetList(List newTargetList, Character character, float distanceRating, int maxTargets, bool targetGround = false) { 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(CreateTarget(character, distanceRating, targetGround)); num = distanceRating; } return num; } newTargetList.Insert(targetListIndexBasedOnDistance, CreateTarget(character, distanceRating, targetGround)); if (newTargetList.Count > maxTargets) { newTargetList.RemoveAt(maxTargets); num = newTargetList[newTargetList.Count - 1].DistanceRating; } return num; } protected int GetTargetListIndexBasedOnDistance(List newTargetList, float distance) { int num = 0; foreach (Target newTarget in newTargetList) { if (distance < newTarget.DistanceRating) { return num; } num++; } return int.MaxValue; } private Target CreateTarget(Character character, float distanceRating, bool targetGround) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new Target { Character = character, Location = character.GetCenterPoint(), DistanceRating = distanceRating, IsMoveOrder = targetGround }; } private float GetRangeToCharacter(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(character.GetCenterPoint(), _turretAimPoint.transform.position); } protected bool CanSeeCharacter(Character character, GameObject aimPoint) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = character.m_eye.position - aimPoint.transform.position; return !Physics.Raycast(aimPoint.transform.position, ((Vector3)(ref val)).normalized, ((Vector3)(ref val)).magnitude, _viewBlockMask); } private bool CharacterBehindPlayers(Character character) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = character.GetCenterPoint() - _turretAimPoint.transform.position; RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(new Ray(_turretAimPoint.transform.position, ((Vector3)(ref val)).normalized), ref val2, ((Vector3)(ref val)).magnitude, _viewBlockMaskPlayersCharactersOnly)) { return false; } Character component = ((Component)((Component)((RaycastHit)(ref val2)).collider).transform.root).gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { AddWarningMsg("Target search: Unexpected scanline hit, NOT A CHARACTER: " + ((Object)((Component)((Component)((RaycastHit)(ref val2)).collider).transform.root).gameObject).name); HelperLib.PrintOutGameObjectInfo(((Component)((Component)((RaycastHit)(ref val2)).collider).transform.root).gameObject); return false; } if ((Object)(object)component == (Object)(object)character) { return false; } if ((int)component.GetFaction() != 0) { return false; } return true; } protected virtual 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) 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(); if ((Object)(object)component != (Object)null) { 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_FireTurretGun", new object[3] { _nextBarrelIdToUse, ((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal }); } protected void ApplyDamageToCharacterHit(Character characterHit, HitData hitData) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)characterHit == (Object)null) && !(characterHit.GetHealth() <= 0f)) { if ((int)characterHit.GetFaction() == 0) { float num = 0.25f; hitData.m_damage.m_blunt *= num; hitData.m_damage.m_slash *= num; hitData.m_damage.m_pierce *= num; hitData.m_damage.m_chop *= num; hitData.m_damage.m_pickaxe *= num; hitData.m_damage.m_fire *= num; hitData.m_damage.m_frost *= num; hitData.m_damage.m_lightning *= num; hitData.m_damage.m_poison *= num; hitData.m_damage.m_spirit *= num; hitData.m_staggerMultiplier *= 4f; } characterHit.Damage(hitData); } } protected void DamageAreaTargets(Vector3 hitPosition, HitData hitData, bool onlyDamageCharacters) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_005e: 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_006d: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) if (DamageRadius <= 0f || hitData == null) { return; } Collider[] array = Physics.OverlapSphere(hitPosition, DamageRadius, _rayMaskExplosionArea); foreach (Collider val in array) { Character component = ((Component)((Component)val).transform.root).gameObject.GetComponent(); if (onlyDamageCharacters && (Object)(object)component == (Object)null) { continue; } Vector3 val2 = (val.providesContacts ? val.ClosestPoint(hitPosition) : val.ClosestPointOnBounds(hitPosition)); float num = Vector3.Distance(hitPosition, val2) - 1f; if ((double)num < 0.0) { num = 0f; } float num2 = (DamageRadius - num) / DamageRadius; num2 *= num2; if (num2 <= 0.05f) { continue; } if (num2 > 1f) { AddDebugMsg("DamageAreaTargets: >> damageRatio above 100%, set 10% of damage (most likely non-convex object)"); num2 = 0.1f; } if ((Object)(object)component != (Object)null) { if (!(component.GetHealth() <= 0f)) { float num3 = 1f; if (UniformDamageThroughDamageRadius) { num2 = 1f; } if ((int)component.GetFaction() == 0) { num2 = 0.25f; num3 = 4f; } HitData val3 = hitData.Clone(); val3.m_hitCollider = val; val3.m_point = val2; val3.m_damage.m_blunt *= num2; val3.m_damage.m_slash *= num2; val3.m_damage.m_pierce *= num2; val3.m_damage.m_chop *= num2; val3.m_damage.m_pickaxe *= num2; val3.m_damage.m_fire *= num2; val3.m_damage.m_frost *= num2; val3.m_damage.m_lightning *= num2; val3.m_damage.m_poison *= num2; val3.m_damage.m_spirit *= num2; val3.m_staggerMultiplier *= num3; component.Damage(val3); } continue; } float num4 = (hitData.m_damage.m_pierce + hitData.m_damage.m_fire) * 1f; HitData val4 = hitData.Clone(); val4.m_hitCollider = val; val4.m_point = val2; val4.m_damage.m_blunt = 0f; val4.m_damage.m_slash = 0f; val4.m_damage.m_pierce = 0f; val4.m_damage.m_chop = num4 * num2; val4.m_damage.m_pickaxe = num4 * num2 * 0.5f; val4.m_damage.m_fire = 0f; val4.m_damage.m_frost = 0f; val4.m_damage.m_lightning = 0f; val4.m_damage.m_poison = 0f; val4.m_damage.m_spirit = 0f; val4.m_toolTier = 10; val4.m_pushForce = 0f; TreeBase component2 = ((Component)((Component)val).transform.root).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.Damage(val4); continue; } TreeLog component3 = ((Component)((Component)val).transform.root).gameObject.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.Damage(val4); continue; } Destructible component4 = ((Component)((Component)val).transform.root).gameObject.GetComponent(); if ((Object)(object)component4 != (Object)null) { component4.Damage(val4); continue; } MineRock5 component5 = ((Component)((Component)val).transform.root).gameObject.GetComponent(); if ((Object)(object)component5 != (Object)null) { component5.Damage(val4); } } } private void DamageFlamethrowerTargets(Vector3 hitPosition, HitData hitData) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) Collider[] array = Physics.OverlapCapsule(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * Range, 1f, _rayMaskSolids); Character val = default(Character); for (int i = 0; i < array.Length; i++) { if (((Component)array[i]).TryGetComponent(ref val) && (int)val.GetFaction() != 0 && !val.IsTamed() && val.GetHealth() > 0f) { val.Damage(hitData); } } } protected virtual void ControlAndMoveMissilesOrProjectilesOrDrones() { } protected void RPC_FireTurretGun(long sender, int barrelId, Vector3 impactLocation, Vector3 impactNormal) { //IL_0091: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (_barrelList != null && barrelId + 1 <= _barrelList.Count) { Barrel barrel = _barrelList[barrelId]; GameObject obj = Object.Instantiate(barrel.LaunchEffectGameObject, barrel.ThisBarrelGameObject.transform, false); obj.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj, 5f); obj.SetActive(true); GameObject obj2 = Object.Instantiate(barrel.LaunchAudioGameObject, barrel.ThisBarrelGameObject.transform, false); obj2.transform.SetParent((Transform)null); Object.Destroy((Object)(object)obj2, 1f); obj2.SetActive(true); Quaternion rotation = default(Quaternion); ((Quaternion)(ref rotation)).SetLookRotation(impactNormal); GameObject obj3 = Object.Instantiate(_dirtImpactPrefab, (Transform)null); obj3.transform.position = impactLocation; obj3.transform.rotation = rotation; obj3.SetActive(false); obj3.SetActive(true); Object.Destroy((Object)(object)obj3, 10f); } } } } namespace ZarkowTurretDefense.Models { [Serializable] public class BuildingpartConfigRequirement { public string item; public int amount; public static RequirementConfig Convert(BuildingpartConfigRequirement buildingpartConfigRequirement) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0035: Expected O, but got Unknown return new RequirementConfig { Amount = MathHelper.MultiplyWithFloatWithFloor(buildingpartConfigRequirement.amount, ZTurretDefense.CostModifier.Value, 1), Item = buildingpartConfigRequirement.item, Recover = true }; } } [Serializable] public class BuildingpartConfig { public string name; public string bundleName; public string prefabPath; public string description; public string pieceTable; public string craftingStation; public bool enabled; public string type; public List resources; public static CustomPiece Convert(GameObject prefab, BuildingpartConfig buildingpartConfig) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown return new CustomPiece(prefab, true, new PieceConfig { Name = buildingpartConfig.name, Description = buildingpartConfig.description, Enabled = buildingpartConfig.enabled, PieceTable = buildingpartConfig.pieceTable, CraftingStation = buildingpartConfig.craftingStation, Category = "BuildingParts", Requirements = buildingpartConfig.resources.Select(BuildingpartConfigRequirement.Convert).ToArray(), AllowedInDungeons = true }); } } [Serializable] public class TurretConfigRequirement { public string item; public int amount; public static RequirementConfig Convert(TurretConfigRequirement turretConfigRequirement) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0035: Expected O, but got Unknown return new RequirementConfig { Amount = MathHelper.MultiplyWithFloatWithFloor(turretConfigRequirement.amount, ZTurretDefense.CostModifier.Value, 1), Item = turretConfigRequirement.item, Recover = true }; } } [Serializable] public class TurretConfig { public string name; public string bundleName; public string prefabPath; public string description; public string pieceTable; public string craftingStation; public bool enabled; public string type; public float fireInterval; public float reloadTime; public int ammoCount; public int maximumNumberOfTrackedTargets = 1; public bool mustHaveLineOfSightToTrack; public bool ignorePlayerForTargeting; public bool onlyPlayerForTargeting; public bool ignoreThatTargetIsBehindCover; public float missileTurnRate; public float missileVelocity; public float projectileVelocity; public float damage; public float bluntDamage; public float pierceDamage; public float chopDamage; public float pickaxeDamage; public float fireDamage; public float frostDamage; public float lightningDamage; public float poisonDamage; public float spiritDamage; public float range; public float minimumRange; public float droneAttackRange; public float damageRadius; public float rangedDamage; public float rangedBluntDamage; public float rangedPierceDamage; public float rangedChopDamage; public float rangedPickaxeDamage; public float rangedFireDamage; public float rangedFrostDamage; public float rangedLightningDamage; public float rangedPoisonDamage; public float rangedSpiritDamage; public bool uniformDamageThroughDamageRadius; public bool healingTarget; public float healingAmount; public bool repairTarget; public bool patrolCloseToTurret; public List resources; public static CustomPiece Convert(GameObject prefab, TurretConfig turretConfig) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown return new CustomPiece(prefab, true, new PieceConfig { Name = turretConfig.name, Description = turretConfig.description, Enabled = turretConfig.enabled, PieceTable = turretConfig.pieceTable, CraftingStation = turretConfig.craftingStation, Category = "Turrets", Requirements = turretConfig.resources.Select(TurretConfigRequirement.Convert).ToArray(), AllowedInDungeons = true }); } } }