Ejemplo n.º 1
0
 public static void Postfix(LocalCharacterControl __instance, bool ___m_autoRun)
 {
     if (!SuperSprint.modSettings.autoRun ||
         __instance.Character.Faction != Character.Factions.Player)
     {
         return;
     }
     autoRun = ___m_autoRun;
 }
Ejemplo n.º 2
0
 static void Postfix(LocalCharacterControl __instance)
 {
     if (__instance.InputLocked)
     {
         return;
     }
     if (Meditation.EnableSitting.Value && Meditation.SitKey.Value.IsDown())
     {
         __instance.Character.CastSpell(Character.SpellCastType.Sit, __instance.Character.gameObject, Character.SpellCastModifier.Immobilized, 1, -1f);
     }
 }
Ejemplo n.º 3
0
        public static void UpdateInteraction(LocalCharacterControl __instance)
        {
            if (__instance.InputLocked)
            {
                return;
            }

            try
            {
                if (CustomKeybindings.GetKeyDown("QuickSave"))
                {
                    SaveSystemReworked.MyLogger.LogDebug("QuickSave");
                    SaveManager.Instance.Save(true, true);
                    //QuickSave = SaveManager.Instance.ChooseCharacterSaveInstance(charUID, 0);

                    if ((bool)Global.AudioManager)
                    {
                        Global.AudioManager.PlaySound(GlobalAudioManager.Sounds.UI_NEWGAME_SelectSave);
                    }
                }
                //if (CustomKeybindings.GetKeyDown("QuickLoad"))
                //{
                //    SaveSystemReworked.MyLogger.LogDebug("QuickLoad");
                //    if (QuickSave == null)
                //    {
                //        QuickSave = SaveManager.Instance.ChooseCharacterSaveInstance(charUID, 0);
                //    }
                //    SplitScreenManager.Instance.LocalPlayers[0].SetChosenSave(QuickSave);

                //    QuickSave.ApplyLoadedSaveToChar(__instance.Character);
                //}
            }
            catch (Exception ex)
            {
                SaveSystemReworked.MyLogger.LogError(ex.Message);
            }
        }
