Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MortarMod v1.18.4
MortarMod.dll
Decompiled 5 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MortarMod")] [assembly: AssemblyDescription("MortarMod by Skarif: direct, overhead and coordinate mortar aiming.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Skarif")] [assembly: AssemblyProduct("MortarMod")] [assembly: AssemblyCopyright("Copyright © Skarif 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2bf04a5f-6cce-4a57-b708-aae10229b41e")] [assembly: AssemblyFileVersion("1.18.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.18.1.0")] namespace MortarMod; [BepInPlugin("com.Skarif.mortarmod", "Mortar Mod", "1.18.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class MortarPlugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.Skarif.mortarmod"; public const string PLUGIN_NAME = "Mortar Mod"; public const string PLUGIN_VERSION = "1.18.1"; private readonly Harmony _harmony = new Harmony("com.Skarif.mortarmod"); internal static GameObject DynamiteImpact; internal static GameObject MuzzleFire; private void Awake() { MortarText.Register(); PrefabManager.OnVanillaPrefabsAvailable += CreateMortarPrefab; _harmony.PatchAll(); ((Component)this).gameObject.AddComponent<MortarHud>(); ((Component)this).gameObject.AddComponent<MortarCoordinateMode>(); Logger.LogInfo((object)"Mortar Mod initialized."); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= CreateMortarPrefab; _harmony.UnpatchSelf(); } private void CreateMortarPrefab() { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //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) PrefabManager.OnVanillaPrefabsAvailable -= CreateMortarPrefab; Logger.LogInfo((object)"=== НАЧАЛО ЗАГРУЗКИ МИНОМЁТА ==="); try { Assembly assembly = typeof(MortarPlugin).Assembly; AssetBundle val = AssetUtils.LoadAssetBundleFromResources("mortar", assembly); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"ОШИБКА: AssetBundle 'mortar' не найден!"); return; } GameObject val2 = val.LoadAsset<GameObject>("assets/mortar.prefab"); if ((Object)(object)val2 == (Object)null) { val.Unload(false); Logger.LogError((object)"ОШИБКА: Префаб 'assets/mortar.prefab' не найден!"); return; } GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("Mortar_Prefab", val2); val.Unload(false); if (!Object.op_Implicit((Object)(object)val3)) { throw new InvalidOperationException("Не удалось клонировать префаб mortar."); } val3.layer = LayerMask.NameToLayer("piece"); if (!Object.op_Implicit((Object)(object)val3.GetComponent<ZNetView>())) { val3.AddComponent<ZNetView>().m_persistent = true; } MortarArticulation.PreparePrefab(val3); Piece val4 = val3.GetComponent<Piece>(); if (!Object.op_Implicit((Object)(object)val4)) { val4 = val3.AddComponent<Piece>(); } val4.m_name = "$skarif_mortar_name"; val4.m_description = "$skarif_mortar_description"; val4.m_category = (PieceCategory)0; if ((int)SystemInfo.graphicsDeviceType != 4) { val4.m_icon = RenderManager.Instance.Render(val3, RenderManager.IsometricRotation); } if (!Object.op_Implicit((Object)(object)val3.GetComponent<WearNTear>())) { val3.AddComponent<WearNTear>().m_health = 400f; } MortarModelColliders.Prepare(val3); MortarAudioAssets.Prepare(val3); MortarShotAudio.Prepare(); if (!Object.op_Implicit((Object)(object)val3.GetComponent<MortarLogic>())) { val3.AddComponent<MortarLogic>(); } PieceConfig val5 = new PieceConfig(); val5.PieceTable = "Hammer"; val5.Category = "Misc"; val5.AddRequirement(new RequirementConfig("Wood", 1, 0, true)); CustomPiece val6 = new CustomPiece(val3, true, val5); PieceManager.Instance.AddPiece(val6); GameObject prefab = PrefabManager.Instance.GetPrefab("vfx_FireAddFuel"); if (Object.op_Implicit((Object)(object)prefab)) { MuzzleFire = PrefabManager.Instance.CreateClonedPrefab("Mortar_FireAddFuel", prefab); ParticleSystem[] componentsInChildren = MuzzleFire.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { MainModule main = componentsInChildren[i].main; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; } PrefabManager.Instance.AddPrefab(MuzzleFire); } else { Logger.LogWarning((object)"[Mortar] vfx_FireAddFuel не найден; дульный эффект недоступен."); } GameObject prefab2 = PrefabManager.Instance.GetPrefab("bombdynamite_explosion"); if (Object.op_Implicit((Object)(object)prefab2)) { DynamiteImpact = PrefabManager.Instance.CreateClonedPrefab("Mortar_DynamiteImpact", prefab2); Aoe[] componentsInChildren2 = DynamiteImpact.GetComponentsInChildren<Aoe>(true); foreach (Aoe obj in componentsInChildren2) { obj.m_activationDelay = 0f; obj.m_ttl = 0.001f; obj.m_ttlMax = 0f; } PrefabManager.Instance.AddPrefab(DynamiteImpact); } else { Logger.LogWarning((object)"[Mortar] bombdynamite_explosion не найден; мгновенный взрыв недоступен."); } Logger.LogInfo((object)"=== МИНОМЁТ УСПЕШНО ЗАРЕГИСТРИРОВАН С ИКОНКОЙ ==="); } catch (Exception arg) { Logger.LogError((object)$"КРИТИЧЕСКАЯ ОШИБКА: {arg}"); } } } internal static class MortarText { private static CustomLocalization _localization; internal static void Register() { if (_localization != null) { return; } _localization = LocalizationManager.Instance.GetLocalization(); Assembly assembly = typeof(MortarText).Assembly; string[] array = new string[4] { "English", "Russian", "Ukrainian", "Spanish" }; foreach (string text in array) { using Stream stream = assembly.GetManifestResourceStream("MortarMod.Localization." + text + ".json"); if (stream == null) { throw new InvalidDataException("Missing MortarMod translation: " + text); } using StreamReader streamReader = new StreamReader(stream); _localization.AddJsonFile(text, streamReader.ReadToEnd()); } } internal static string Get(string key, params object[] arguments) { string text = _localization.TryTranslate("$skarif_mortar_" + key); if (arguments.Length != 0) { text = string.Format(CultureInfo.CurrentCulture, text, arguments); } if (Localization.instance == null) { return text; } return Localization.instance.Localize(text); } } public sealed class AmmoRound { public string Prefab { get; } public int Quality { get; } public int Variant { get; } public int WorldLevel { get; } public AmmoRound(string prefab, int quality = 1, int variant = 0, int worldLevel = 0) { if (string.IsNullOrEmpty(prefab) || prefab.IndexOfAny(new char[3] { '|', '\n', '\r' }) >= 0) { throw new ArgumentException("Invalid ammo prefab", "prefab"); } Prefab = prefab; Quality = Math.Max(1, quality); Variant = Math.Max(0, variant); WorldLevel = Math.Max(0, worldLevel); } public string Encode() { return string.Join("|", Prefab, Quality.ToString(CultureInfo.InvariantCulture), Variant.ToString(CultureInfo.InvariantCulture), WorldLevel.ToString(CultureInfo.InvariantCulture)); } } public sealed class AmmoQueue { public const int Capacity = 5; public const int MaxCapacity = 8; private readonly List<AmmoRound> _rounds = new List<AmmoRound>(); public int Count => _rounds.Count; public AmmoRound this[int index] => _rounds[index]; public bool Enqueue(AmmoRound round, int capacity = 5) { if (round == null || Count >= Math.Min(8, capacity)) { return false; } _rounds.Add(round); return true; } public void Dequeue() { if (Count > 0) { _rounds.RemoveAt(0); } } public string Encode() { return string.Join("\n", _rounds.ConvertAll((AmmoRound round) => round.Encode())); } public static AmmoQueue Decode(string value) { AmmoQueue ammoQueue = new AmmoQueue(); if (string.IsNullOrEmpty(value)) { return ammoQueue; } string[] array = value.Split(new char[1] { '\n' }); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '|' }); if (array2.Length != 4 || !int.TryParse(array2[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array2[2], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || !int.TryParse(array2[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result3)) { throw new FormatException("Invalid mortar ammo queue"); } if (!ammoQueue.Enqueue(new AmmoRound(array2[0], result, result2, result3), 8)) { throw new FormatException("Mortar ammo queue exceeds capacity"); } } return ammoQueue; } } internal static class AmmoCatalog { internal static readonly Dictionary<string, string> Legacy = new Dictionary<string, string> { { "BombOoze", "oozebomb_projectile" }, { "BombSmoke", "smokebomb_projectile" }, { "BombBlob_Poison", "blob_projectile_aoe" }, { "BombBlob_PoisonElite", "BombBlob_PoisonElite_projectile" }, { "BombBlob_Frost", "BombBlob_Frost_projectile" }, { "BombBlob_Tar", "BombBlob_Tar_projectile" }, { "BombBlob_Lava", "BombBlob_Lava_projectile" }, { "BombBile", "siegebomb_projectile" }, { "BombLava", "lavabomb_projectile" } }; internal static ItemData GetItem(AmmoRound round) { GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(round.Prefab) : null); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); if (!Object.op_Implicit((Object)(object)val2)) { return null; } ItemData obj = val2.m_itemData.Clone(); obj.m_dropPrefab = val; obj.m_stack = 1; obj.m_quality = round.Quality; obj.m_variant = round.Variant; obj.m_worldLevel = round.WorldLevel; return obj; } internal static GameObject GetProjectile(ItemData item) { if (item?.m_shared == null) { return null; } GameObject val = item.m_shared.m_attack?.m_attackProjectile; if (!Object.op_Implicit((Object)(object)val)) { val = item.m_shared.m_secondaryAttack?.m_attackProjectile; } if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)item.m_dropPrefab) && Object.op_Implicit((Object)(object)ZNetScene.instance) && Legacy.TryGetValue(((Object)item.m_dropPrefab).name, out var value)) { val = ZNetScene.instance.GetPrefab(value); } if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.GetComponent<Projectile>())) { return null; } return val; } internal static bool IsBomb(ItemData item) { if (item == null || !Object.op_Implicit((Object)(object)item.m_dropPrefab)) { return false; } if (((Object)item.m_dropPrefab).name.StartsWith("Bomb", StringComparison.OrdinalIgnoreCase) || Legacy.ContainsKey(((Object)item.m_dropPrefab).name)) { return Object.op_Implicit((Object)(object)GetProjectile(item)); } return false; } internal static void LogAvailable() { if (!Object.op_Implicit((Object)(object)ObjectDB.instance)) { return; } List<string> list = new List<string>(); foreach (GameObject item in ObjectDB.instance.m_items) { ItemDrop val = (Object.op_Implicit((Object)(object)item) ? item.GetComponent<ItemDrop>() : null); if (Object.op_Implicit((Object)(object)val) && IsBomb(val.m_itemData)) { list.Add(((Object)item).name); } } list.Sort(StringComparer.Ordinal); Logger.LogInfo((object)("[Mortar] Доступные бомбы: " + string.Join(", ", list))); } } public class MortarLogic : MonoBehaviour, Interactable, Hoverable { public const float MaxRange = 200f; internal const float TargetRadius = 2.5f; private const float Cooldown = 1.5f; private const string QueueKey = "mortar_queue_v2"; private const string TargetKey = "mortar_last_target_v1"; private const string HasTargetKey = "mortar_has_target_v1"; private const string HeadingKey = "mortar_camera_heading_v1"; private ZNetView _nview; private MortarArticulation _articulation; private string _aimAmmo; private float _aimGravity = 9.81f; private MortarReticle _reticle; private Vector3 _target; private Vector3 _viewDirection = Vector3.forward; private float _saveTargetAt; private float _cooldown; private float _enteredAt; private bool _legacyChecked; private string _queueValue; private AmmoQueue _queue = new AmmoQueue(); private Player _pendingPlayer; private Player _operator; private float _pendingAt; private float _operatorPublishAt; private Transform _operatorAnchor; private Vector3 _directDirection; private bool _directReady; private const string DirectLookKey = "mortar_direct_look_v1"; private const string HasDirectLookKey = "mortar_has_direct_look_v1"; private float _directSaveAt; private readonly RaycastHit[] _directHits = (RaycastHit[])(object)new RaycastHit[64]; internal const string CoordinateActiveKey = "mortar_coordinate_active"; internal const string CoordinateControllerKey = "mortar_coordinate_controller"; internal const string CoordinateTargetKey = "mortar_coordinate_target"; internal const string CoordinateOriginKey = "mortar_coordinate_origin"; internal const string CoordinateLeaseKey = "mortar_coordinate_lease"; internal const string CoordinateCellsKey = "mortar_coordinate_cells"; internal const string CoordinatePrecisionKey = "mortar_coordinate_precision"; private bool _coordinateSalvo; private Vector2[] _coordinateSpread; private int _coordinateShot; private float _coordinateFlightUntil; private float _supportScanAt; private float _supplyAt; private int _supportCapacity = 5; private int _supportCells = 100; private readonly List<Piece> _supportPieces = new List<Piece>(); private readonly List<Container> _supplyBarrels = new List<Container>(); public static MortarLogic ActiveMortar { get; private set; } public bool FirstPerson { get; private set; } internal bool CoordinateHighPrecision { get { ZDO coordinateData = CoordinateData; if (coordinateData == null) { return true; } return coordinateData.GetBool("mortar_coordinate_precision", true); } } internal bool CoordinateBusy { get { if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && Object.op_Implicit((Object)(object)ZNet.instance) && _nview.GetZDO().GetBool("mortar_coordinate_active", false)) { return (double)_nview.GetZDO().GetFloat("mortar_coordinate_lease", 0f) > ZNet.instance.GetTimeSeconds(); } return false; } } internal ZDO CoordinateData { get { if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid()) { return null; } return _nview.GetZDO(); } } internal float CoordinateFlightUntil => _coordinateFlightUntil; internal int AmmoCapacity { get { RefreshSupport(force: false); return _supportCapacity; } } internal int CoordinateCells { get { RefreshSupport(force: true); return _supportCells; } } public AmmoQueue GetQueue() { if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid()) { return _queue; } string text = _nview.GetZDO().GetString("mortar_queue_v2", ""); if (text != _queueValue) { _queue = AmmoQueue.Decode(text); _queueValue = text; } return _queue; } private void SaveQueue() { _queueValue = _queue.Encode(); _nview.GetZDO().Set("mortar_queue_v2", _queueValue); } private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) _nview = ((Component)this).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid()) { _articulation = ((Component)this).GetComponent<MortarArticulation>(); _reticle = new GameObject("MortarTargetingReticle").AddComponent<MortarReticle>(); _reticle.Initialize(2.5f); WearNTear component = ((Component)this).GetComponent<WearNTear>(); if (Object.op_Implicit((Object)(object)component)) { component.m_onDestroyed = (Action)Delegate.Combine(component.m_onDestroyed, new Action(DropLoadedAmmo)); } } } private void OnDestroy() { if ((Object)(object)ActiveMortar == (Object)(object)this) { ExitControl(); } if (Object.op_Implicit((Object)(object)_reticle)) { Object.Destroy((Object)(object)((Component)_reticle).gameObject); } } private void Update() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0271: 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_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_02e6: 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_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: 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_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) UpdatePendingInteraction(); UpdateCoordinateLock(); _cooldown = Mathf.Max(0f, _cooldown - Time.deltaTime); if (!_legacyChecked && Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner() && Object.op_Implicit((Object)(object)ObjectDB.instance) && Object.op_Implicit((Object)(object)ZNetScene.instance)) { MigrateLegacyAmmo(); _legacyChecked = true; } if (_legacyChecked) { UpdateSupply(); } if ((Object)(object)ActiveMortar != (Object)(object)this) { return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_nview.IsOwner() || CoordinateBusy || !Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting() || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) > 10f) { ExitControl(); return; } PublishOperator(localPlayer); if (MortarCoordinateMode.BlocksMapInput) { return; } _target.y = MortarSurface.GetHeight(_target); if (!FirstPerson) { SaveTarget(force: false); } if ((Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) || Console.IsVisible() || InventoryGui.IsVisible() || Menu.IsVisible() || TextInput.IsVisible()) { return; } if (Time.time - _enteredAt > 0.3f && (ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse") || ZInput.GetButtonDown("Jump") || ZInput.GetButtonDown("JoyJump"))) { ExitControl(); return; } if (FirstPerson) { UpdateDirectAim(localPlayer); if (_cooldown <= 0f && (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyAttack"))) { Fire(localPlayer); } return; } float num = ZInput.GetJoyLeftStickX() + (ZInput.GetButton("Right") ? 1f : 0f) - (ZInput.GetButton("Left") ? 1f : 0f); float num2 = 0f - ZInput.GetJoyLeftStickY() + (ZInput.GetButton("Forward") ? 1f : 0f) - (ZInput.GetButton("Backward") ? 1f : 0f); Vector3 aimDirection = GetAimDirection(); Vector3 val = Vector3.ClampMagnitude(Vector3.Cross(Vector3.up, aimDirection) * num + aimDirection * num2, 1f) * (20f * Time.deltaTime); Vector3 target = ClampTarget(_target + val); _target = target; _target.y = MortarSurface.GetHeight(_target); _viewDirection = MortarViewMath.Heading(_viewDirection, _target - ((Component)this).transform.position, Time.deltaTime); if (Object.op_Implicit((Object)(object)_articulation)) { _articulation.AimAt(_target, GetAimGravity(), instant: false); } if (_cooldown <= 0f && (ZInput.GetButtonDown("Attack") || ZInput.GetButtonDown("JoyAttack"))) { Fire(localPlayer); } } internal Vector3 ClampTarget(Vector3 position) { //IL_0000: 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_0011: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = position - ((Component)this).transform.position; val.y = 0f; val = Vector3.ClampMagnitude(val, 200f); return new Vector3(((Component)this).transform.position.x + val.x, position.y, ((Component)this).transform.position.z + val.z); } internal Vector3 GetAimDirection() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _viewDirection; } private void SaveTarget(bool force) { //IL_0028: 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_007a: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner() && MortarViewMath.IsFinite(_target) && (force || !(Time.time < _saveTargetAt))) { _saveTargetAt = Time.time + 0.5f; ZDO zDO = _nview.GetZDO(); zDO.Set("mortar_last_target_v1", _target); zDO.Set("mortar_camera_heading_v1", _viewDirection); zDO.Set("mortar_has_target_v1", true); } } private float GetAimGravity() { AmmoQueue queue = GetQueue(); string text = ((queue.Count > 0) ? queue[0].Prefab : ""); if (_aimAmmo != text) { _aimAmmo = text; GameObject val = ((queue.Count > 0) ? AmmoCatalog.GetProjectile(AmmoCatalog.GetItem(queue[0])) : null); _aimGravity = MortarBallistics.Gravity(Object.op_Implicit((Object)(object)val) ? val.GetComponent<Projectile>() : null); } return _aimGravity; } private bool IsTargetLoaded() { //IL_0055: 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_0061: 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_006c: 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_0079: 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_0085: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_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_00c4: 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_00dd: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { return false; } float num = ((CoordinateBusy || _coordinateSalvo) ? (10f * (CoordinateHighPrecision ? 0.5f : 1f)) : 2.5f); Vector3[] array = (Vector3[])(object)new Vector3[9] { Vector3.zero, Vector3.forward * num, Vector3.back * num, Vector3.left * num, Vector3.right * num, new Vector3(num, 0f, num), new Vector3(num, 0f, 0f - num), new Vector3(0f - num, 0f, num), new Vector3(0f - num, 0f, 0f - num) }; foreach (Vector3 val in array) { if (!ZNetScene.instance.IsAreaReady(_target + val)) { return false; } } return true; } public bool Interact(Humanoid user, bool hold, bool alt) { Player val = (Player)(object)((user is Player) ? user : null); if (val == null || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid()) { return false; } if (CoordinateBusy || MortarCoordinateMode.MapOpen) { return false; } if (Object.op_Implicit((Object)(object)ActiveMortar) || hold || Object.op_Implicit((Object)(object)_pendingPlayer)) { return false; } _nview.ClaimOwnership(); if (!_nview.IsOwner()) { return false; } MigrateLegacyAmmo(); if (ZInput.GetKey((KeyCode)304, true) || ZInput.GetKey((KeyCode)303, true)) { LoadAmmo(val, null); return true; } _pendingPlayer = val; _pendingAt = Time.time; return true; } private void EnterControl(Player player, bool firstPerson) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0120: 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_0128: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: 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) if (CoordinateBusy || MortarCoordinateMode.BlocksMapInput || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_nview.IsOwner() || ((Character)player).IsAttached() || !Object.op_Implicit((Object)(object)_articulation) || !Object.op_Implicit((Object)(object)_articulation.Muzzle) || (firstPerson && !Object.op_Implicit((Object)(object)_articulation.Seat))) { return; } if (GetQueue().Count == 0 && !firstPerson) { ((Character)player).Message((MessageType)2, MortarText.Get("empty"), 0, (Sprite)null, false); return; } if (Object.op_Implicit((Object)(object)ActiveMortar)) { ActiveMortar.ExitControl(); } ActiveMortar = this; FirstPerson = firstPerson; _enteredAt = Time.time; ZDO zDO = _nview.GetZDO(); Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 15f; Vector3 val2 = (zDO.GetBool("mortar_has_target_v1", false) ? zDO.GetVec3("mortar_last_target_v1", val) : val); _target = ClampTarget(MortarViewMath.IsFinite(val2) ? val2 : val); _viewDirection = MortarViewMath.Heading(zDO.GetVec3("mortar_camera_heading_v1", ((Component)this).transform.forward), _target - ((Component)this).transform.position, 4f); _target.y = MortarSurface.GetHeight(_target); if (FirstPerson) { RestoreDirectLook(player); } BeginOperator(player); if (FirstPerson) { UpdateDirectAim(player); } MortarStreaming.Publish(immediate: true); ((Character)player).Message((MessageType)1, FirstPerson ? MortarText.Get("direct_help") : MortarText.Get("scope_help"), 0, (Sprite)null, false); } private void ExitControl() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ActiveMortar == (Object)(object)this) { MortarStreaming.RetainAim(GetTargetPosition()); } if ((Object)(object)ActiveMortar == (Object)(object)this && !FirstPerson) { SaveTarget(force: true); } if ((Object)(object)ActiveMortar == (Object)(object)this && FirstPerson) { SaveDirectLook(force: true); } EndOperator(); if ((Object)(object)ActiveMortar == (Object)(object)this) { ActiveMortar = null; } FirstPerson = false; if (Object.op_Implicit((Object)(object)_reticle)) { ((Component)_reticle).gameObject.SetActive(false); } MortarStreaming.Publish(immediate: true); } public bool UseItem(Humanoid user, ItemData item) { if (CoordinateBusy || MortarCoordinateMode.MapOpen) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if (val == null || !AmmoCatalog.IsBomb(item) || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid()) { return false; } _nview.ClaimOwnership(); if (!_nview.IsOwner()) { return false; } MigrateLegacyAmmo(); LoadAmmo(val, item); return true; } private void LoadAmmo(Player player, ItemData item) { AmmoQueue queue = GetQueue(); if (queue.Count >= AmmoCapacity) { ((Character)player).Message((MessageType)2, MortarText.Get("full", queue.Count, AmmoCapacity), 0, (Sprite)null, false); return; } Inventory inventory = ((Humanoid)player).GetInventory(); if (item == null) { ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon(); item = (ItemData)((AmmoCatalog.IsBomb(currentWeapon) && inventory.GetAllItems().Contains(currentWeapon)) ? ((object)currentWeapon) : ((object)inventory.GetAllItems().Find((ItemData candidate) => AmmoCatalog.IsBomb(candidate)))); } if (!AmmoCatalog.IsBomb(item)) { ((Character)player).Message((MessageType)2, MortarText.Get("no_bombs"), 0, (Sprite)null, false); return; } AmmoRound round = new AmmoRound(((Object)item.m_dropPrefab).name, item.m_quality, item.m_variant, item.m_worldLevel); if (inventory.RemoveItem(item, 1)) { queue.Enqueue(round, AmmoCapacity); SaveQueue(); ((Character)player).Message((MessageType)2, MortarText.Get("loaded", Localization.instance.Localize(item.m_shared.m_name), queue.Count, AmmoCapacity), 0, (Sprite)null, false); } } private void MigrateLegacyAmmo() { //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) GetQueue(); ZDO zDO = _nview.GetZDO(); foreach (KeyValuePair<string, string> item2 in AmmoCatalog.Legacy) { string text = "ammo_" + item2.Key; int num = Mathf.Max(0, zDO.GetInt(text, 0)); if (num == 0) { continue; } AmmoRound round = new AmmoRound(item2.Key); ItemData item = AmmoCatalog.GetItem(round); if (item == null) { continue; } while (num > 0 && _queue.Enqueue(round, AmmoCapacity)) { SaveQueue(); zDO.Set(text, --num); } while (num > 0) { int num2 = (item.m_stack = Mathf.Min(num, Mathf.Max(1, item.m_shared.m_maxStackSize))); if (!Object.op_Implicit((Object)(object)ItemDrop.DropItem(item, num2, ((Component)this).transform.position + Vector3.up * 1.5f, Quaternion.identity))) { break; } num -= num2; zDO.Set(text, num); } } } private bool Fire(Player player) { //IL_00f5: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ee: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_01ec: 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_01f1: 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) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: 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_0272: 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_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: 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_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Expected O, but got Unknown //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_049f: 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_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) if (CoordinateBusy && !_coordinateSalvo) { return false; } if (FirstPerson && !_directReady) { ((Character)player).Message((MessageType)2, MortarText.Get("out_of_range"), 0, (Sprite)null, false); return false; } AmmoQueue queue = GetQueue(); if (queue.Count == 0) { ((Character)player).Message((MessageType)2, MortarText.Get("no_ammo"), 0, (Sprite)null, false); return false; } if (!IsTargetLoaded()) { ((Character)player).Message((MessageType)2, MortarText.Get("loading"), 0, (Sprite)null, false); return false; } ItemData item = AmmoCatalog.GetItem(queue[0]); GameObject projectile = AmmoCatalog.GetProjectile(item); if (!Object.op_Implicit((Object)(object)projectile)) { ((Character)player).Message((MessageType)2, MortarText.Get("missing_ammo"), 0, (Sprite)null, false); return false; } Vector2 val = (FirstPerson ? Vector2.zero : (_coordinateSalvo ? _coordinateSpread[_coordinateShot] : (Random.insideUnitCircle * 2.5f))); Vector3 impact = _target + new Vector3(val.x, 0f, val.y); if (!_coordinateSalvo) { impact = ClampTarget(impact); } if (!FirstPerson) { impact.y = MortarSurface.GetHeight(impact); } if (!Object.op_Implicit((Object)(object)_articulation) || !Object.op_Implicit((Object)(object)_articulation.Muzzle)) { Logger.LogError((object)"[Mortar] Не найдены оси новой модели или точка вылета."); return false; } float gravity = (FirstPerson ? 9.81f : MortarBallistics.Gravity(projectile.GetComponent<Projectile>())); if (FirstPerson) { _articulation.AimAlong(_directDirection, instant: true); } else if (!_coordinateSalvo) { _articulation.AimAt(impact, gravity, instant: true); } Vector3 position = _articulation.Muzzle.position; Vector3 val2; float flightTime; if (FirstPerson) { val2 = _directDirection * 42f; if (!PredictDirect(position, val2, gravity, out impact, out flightTime)) { ((Character)player).Message((MessageType)2, MortarText.Get("out_of_range"), 0, (Sprite)null, false); return false; } _target = impact; if (!IsTargetLoaded()) { ((Character)player).Message((MessageType)2, MortarText.Get("loading"), 0, (Sprite)null, false); return false; } } else { val2 = (_coordinateSalvo ? MortarBallistics.CoordinateVelocity(position, impact, gravity, Time.fixedDeltaTime, out flightTime) : MortarBallistics.Velocity(position, impact, gravity, out flightTime)); } if (MortarOperatorSafety.BlocksShot(player, position, ((Vector3)(ref val2)).normalized) || MortarOperatorSafety.BlocksShot(player, ((Character)player).GetEyePoint(), ((Vector3)(ref val2)).normalized)) { return false; } GameObject val3 = Object.Instantiate<GameObject>(projectile, position, Quaternion.identity); MortarShotAudio.Mark(val3); Projectile component = val3.GetComponent<Projectile>(); component.m_gravity = gravity; component.m_drag = 0f; component.m_doOwnerRaytest = false; component.m_canHitWater = true; component.m_bounceOnWater = false; if (queue[0].Prefab == "BombDynamite" && Object.op_Implicit((Object)(object)MortarPlugin.DynamiteImpact)) { component.m_spawnOnHit = MortarPlugin.DynamiteImpact; component.m_spawnOffset = Vector3.zero; } MortarShell mortarShell = val3.AddComponent<MortarShell>(); mortarShell.Initialize(((Component)this).transform); val3.transform.rotation = Quaternion.LookRotation(val2); HitData val4 = new HitData { m_damage = item.GetDamage(), m_pushForce = item.m_shared.m_attackForce, m_backstabBonus = item.m_shared.m_backstabBonus, m_blockable = item.m_shared.m_blockable, m_dodgeable = item.m_shared.m_dodgeable, m_skill = item.m_shared.m_skillType, m_toolTier = (short)item.m_shared.m_toolTier, m_ranged = true, m_variant = (short)item.m_variant }; if (Object.op_Implicit((Object)(object)item.m_shared.m_attackStatusEffect) && Random.value < item.m_shared.m_attackStatusEffectChance) { val4.m_statusEffectHash = item.m_shared.m_attackStatusEffect.NameHash(); } val4.SetAttacker((Character)(object)player); component.m_ttl = Mathf.Max(component.m_ttl, flightTime + 5f); try { component.Setup((Character)(object)player, val2, -1f, val4, item, (ItemData)null); } catch { ZNetScene.instance.Destroy(val3); throw; } mortarShell.Track(component, position, impact, val2, gravity, flightTime); MortarShotAudio.Play(position); if (Object.op_Implicit((Object)(object)MortarPlugin.MuzzleFire)) { Quaternion val5 = _articulation.Muzzle.rotation * Quaternion.FromToRotation(Vector3.up, Vector3.forward); Object.Instantiate<GameObject>(MortarPlugin.MuzzleFire, position, val5).transform.SetParent(_articulation.Muzzle, true); } queue.Dequeue(); SaveQueue(); _cooldown = 1.5f; MortarStreaming.Retain(impact, flightTime + 3f); if (_coordinateSalvo) { _coordinateFlightUntil = Mathf.Max(_coordinateFlightUntil, Time.time + flightTime + 3f); } return true; } internal void DrawCircle(Camera camera) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_reticle) && !FirstPerson) { _reticle.Draw(_target, camera); } } public string GetHoverText() { if (!CoordinateBusy) { return MortarText.Get("hover", GetQueue().Count, AmmoCapacity); } return MortarText.Get("busy"); } public string GetHoverName() { return MortarText.Get("name"); } public float GetHoverOffset() { return 0f; } public Vector3 GetTargetPosition() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _target; } public float GetCooldownRatio() { return Mathf.Clamp01(_cooldown / 1.5f); } private void UpdatePendingInteraction() { //IL_0045: 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) if (!Object.op_Implicit((Object)(object)_pendingPlayer)) { return; } Player pendingPlayer = _pendingPlayer; if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !Object.op_Implicit((Object)(object)pendingPlayer) || ((Character)pendingPlayer).IsDead() || Vector3.Distance(((Component)pendingPlayer).transform.position, ((Component)this).transform.position) > 5f || Menu.IsVisible() || InventoryGui.IsVisible() || Console.IsVisible()) { _pendingPlayer = null; return; } bool flag = ZInput.GetButton("Use") || ZInput.GetButton("JoyUse"); if (!flag || !(Time.time - _pendingAt < 0.5f)) { _pendingPlayer = null; EnterControl(pendingPlayer, flag); } } private void BeginOperator(Player player) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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) _operator = player; _operatorAnchor = new GameObject("MortarOperatorAnchor").transform; if (FirstPerson) { ((Component)_operatorAnchor).gameObject.AddComponent<MortarSeatAttachment>().Initialize(this, player, _articulation.Seat, _articulation.Muzzle.forward); } else { _operatorAnchor.SetParent(((Component)this).transform, true); _operatorAnchor.position = ((Component)player).transform.position; _operatorAnchor.rotation = ((Component)player).transform.rotation; } Vector3 val = _operatorAnchor.InverseTransformPoint(((Component)player).transform.position); ((Character)player).AttachStart(_operatorAnchor, ((Component)this).gameObject, false, false, (Object)(object)((Component)this).GetComponentInParent<Ship>() != (Object)null, "attach_chair", val, (Transform)null); PublishOperator(player); } private void PublishOperator(Player player) { if (!(Time.time < _operatorPublishAt)) { _operatorPublishAt = Time.time + 0.5f; ZNetView component = ((Component)player).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner()) { component.GetZDO().Set("mortar_operator_until_v1", (long)ZNet.instance.GetTimeSeconds() + 3); } } } private void EndOperator() { MortarPlayerCamera.Restore(); if (Object.op_Implicit((Object)(object)_operator)) { ZNetView component = ((Component)_operator).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.IsValid() && component.IsOwner()) { component.GetZDO().Set("mortar_operator_until_v1", 0L); } if (Object.op_Implicit((Object)(object)component) && component.IsValid() && Object.op_Implicit((Object)(object)_operatorAnchor) && ((Character)_operator).IsAttached()) { ((Character)_operator).AttachStop(); } } _operator = null; _operatorPublishAt = 0f; if (Object.op_Implicit((Object)(object)_operatorAnchor)) { Object.Destroy((Object)(object)((Component)_operatorAnchor).gameObject); } } private void UpdateDirectAim(Player player) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_005d: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = MortarOperatorPose.Look(player); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; float num2 = Mathf.Clamp(Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f, -15f, 65f); _directDirection = Quaternion.Euler(0f - num2, num, 0f) * Vector3.forward; SaveDirectLook(force: false); _articulation.AimAlong(_directDirection, instant: false); SyncOperatorSeat(); _directReady = PredictDirect(_articulation.Muzzle.position, _directDirection * 42f, 9.81f, out _target, out var _); } private void RestoreDirectLook(Player player) { //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_001a: 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_0032: 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_00b0: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = _nview.GetZDO(); Vector3 val = (zDO.GetBool("mortar_has_direct_look_v1", false) ? zDO.GetVec3("mortar_direct_look_v1", Vector3.zero) : Vector3.zero); if (!MortarDirectBallistics.ValidLook(val)) { Vector3 val2 = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z); val = ((Vector3)(ref val2)).normalized * Mathf.Cos((float)Math.PI / 12f) + Vector3.up * Mathf.Sin((float)Math.PI / 12f); } ((Vector3)(ref val)).Normalize(); player.SetMouseLookForward(true); ((Character)player).SetLookDir(new Vector3(val.x, 0f, val.z), 0f); player.SetMouseLook(new Vector2(0f, Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f)); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; float num2 = Mathf.Clamp(Mathf.Asin(Mathf.Clamp(val.y, -1f, 1f)) * 57.29578f, -15f, 65f); _directDirection = Quaternion.Euler(0f - num2, num, 0f) * Vector3.forward; _articulation.AimAlong(_directDirection, instant: true); } private void SaveDirectLook(bool force) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) if (FirstPerson && Object.op_Implicit((Object)(object)_operator) && Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner() && (force || !(Time.time < _directSaveAt))) { Vector3 value = MortarOperatorPose.Look(_operator); if (MortarDirectBallistics.ValidLook(value)) { _directSaveAt = Time.time + 0.5f; ZDO zDO = _nview.GetZDO(); zDO.Set("mortar_direct_look_v1", ((Vector3)(ref value)).normalized); zDO.Set("mortar_has_direct_look_v1", true); } } } internal void SyncOperatorSeat() { MortarOperatorPose.Sync(_operator); } private bool PredictDirect(Vector3 start, Vector3 velocity, float gravity, out Vector3 impact, out float time) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_0225: 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_005d: 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_0063: 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_0068: 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_008c: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01dd: 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_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) Vector3 val = start; float num3 = default(float); for (int i = 1; i <= 200; i++) { time = (float)i * 0.1f; Vector3 val2 = MortarDirectBallistics.Position(start, velocity, gravity, time); Vector3 val3 = val2 - ((Component)this).transform.position; val3.y = 0f; if (((Vector3)(ref val3)).sqrMagnitude > 40000f) { impact = ClampTarget(val2); return false; } Vector3 val4 = val2 - val; int num = Physics.RaycastNonAlloc(val, ((Vector3)(ref val4)).normalized, _directHits, ((Vector3)(ref val4)).magnitude, -5, (QueryTriggerInteraction)1); float num2 = float.MaxValue; Vector3 val5 = val2; for (int j = 0; j < num; j++) { Collider collider = ((RaycastHit)(ref _directHits[j])).collider; if (Object.op_Implicit((Object)(object)collider) && !((Component)collider).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)collider).GetComponentInParent<Player>() == (Object)(object)_operator) && ((RaycastHit)(ref _directHits[j])).distance < num2) { num2 = ((RaycastHit)(ref _directHits[j])).distance; val5 = ((RaycastHit)(ref _directHits[j])).point; } } float waterHeight = MortarSurface.GetWaterHeight(val2); if (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || !ZoneSystem.instance.GetGroundHeight(val2, ref num3)) { num3 = ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetHeight(val2) : (-10000f)); } float num4 = Mathf.Max(waterHeight, num3); if (num2 < float.MaxValue) { impact = val5; time -= 0.1f * (1f - num2 / Mathf.Max(0.001f, ((Vector3)(ref val4)).magnitude)); return true; } if (val2.y <= num4) { float num5 = Mathf.Clamp01((val.y - num4) / Mathf.Max(0.001f, val.y - val2.y)); impact = Vector3.Lerp(val, val2, num5); impact.y = num4; time -= 0.1f * (1f - num5); return true; } val = val2; } impact = ClampTarget(val); time = 20f; return false; } private void DropLoadedAmmo() { if (!Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_nview.IsOwner()) { return; } if ((Object)(object)ActiveMortar == (Object)(object)this) { ExitControl(); } MigrateLegacyAmmo(); MortarAmmoRecovery.Drain(GetQueue(), delegate(AmmoRound round) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) ItemData item = AmmoCatalog.GetItem(round); if (item == null) { Logger.LogWarning((object)("[Mortar] Не удалось вернуть недоступный боеприпас: " + round.Prefab)); return false; } item.m_stack = 1; return Object.op_Implicit((Object)(object)ItemDrop.DropItem(item, 1, ((Component)this).transform.position + Vector3.up * 0.8f, Quaternion.identity)); }, SaveQueue); } private void UpdateCoordinateLock() { if (Object.op_Implicit((Object)(object)_nview) && _nview.IsValid() && _nview.IsOwner() && Object.op_Implicit((Object)(object)ZNet.instance)) { ZDO zDO = _nview.GetZDO(); if (zDO.GetBool("mortar_coordinate_active", false) && (double)zDO.GetFloat("mortar_coordinate_lease", 0f) <= ZNet.instance.GetTimeSeconds()) { zDO.Set("mortar_coordinate_active", false); } } } internal bool BeginCoordinates(Player player, Vector3 origin, Vector3 target, int cells, bool highPrecision) { //IL_0038: 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_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_0069: 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_014b: 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_0157: 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_01a5: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead() || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || CoordinateBusy || Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) > 5f || cells > CoordinateCells || !MortarCoordinateGrid.Contains(origin, target, cells) || Vector3.Distance(origin, ((Component)this).transform.position) > 10f) { return false; } _nview.ClaimOwnership(); if (!_nview.IsOwner() || !Object.op_Implicit((Object)(object)_articulation) || !Object.op_Implicit((Object)(object)_articulation.Muzzle)) { return false; } MigrateLegacyAmmo(); AmmoQueue queue = GetQueue(); if (queue.Count == 0) { ((Character)player).Message((MessageType)2, MortarText.Get("load_first"), 0, (Sprite)null, false); return false; } for (int i = 0; i < queue.Count; i++) { if (!Object.op_Implicit((Object)(object)AmmoCatalog.GetProjectile(AmmoCatalog.GetItem(queue[i])))) { ((Character)player).Message((MessageType)2, MortarText.Get("queue_missing"), 0, (Sprite)null, false); return false; } } if ((Object)(object)ActiveMortar == (Object)(object)this) { ExitControl(); } _pendingPlayer = null; _target = target; _target.y = MortarSurface.GetHeight(target); _coordinateFlightUntil = 0f; ZDO zDO = _nview.GetZDO(); zDO.Set("mortar_coordinate_origin", origin); zDO.Set("mortar_coordinate_cells", cells); zDO.Set("mortar_coordinate_precision", highPrecision); zDO.Set("mortar_coordinate_target", target); zDO.Set("mortar_coordinate_controller", ZDOMan.GetSessionID()); zDO.Set("mortar_coordinate_active", true); RefreshCoordinates(); return true; } internal bool RefreshCoordinates() { ZDO coordinateData = CoordinateData; if (coordinateData == null || !Object.op_Implicit((Object)(object)ZNet.instance) || coordinateData.GetLong("mortar_coordinate_controller", 0L) != ZDOMan.GetSessionID()) { return false; } if (!_nview.IsOwner()) { _nview.ClaimOwnership(); } if (!_nview.IsOwner()) { return false; } coordinateData.Set("mortar_coordinate_lease", (float)(ZNet.instance.GetTimeSeconds() + 12.0)); return true; } internal bool AimCoordinates(out bool loaded) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0039: Unknown result type (might be due to invalid IL or missing references) _target = CoordinateData.GetVec3("mortar_coordinate_target", Vector3.zero); _target.y = MortarSurface.GetHeight(_target); _articulation.AimAt(_target, GetAimGravity(), instant: false); loaded = IsTargetLoaded(); return _articulation.IsAligned; } internal bool CoordinateVolley(Player player) { //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) int count = GetQueue().Count; _coordinateSpread = (Vector2[])(object)new Vector2[count]; for (int i = 0; i < count; i++) { _coordinateSpread[i] = MortarCoordinateGrid.Spread(Random.value, Random.value, CoordinateHighPrecision); } _coordinateSalvo = true; try { for (int j = 0; j < count; j++) { _coordinateShot = j; if (!Fire(player)) { return false; } } CoordinateData.Set("mortar_coordinate_active", false); return true; } finally { _coordinateSalvo = false; _coordinateSpread = null; } } internal void CancelCoordinates() { if (RefreshCoordinates()) { CoordinateData.Set("mortar_coordinate_active", false); CoordinateData.Set("mortar_coordinate_lease", 0f); } } private void RefreshSupport(bool force) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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 (!force && Time.time < _supportScanAt) { return; } _supportScanAt = Time.time + 1f; _supportPieces.Clear(); _supplyBarrels.Clear(); Piece.GetAllPiecesInRadius(((Component)this).transform.position, 10.01f, _supportPieces); int num = 0; int num2 = 0; foreach (Piece supportPiece in _supportPieces) { if (!Object.op_Implicit((Object)(object)supportPiece) || Vector3.Distance(((Component)supportPiece).transform.position, ((Component)this).transform.position) > 10f) { continue; } ZNetView component = ((Component)supportPiece).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component) || !component.IsValid()) { continue; } int prefab = component.GetZDO().GetPrefab(); if (prefab == StringExtensionMethods.GetStableHashCode("piece_cartographytable")) { num++; } if (prefab == StringExtensionMethods.GetStableHashCode("piece_chest_barrel")) { Container component2 = ((Component)supportPiece).GetComponent<Container>(); if (Object.op_Implicit((Object)(object)component2)) { num2++; _supplyBarrels.Add(component2); } } } _supportCapacity = MortarSupportRules.Capacity(num2); _supportCells = MortarSupportRules.Cells(num); _supplyBarrels.Sort(delegate(Container a, Container b) { //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_002c: 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_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) Vector3 val = ((Component)a).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; val = ((Component)b).transform.position - ((Component)this).transform.position; return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude); }); } private void UpdateSupply() { if (Time.time < _supplyAt || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_nview.IsOwner() || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || ((Character)Player.m_localPlayer).IsDead() || _coordinateSalvo || _cooldown > 0f) { return; } _supplyAt = Time.time + 1f; RefreshSupport(force: true); if (GetQueue().Count >= AmmoCapacity) { return; } Container[] array = _supplyBarrels.ToArray(); foreach (Container val in array) { if (GetQueue().Count >= AmmoCapacity) { break; } if (Object.op_Implicit((Object)(object)val)) { MortarSupplyBarrel component = ((Component)val).GetComponent<MortarSupplyBarrel>(); if (Object.op_Implicit((Object)(object)component)) { component.RequestSupply(this, Player.m_localPlayer); } } } } internal void TakeSupply(Container container) { //IL_005a: 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) if (!Object.op_Implicit((Object)(object)container) || !container.IsOwner() || container.IsInUse() || !Object.op_Implicit((Object)(object)_nview) || !_nview.IsValid() || !_nview.IsOwner() || _coordinateSalvo || _cooldown > 0f || Vector3.Distance(((Component)this).transform.position, ((Component)container).transform.position) > 10f) { return; } RefreshSupport(force: true); AmmoQueue queue = GetQueue(); Inventory inventory = container.GetInventory(); if (inventory == null) { return; } int ammoCapacity = AmmoCapacity; while (queue.Count < ammoCapacity) { ItemData val = inventory.GetAllItems().Find((ItemData candidate) => AmmoCatalog.IsBomb(candidate)); if (val != null) { AmmoRound round = new AmmoRound(((Object)val.m_dropPrefab).name, val.m_quality, val.m_variant, val.m_worldLevel); ItemData val2 = val.Clone(); val2.m_stack = 1; if (inventory.RemoveItem(val, 1)) { if (!queue.Enqueue(round, ammoCapacity)) { inventory.AddItem(val2); break; } SaveQueue(); continue; } break; } break; } } } internal static class MortarSurface { internal static float GetWaterHeight(Vector3 point, bool visual = false) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_01b4: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) float num = -10000f; foreach (WaterVolume instance in WaterVolume.Instances) { if (!Object.op_Implicit((Object)(object)instance)) { continue; } Collider component = ((Component)instance).GetComponent<Collider>(); if (!Object.op_Implicit((Object)(object)component)) { continue; } Bounds bounds = component.bounds; if (point.x < ((Bounds)(ref bounds)).min.x || point.x > ((Bounds)(ref bounds)).max.x || point.z < ((Bounds)(ref bounds)).min.z || point.z > ((Bounds)(ref bounds)).max.z) { continue; } float num2 = instance.GetWaterSurface(point, 1f); if (visual && Object.op_Implicit((Object)(object)instance.m_waterSurface) && instance.m_useGlobalWind) { Material sharedMaterial = ((Renderer)instance.m_waterSurface).sharedMaterial; if (Object.op_Implicit((Object)(object)sharedMaterial)) { float num3 = instance.CalcWave(point, instance.Depth(point), sharedMaterial.GetFloat("_WaterTime"), 1f, 1f - (float)WorldGenerator.DeepNorthWaveFade(point.x, point.z)); num2 = ((Component)instance).transform.position.y + instance.m_surfaceOffset + num3; if (instance.m_forceDepth < 0f && Utils.LengthXZ(point) > 10500f) { num2 -= 100f; } } } num = Mathf.Max(num, num2); } if (num > -9999f) { return num; } Vector3 val = point; if (Object.op_Implicit((Object)(object)ZoneSystem.instance)) { val.y = ZoneSystem.instance.m_waterLevel - 0.5f; } num = Mathf.Max(Floating.GetLiquidLevel(val, 1f, (LiquidType)0), Floating.GetLiquidLevel(point, 1f, (LiquidType)0)); if (num < -9999f && Object.op_Implicit((Object)(object)ZoneSystem.instance) && point.y < ZoneSystem.instance.m_waterLevel) { num = ZoneSystem.instance.m_waterLevel - ((Utils.LengthXZ(point) > 10500f) ? 100f : 0f); } return num; } internal static float GetHeight(Vector3 point, bool visual = false) { //IL_0000: 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_004a: 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_0018: 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_002e: Unknown result type (might be due to invalid IL or missing references) float num = point.y; if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && !ZoneSystem.instance.GetSolidHeight(point, ref num, 1000)) { num = ((WorldGenerator.instance != null) ? WorldGenerator.instance.GetHeight(point) : point.y); } return Mathf.Max(num, GetWaterHeight(new Vector3(point.x, num, point.z), visual)); } } public sealed class MortarShell : MonoBehaviour { internal static readonly List<MortarShell> Flying = new List<MortarShell>(); private Transform _source; private float _ignoreUntil; internal Transform Source => _source; internal Vector3 Start { get; private set; } internal Vector3 Impact { get; private set; } internal Vector3 Velocity { get; private set; } internal float Gravity { get; private set; } internal float FlightTime { get; private set; } internal float LaunchedAt { get; private set; } internal void Track(Projectile projectile, Vector3 start, Vector3 impact, Vector3 velocity, float gravity, float flightTime) { //IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown Start = start; Impact = impact; Velocity = velocity; Gravity = gravity; FlightTime = flightTime; LaunchedAt = Time.time; projectile.m_onHit = (OnProjectileHit)Delegate.Combine((Delegate?)(object)projectile.m_onHit, (Delegate?)(OnProjectileHit)delegate { Flying.Remove(this); }); Flying.Add(this); } internal Vector3 PositionAt(float time) { //IL_0001: 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_000d: 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_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) return Start + Velocity * time - Vector3.up * (0.5f * Gravity * time * time); } private void OnDestroy() { Flying.Remove(this); } public void Initialize(Transform source) { _source = source; _ignoreUntil = Time.time + 0.3f; } public bool IgnoreLaunchCollider(Collider collider) { if (Object.op_Implicit((Object)(object)collider) && Object.op_Implicit((Object)(object)_source) && Time.time < _ignoreUntil) { if (!((Object)(object)((Component)collider).transform == (Object)(object)_source)) { return ((Component)collider).transform.IsChildOf(_source); } return true; } return false; } } public sealed class MortarArticulation : MonoBehaviour { private const string AnglesKey = "mortar_aim_angles_v2"; private const float DegreesPerSecond = 240f; private ZNetView _view; private Transform _yaw; private Transform _pitch; private Transform _muzzle; private Transform _seat; private Vector3 _hinge; private Vector3 _pitchHingeOffset; private Vector3 _neutralMuzzleOffset; private Quaternion _yawRestRotation; private Quaternion _pitchRestRotation; private Vector3 _angles; private Vector3 _publishedAngles; private float _publishAt; private bool _bound; private Vector3 _desiredAngles; public bool IsAligned { get { if (Mathf.Abs(Mathf.DeltaAngle(_angles.x, _desiredAngles.x)) < 0.5f) { return Mathf.Abs(Mathf.DeltaAngle(_angles.y, _desiredAngles.y)) < 0.5f; } return false; } } public Transform Muzzle => _muzzle; public Transform Seat => _seat; internal static void PreparePrefab(GameObject prefab) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00dd: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) Transform transform = prefab.transform; Transform val = Find(transform, "Empty.001"); Transform val2 = Find(transform, "Empty"); Transform val3 = Find(transform, "tip_1_metal"); Transform val4 = Find(transform, "Cube"); if (!Object.op_Implicit((Object)(object)val4) || (Object)(object)val4.parent != (Object)(object)val || !Object.op_Implicit((Object)(object)((Component)val4).GetComponent<MeshFilter>())) { throw new InvalidOperationException("mortar: ожидается сиденье Empty.001/Cube с MeshFilter."); } if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val3) || (Object)(object)val2.parent != (Object)(object)val || (Object)(object)val3.parent != (Object)(object)val2) { throw new InvalidOperationException("mortar: ожидается Empty.001/Empty/tip_1_metal"); } MortarSeatMesh.Prepare(val4, Find(transform, "base_wood")); Vector3 val5 = val3.TransformDirection(new Vector3(0.17364818f, 0.9848077f, 0f)); Vector3 normalized = ((Vector3)(ref val5)).normalized; Transform transform2 = new GameObject("MortarMuzzle").transform; transform2.SetParent(val2, false); transform2.position = val3.TransformPoint(new Vector3(0.006935806f, 0.021933345f, -3.0054245E-05f)) + normalized * 0.15f; transform2.rotation = Quaternion.LookRotation(normalized); if (!Object.op_Implicit((Object)(object)prefab.GetComponent<MortarArticulation>())) { prefab.AddComponent<MortarArticulation>(); } } private static Transform Find(Transform root, string name) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == name) { return val; } } return null; } private void Awake() { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00d3: 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_00dd: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_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) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) _view = ((Component)this).GetComponent<ZNetView>(); _yaw = ((Component)this).transform.Find("Empty.001"); _pitch = ((Component)this).transform.Find("Empty.001/Empty"); _seat = ((Component)this).transform.Find("Empty.001/Cube"); _muzzle = (Object.op_Implicit((Object)(object)_pitch) ? _pitch.Find("MortarMuzzle") : null); _bound = Object.op_Implicit((Object)(object)_yaw) && Object.op_Implicit((Object)(object)_pitch) && Object.op_Implicit((Object)(object)_muzzle); if (_bound) { _hinge = ((Component)this).transform.InverseTransformPoint(_yaw.position); Vector3 val = ((Component)this).transform.InverseTransformPoint(_pitch.position); _pitchHingeOffset = val - _hinge; _yawRestRotation = _yaw.localRotation; _pitchRestRotation = _pitch.localRotation; _neutralMuzzleOffset = ((Component)this).transform.InverseTransformPoint(_muzzle.position) - val; if (Object.op_Implicit((Object)(object)_view) && _view.IsValid()) { _angles = _view.GetZDO().GetVec3("mortar_aim_angles_v2", Vector3.zero); Apply(_angles, instant: true); } } } private void Update() { //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) if (_bound && Object.op_Implicit((Object)(object)_view) && _view.IsValid()) { MortarLogic component = ((Component)this).GetComponent<MortarLogic>(); if ((!((Object)(object)MortarLogic.ActiveMortar == (Object)(object)component) || !_view.IsOwner()) && (!Object.op_Implicit((Object)(object)component) || !component.CoordinateBusy || !_view.IsOwner())) { Apply(_view.GetZDO().GetVec3("mortar_aim_angles_v2", Vector3.zero), instant: false); } } } internal void AimAt(Vector3 target, float gravity, bool instant) { //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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) if (_bound && Object.op_Implicit((Object)(object)_view) && _view.IsValid() && _view.IsOwner()) { Vector3 val = (_desiredAngles = MortarAimSolver.Solve(new MortarAimFrame { Hinge = ((Component)this).transform.TransformPoint(_hinge), PitchHingeOffset = _pitchHingeOffset, Offset = _neutralMuzzleOffset, Right = ((Component)this).transform.right, Up = ((Component)this).transform.up, Forward = ((Component)this).transform.forward, ScaledRight = ((Component)this).transform.TransformVector(Vector3.right), ScaledUp = ((Component)this).transform.TransformVector(Vector3.up), ScaledForward = ((Component)this).transform.TransformVector(Vector3.forward) }, _muzzle.position, target, gravity, _angles.x)); Apply(val, instant); MortarLogic component = ((Component)this).GetComponent<MortarLogic>(); Vector3 val2 = ((Object.op_Implicit((Object)(object)component) && component.CoordinateBusy) ? _angles : val); if (instant || (Time.time >= _publishAt && (Mathf.Abs(Mathf.DeltaAngle(_publishedAngles.x, val2.x)) > 0.15f || Mathf.Abs(Mathf.DeltaAngle(_publishedAngles.y, val2.y)) > 0.15f))) { _view.GetZDO().Set("mortar_aim_angles_v2", val2); _publishedAngles = val2; _publishAt = Time.time + 0.1f; } } } internal void AimAlong(Vector3 direction, bool instant) { //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) //IL_003c: 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_004a: 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_0060: 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_007d: 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_00c7: Unknown result type (might be due to invalid IL or missing references) if (_bound && Object.op_Implicit((Object)(object)_view) && _view.IsValid() && _view.IsOwner()) { Vector3 val = ((Component)this).transform.InverseTransformDirection(direction); float num = Mathf.Sqrt(val.x * val.x + val.z * val.z); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Atan2(val.x, val.z) * 57.29578f - 90f, Mathf.Atan2(val.y, num) * 57.29578f - 80f, 0f); Apply(val2, instant); if (instant || Time.time >= _publishAt) { _view.GetZDO().Set("mortar_aim_angles_v2", val2); _publishAt = Time.time + 0.1f; } } } private void Apply(Vector3 target, bool instant) { //IL_004c: 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_007f: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_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) MortarLogic component = ((Component)this).GetComponent<MortarLogic>(); float num = ((Object.op_Implicit((Object)(object)component) && component.CoordinateBusy) ? 12f : 240f); _angles.x = (instant ? target.x : Mathf.MoveTowardsAngle(_angles.x, target.x, num * Time.deltaTime)); _angles.y = (instant ? target.y : Mathf.MoveTowardsAngle(_angles.y, target.y, num * Time.deltaTime)); _yaw.localRotation = Quaternion.AngleAxis(_angles.x, Vector3.up) * _yawRestRotation; _pitch.localRotation = Quaternion.AngleAxis(_angles.y, Vector3.forward) * _pitchRestRotation; } } internal static class MortarBallistics { internal const float ArcHeight = 12f; internal static float Gravity(Projectile projectile) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0.01f, (Object.op_Implicit((Object)(object)projectile) && projectile.m_gravity > 0.01f) ? projectile.m_gravity : Mathf.Abs(Physics.gravity.y)); } internal static Vector3 Velocity(Vector3 start, Vector3 impact, float gravity, out float flightTime) { //IL_000d: 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_002b: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) gravity = Mathf.Max(0.01f, gravity); float num = Mathf.Max(start.y, impact.y) + 12f; float num2 = Mathf.Sqrt(2f * (num - start.y) / gravity); flightTime = num2 + Mathf.Sqrt(2f * (num - impact.y) / gravity); Vector3 val = impact - start; val.y = 0f; return val / flightTime + Vector3.up * (gravity * num2); } internal static Vector3 CoordinateVelocity(Vector3 start, Vector3 impact, float gravity, float fixedStep, out float flightTime) { //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_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_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_0013: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Velocity(start, impact, gravity, out flightTime); if (fixedStep <= 0f) { return val; } float num = flightTime / fixedStep; float num2 = num - (float)(int)num; float num3 = fixedStep * 0.5f + fixedStep * fixedStep * num2 * (1f - num2) / (2f * flightTime); return val + Vector3.up * (Mathf.Max(0.01f, gravity) * num3); } } internal struct MortarAimFrame { internal Vector3 Hinge; internal Vector3 PitchHingeOffset; internal Vector3 Offset; internal Vector3 Right; internal Vector3 Up; internal Vector3 Forward; internal Vector3 ScaledRight; internal Vector3 ScaledUp; internal Vector3 ScaledForward; } internal static class MortarAimSolver { internal static Vector3 Solve(MortarAimFrame frame, Vector3 start, Vector3 target, float gravity, float previousYaw) { //IL_001a: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002