Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Hover()

bool Terraria.Mount.Hover ( Player mountedPlayer)
inline

Definition at line 2807 of file Mount.cs.

2808 {
2809 bool flag = DoesHoverIgnoresFatigue();
2810 bool flag2 = _frameState == 2 || _frameState == 4;
2811 if (_type == 49)
2812 {
2813 flag2 = _frameState == 4;
2814 }
2815 if (flag2)
2816 {
2817 bool flag3 = true;
2818 float num = 1f;
2819 float num2 = mountedPlayer.gravity / Player.defaultGravity;
2820 if (mountedPlayer.slowFall)
2821 {
2822 num2 /= 3f;
2823 }
2824 if (num2 < 0.25f)
2825 {
2826 num2 = 0.25f;
2827 }
2828 if (!flag)
2829 {
2830 if (_flyTime > 0)
2831 {
2832 _flyTime--;
2833 }
2834 else if (_fatigue < _fatigueMax)
2835 {
2836 _fatigue += num2;
2837 }
2838 else
2839 {
2840 flag3 = false;
2841 }
2842 }
2843 if (_type == 12 && !mountedPlayer.MountFishronSpecial)
2844 {
2845 num = 0.5f;
2846 }
2847 float num3 = _fatigue / _fatigueMax;
2848 if (flag)
2849 {
2850 num3 = 0f;
2851 }
2852 bool flag4 = true;
2853 if (_type == 48)
2854 {
2855 flag4 = false;
2856 }
2857 float num4 = 4f * num3;
2858 float num5 = 4f * num3;
2859 bool flag5 = false;
2860 if (_type == 48)
2861 {
2862 num4 = 0f;
2863 num5 = 0f;
2864 if (!flag3)
2865 {
2866 flag5 = true;
2867 }
2868 if (mountedPlayer.controlDown)
2869 {
2870 num5 = 8f;
2871 }
2872 }
2873 if (num4 == 0f)
2874 {
2875 num4 = -0.001f;
2876 }
2877 if (num5 == 0f)
2878 {
2879 num5 = -0.001f;
2880 }
2881 float num6 = mountedPlayer.velocity.Y;
2882 if (flag4 && (mountedPlayer.controlUp || mountedPlayer.controlJump) && flag3)
2883 {
2884 num4 = -2f - 6f * (1f - num3);
2885 if (_type == 48)
2886 {
2887 num4 /= 3f;
2888 }
2889 num6 -= _data.acceleration * num;
2890 }
2891 else if (mountedPlayer.controlDown)
2892 {
2893 num6 += _data.acceleration * num;
2894 num5 = 8f;
2895 }
2896 else if (flag5)
2897 {
2898 float num7 = mountedPlayer.gravity * mountedPlayer.gravDir;
2899 num6 += num7;
2900 num5 = 4f;
2901 }
2902 else
2903 {
2904 _ = mountedPlayer.jump;
2905 }
2906 if (num6 < num4)
2907 {
2908 num6 = ((!(num4 - num6 < _data.acceleration)) ? (num6 + _data.acceleration * num) : num4);
2909 }
2910 else if (num6 > num5)
2911 {
2912 num6 = ((!(num6 - num5 < _data.acceleration)) ? (num6 - _data.acceleration * num) : num5);
2913 }
2914 mountedPlayer.velocity.Y = num6;
2915 if (num4 == -0.001f && num5 == -0.001f && num6 == -0.001f)
2916 {
2917 mountedPlayer.position.Y -= -0.001f;
2918 }
2919 mountedPlayer.fallStart = (int)(mountedPlayer.position.Y / 16f);
2920 }
2921 else if (!flag)
2922 {
2923 mountedPlayer.velocity.Y += mountedPlayer.gravity * mountedPlayer.gravDir;
2924 }
2925 else if (mountedPlayer.velocity.Y == 0f)
2926 {
2927 Vector2 velocity = Vector2.UnitY * mountedPlayer.gravDir * 1f;
2928 if (Collision.TileCollision(mountedPlayer.position, velocity, mountedPlayer.width, mountedPlayer.height, fallThrough: false, fall2: false, (int)mountedPlayer.gravDir).Y != 0f || mountedPlayer.controlDown)
2929 {
2930 mountedPlayer.velocity.Y = 0.001f;
2931 }
2932 }
2933 else if (mountedPlayer.velocity.Y == -0.001f)
2934 {
2935 mountedPlayer.velocity.Y -= -0.001f;
2936 }
2937 if (_type == 7)
2938 {
2939 float num8 = mountedPlayer.velocity.X / _data.dashSpeed;
2940 if ((double)num8 > 0.95)
2941 {
2942 num8 = 0.95f;
2943 }
2944 if ((double)num8 < -0.95)
2945 {
2946 num8 = -0.95f;
2947 }
2948 float fullRotation = (float)Math.PI / 4f * num8 / 2f;
2949 float num9 = Math.Abs(2f - (float)_frame / 2f) / 2f;
2950 Lighting.AddLight((int)(mountedPlayer.position.X + (float)(mountedPlayer.width / 2)) / 16, (int)(mountedPlayer.position.Y + (float)(mountedPlayer.height / 2)) / 16, 0.4f, 0.2f * num9, 0f);
2951 mountedPlayer.fullRotation = fullRotation;
2952 }
2953 else if (_type == 8)
2954 {
2955 float num10 = mountedPlayer.velocity.X / _data.dashSpeed;
2956 if ((double)num10 > 0.95)
2957 {
2958 num10 = 0.95f;
2959 }
2960 if ((double)num10 < -0.95)
2961 {
2962 num10 = -0.95f;
2963 }
2964 float fullRotation2 = (float)Math.PI / 4f * num10 / 2f;
2965 mountedPlayer.fullRotation = fullRotation2;
2966 DrillMountData obj = (DrillMountData)_mountSpecificData;
2967 float outerRingRotation = obj.outerRingRotation;
2968 outerRingRotation += mountedPlayer.velocity.X / 80f;
2969 if (outerRingRotation > (float)Math.PI)
2970 {
2971 outerRingRotation -= (float)Math.PI * 2f;
2972 }
2973 else if (outerRingRotation < -(float)Math.PI)
2974 {
2975 outerRingRotation += (float)Math.PI * 2f;
2976 }
2977 obj.outerRingRotation = outerRingRotation;
2978 }
2979 else if (_type == 23)
2980 {
2981 float value = (0f - mountedPlayer.velocity.Y) / _data.dashSpeed;
2982 value = MathHelper.Clamp(value, -1f, 1f);
2983 float value2 = mountedPlayer.velocity.X / _data.dashSpeed;
2984 value2 = MathHelper.Clamp(value2, -1f, 1f);
2985 float num11 = -(float)Math.PI / 16f * value * (float)mountedPlayer.direction;
2986 float num12 = (float)Math.PI / 16f * value2;
2987 float fullRotation3 = num11 + num12;
2988 mountedPlayer.fullRotation = fullRotation3;
2989 mountedPlayer.fullRotationOrigin = new Vector2(mountedPlayer.width / 2, mountedPlayer.height);
2990 }
2991 return true;
2992 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Abs(double value)
const double PI
Definition Math.cs:16
MountData _data
Definition Mount.cs:287
object _mountSpecificData
Definition Mount.cs:329
float _fatigue
Definition Mount.cs:309
bool DoesHoverIgnoresFatigue()
Definition Mount.cs:2994
int _frameState
Definition Mount.cs:301
float _fatigueMax
Definition Mount.cs:311

References Terraria.Mount._data, Terraria.Mount._fatigue, Terraria.Mount._fatigueMax, Terraria.Mount._flyTime, Terraria.Mount._frame, Terraria.Mount._frameState, Terraria.Mount._mountSpecificData, Terraria.Mount._type, System.Math.Abs(), Terraria.Mount.MountData.acceleration, Terraria.Lighting.AddLight(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.Mount.MountData.dashSpeed, Terraria.Player.defaultGravity, Terraria.Mount.DoesHoverIgnoresFatigue(), System.obj, System.Math.PI, Terraria.Collision.TileCollision(), System.value, and Microsoft.Xna.Framework.Graphics.Vector2.