Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Sign.cs
Go to the documentation of this file.
1namespace Terraria;
2
3public class Sign
4{
5 public const int maxSigns = 1000;
6
7 public int x;
8
9 public int y;
10
11 public string text;
12
13 public static void KillSign(int x, int y)
14 {
15 for (int i = 0; i < 1000; i++)
16 {
17 if (Main.sign[i] != null && Main.sign[i].x == x && Main.sign[i].y == y)
18 {
19 Main.sign[i] = null;
20 }
21 }
22 }
23
24 public static int ReadSign(int i, int j, bool CreateIfMissing = true)
25 {
26 int num = Main.tile[i, j].frameX / 18;
27 int num2 = Main.tile[i, j].frameY / 18;
28 num %= 2;
29 int num3 = i - num;
30 int num4 = j - num2;
31 if (!Main.tileSign[Main.tile[num3, num4].type])
32 {
33 KillSign(num3, num4);
34 return -1;
35 }
36 int num5 = -1;
37 for (int k = 0; k < 1000; k++)
38 {
39 if (Main.sign[k] != null && Main.sign[k].x == num3 && Main.sign[k].y == num4)
40 {
41 num5 = k;
42 break;
43 }
44 }
45 if (num5 < 0 && CreateIfMissing)
46 {
47 for (int l = 0; l < 1000; l++)
48 {
49 if (Main.sign[l] == null)
50 {
51 num5 = l;
52 Main.sign[l] = new Sign();
53 Main.sign[l].x = num3;
54 Main.sign[l].y = num4;
55 Main.sign[l].text = "";
56 break;
57 }
58 }
59 }
60 return num5;
61 }
62
63 public static void TextSign(int i, string text)
64 {
65 if (Main.tile[Main.sign[i].x, Main.sign[i].y] == null || !Main.tile[Main.sign[i].x, Main.sign[i].y].active() || !Main.tileSign[Main.tile[Main.sign[i].x, Main.sign[i].y].type])
66 {
67 Main.sign[i] = null;
68 }
69 else
70 {
71 Main.sign[i].text = text;
72 }
73 }
74
75 public override string ToString()
76 {
77 return "x" + x + "\ty" + y + "\t" + text;
78 }
79}
static bool[] tileSign
Definition Main.cs:1505
static Tile[,] tile
Definition Main.cs:1675
static Sign[] sign
Definition Main.cs:1701
int y
Definition Sign.cs:9
override string ToString()
Definition Sign.cs:75
string text
Definition Sign.cs:11
static int ReadSign(int i, int j, bool CreateIfMissing=true)
Definition Sign.cs:24
static void TextSign(int i, string text)
Definition Sign.cs:63
static void KillSign(int x, int y)
Definition Sign.cs:13
const int maxSigns
Definition Sign.cs:5
int x
Definition Sign.cs:7