Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CultistRitual.cs
Go to the documentation of this file.
3using Terraria.ID;
4
6
7public class CultistRitual
8{
9 public const int delayStart = 86400;
10
11 public const int respawnDelay = 43200;
12
13 private const int timePerCultist = 3600;
14
15 private const int recheckStart = 600;
16
17 public static int delay;
18
19 public static int recheck;
20
21 public static void UpdateTime()
22 {
23 if (Main.netMode == 1)
24 {
25 return;
26 }
28 if (delay < 0)
29 {
30 delay = 0;
31 }
33 if (recheck < 0)
34 {
35 recheck = 0;
36 }
37 if (delay == 0 && recheck == 0)
38 {
39 recheck = 600;
40 if (NPC.AnyDanger())
41 {
42 recheck *= 6;
43 }
44 else
45 {
47 }
48 }
49 }
50
51 public static void CultistSlain()
52 {
53 delay -= 3600;
54 }
55
56 public static void TabletDestroyed()
57 {
58 delay = 43200;
59 }
60
61 public static void TrySpawning(int x, int y)
62 {
63 if (!WorldGen.PlayerLOS(x - 6, y) && !WorldGen.PlayerLOS(x + 6, y) && CheckRitual(x, y))
64 {
65 NPC.NewNPC(new EntitySource_WorldEvent(), x * 16 + 8, (y - 4) * 16 - 8, 437);
66 }
67 }
68
69 private static bool CheckRitual(int x, int y)
70 {
72 {
73 return false;
74 }
75 if (y < 7 || WorldGen.SolidTile(Main.tile[x, y - 7]))
76 {
77 return false;
78 }
79 if (NPC.AnyNPCs(437))
80 {
81 return false;
82 }
83 Vector2 center = new Vector2(x * 16 + 8, y * 16 - 64 - 8 - 27);
84 Point[] spawnPoints = null;
85 if (!CheckFloor(center, out spawnPoints))
86 {
87 return false;
88 }
89 return true;
90 }
91
92 public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints)
93 {
94 Point[] array = new Point[4];
95 int num = 0;
96 Point point = Center.ToTileCoordinates();
97 for (int i = -5; i <= 5; i += 2)
98 {
99 if (i == -1 || i == 1)
100 {
101 continue;
102 }
103 for (int j = -5; j < 12; j++)
104 {
105 int num2 = point.X + i * 2;
106 int num3 = point.Y + j;
107 if ((WorldGen.SolidTile(num2, num3) || TileID.Sets.Platforms[Framing.GetTileSafely(num2, num3).type]) && (!Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1) || (!Collision.SolidTiles(num2, num2, num3 - 3, num3 - 1) && !Collision.SolidTiles(num2 + 1, num2 + 1, num3 - 3, num3 - 2) && !Collision.SolidTiles(num2 - 1, num2 - 1, num3 - 3, num3 - 2))))
108 {
109 array[num++] = new Point(num2, num3);
110 break;
111 }
112 }
113 }
114 if (num != 4)
115 {
116 spawnPoints = null;
117 return false;
118 }
119 spawnPoints = array;
120 return true;
121 }
122}
static bool SolidTiles(Vector2 position, int width, int height)
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:419
static bool CheckRitual(int x, int y)
static bool CheckFloor(Vector2 Center, out Point[] spawnPoints)
static void TrySpawning(int x, int y)
static bool[] Platforms
Definition TileID.cs:163
static int netMode
Definition Main.cs:2095
static int dungeonX
Definition Main.cs:1218
static Tile[,] tile
Definition Main.cs:1675
static int dungeonY
Definition Main.cs:1220
static int dayRate
Definition Main.cs:746
static bool hardMode
Definition Main.cs:1022
static bool AnyDanger(bool quickBossNPCCheck=false, bool ignorePillarsAndMoonlordCountdown=false)
Definition NPC.cs:77014
static bool AnyNPCs(int Type)
Definition NPC.cs:86689
static int NewNPC(IEntitySource source, int X, int Y, int Type, int Start=0, float ai0=0f, float ai1=0f, float ai2=0f, float ai3=0f, int Target=255)
Definition NPC.cs:77654
static bool downedGolemBoss
Definition NPC.cs:365
static bool downedBoss3
Definition NPC.cs:349
static bool SolidTile(Tile testTile)
static bool PlayerLOS(int x, int y)