Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Entity.cs
Go to the documentation of this file.
1using System;
3
4namespace Terraria;
5
6public abstract class Entity
7{
8 public int whoAmI;
9
10 public bool active;
11
12 internal long entityId;
13
15
17
19
21
22 public int oldDirection;
23
24 public int direction = 1;
25
26 public int width;
27
28 public int height;
29
30 public bool wet;
31
32 public bool shimmerWet;
33
34 public bool honeyWet;
35
36 public byte wetCount;
37
38 public bool lavaWet;
39
40 public virtual Vector2 VisualPosition => position;
41
43 {
44 get
45 {
46 return new Vector2(position.X + (float)(width / 2), position.Y + (float)(height / 2));
47 }
48 set
49 {
50 position = new Vector2(value.X - (float)(width / 2), value.Y - (float)(height / 2));
51 }
52 }
53
55 {
56 get
57 {
58 return new Vector2(position.X, position.Y + (float)(height / 2));
59 }
60 set
61 {
62 position = new Vector2(value.X, value.Y - (float)(height / 2));
63 }
64 }
65
67 {
68 get
69 {
70 return new Vector2(position.X + (float)width, position.Y + (float)(height / 2));
71 }
72 set
73 {
74 position = new Vector2(value.X - (float)width, value.Y - (float)(height / 2));
75 }
76 }
77
78 public Vector2 Top
79 {
80 get
81 {
82 return new Vector2(position.X + (float)(width / 2), position.Y);
83 }
84 set
85 {
86 position = new Vector2(value.X - (float)(width / 2), value.Y);
87 }
88 }
89
91 {
92 get
93 {
94 return position;
95 }
96 set
97 {
99 }
100 }
101
103 {
104 get
105 {
106 return new Vector2(position.X + (float)width, position.Y);
107 }
108 set
109 {
110 position = new Vector2(value.X - (float)width, value.Y);
111 }
112 }
113
115 {
116 get
117 {
118 return new Vector2(position.X + (float)(width / 2), position.Y + (float)height);
119 }
120 set
121 {
122 position = new Vector2(value.X - (float)(width / 2), value.Y - (float)height);
123 }
124 }
125
127 {
128 get
129 {
130 return new Vector2(position.X, position.Y + (float)height);
131 }
132 set
133 {
134 position = new Vector2(value.X, value.Y - (float)height);
135 }
136 }
137
139 {
140 get
141 {
142 return new Vector2(position.X + (float)width, position.Y + (float)height);
143 }
144 set
145 {
146 position = new Vector2(value.X - (float)width, value.Y - (float)height);
147 }
148 }
149
151 {
152 get
153 {
154 return new Vector2(width, height);
155 }
156 set
157 {
158 width = (int)value.X;
159 height = (int)value.Y;
160 }
161 }
162
164 {
165 get
166 {
167 return new Rectangle((int)position.X, (int)position.Y, width, height);
168 }
169 set
170 {
171 position = new Vector2(value.X, value.Y);
172 width = value.Width;
173 height = value.Height;
174 }
175 }
176
177 public float AngleTo(Vector2 Destination)
178 {
179 return (float)Math.Atan2(Destination.Y - Center.Y, Destination.X - Center.X);
180 }
181
182 public float AngleFrom(Vector2 Source)
183 {
184 return (float)Math.Atan2(Center.Y - Source.Y, Center.X - Source.X);
185 }
186
187 public float Distance(Vector2 Other)
188 {
189 return Vector2.Distance(Center, Other);
190 }
191
193 {
195 }
196
197 public Vector2 DirectionTo(Vector2 Destination)
198 {
199 return Vector2.Normalize(Destination - Center);
200 }
201
203 {
204 return Vector2.Normalize(Center - Source);
205 }
206
207 public bool WithinRange(Vector2 Target, float MaxRange)
208 {
209 return Vector2.DistanceSquared(Center, Target) <= MaxRange * MaxRange;
210 }
211}
static double Atan2(double y, double x)
Vector2 BottomRight
Definition Entity.cs:139
Vector2 DirectionFrom(Vector2 Source)
Definition Entity.cs:202
long entityId
Definition Entity.cs:12
float AngleTo(Vector2 Destination)
Definition Entity.cs:177
Vector2 oldPosition
Definition Entity.cs:18
bool honeyWet
Definition Entity.cs:34
Vector2 TopRight
Definition Entity.cs:103
Vector2 Center
Definition Entity.cs:43
Vector2 Size
Definition Entity.cs:151
Vector2 BottomLeft
Definition Entity.cs:127
Vector2 TopLeft
Definition Entity.cs:91
bool shimmerWet
Definition Entity.cs:32
float DistanceSQ(Vector2 Other)
Definition Entity.cs:192
float AngleFrom(Vector2 Source)
Definition Entity.cs:182
Vector2 Top
Definition Entity.cs:79
int oldDirection
Definition Entity.cs:22
Vector2 Bottom
Definition Entity.cs:115
Vector2 velocity
Definition Entity.cs:16
Vector2 Left
Definition Entity.cs:55
float Distance(Vector2 Other)
Definition Entity.cs:187
Rectangle Hitbox
Definition Entity.cs:164
Vector2 position
Definition Entity.cs:14
Vector2 oldVelocity
Definition Entity.cs:20
byte wetCount
Definition Entity.cs:36
Vector2 DirectionTo(Vector2 Destination)
Definition Entity.cs:197
virtual Vector2 VisualPosition
Definition Entity.cs:40
bool WithinRange(Vector2 Target, float MaxRange)
Definition Entity.cs:207
Vector2 Right
Definition Entity.cs:67
static float DistanceSquared(Vector2 value1, Vector2 value2)
Definition Vector2.cs:107
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91