csharp/SonicZentropy/PoE2Mods.pw/Mods/PoE2Mods/ShipMechanicsMod/WorldMapPlayer.cs

ShipMechanicsMod
WorldMapPlayer.cs
using Patchwork;

using UnityEngine;
using UnityEngine.AI;
using Game;
using Game.GameData;
using Onyx;

namespace PoE2Mods
{
    [ModifiesType("Game.WorldMapPlayer")]
    public clast mod_WorldMapPlayer : WorldMapPlayer
    {
        [NewMember]
        public bool UseMod;

        /// 
        /// Read the config file, then call OnyxStart().
        /// 
        [ModifiesMember("OnyxStart")]
        public void mod_OnyxStart()
        {
            UseMod = UserConfig.GetValueAsBool("ShipMechanics", "clickThroughFog");

            // TPS: Original code
            this.m_destinationDummyObject = new GameObject("WorldMapDestinationDummy");
            this.m_destinationDummyObject.transform.SetParent(base.transform.parent, false);
            this.Respawn();
            SingletonBehavior.Instance.FocusOnPoint(base.transform.position, 0f);
            SingletonBehavior.Instance.UpdateCamera();
        }

        /// 
        /// Modification: Allows player to navigate to walkable areas currently hidden by fog.
        /// 
        [ModifiesMember("OnyxUpdate")]
        public void mod_OnyxUpdate()
        {
            // TPS: this will call WorldMapPlayer.OnyxUpdate(), so leave out
            // base.OnyxUpdate();

            if (this.m_firstUpdate)
            {
                this.OnActiveShipChanged(SingletonBehavior.Instance.ActiveShipType);
                this.m_firstUpdate = false;
            }
            GameState.PlayerCharacter.UpdateCursor();
            this.SetAgentAreaMask();
            this.SetAgentSpeed();
            bool flag = false;
            bool flag2 = false;
            if (SingletonBehavior.Instance.AllowTravel)
            {
                bool flag3; // TPS: represents when the player has queued a movement action
                bool flag4;
                if (SingletonBehavior.Instance.IsFollowActive)
                {
                    flag3 = (GameInput.GetControl(MappedControl.MOVE, false) || GameInput.GetControl(MappedControl.FOLLOW_CURSOR_MOVE, false) || GameInput.GetControl(MappedControl.ROTATE_FORMATION, false));
                    flag4 = false;
                    if ((GameInput.GetControlDown(MappedControl.MOVE, true) || GameInput.GetControlDown(MappedControl.FOLLOW_CURSOR_MOVE, true) || GameInput.GetControlDown(MappedControl.ROTATE_FORMATION, true)) && !this.m_isPlayingAudio)
                    {
                        UIAudioManager.Instance.PlayWorldMapPathingBegin(this.CurrentTransitMode);
                        this.m_isPlayingAudio = true;
                    }
                    flag3 = (flag3 && GameInput.IsKeyUpAvailable(KeyCode.Mouse0));
                    flag = (GameInput.GetControlUp(MappedControl.MOVE, true) || GameInput.GetControlUp(MappedControl.FOLLOW_CURSOR_MOVE, true) || GameInput.GetControlUp(MappedControl.ROTATE_FORMATION, true));
                }
                else
                {
                    flag3 = (GameInput.GetControlUp(MappedControl.MOVE, true) || GameInput.GetControlUp(MappedControl.FOLLOW_CURSOR_MOVE, true) || GameInput.GetControlUp(MappedControl.ROTATE_FORMATION, true));
                    flag4 = true;
                    flag = true;
                }
                // TPS: Allow movement action to take place even if the fog of war is active at the cursor's current position
//              if (flag3 && this.CanReachMousePosition() && SingletonBehavior.Instance.IsFogRevealed(GameInput.WorldMousePosition) && this.NavigateTo(GameInput.WorldMousePosition))
                if (flag3 
                    && this.CanReachMousePosition() 
                    && this.NavigateTo(GameInput.WorldMousePosition)
                    && (UseMod || SingletonBehavior.Instance.IsFogRevealed(GameInput.WorldMousePosition)))
                {
                    if (flag4 && !this.m_isPlayingAudio)
                    {
                        UIAudioManager.Instance.PlayWorldMapPathingBegin(this.CurrentTransitMode);
                        this.m_isPlayingAudio = true;
                    }
                    if (!flag4)
                    {
                        Vector2 vector = Camera.main.WorldToScreenPoint(GameInput.WorldMousePosition) - Camera.main.WorldToScreenPoint(base.transform.position);
                        int num = Mathf.CeilToInt((Mathf.Atan2(vector.y, vector.x) - 0.196349546f) / 0.3926991f);
                        GameCursor.DesiredCursor = GameCursor.CursorType.ShipMove_N + (-num + 16 + 4) % 16;
                        flag2 = true;
                    }
                }
            }
            if (GameInput.GetControlUp(MappedControl.CANCEL_ACTION, true))
            {
                this.ClearDestination();
                UIWorldMapPlayerDestinationNugget.Show(false);
            }
            bool flag5 = false;
            if (this.HasDestination)
            {
                if (this.m_targetIcon != null)
                {
                    if (this.m_targetInteractionPoint != null)
                    {
                        NavMeshHit navMeshHit;
                        if (!this.UseNavMesh || !NavMesh.Raycast(base.transform.position, this.m_targetInteractionPoint.transform.position, out navMeshHit, this.m_agent.areaMask))
                        {
                            float num2 = this.m_targetInteractionPoint.transform.position.x - base.transform.position.x;
                            float num3 = this.m_targetInteractionPoint.transform.position.z - base.transform.position.z;
                            float num4 = num2 * num2 + num3 * num3;
                            if (num4