/
AGSBoundingBoxes.cs
64 lines (55 loc) · 2.58 KB
/
AGSBoundingBoxes.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
namespace AGS.API
{
/// <summary>
/// The bounding boxes used for the entity.
/// </summary>
public class AGSBoundingBoxes
{
//todo: make those properties readonly, should only be set by the engine, should be in the API
#region AGSBoundingBoxes implementation
/// <summary>
/// Gets or sets the bounding box in viewport coordinages (used for rendering the entity).
/// This should be only set from the engine.
/// </summary>
/// <value>The render box.</value>
public AGSBoundingBox ViewportBox { get; set; }
/// <summary>
/// Gets or sets the bounding box in world coordinates (used for collision checks).
/// This should be only set from the engine.
/// </summary>
/// <value>The hit-test box.</value>
public AGSBoundingBox WorldBox { get; set; }
/// <summary>
/// Gets or sets the texture box which specifies which part of the texture is used on the render box.
/// Usually this would be the entire texture: (0,0)-(1,1), unless cropped by a cropping component.
/// This should be only set from the engine.
/// </summary>
/// <value>The texture box.</value>
public FourCorners<Vector2> TextureBox { get; set; }
/// <summary>
/// Gets or sets the viewport bounding box before the object was cropped.
/// This will usually be the same as the viewport box unless the object was actually cropped (i.e if
/// it had the <see cref="ICropSelfComponent"/> attached, maybe inside a scrolling panel, for example).
/// </summary>
/// <value>The pre crop render box.</value>
public AGSBoundingBox PreCropViewportBox { get; set; }
#endregion
public bool Equals(AGSBoundingBoxes boxes)
{
if (this == boxes) return true;
if (boxes == null) return false;
if (TextureBox == null && boxes.TextureBox != null) return false;
if (TextureBox != null && boxes.TextureBox == null) return false;
if (TextureBox != null && !TextureBox.Equals(boxes.TextureBox)) return false;
return ViewportBox.Equals(boxes.ViewportBox) && WorldBox.Equals(boxes.WorldBox)
&& PreCropViewportBox.Equals(boxes.PreCropViewportBox);
}
public void CopyFrom(AGSBoundingBoxes boxes)
{
ViewportBox = boxes.ViewportBox;
WorldBox = boxes.WorldBox;
PreCropViewportBox = boxes.PreCropViewportBox;
TextureBox = boxes.TextureBox;
}
}
}