Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MysticLogFairiesEvent.cs
Go to the documentation of this file.
1using System;
6
8
10{
11 private bool _canSpawnFairies;
12
14
15 private const int DELAY_BETWEEN_ATTEMPTS = 60;
16
18
19 public void WorldClear()
20 {
21 _canSpawnFairies = false;
24 }
25
26 public void StartWorld()
27 {
28 if (Main.netMode != 1)
29 {
31 }
32 }
33
34 public void StartNight()
35 {
36 if (Main.netMode != 1)
37 {
38 _canSpawnFairies = true;
41 }
42 }
43
44 public void UpdateTime()
45 {
47 {
50 {
53 }
54 }
55 }
56
57 private bool IsAGoodTime()
58 {
59 if (Main.dayTime)
60 {
61 return false;
62 }
63 if (!Main.remixWorld)
64 {
65 if (Main.time < 6480.0000965595245)
66 {
67 return false;
68 }
69 if (Main.time > 25920.000386238098)
70 {
71 return false;
72 }
73 }
74 return true;
75 }
76
77 private void TrySpawningFairies()
78 {
80 {
81 return;
82 }
84 bool flag = false;
85 for (int i = 0; i < Main.dayRate; i++)
86 {
87 if (Main.rand.Next(oneOverSpawnChance) == 0)
88 {
89 flag = true;
90 break;
91 }
92 }
93 if (!flag)
94 {
95 return;
96 }
97 int index = Main.rand.Next(_stumpCoords.Count);
99 Vector2 vector = p.ToWorldCoordinates(24f);
100 vector.Y -= 50f;
101 if (WorldGen.PlayerLOS(p.X, p.Y))
102 {
103 return;
104 }
105 int num = Main.rand.Next(1, 4);
106 if (Main.rand.Next(7) == 0)
107 {
108 num++;
109 }
110 int num2 = Utils.SelectRandom(Main.rand, new short[3] { 585, 584, 583 });
111 for (int j = 0; j < num; j++)
112 {
113 num2 = Utils.SelectRandom(Main.rand, new short[3] { 585, 584, 583 });
114 if (Main.tenthAnniversaryWorld && Main.rand.Next(4) != 0)
115 {
116 num2 = 583;
117 }
118 int num3 = NPC.NewNPC(new EntitySource_WorldEvent(), (int)vector.X, (int)vector.Y, num2);
119 if (Main.netMode == 2 && num3 < 200)
120 {
121 NetMessage.SendData(23, -1, -1, null, num3);
122 }
123 }
124 _canSpawnFairies = false;
125 }
126
127 public void FallenLogDestroyed()
128 {
129 if (Main.netMode != 1)
130 {
132 }
133 }
134
136 {
138 NPC.fairyLog = false;
139 int num = (int)Main.worldSurface - 10;
140 int num2 = 100;
141 int num3 = Main.maxTilesX - 100;
142 if (Main.remixWorld)
143 {
144 num = Main.maxTilesY - 350;
145 num2 = (int)Main.rockLayer;
146 }
147 int num4 = 3;
148 int num5 = 2;
150 for (int i = 100; i < num3; i += num4)
151 {
152 for (int num6 = num; num6 >= num2; num6 -= num5)
153 {
154 Tile tile = Main.tile[i, num6];
155 if (tile.active() && tile.type == 488 && tile.liquid == 0)
156 {
157 list.Add(new Point(i, num6));
158 NPC.fairyLog = true;
159 }
160 }
161 }
162 foreach (Point item in list)
163 {
165 }
166 }
167
169 {
171 Point result = stumpRandomPoint;
172 result.X -= tile.frameX / 18;
173 result.Y -= tile.frameY / 18;
174 return result;
175 }
176
178 {
179 int num = 1;
180 MoonPhase moonPhase = Main.GetMoonPhase();
181 num = ((moonPhase != 0 && moonPhase != MoonPhase.Empty) ? 10800 : 3600);
182 return num / 60;
183 }
184}
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static double time
Definition Main.cs:1284
static MoonPhase GetMoonPhase()
Definition Main.cs:3058
static double worldSurface
Definition Main.cs:1272
static int netMode
Definition Main.cs:2095
static double rockLayer
Definition Main.cs:1274
static bool dayTime
Definition Main.cs:1282
static bool bloodMoon
Definition Main.cs:1296
static Tile[,] tile
Definition Main.cs:1675
static int invasionType
Definition Main.cs:1970
static UnifiedRandom rand
Definition Main.cs:1387
static float maxRaining
Definition Main.cs:1304
static bool tenthAnniversaryWorld
Definition Main.cs:343
static int dayRate
Definition Main.cs:746
static bool snowMoon
Definition Main.cs:1300
static bool pumpkinMoon
Definition Main.cs:1298
static bool remixWorld
Definition Main.cs:349
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 int MoonLordCountdown
Definition NPC.cs:51
static void SendData(int msgType, int remoteClient=-1, int ignoreClient=-1, NetworkText text=null, int number=0, float number2=0f, float number3=0f, float number4=0f, int number5=0, int number6=0, int number7=0)
Definition NetMessage.cs:88
byte liquid
Definition Tile.cs:12
ushort type
Definition Tile.cs:8
bool active()
Definition Tile.cs:565
static bool PlayerLOS(int x, int y)