Ejemplo n.º 4
0
            public static bool Prefix(LocalCharacterControl __instance)
            {
                var self = __instance;

                var m_character       = At.GetField(self as CharacterControl, "m_character") as Character;
                var m_targetingSystem = m_character.TargetingSystem;

                bool m_lockHoldUp = false;

                if (!m_character.CharacterCamera.InZoomMode &&
                    (ControlsInput.LockToggle(m_character.OwnerPlayerSys.PlayerID) || ControlsInput.LockHoldDown(m_character.OwnerPlayerSys.PlayerID)))
                {
                    At.SetField(self, "m_lockHoldUp", false);

                    if (m_targetingSystem.Locked)
                    {
                        At.Invoke(self, "ReleaseTarget");

                        if (self.ControlMode == LocalCharacterControl.CameraControlMode.Classic)
                        {
                            self.FaceLikeCamera = false;
                        }
                    }
                    else
                    {
                        At.Invoke(self, "AcquireTarget");

                        if (m_targetingSystem.Locked && self.ControlMode == LocalCharacterControl.CameraControlMode.Classic)
                        {
                            self.FaceLikeCamera = true;
                        }
                    }
                }

                if (ControlsInput.LockHoldUp(m_character.OwnerPlayerSys.PlayerID))
                {
                    m_lockHoldUp = true;
                    At.SetField(self, "m_lockHoldUp", true);
                }

                if (!m_character.CharacterCamera.InZoomMode && m_lockHoldUp)
                {
                    At.Invoke(self, "ReleaseTarget");
                }

                if (Input.GetMouseButtonDown(3) && self.TargetMode == LocalCharacterControl.TargetingMode.Aim)
                {
                    Ray ray = m_character.CharacterCamera.CameraScript.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out RaycastHit raycastHit, m_targetingSystem.TrueRange * 1.5f, Global.AimTargetMask))
                    {
                        LockingPoint lockingPoint = raycastHit.collider.GetComponent <LockingPoint>();
                        if (lockingPoint == null)
                        {
                            Character characterOwner = raycastHit.collider.GetCharacterOwner();
                            if (characterOwner)
                            {
                                lockingPoint = characterOwner.LockingPoint;
                            }
                        }
                        if (lockingPoint)
                        {
                            At.Invoke(self, "SwitchTarget", new object[] { lockingPoint });
                        }
                    }
                }

                if (m_targetingSystem.Locked && !m_character.CharacterCamera.InZoomMode)
                {
                    if (!self.FaceLikeCamera)
                    {
                        self.FaceLikeCamera = true;
                    }

                    if (self.TargetMode == LocalCharacterControl.TargetingMode.Classic)
                    {
                        Vector2 vector = new Vector2(
                            ControlsInput.SwitchTargetHorizontal(m_character.OwnerPlayerSys.PlayerID),
                            ControlsInput.SwitchTargetVertical(m_character.OwnerPlayerSys.PlayerID));

                        float magnitude = vector.magnitude;

                        float m_lastTargetSwitchTime = (float)At.GetField(self, "m_lastTargetSwitchTime");

                        if (Time.time - m_lastTargetSwitchTime > 0.3f)
                        {
                            //Vector2 m_previousInput = (Vector2)At.GetValue(typeof(LocalCharacterControl), self, "m_previousInput");
                            //float magnitude2 = (vector - m_previousInput).magnitude;

                            //if (magnitude2 >= 0.45f && magnitude > 0.6f)
                            //{
                            //    At.Call(self, "SwitchTarget", new object[] { vector });
                            //}

                            // this is for bows
                            if (m_character.CurrentWeapon is ProjectileWeapon)
                            {
                                var m_timeOfLastAimOffset = (float)At.GetField(self, "m_timeOfLastAimOffset");
                                var m_timeToNextAimOffset = (float)At.GetField(self, "m_timeToNextAimOffset");
                                var m_aimOffsetRandom     = (Vector2)At.GetField(self, "m_aimOffsetRandom");

                                if (ControlsInput.IsLastActionGamepad(m_character.OwnerPlayerSys.PlayerID))
                                {
                                    Vector2 a = vector;
                                    a.x *= -1f;
                                    if (Time.time - m_timeOfLastAimOffset > m_timeToNextAimOffset)
                                    {
                                        m_aimOffsetRandom = UnityEngine.Random.insideUnitCircle;
                                        At.SetField(self, "m_aimOffsetRandom", m_aimOffsetRandom);
                                        At.SetField(self, "m_timeOfLastAimOffset", Time.time);
                                        At.SetField(self, "m_timeToNextAimOffset", UnityEngine.Random.Range(0.1f, 0.3f));
                                    }

                                    a += m_aimOffsetRandom * ((Vector3)At.GetField(self, "m_modifMoveInput")).magnitude * Time.deltaTime * 0.5f;

                                    m_character.TargetingSystem.LockingPointOffset = Vector2.Scale(a, new Vector2(-1f, 1f));
                                }
                                else
                                {
                                    Vector2 vector2 = vector * self.LockAimMouseSense;
                                    vector2.x *= -1f;
                                    if (Time.time - m_timeOfLastAimOffset > m_timeToNextAimOffset)
                                    {
                                        m_aimOffsetRandom = UnityEngine.Random.insideUnitCircle;
                                        At.SetField(self, "m_aimOffsetRandom", m_aimOffsetRandom);
                                        At.SetField(self, "m_timeOfLastAimOffset", Time.time);
                                        At.SetField(self, "m_timeToNextAimOffset", UnityEngine.Random.Range(0.1f, 0.3f));
                                    }
                                    vector2 += m_aimOffsetRandom * ((Vector3)At.GetField(self, "m_modifMoveInput")).magnitude * Time.deltaTime * 0.5f;
                                    m_character.TargetingSystem.LockingPointOffset -= new Vector3(vector2.x, vector2.y, 0);
                                    m_character.TargetingSystem.LockingPointOffset  = Vector3.ClampMagnitude(m_character.TargetingSystem.LockingPointOffset, 1f);
                                }
                            }
                            At.SetField(self, "m_previousInput", vector);
                        }
                        else if (ControlsInput.IsLastActionGamepad(m_character.OwnerPlayerSys.PlayerID) && magnitude == 0f)
                        {
                            At.SetField(self, "m_lastTargetSwitchTime", 0f);
                        }
                    }
                    else if (self.TargetMode == LocalCharacterControl.TargetingMode.Aim)
                    {
                        Global.LockCursor(false);
                    }

                    Vector3 lockedPointPos    = m_targetingSystem.LockedPointPos;
                    float   m_lastInSightTime = (float)At.GetField(self, "m_lastInSightTime");
                    if (!Physics.Linecast(m_character.CenterPosition, lockedPointPos, Global.SightHideMask))
                    {
                        m_lastInSightTime = Time.time;
                        At.SetField(self, "m_lastInSightTime", m_lastInSightTime);
                    }

                    bool isLocked = m_targetingSystem.LockedCharacter != null && !m_targetingSystem.LockedCharacter.Alive;
                    if (Vector3.Distance(lockedPointPos, m_character.CenterPosition) > m_targetingSystem.TrueRange + 2f || Time.time - m_lastInSightTime > 1f || isLocked)
                    {
                        At.Invoke(self, "ReleaseTarget");
                        self.Invoke("AcquireTarget", 0.5f);
                    }
                }
                else
                {
                    m_targetingSystem.LockingPointOffset = Vector3.zero;
                    if (m_character.CharacterCamera.InZoomMode)
                    {
                        float m_lastFreeAimUpdateTime = (float)At.GetField(self, "m_lastFreeAimUpdateTime");
                        if (Time.time - m_lastFreeAimUpdateTime > 0.05f)
                        {
                            m_lastFreeAimUpdateTime = Time.time;
                            At.SetField(self, "m_lastFreeAimUpdateTime", m_lastFreeAimUpdateTime);

                            bool m_debugFreeAim = (bool)At.GetField(self, "m_debugFreeAim");

                            At.SetField(self, "m_freeAimTargetPos", m_character.CharacterCamera.GetObstaclePos(new Vector3(0.5f, 0.5f, 0f), m_debugFreeAim));
                        }


                        var m_freeAimLockingPoint = At.GetField(self, "m_freeAimLockingPoint") as LockingPoint;
                        var m_freeAimTargetPos    = (Vector3)At.GetField(self, "m_freeAimTargetPos");
                        if ((bool)At.GetField(self, "m_wasFreeAiming"))
                        {
                            float num = (m_freeAimLockingPoint.transform.position - m_freeAimTargetPos).sqrMagnitude;
                            num = Mathf.Max(num, 10f);
                            m_freeAimLockingPoint.transform.position = Vector3.Lerp(m_freeAimLockingPoint.transform.position, m_freeAimTargetPos, num * Time.deltaTime);
                        }
                        else
                        {
                            m_freeAimLockingPoint.transform.position = m_freeAimTargetPos;
                        }
                    }
                }

                At.SetField(self, "m_wasFreeAiming", m_character.CharacterCamera.InZoomMode);

                return(false);
            }
