TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
CultistRitual.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework;
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 double delay;
18
19 public static double recheck;
20
21 public static void UpdateTime()
22 {
23 if (Main.netMode == 1)
24 {
25 return;
26 }
28 if (delay < 0.0)
29 {
30 delay = 0.0;
31 }
33 if (recheck < 0.0)
34 {
35 recheck = 0.0;
36 }
37 if (delay == 0.0 && recheck == 0.0)
38 {
39 recheck = 600.0;
40 if (NPC.AnyDanger())
41 {
42 recheck *= 6.0;
43 }
44 else
45 {
47 }
48 }
49 }
50
51 public static void CultistSlain()
52 {
53 delay -= 3600.0;
54 }
55
56 public static void TabletDestroyed()
57 {
58 delay = 43200.0;
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 {
71 //IL_0064: Unknown result type (might be due to invalid IL or missing references)
72 if (delay != 0.0 || !Main.hardMode || !NPC.downedGolemBoss || !NPC.downedBoss3)
73 {
74 return false;
75 }
76 if (y < 7 || WorldGen.SolidTile(Main.tile[x, y - 7]))
77 {
78 return false;
79 }
80 if (NPC.AnyNPCs(437))
81 {
82 return false;
83 }
84 Vector2 center = new Vector2((float)(x * 16 + 8), (float)(y * 16 - 64 - 8 - 27));
85 Point[] spawnPoints = null;
87 {
88 return false;
89 }
90 return true;
91 }
92
93 public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints)
94 {
95 //IL_0009: Unknown result type (might be due to invalid IL or missing references)
96 //IL_000a: Unknown result type (might be due to invalid IL or missing references)
97 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
98 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
99 //IL_003b: Unknown result type (might be due to invalid IL or missing references)
100 //IL_00cf: Unknown result type (might be due to invalid IL or missing references)
101 //IL_00d4: Unknown result type (might be due to invalid IL or missing references)
102 Point[] array = (Point[])(object)new Point[4];
103 int num = 0;
104 Point point = Center.ToTileCoordinates();
105 for (int i = -5; i <= 5; i += 2)
106 {
107 if (i == -1 || i == 1)
108 {
109 continue;
110 }
111 for (int j = -5; j < 12; j++)
112 {
113 int num2 = point.X + i * 2;
114 int num3 = point.Y + j;
115 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))))
116 {
117 array[num++] = new Point(num2, num3);
118 break;
119 }
120 }
121 }
122 if (num != 4)
123 {
124 spawnPoints = null;
125 return false;
126 }
127 spawnPoints = array;
128 return true;
129 }
130}
static bool SolidTiles(Vector2 position, int width, int height)
Inconsistently used by vanilla when spawning more exotic things like the lunatic pillars,...
static Tile GetTileSafely(Vector2 position)
Definition Framing.cs:421
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:219
static double desiredWorldEventsUpdateRate
Definition Main.cs:2724
static int netMode
Denotes the current network mode: 0 for single player client, 1 for multiplayer client,...
Definition Main.cs:2182
static int dungeonX
Definition Main.cs:1293
static int dungeonY
Definition Main.cs:1295
static Tilemap tile
Definition Main.cs:1820
static bool hardMode
Definition Main.cs:1091
static bool AnyDanger(bool quickBossNPCCheck=false, bool ignorePillarsAndMoonlordCountdown=false)
Definition NPC.cs:90479
static bool AnyNPCs(int Type)
Returns true if there are any active NPC in the world of the given NPC type (F:Terraria....
Definition NPC.cs:106615
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)
Spawns an NPC into the game world with the given type. This method should not be called on multipla...
Definition NPC.cs:91239
static bool downedGolemBoss
Denotes whether or not Golem has been defeated at least once in the current world.
Definition NPC.cs:842
static bool downedBoss3
Denotes whether or not Skeletron has been defeated at least once in the current world.
Definition NPC.cs:801
static bool SolidTile(Tile testTile)
static bool PlayerLOS(int x, int y)