forked from bippity/AdvancedWarpplates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwarpplate.cs
84 lines (77 loc) · 2.6 KB
/
warpplate.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
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
namespace AdvancedWarpplates
{
/// <summary>
/// Contains the properties of a warpplate in the world
/// </summary>
public class Warpplate
{
public Rectangle Area { get; set; }
public Vector2 WarpplatePos { get; set; }
public string Name { get; set; }
public string Destination { get; set; }
public string WorldID { get; set; }
public List<int> AllowedIDs { get; set; }
public int Type { get; set; }
public int Delay { get; set; }
public string Label
{
get { return _label ?? Name; }
set { _label = value; }
}
private string _label;
public Warpplate()
{
WarpplatePos = Vector2.Zero;
Area = Rectangle.Empty;
Name = string.Empty;
Destination = string.Empty;
WorldID = string.Empty;
AllowedIDs = new List<int>();
Type = 0;
}
public Warpplate(Vector2 warpplatepos, Rectangle Warpplate, string name, string destination, bool disablebuild, string WarpplateWorldIDz, string label, int type)
: this()
{
WarpplatePos = warpplatepos;
Area = Warpplate;
Name = name;
Label = label;
Destination = destination;
WorldID = WarpplateWorldIDz;
Delay = 4;
Type = type;
}
/// <summary>
/// Checks whether a given point is inside the warpplate's area
/// </summary>
/// <param name="point">The point to check</param>
/// <returns>Whether a given point is inside the warpplate's area</returns>
public bool InArea(Rectangle point)
{
if (Area.Contains(point.X, point.Y))
{
return true;
}
return false;
}
/// <summary>
/// Gets the destination name, or if there is no destination gets the default "(none)"
/// </summary>
/// <returns>Destination name or default</returns>
public string GetDestinationOrDefault()
{
return Destination ?? "(none)";
}
/// <summary>
/// Gets the label, or if there is no label gets the default
/// </summary>
/// <returns>Label or default label</returns>
public string GetLabelOrDefault()
{
return _label ?? Name + " (default)";
}
}
}