-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathButtonDelayWorld.cs
More file actions
37 lines (30 loc) · 883 Bytes
/
ButtonDelayWorld.cs
File metadata and controls
37 lines (30 loc) · 883 Bytes
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
using Terraria.DataStructures;
using Terraria.ModLoader;
namespace MechTransfer
{
internal class ButtonDelayWorld : ModSystem
{
private Point16? buttonPosition = null;
private int delay;
private const int StartDelay = 30;
public void setPoint(Point16 p)
{
buttonPosition = p;
delay = StartDelay;
}
public bool isPoint(Point16 p, int w, int h)
{
if (!buttonPosition.HasValue)
return false;
int xOffset = p.X - buttonPosition.Value.X;
int yOffset = p.Y - buttonPosition.Value.Y;
return xOffset >= 0 && yOffset >= 0 && xOffset < w && yOffset < h;
}
public override void PostDrawTiles()
{
delay--;
if (delay < 1)
buttonPosition = null;
}
}
}