Ejemplo n.º 5
0
        private void LocalCharacterControl_UpdateInteractionHook(On.LocalCharacterControl.orig_UpdateInteraction orig, LocalCharacterControl localCharCtrl)
        {
            orig(localCharCtrl);

            // Do nothing if input is locked
            if (localCharCtrl.InputLocked)
            {
                return;
            }

            int    playerID      = localCharCtrl.Character.OwnerPlayerSys.PlayerID;
            string charID        = localCharCtrl.Character.UID;
            var    quickSlotMngr = localCharCtrl.Character.QuickSlotMngr;

            // AnyQuickSlotUsed checks if a quickslot is being activated
            bool quickSlotActivated = AnyQuickSlotUsed(playerID);

            // Uses the name string argument from CustomKeybindings.AddAction()
            // If a quickslot is NOT being used...
            if (!quickSlotActivated)
            {
                // ...and you actually press the button assigned to "switch quick slot bars...
                if (CustomKeybindings.m_playerInputManager[playerID].GetButtonDown("Switch Quick Slot Bars"))
                {
                    Debug.Log("localCharacterControl character = " + localCharCtrl.Character.UID + " | " + localCharCtrl.Character.Name);

                    // If the current BarMode is FIRST...
                    if (charCurrentBarMode[charID] == BarMode.FIRST)
                    {
                        if (dev)
                        {
                            Debug.Log("Switching to SECOND skill bar");
                        }

                        // Set barMode to SECOND
                        charCurrentBarMode[charID] = BarMode.SECOND;
                        // And repopulate the default-behaviour skill bar w/ entries from quickSlots2[]
                        PopulateSkillBar(localCharCtrl.Character);
                    }
                    // Else if the current BarMode is SECOND...
                    else if (charCurrentBarMode[charID] == BarMode.SECOND)
                    {
                        if (dev)
                        {
                            Debug.Log("Switching to FIRST skill bar");
                        }

                        // Set barMode to FIRST
                        charCurrentBarMode[charID] = BarMode.FIRST;
                        // And repopulate the default-behaviour skill bar w/ entries from quickSlots1[]
                        PopulateSkillBar(localCharCtrl.Character);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        public static bool UpdateQuickSlotsPrefix(LocalCharacterControl __instance)
        {
            if (__instance.Character != null && __instance.Character.QuickSlotMngr != null)
            {
                int playerID = __instance.Character.OwnerPlayerSys.PlayerID;
                if (!__instance.Character.CharacterUI.IsMenuFocused)
                {
                    __instance.Character.QuickSlotMngr.ShowQuickSlotSection1 = ControlsInput.QuickSlotToggle1(playerID);
                    __instance.Character.QuickSlotMngr.ShowQuickSlotSection2 = ControlsInput.QuickSlotToggle2(playerID);
                }

                if (m_playerInputManager[playerID].GetButtonDown("Sit_Emote"))
                {
                    __instance.Character.CastSpell(Character.SpellCastType.Sit, __instance.Character.gameObject, Character.SpellCastModifier.Immobilized, 1, -1f);
                }
                else if (m_playerInputManager[playerID].GetButtonDown("Alternate_Idle_Emote"))
                {
                    __instance.Character.CastSpell(Character.SpellCastType.IdleAlternate, __instance.Character.gameObject, Character.SpellCastModifier.Immobilized, 1, -1f);
                }
                else if (ControlsInput.QuickSlotInstant1(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(0);
                }
                else if (ControlsInput.QuickSlotInstant2(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(1);
                }
                else if (ControlsInput.QuickSlotInstant3(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(2);
                }
                else if (ControlsInput.QuickSlotInstant4(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(3);
                }
                else if (ControlsInput.QuickSlotInstant5(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(4);
                }
                else if (ControlsInput.QuickSlotInstant6(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(5);
                }
                else if (ControlsInput.QuickSlotInstant7(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(6);
                }
                else if (ControlsInput.QuickSlotInstant8(playerID))
                {
                    __instance.Character.QuickSlotMngr.QuickSlotInput(7);
                }
                else
                {
                    //Debug.Log("ExtendedQuickslots - UpdateQuickSlotsPatch() else");
                    for (var x = 0; x < ExtendedQuickslots.numSlots; ++x)
                    {
                        bool inputRecieved = m_playerInputManager[playerID].GetButtonDown(string.Format("QS_Instant{0}", x + 12));
                        //Debug.Log(string.Format("Checking QS_Instant{0}: {1}", x+12, inputRecieved));
                        if (inputRecieved)
                        {
                            Debug.Log("ExtendedQuickslots - UpdateQuickSlotsPatch() QS_Instant" + (x + 12));
                            __instance.Character.QuickSlotMngr.QuickSlotInput(x + 11);
                            break;
                        }
                    }
                }
            }
            return(false);
        }
        public void detectMovementInputs(On.LocalCharacterControl.orig_DetectMovementInputs orig, LocalCharacterControl self)
        {
            Type tSelf = self.GetType();

            // Remove the need for reflection as much as possible
            // These need to be manually set
            Vector2 sm_moveInput;
            Vector3 sm_modifMoveInput;

            // This should update anything changed inside of it
            Character m_character = self.Character;

            if (self.InputLocked)
            {
                sm_moveInput      = Vector2.zero;
                sm_modifMoveInput = (Vector3)Vector2.zero;
                // Exit condition, so set stuff
                m_moveInput.SetValue(self, sm_moveInput);
                m_modifMoveInput.SetValue(self, sm_modifMoveInput);

                if (!m_character.Sprinting)
                {
                    return;
                }
                m_character.SprintInput(false);
            }
            else
            {
                // Static methods are great
                sm_moveInput.x = ControlsInput.MoveHorizontal(m_character.OwnerPlayerSys.PlayerID);
                sm_moveInput.y = ControlsInput.MoveVertical(m_character.OwnerPlayerSys.PlayerID);

                // If we're autorunning
                if ((bool)m_autoRun.GetValue(self))
                {
                    if ((double)sm_moveInput.y == 0.0)
                    {
                        sm_moveInput.y = 1f;
                    }
                    else
                    {
                        StopAutoRun.Invoke(self, null);
                    }
                }

                // Make sure the magnitude of our input vector is at max 1
                sm_moveInput = (Vector2)Vector3.ClampMagnitude((Vector3)sm_moveInput, 1f);
                // Switch to 3D vector
                sm_modifMoveInput = (Vector3)sm_moveInput;

                // Sprinting
                if (ControlsInput.Sprint(m_character.OwnerPlayerSys.PlayerID) && m_character.InLocomotion && m_character.Stats.CanSprint() && ((!m_character.LocomotionAction || (double)m_character.MobileCastMoveMult == -1.0) && (double)sm_moveInput.sqrMagnitude > 0.100000001490116))
                {
                    // We can cast this because m_sprintTime is always a float
                    m_sprintTime.SetValue(self, (float)m_sprintTime.GetValue(self) + Time.deltaTime);

                    if (m_character.Sneaking)
                    {
                        m_character.StealthInput(false);
                    }
                    if (m_character.CurrentlyChargingAttack && !m_character.CancelChargingSent)
                    {
                        m_character.CancelCharging();
                    }

                    // I think this normalize call is pointless
                    sm_modifMoveInput.Normalize();
                    sm_modifMoveInput *= m_character.Speed * 1.75f;
                    m_sprintFacing.SetValue(self, true);
                    m_character.SprintInput(true);

                    if (m_character.BlockDesired)
                    {
                        m_character.BlockInput(false);
                    }
                }
                else // Not sprinting
                {
                    m_sprintTime.SetValue(self, 0.0f);

                    // Do the calculations for our speed normally, then apply modifiers
                    // Having your weapon unsheathed makes you 12.5% slower
                    sm_modifMoveInput *= !m_character.Sheathed ? m_character.Speed * 0.875f : m_character.Speed;

                    // Modify speed based on sneaking status
                    if (m_character.Sneaking)
                    {
                        // Vanilla values have movement speed capped at 2.3 while sneaking, with a 30% increase with the skill
                        float sneakMod = baseSneakSpeed;

                        // Handle "Stealth Training" skill
                        if (m_character.Inventory.SkillKnowledge.IsItemLearned(8205190))
                        {
                            sneakMod *= stealthTrainingBonus;
                        }

                        sm_modifMoveInput *= sneakMod;
                    }


                    if (m_character.Sprinting)
                    {
                        m_character.SprintInput(false);
                    }
                    if (m_character.Blocking || m_character.CurrentlyChargingAttack)
                    {
                        sm_modifMoveInput *= 0.6f;
                    }
                    if (!m_character.LocomotionAllowed)
                    {
                        sm_modifMoveInput *= 0.1f;
                    }
                    if (m_character.LocomotionAction && (double)m_character.MobileCastMoveMult > 0.0)
                    {
                        sm_modifMoveInput *= m_character.MobileCastMoveMultSmooth;
                    }
                    if (m_character.Sliding)
                    {
                        sm_modifMoveInput *= 0.6f;
                    }
                    if (m_character.Falling)
                    {
                        sm_modifMoveInput *= 0.3f;
                    }

                    if (self.FaceLikeCamera)
                    {
                        Vector2 modifMoveInput = (Vector2)sm_modifMoveInput;
                        float   num            = 0.1f;
                        sm_modifMoveInput.y *= (float)(1.0 + (double)Mathf.Abs(modifMoveInput.x) * (double)num);
                        sm_modifMoveInput.x *= (float)(1.0 + (double)Mathf.Abs(modifMoveInput.y) * (double)num);
                    }
                    m_sprintFacing.SetValue(self, false);
                }
                // General movement modifiers
                sm_modifMoveInput *= self.MovementMultiplier * m_character.Stats.MovementSpeed;

                if (m_character.PreparingToSleep)
                {
                    sm_modifMoveInput *= 0.0f;
                }

                // There is an exit condition ahead, so set values
                m_modifMoveInput.SetValue(self, sm_modifMoveInput);
                m_moveInput.SetValue(self, sm_moveInput);

                if ((m_character.CharacterUI == null || !m_character.CharacterUI.IsMenuJustToggled) && ControlsInput.DodgeButton(m_character.OwnerPlayerSys.PlayerID))
                {
                    Transform horiControl = (Transform)m_horiControl.GetValue(self);

                    m_character.DodgeInput(horiControl.forward * sm_moveInput.y + horiControl.right * sm_moveInput.x);
                    StopAutoRun.Invoke(self, null);
                }
                if (ControlsInput.AutoRun(m_character.OwnerPlayerSys.PlayerID))
                {
                    m_autoRun.SetValue(self, !(bool)m_autoRun.GetValue(self));
                }

                if (!((bool)m_character.CharacterUI) || m_character.CharacterUI.IsMenuJustToggled || (ControlsInput.QuickSlotToggled(m_character.OwnerPlayerSys.PlayerID) || !ControlsInput.StealthButton(m_character.OwnerPlayerSys.PlayerID)))
                {
                    return;
                }

                m_character.StealthInput(!m_character.Sneaking);
            }
        }
Ejemplo n.º 8
0
 static public bool TryGetLocal(LocalCharacterControl localCharacterControl, out Data player)
 => TryGetLocal(GetPlayerID(localCharacterControl), out player);
Ejemplo n.º 9
0
 static public Data GetLocal(LocalCharacterControl localCharacterControl)
 => GetLocal(GetPlayerID(localCharacterControl));
Ejemplo n.º 10
0
 static private int GetPlayerID(LocalCharacterControl localCharacterControl)
 => localCharacterControl.Character.OwnerPlayerSys.PlayerID;
Ejemplo n.º 11
0
        public void LocalCharacterControl_UpdateInteraction(On.LocalCharacterControl.orig_UpdateInteraction orig, LocalCharacterControl self)
        {
            orig(self);

            if (self.InputLocked)
            {
                return;
            }

            var localplayerID = self.Character.OwnerPlayerSys.PlayerID;

            if (CustomKeybindings.m_playerInputManager[localplayerID].GetButtonUp(AggroToggleKey))
            {
                EnemiesAggressive = !EnemiesAggressive;
            }
        }
Ejemplo n.º 12
0
            public static bool Prefix(LocalCharacterControl __instance)
            {
                var self = __instance;

                var character       = self.m_character;
                var targetingSystem = character.TargetingSystem;

                if (!character.CharacterCamera.InZoomMode &&
                    (ControlsInput.LockToggle(character.OwnerPlayerSys.PlayerID) ||
                     ControlsInput.LockHoldDown(character.OwnerPlayerSys.PlayerID)))
                {
                    self.m_lockHoldUp = false;

                    if (targetingSystem.Locked)
                    {
                        self.ReleaseTarget();

                        if (self.ControlMode == LocalCharacterControl.CameraControlMode.Classic)
                        {
                            self.FaceLikeCamera = false;
                        }
                    }
                    else
                    {
                        self.AcquireTarget();

                        if (targetingSystem.Locked && self.ControlMode == LocalCharacterControl.CameraControlMode.Classic)
                        {
                            self.FaceLikeCamera = true;
                        }
                    }
                }

                if (ControlsInput.LockHoldUp(character.OwnerPlayerSys.PlayerID))
                {
                    self.m_lockHoldUp = true;
                }

                if (!character.CharacterCamera.InZoomMode && self.m_lockHoldUp)
                {
                    self.ReleaseTarget();
                }

                if (Input.GetMouseButtonDown(3) && self.TargetMode == LocalCharacterControl.TargetingMode.Aim)
                {
                    Ray ray = character.CharacterCamera.CameraScript.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out RaycastHit raycastHit, targetingSystem.TrueRange * 1.5f, Global.AimTargetMask))
                    {
                        LockingPoint lockingPoint = raycastHit.collider.GetComponent <LockingPoint>();
                        if (lockingPoint == null)
                        {
                            Character characterOwner = raycastHit.collider.GetCharacterOwner();
                            if (characterOwner)
                            {
                                lockingPoint = characterOwner.LockingPoint;
                            }
                        }
                        if (lockingPoint)
                        {
                            self.SwitchTarget(lockingPoint);
                        }
                    }
                }

                if (targetingSystem.Locked && !character.CharacterCamera.InZoomMode)
                {
                    if (!self.FaceLikeCamera)
                    {
                        self.FaceLikeCamera = true;
                    }

                    if (self.TargetMode == LocalCharacterControl.TargetingMode.Classic)
                    {
                        Vector2 inputVector = new Vector2(
                            ControlsInput.SwitchTargetHorizontal(character.OwnerPlayerSys.PlayerID),
                            ControlsInput.SwitchTargetVertical(character.OwnerPlayerSys.PlayerID));

                        if (character.CurrentWeapon is ProjectileWeapon)
                        {
                            // this is for bows
                            if (ControlsInput.IsLastActionGamepad(character.OwnerPlayerSys.PlayerID))
                            {
                                Vector2 bowVector = inputVector;
                                bowVector.x *= -1f;
                                if (Time.time - self.m_timeOfLastAimOffset > self.m_timeToNextAimOffset)
                                {
                                    self.m_aimOffsetRandom     = UnityEngine.Random.insideUnitCircle;
                                    self.m_timeOfLastAimOffset = Time.time;
                                    self.m_timeToNextAimOffset = UnityEngine.Random.Range(0.1f, 0.3f);
                                }
                                bowVector += self.m_aimOffsetRandom * self.m_modifMoveInput.magnitude * Time.deltaTime * 0.5f;
                                character.TargetingSystem.LockingPointOffset = Vector2.Scale(bowVector, new Vector2(-1f, 1f));
                            }
                            else
                            {
                                Vector2 aimVector = inputVector * self.LockAimMouseSense;
                                aimVector.x *= -1f;
                                if (Time.time - self.m_timeOfLastAimOffset > self.m_timeToNextAimOffset)
                                {
                                    self.m_aimOffsetRandom     = UnityEngine.Random.insideUnitCircle;
                                    self.m_timeOfLastAimOffset = Time.time;
                                    self.m_timeToNextAimOffset = UnityEngine.Random.Range(0.1f, 0.3f);
                                }
                                aimVector += self.m_aimOffsetRandom * self.m_modifMoveInput.magnitude * Time.deltaTime * 0.5f;
                                character.TargetingSystem.LockingPointOffset -= new Vector3(aimVector.x, aimVector.y, 0);
                                character.TargetingSystem.LockingPointOffset  = Vector3.ClampMagnitude(
                                    character.TargetingSystem.LockingPointOffset,
                                    1f);
                            }
                        }
                        self.m_previousInput = inputVector;
                    }
                    else if (self.TargetMode == LocalCharacterControl.TargetingMode.Aim)
                    {
                        Global.LockCursor(false);
                    }

                    Vector3 lockedPointPos = targetingSystem.LockedPointPos;
                    if (!Physics.Linecast(character.CenterPosition, lockedPointPos, Global.SightHideMask))
                    {
                        self.m_lastInSightTime = Time.time;
                    }

                    bool isLocked = targetingSystem.LockedCharacter != null && targetingSystem.LockedCharacter.Alive;
                    if (Vector3.Distance(lockedPointPos, character.CenterPosition) > targetingSystem.TrueRange + 2f ||
                        Time.time - self.m_lastInSightTime > 1f ||
                        !isLocked)
                    {
                        self.ReleaseTarget();
                        self.Invoke("AcquireTarget", 0.5f);
                    }
                }
                else
                {
                    targetingSystem.LockingPointOffset = Vector3.zero;
                    if (character.CharacterCamera.InZoomMode)
                    {
                        if (Time.time - self.m_lastFreeAimUpdateTime > 0.05f)
                        {
                            self.m_lastFreeAimUpdateTime = Time.time;
                            self.m_freeAimTargetPos      = character.CharacterCamera.GetObstaclePos(new Vector3(0.5f, 0.5f, 0f), self.m_debugFreeAim);
                        }

                        if (self.m_wasFreeAiming)
                        {
                            float num = (self.m_freeAimLockingPoint.transform.position - self.m_freeAimTargetPos).sqrMagnitude;
                            num = Mathf.Max(num, 10f);
                            self.m_freeAimLockingPoint.transform.position = Vector3.Lerp(
                                self.m_freeAimLockingPoint.transform.position,
                                self.m_freeAimTargetPos, num * Time.deltaTime);
                        }
                        else
                        {
                            self.m_freeAimLockingPoint.transform.position = self.m_freeAimTargetPos;
                        }
                    }
                }

                self.m_wasFreeAiming = character.CharacterCamera.InZoomMode;

                return(false);
            }