forked from sruon/ffxivlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Movement.cs
160 lines (124 loc) · 4.75 KB
/
Movement.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.Runtime.InteropServices;
namespace ffxivlib
{
public class Movement : BaseObject<Movement.MOVEMENTINFO>
{
#region Constructor
public Movement(MOVEMENTINFO structure, IntPtr address)
: base(structure, address)
{
Initialize();
}
#endregion
#region Properties
public bool IsMoving { get; set; }
public bool IsHeading { get; set; }
public bool IsWalking { get; set; }
public bool IsFollowing { get; set; }
public float CurrentSpeed { get; set; }
public float ForwardSpeed { get; set; }
public float SideSpeed { get; set; }
public float BackwardSpeed { get; set; }
public float Heading { get; set; }
public float X { get; set; }
public float Z { get; set; }
public float Y { get; set; }
public bool IsHeadingLeft { get; set; }
public bool IsHeadingRight { get; set; }
public bool IsMovingRight { get; set; }
public bool IsMovingLeft { get; set; }
public bool IsMovingBackward { get; set; }
public bool IsMovingForward { get; set; }
#endregion
#region Unmanaged structure
[StructLayout(LayoutKind.Explicit, Pack = 1)]
public struct MOVEMENTINFO
{
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0)] public bool IsMoving;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x1)] public bool IsHeading;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x2)] public bool IsWalking;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x4)] public bool IsFollowing;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x18)] public float CurrentSpeed;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x20)] public float ForwardSpeed;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x28)] public float SideSpeed;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x30)] public float BackwardSpeed;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x278)] public float Heading;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x284)] public float X;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x288)] public float Z;
[MarshalAs(UnmanagedType.R4)] [FieldOffset(0x28C)] public float Y;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x524)] public bool IsHeadingLeft;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x530)] public bool IsHeadingRight;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x534)] public bool IsMovingRight;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x564)] public bool IsMovingLeft;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x56C)] public bool IsMovingBackward;
[MarshalAs(UnmanagedType.I1)] [FieldOffset(0x57C)] public bool IsMovingForward;
};
#endregion
#region Helper methods
/// <summary>
/// Start moving to the right.
/// </summary>
public void MoveRight()
{
this.Modify("IsMovingRight", true);
}
/// <summary>
/// Start moving to the left.
/// </summary>
public void MoveLeft()
{
this.Modify("IsMovingLeft", true);
}
/// <summary>
/// Start moving forward.
/// </summary>
public void MoveForward()
{
this.Modify("IsMovingForward", true);
}
/// <summary>
/// Start moving backward.
/// </summary>
public void MoveBackward()
{
this.Modify("IsMovingBackward", true);
}
/// <summary>
/// Start heading left.
/// </summary>
public void HeadLeft()
{
this.Modify("IsHeadingLeft", true);
}
/// <summary>
/// Start heading right.
/// </summary>
public void HeadRight()
{
this.Modify("IsHeadingRight", true);
}
/// <summary>
/// Stop any movement.
/// </summary>
public void StopMoving()
{
this.Modify("IsMovingRight", false);
this.Modify("IsMovingLeft", false);
this.Modify("IsMovingForward", false);
this.Modify("IsMovingBackward", false);
this.Modify("IsHeadingLeft", false);
this.Modify("IsHeadingRight", false);
}
#endregion
}
public partial class FFXIVLIB
{
public Movement GetMovement()
{
IntPtr pointer = _mr.ResolvePointerPath(Constants.MOVEMENTPTR);
var movementInfo = new Movement(_mr.CreateStructFromAddress<Movement.MOVEMENTINFO>(pointer), pointer);
return movementInfo;
}
}
}