Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WorldUIAnchor.cs
Go to the documentation of this file.
1
using
System
;
2
using
Microsoft.Xna.Framework
;
3
4
namespace
Terraria.GameContent.UI
;
5
6
public
class
WorldUIAnchor
7
{
8
public
enum
AnchorType
9
{
10
Entity
,
11
Tile
,
12
Pos
,
13
None
14
}
15
16
public
AnchorType
type
;
17
18
public
Entity
entity
;
19
20
public
Vector2
pos
=
Vector2
.
Zero
;
21
22
public
Vector2
size
=
Vector2
.
Zero
;
23
24
public
WorldUIAnchor
()
25
{
26
type
=
AnchorType
.None;
27
}
28
29
public
WorldUIAnchor
(
Entity
anchor)
30
{
31
type
=
AnchorType
.Entity;
32
entity
= anchor;
33
}
34
35
public
WorldUIAnchor
(
Vector2
anchor)
36
{
37
type
=
AnchorType
.Pos;
38
pos
= anchor;
39
}
40
41
public
WorldUIAnchor
(
int
topLeftX,
int
topLeftY,
int
width,
int
height)
42
{
43
type
=
AnchorType
.Tile;
44
pos
=
new
Vector2
((
float
)topLeftX + (
float
)width / 2f, (
float
)topLeftY + (
float
)height / 2f) * 16f;
45
size
=
new
Vector2
(width, height) * 16f;
46
}
47
48
public
bool
InRange
(
Vector2
target,
float
tileRangeX,
float
tileRangeY)
49
{
50
switch
(
type
)
51
{
52
case
AnchorType
.Entity:
53
if
(
Math
.
Abs
(target.
X
-
entity
.
Center
.
X
) <= tileRangeX * 16f + (
float
)
entity
.
width
/ 2f)
54
{
55
return
Math
.
Abs
(target.
Y
-
entity
.
Center
.
Y
) <= tileRangeY * 16f + (float)
entity
.
height
/ 2f;
56
}
57
return
false
;
58
case
AnchorType
.Pos:
59
if
(
Math
.
Abs
(target.
X
-
pos
.
X
) <= tileRangeX * 16f)
60
{
61
return
Math
.
Abs
(target.
Y
-
pos
.
Y
) <= tileRangeY * 16f;
62
}
63
return
false
;
64
case
AnchorType
.Tile:
65
if
(
Math
.
Abs
(target.
X
-
pos
.
X
) <= tileRangeX * 16f +
size
.
X
/ 2f)
66
{
67
return
Math
.
Abs
(target.
Y
-
pos
.
Y
) <= tileRangeY * 16f + size.Y / 2f;
68
}
69
return
false
;
70
default
:
71
return
true
;
72
}
73
}
74
}
System.Math.Abs
static double Abs(double value)
System.Math
Definition
Math.cs:13
Terraria.Entity.Center
Vector2 Center
Definition
Entity.cs:43
Terraria.Entity.width
int width
Definition
Entity.cs:26
Terraria.Entity.height
int height
Definition
Entity.cs:28
Terraria.Entity
Definition
Entity.cs:7
Terraria.GameContent.UI.WorldUIAnchor.pos
Vector2 pos
Definition
WorldUIAnchor.cs:20
Terraria.GameContent.UI.WorldUIAnchor.InRange
bool InRange(Vector2 target, float tileRangeX, float tileRangeY)
Definition
WorldUIAnchor.cs:48
Terraria.GameContent.UI.WorldUIAnchor.size
Vector2 size
Definition
WorldUIAnchor.cs:22
Terraria.GameContent.UI.WorldUIAnchor.WorldUIAnchor
WorldUIAnchor(Entity anchor)
Definition
WorldUIAnchor.cs:29
Terraria.GameContent.UI.WorldUIAnchor.entity
Entity entity
Definition
WorldUIAnchor.cs:18
Terraria.GameContent.UI.WorldUIAnchor.AnchorType
AnchorType
Definition
WorldUIAnchor.cs:9
Terraria.GameContent.UI.WorldUIAnchor.AnchorType.Entity
@ Entity
Terraria.GameContent.UI.WorldUIAnchor.AnchorType.None
@ None
Terraria.GameContent.UI.WorldUIAnchor.AnchorType.Tile
@ Tile
Terraria.GameContent.UI.WorldUIAnchor.AnchorType.Pos
@ Pos
Terraria.GameContent.UI.WorldUIAnchor.WorldUIAnchor
WorldUIAnchor(Vector2 anchor)
Definition
WorldUIAnchor.cs:35
Terraria.GameContent.UI.WorldUIAnchor.type
AnchorType type
Definition
WorldUIAnchor.cs:16
Terraria.GameContent.UI.WorldUIAnchor.WorldUIAnchor
WorldUIAnchor()
Definition
WorldUIAnchor.cs:24
Terraria.GameContent.UI.WorldUIAnchor.WorldUIAnchor
WorldUIAnchor(int topLeftX, int topLeftY, int width, int height)
Definition
WorldUIAnchor.cs:41
Terraria.GameContent.UI.WorldUIAnchor
Definition
WorldUIAnchor.cs:7
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System
Definition
BlockingCollection.cs:8
Terraria.GameContent.UI
Definition
BigProgressBarCache.cs:1
Microsoft.Xna.Framework.Vector2.X
float X
Definition
Vector2.cs:14
Microsoft.Xna.Framework.Vector2.Zero
static Vector2 Zero
Definition
Vector2.cs:27
Microsoft.Xna.Framework.Vector2.Y
float Y
Definition
Vector2.cs:17
Microsoft.Xna.Framework.Vector2
Definition
Vector2.cs:12
source
Terraria.GameContent.UI
WorldUIAnchor.cs
Generated by
1.10.0