Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
DelegateMethods.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8
9namespace Terraria;
10
11public static class DelegateMethods
12{
13 public static class CharacterPreview
14 {
15 public static void EtsyPet(Projectile proj, bool walking)
16 {
17 Float(proj, walking);
18 if (walking)
19 {
20 float num = (float)Main.timeForVisualEffects % 90f / 90f;
21 proj.localAI[1] = (float)Math.PI * 2f * num;
22 }
23 else
24 {
25 proj.localAI[1] = 0f;
26 }
27 }
28
29 public static void CompanionCubePet(Projectile proj, bool walking)
30 {
31 if (walking)
32 {
33 float percent = (float)Main.timeForVisualEffects % 30f / 30f;
34 float percent2 = (float)Main.timeForVisualEffects % 120f / 120f;
35 float num = Utils.MultiLerp(percent, 0f, 0f, 16f, 20f, 20f, 16f, 0f, 0f);
36 float num2 = Utils.MultiLerp(percent2, 0f, 0f, 0.25f, 0.25f, 0.5f, 0.5f, 0.75f, 0.75f, 1f, 1f);
37 proj.position.Y -= num;
38 proj.rotation = (float)Math.PI * 2f * num2;
39 }
40 else
41 {
42 proj.rotation = 0f;
43 }
44 }
45
46 public static void BerniePet(Projectile proj, bool walking)
47 {
48 if (walking)
49 {
50 proj.position.X += 6f;
51 }
52 }
53
54 public static void SlimePet(Projectile proj, bool walking)
55 {
56 if (walking)
57 {
58 float percent = (float)Main.timeForVisualEffects % 30f / 30f;
59 proj.position.Y -= Utils.MultiLerp(percent, 0f, 0f, 16f, 20f, 20f, 16f, 0f, 0f);
60 }
61 }
62
63 public static void WormPet(Projectile proj, bool walking)
64 {
65 float num = -0.3985988f;
66 Vector2 vector = (Vector2.UnitY * 2f).RotatedBy(num);
67 Vector2 position = proj.position;
68 int num2 = proj.oldPos.Length;
69 if (proj.type == 893)
70 {
71 num2 = proj.oldPos.Length - 30;
72 }
73 for (int i = 0; i < proj.oldPos.Length; i++)
74 {
75 position -= vector;
76 if (i < num2)
77 {
78 proj.oldPos[i] = position;
79 }
80 else if (i > 0)
81 {
82 proj.oldPos[i] = proj.oldPos[i - 1];
83 }
84 vector = vector.RotatedBy(-0.05235987901687622);
85 }
86 proj.rotation = vector.ToRotation() + (float)Math.PI / 10f + (float)Math.PI;
87 if (proj.type == 887)
88 {
89 proj.rotation += (float)Math.PI / 8f;
90 }
91 if (proj.type == 893)
92 {
93 proj.rotation += (float)Math.PI / 2f;
94 }
95 }
96
97 public static void FloatAndSpinWhenWalking(Projectile proj, bool walking)
98 {
99 Float(proj, walking);
100 if (walking)
101 {
102 proj.rotation = (float)Math.PI * 2f * ((float)Main.timeForVisualEffects % 20f / 20f);
103 }
104 else
105 {
106 proj.rotation = 0f;
107 }
108 }
109
110 public static void FloatAndRotateForwardWhenWalking(Projectile proj, bool walking)
111 {
112 Float(proj, walking);
113 RotateForwardWhenWalking(proj, walking);
114 }
115
116 public static void Float(Projectile proj, bool walking)
117 {
118 float num = 0.5f;
119 float num2 = (float)Main.timeForVisualEffects % 60f / 60f;
120 proj.position.Y += 0f - num + (float)(Math.Cos(num2 * ((float)Math.PI * 2f) * 2f) * (double)(num * 2f));
121 }
122
123 public static void RotateForwardWhenWalking(Projectile proj, bool walking)
124 {
125 if (walking)
126 {
127 proj.rotation = (float)Math.PI / 6f;
128 }
129 else
130 {
131 proj.rotation = 0f;
132 }
133 }
134 }
135
136 public static class Mount
137 {
138 public static bool NoHandPosition(Player player, out Vector2? position)
139 {
140 position = null;
141 return true;
142 }
143
144 public static bool WolfMouthPosition(Player player, out Vector2? position)
145 {
146 Vector2 spinningpoint = new Vector2(player.direction * 22, player.gravDir * -6f);
147 position = player.RotatedRelativePoint(player.MountedCenter, reverseRotation: false, addGfxOffY: false) + spinningpoint.RotatedBy(player.fullRotation);
148 return true;
149 }
150 }
151
152 public static class Minecart
153 {
154 public static Vector2 rotationOrigin;
155
156 public static float rotation;
157
158 public static void Sparks(Vector2 dustPosition)
159 {
160 dustPosition += new Vector2((Main.rand.Next(2) == 0) ? 13 : (-13), 0f).RotatedBy(rotation);
161 int num = Dust.NewDust(dustPosition, 1, 1, 213, Main.rand.Next(-2, 3), Main.rand.Next(-2, 3));
162 Main.dust[num].noGravity = true;
163 Main.dust[num].fadeIn = Main.dust[num].scale + 1f + 0.01f * (float)Main.rand.Next(0, 51);
164 Main.dust[num].noGravity = true;
165 Main.dust[num].velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
166 Main.dust[num].velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
167 Main.dust[num].velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
168 Main.dust[num].position.Y -= 4f;
169 if (Main.rand.Next(3) != 0)
170 {
171 Main.dust[num].noGravity = false;
172 }
173 else
174 {
175 Main.dust[num].scale *= 0.6f;
176 }
177 }
178
179 public static void JumpingSound(Player Player, Vector2 Position, int Width, int Height)
180 {
181 }
182
183 public static void LandingSound(Player Player, Vector2 Position, int Width, int Height)
184 {
185 SoundEngine.PlaySound(SoundID.Item53, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
186 }
187
188 public static void BumperSound(Player Player, Vector2 Position, int Width, int Height)
189 {
190 SoundEngine.PlaySound(SoundID.Item56, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
191 }
192
193 public static void SpawnFartCloud(Player Player, Vector2 Position, int Width, int Height, bool useDelay = true)
194 {
195 if (useDelay)
196 {
198 {
199 return;
200 }
201 Player.fartKartCloudDelay = 20;
202 }
203 float num = 10f;
204 float y = -4f;
205 Vector2 vector = Position + new Vector2(Width / 2 - 18, Height - 16);
206 Vector2 vector2 = Player.velocity * 0.1f;
207 if (vector2.Length() > 2f)
208 {
209 vector2 = vector2.SafeNormalize(Vector2.Zero) * 2f;
210 }
211 int num2 = Gore.NewGore(vector + new Vector2(0f, y), Vector2.Zero, Main.rand.Next(435, 438));
212 Main.gore[num2].velocity *= 0.2f;
213 Main.gore[num2].velocity += vector2;
214 Main.gore[num2].velocity.Y *= 0.75f;
215 num2 = Gore.NewGore(vector + new Vector2(0f - num, y), Vector2.Zero, Main.rand.Next(435, 438));
216 Main.gore[num2].velocity *= 0.2f;
217 Main.gore[num2].velocity += vector2;
218 Main.gore[num2].velocity.Y *= 0.75f;
219 num2 = Gore.NewGore(vector + new Vector2(num, y), Vector2.Zero, Main.rand.Next(435, 438));
220 Main.gore[num2].velocity *= 0.2f;
221 Main.gore[num2].velocity += vector2;
222 Main.gore[num2].velocity.Y *= 0.75f;
223 if (Player.mount.Active && Player.mount.Type == 53)
224 {
225 Vector2 vector3 = Position + new Vector2(Width / 2, Height + 10);
226 float num3 = 30f;
227 float num4 = -16f;
228 for (int i = 0; i < 15; i++)
229 {
230 Dust dust = Dust.NewDustPerfect(vector3 + new Vector2(0f - num3 + num3 * 2f * Main.rand.NextFloat(), num4 * Main.rand.NextFloat()), 107, Vector2.Zero, 100, Color.Lerp(new Color(64, 220, 96), Color.White, Main.rand.NextFloat() * 0.3f), 0.6f);
231 dust.velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
232 dust.velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
233 dust.velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
234 dust.velocity += vector2;
235 dust.velocity.Y *= 0.75f;
236 dust.fadeIn = 0.2f + Main.rand.NextFloat() * 0.1f;
237 dust.noGravity = Main.rand.Next(3) == 0;
238 dust.noLightEmittence = true;
239 }
240 }
241 }
242
243 public static void JumpingSoundFart(Player Player, Vector2 Position, int Width, int Height)
244 {
245 SoundEngine.PlaySound(SoundID.Item16, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
246 SpawnFartCloud(Player, Position, Width, Height, useDelay: false);
247 }
248
249 public static void LandingSoundFart(Player Player, Vector2 Position, int Width, int Height)
250 {
251 SoundEngine.PlaySound(SoundID.Item16, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
252 SoundEngine.PlaySound(SoundID.Item53, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
253 SpawnFartCloud(Player, Position, Width, Height, useDelay: false);
254 }
255
256 public static void BumperSoundFart(Player Player, Vector2 Position, int Width, int Height)
257 {
258 SoundEngine.PlaySound(SoundID.Item16, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
259 SoundEngine.PlaySound(SoundID.Item56, (int)Position.X + Width / 2, (int)Position.Y + Height / 2);
260 SpawnFartCloud(Player, Position, Width, Height);
261 }
262
263 public static void SparksFart(Vector2 dustPosition)
264 {
265 dustPosition += new Vector2((Main.rand.Next(2) == 0) ? 13 : (-13), 0f).RotatedBy(rotation);
266 int num = Dust.NewDust(dustPosition, 1, 1, 211, Main.rand.Next(-2, 3), Main.rand.Next(-2, 3), 50, default(Color), 0.8f);
267 if (Main.rand.Next(2) == 0)
268 {
269 Main.dust[num].alpha += 25;
270 }
271 if (Main.rand.Next(2) == 0)
272 {
273 Main.dust[num].alpha += 25;
274 }
275 Main.dust[num].noLight = true;
276 Main.dust[num].noGravity = Main.rand.Next(3) == 0;
277 Main.dust[num].velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
278 Main.dust[num].velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
279 Main.dust[num].velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
280 Main.dust[num].position.Y -= 4f;
281 }
282
283 public static void SparksTerraFart(Vector2 dustPosition)
284 {
285 if (Main.rand.Next(2) == 0)
286 {
287 SparksFart(dustPosition);
288 return;
289 }
290 dustPosition += new Vector2((Main.rand.Next(2) == 0) ? 13 : (-13), 0f).RotatedBy(rotation);
291 int num = Dust.NewDust(dustPosition, 1, 1, 107, Main.rand.Next(-2, 3), Main.rand.Next(-2, 3), 100, Color.Lerp(new Color(64, 220, 96), Color.White, Main.rand.NextFloat() * 0.3f), 0.8f);
292 if (Main.rand.Next(2) == 0)
293 {
294 Main.dust[num].alpha += 25;
295 }
296 if (Main.rand.Next(2) == 0)
297 {
298 Main.dust[num].alpha += 25;
299 }
300 Main.dust[num].noLightEmittence = true;
301 Main.dust[num].noGravity = Main.rand.Next(3) == 0;
302 Main.dust[num].velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
303 Main.dust[num].velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
304 Main.dust[num].velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
305 Main.dust[num].position.Y -= 4f;
306 }
307
308 public static void SparksMech(Vector2 dustPosition)
309 {
310 dustPosition += new Vector2((Main.rand.Next(2) == 0) ? 13 : (-13), 0f).RotatedBy(rotation);
311 int num = Dust.NewDust(dustPosition, 1, 1, 260, Main.rand.Next(-2, 3), Main.rand.Next(-2, 3));
312 Main.dust[num].noGravity = true;
313 Main.dust[num].fadeIn = Main.dust[num].scale + 0.5f + 0.01f * (float)Main.rand.Next(0, 51);
314 Main.dust[num].noGravity = true;
315 Main.dust[num].velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
316 Main.dust[num].velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
317 Main.dust[num].velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
318 Main.dust[num].position.Y -= 4f;
319 if (Main.rand.Next(3) != 0)
320 {
321 Main.dust[num].noGravity = false;
322 }
323 else
324 {
325 Main.dust[num].scale *= 0.6f;
326 }
327 }
328
329 public static void SparksMeow(Vector2 dustPosition)
330 {
331 dustPosition += new Vector2((Main.rand.Next(2) == 0) ? 13 : (-13), 0f).RotatedBy(rotation);
332 int num = Dust.NewDust(dustPosition, 1, 1, 213, Main.rand.Next(-2, 3), Main.rand.Next(-2, 3));
333 Main.dust[num].shader = GameShaders.Armor.GetShaderFromItemId(2870);
334 Main.dust[num].noGravity = true;
335 Main.dust[num].fadeIn = Main.dust[num].scale + 1f + 0.01f * (float)Main.rand.Next(0, 51);
336 Main.dust[num].noGravity = true;
337 Main.dust[num].velocity *= (float)Main.rand.Next(15, 51) * 0.01f;
338 Main.dust[num].velocity.X *= (float)Main.rand.Next(25, 101) * 0.01f;
339 Main.dust[num].velocity.Y -= (float)Main.rand.Next(15, 31) * 0.1f;
340 Main.dust[num].position.Y -= 4f;
341 if (Main.rand.Next(3) != 0)
342 {
343 Main.dust[num].noGravity = false;
344 }
345 else
346 {
347 Main.dust[num].scale *= 0.6f;
348 }
349 }
350 }
351
352 public static Vector3 v3_1 = Vector3.Zero;
353
354 public static Vector2 v2_1 = Vector2.Zero;
355
356 public static float f_1 = 0f;
357
358 public static Color c_1 = Color.Transparent;
359
360 public static int i_1;
361
362 public static bool CheckResultOut;
363
365
366 public static bool[] tileCutIgnore = null;
367
368 public static Color ColorLerp_BlackToWhite(float percent)
369 {
370 return Color.Lerp(Color.Black, Color.White, percent);
371 }
372
373 public static Color ColorLerp_HSL_H(float percent)
374 {
375 return Main.hslToRgb(percent, 1f, 0.5f);
376 }
377
378 public static Color ColorLerp_HSL_S(float percent)
379 {
380 return Main.hslToRgb(v3_1.X, percent, v3_1.Z);
381 }
382
383 public static Color ColorLerp_HSL_L(float percent)
384 {
385 return Main.hslToRgb(v3_1.X, v3_1.Y, 0.15f + 0.85f * percent);
386 }
387
388 public static Color ColorLerp_HSL_O(float percent)
389 {
390 return Color.Lerp(Color.White, Main.hslToRgb(v3_1.X, v3_1.Y, v3_1.Z), percent);
391 }
392
393 public static bool SpreadDirt(int x, int y)
394 {
395 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
396 {
397 return false;
398 }
400 if (WorldGen.PlaceTile(x, y, 0))
401 {
402 if (Main.netMode != 0)
403 {
404 NetMessage.SendData(17, -1, -1, null, 1, x, y);
405 }
406 Vector2 position = new Vector2(x * 16, y * 16);
407 int num = 0;
408 for (int i = 0; i < 3; i++)
409 {
410 Dust dust = Dust.NewDustDirect(position, 16, 16, num, 0f, 0f, 100, Color.Transparent, 2.2f);
411 dust.noGravity = true;
412 dust.velocity.Y -= 1.2f;
413 dust.velocity *= 4f;
414 Dust dust2 = Dust.NewDustDirect(position, 16, 16, num, 0f, 0f, 100, Color.Transparent, 1.3f);
415 dust2.velocity.Y -= 1.2f;
416 dust2.velocity *= 2f;
417 }
418 int num2 = y + 1;
419 if (Main.tile[x, num2] != null && !TileID.Sets.Platforms[Main.tile[x, num2].type] && (Main.tile[x, num2].topSlope() || Main.tile[x, num2].halfBrick()))
420 {
421 WorldGen.SlopeTile(x, num2);
422 if (Main.netMode != 0)
423 {
424 NetMessage.SendData(17, -1, -1, null, 14, x, num2);
425 }
426 }
427 num2 = y - 1;
428 if (Main.tile[x, num2] != null && !TileID.Sets.Platforms[Main.tile[x, num2].type] && Main.tile[x, num2].bottomSlope())
429 {
430 WorldGen.SlopeTile(x, num2);
431 if (Main.netMode != 0)
432 {
433 NetMessage.SendData(17, -1, -1, null, 14, x, num2);
434 }
435 }
436 for (int j = x - 1; j <= x + 1; j++)
437 {
438 for (int k = y - 1; k <= y + 1; k++)
439 {
440 Tile tile = Main.tile[j, k];
441 if (!tile.active() || num == tile.type || (tile.type != 2 && tile.type != 23 && tile.type != 60 && tile.type != 70 && tile.type != 109 && tile.type != 199 && tile.type != 477 && tile.type != 492))
442 {
443 continue;
444 }
445 bool flag = true;
446 for (int l = j - 1; l <= j + 1; l++)
447 {
448 for (int m = k - 1; m <= k + 1; m++)
449 {
450 if (!WorldGen.SolidTile(l, m))
451 {
452 flag = false;
453 }
454 }
455 }
456 if (flag)
457 {
458 WorldGen.KillTile(j, k, fail: true);
459 if (Main.netMode != 0)
460 {
461 NetMessage.SendData(17, -1, -1, null, 0, j, k, 1f);
462 }
463 }
464 }
465 }
466 return true;
467 }
468 Tile tile2 = Main.tile[x, y];
469 if (tile2 == null)
470 {
471 return false;
472 }
473 if (tile2.type < 0 || tile2.type >= TileID.Count)
474 {
475 return false;
476 }
477 if (Main.tileSolid[tile2.type] && !TileID.Sets.Platforms[tile2.type])
478 {
479 return tile2.type == 380;
480 }
481 return true;
482 }
483
484 public static bool SpreadWater(int x, int y)
485 {
486 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
487 {
488 return false;
489 }
490 if (WorldGen.PlaceLiquid(x, y, 0, byte.MaxValue))
491 {
492 Vector2 position = new Vector2(x * 16, y * 16);
493 int type = Dust.dustWater();
494 for (int i = 0; i < 3; i++)
495 {
496 Dust dust = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 2.2f);
497 dust.noGravity = true;
498 dust.velocity.Y -= 1.2f;
499 dust.velocity *= 7f;
500 Dust dust2 = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 1.3f);
501 dust2.velocity.Y -= 1.2f;
502 dust2.velocity *= 4f;
503 }
504 return true;
505 }
506 return false;
507 }
508
509 public static bool SpreadHoney(int x, int y)
510 {
511 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
512 {
513 return false;
514 }
515 if (WorldGen.PlaceLiquid(x, y, 2, byte.MaxValue))
516 {
517 Vector2 position = new Vector2(x * 16, y * 16);
518 int type = 152;
519 for (int i = 0; i < 3; i++)
520 {
521 Dust dust = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 2.2f);
522 dust.velocity.Y -= 1.2f;
523 dust.velocity *= 7f;
524 Dust dust2 = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 1.3f);
525 dust2.velocity.Y -= 1.2f;
526 dust2.velocity *= 4f;
527 }
528 return true;
529 }
530 return false;
531 }
532
533 public static bool SpreadLava(int x, int y)
534 {
535 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
536 {
537 return false;
538 }
539 if (WorldGen.PlaceLiquid(x, y, 1, byte.MaxValue))
540 {
541 Vector2 position = new Vector2(x * 16, y * 16);
542 int type = 35;
543 for (int i = 0; i < 3; i++)
544 {
545 Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 1.2f).velocity *= 7f;
546 Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 0.8f).velocity *= 4f;
547 }
548 return true;
549 }
550 return false;
551 }
552
553 public static bool SpreadDry(int x, int y)
554 {
555 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
556 {
557 return false;
558 }
559 if (WorldGen.EmptyLiquid(x, y))
560 {
561 Vector2 position = new Vector2(x * 16, y * 16);
562 int type = 31;
563 for (int i = 0; i < 3; i++)
564 {
565 Dust dust = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 1.2f);
566 dust.noGravity = true;
567 dust.velocity *= 7f;
568 Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 0.8f).velocity *= 4f;
569 }
570 return true;
571 }
572 return false;
573 }
574
575 public static bool SpreadTest(int x, int y)
576 {
577 Tile tile = Main.tile[x, y];
578 if (WorldGen.SolidTile(x, y) || tile.wall != 0)
579 {
580 tile.active();
581 return false;
582 }
583 return true;
584 }
585
586 public static bool TestDust(int x, int y)
587 {
588 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
589 {
590 return false;
591 }
592 int num = Dust.NewDust(new Vector2(x, y) * 16f + new Vector2(8f), 0, 0, 6);
593 Main.dust[num].noGravity = true;
594 Main.dust[num].noLight = true;
595 return true;
596 }
597
598 public static bool CastLight(int x, int y)
599 {
600 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
601 {
602 return false;
603 }
604 if (Main.tile[x, y] == null)
605 {
606 return false;
607 }
608 Lighting.AddLight(x, y, v3_1.X, v3_1.Y, v3_1.Z);
609 return true;
610 }
611
612 public static bool CastLightOpen(int x, int y)
613 {
614 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
615 {
616 return false;
617 }
618 if (Main.tile[x, y] == null)
619 {
620 return false;
621 }
622 if (!Main.tile[x, y].active() || Main.tile[x, y].inActive() || Main.tileSolidTop[Main.tile[x, y].type] || !Main.tileSolid[Main.tile[x, y].type])
623 {
624 Lighting.AddLight(x, y, v3_1.X, v3_1.Y, v3_1.Z);
625 }
626 return true;
627 }
628
629 public static bool CheckStopForSolids(int x, int y)
630 {
631 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
632 {
633 return false;
634 }
635 if (Main.tile[x, y] == null)
636 {
637 return false;
638 }
639 if (Main.tile[x, y].active() && !Main.tile[x, y].inActive() && !Main.tileSolidTop[Main.tile[x, y].type] && Main.tileSolid[Main.tile[x, y].type])
640 {
641 CheckResultOut = true;
642 return false;
643 }
644 return true;
645 }
646
647 public static bool CastLightOpen_StopForSolids_ScaleWithDistance(int x, int y)
648 {
649 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
650 {
651 return false;
652 }
653 if (Main.tile[x, y] == null)
654 {
655 return false;
656 }
657 if (!Main.tile[x, y].active() || Main.tile[x, y].inActive() || Main.tileSolidTop[Main.tile[x, y].type] || !Main.tileSolid[Main.tile[x, y].type])
658 {
659 Vector3 vector = v3_1;
660 float num = Vector2.Distance(value2: new Vector2(x, y), value1: v2_1);
661 vector *= MathHelper.Lerp(0.65f, 1f, num / f_1);
662 Lighting.AddLight(x, y, vector.X, vector.Y, vector.Z);
663 return true;
664 }
665 return false;
666 }
667
668 public static bool CastLightOpen_StopForSolids(int x, int y)
669 {
670 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
671 {
672 return false;
673 }
674 if (Main.tile[x, y] == null)
675 {
676 return false;
677 }
678 if (!Main.tile[x, y].active() || Main.tile[x, y].inActive() || Main.tileSolidTop[Main.tile[x, y].type] || !Main.tileSolid[Main.tile[x, y].type])
679 {
680 Vector3 vector = v3_1;
681 new Vector2(x, y);
682 Lighting.AddLight(x, y, vector.X, vector.Y, vector.Z);
683 return true;
684 }
685 return false;
686 }
687
688 public static bool SpreadLightOpen_StopForSolids(int x, int y)
689 {
690 if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1)
691 {
692 return false;
693 }
694 if (!Main.tile[x, y].active() || Main.tile[x, y].inActive() || Main.tileSolidTop[Main.tile[x, y].type] || !Main.tileSolid[Main.tile[x, y].type])
695 {
696 Vector3 vector = v3_1;
697 new Vector2(x, y);
698 Lighting.AddLight(x, y, vector.X, vector.Y, vector.Z);
699 return true;
700 }
701 return false;
702 }
703
704 public static bool EmitGolfCartDust_StopForSolids(int x, int y)
705 {
706 if (x < 0 || x >= Main.maxTilesX || y < 0 || y >= Main.maxTilesY)
707 {
708 return false;
709 }
710 if (Main.tile[x, y] == null)
711 {
712 return false;
713 }
714 if (!Main.tile[x, y].active() || Main.tile[x, y].inActive() || Main.tileSolidTop[Main.tile[x, y].type] || !Main.tileSolid[Main.tile[x, y].type])
715 {
716 Dust.NewDustPerfect(new Vector2(x * 16 + 8, y * 16 + 8), 260, Vector2.UnitY * -0.2f);
717 return true;
718 }
719 return false;
720 }
721
722 public static bool NotDoorStand(int x, int y)
723 {
724 if (Main.tile[x, y] != null && Main.tile[x, y].active() && Main.tile[x, y].type == 11)
725 {
726 if (Main.tile[x, y].frameX >= 18)
727 {
728 return Main.tile[x, y].frameX < 54;
729 }
730 return false;
731 }
732 return true;
733 }
734
735 public static bool CutTiles(int x, int y)
736 {
737 if (!WorldGen.InWorld(x, y, 1))
738 {
739 return false;
740 }
741 if (Main.tile[x, y] == null)
742 {
743 return false;
744 }
745 if (!Main.tileCut[Main.tile[x, y].type])
746 {
747 return true;
748 }
749 if (tileCutIgnore[Main.tile[x, y].type])
750 {
751 return true;
752 }
753 if (WorldGen.CanCutTile(x, y, tilecut_0))
754 {
755 WorldGen.KillTile(x, y);
756 if (Main.netMode != 0)
757 {
758 NetMessage.SendData(17, -1, -1, null, 0, x, y);
759 }
760 }
761 return true;
762 }
763
764 public static bool SearchAvoidedByNPCs(int x, int y)
765 {
766 if (!WorldGen.InWorld(x, y, 1))
767 {
768 return false;
769 }
770 if (Main.tile[x, y] == null)
771 {
772 return false;
773 }
774 if (!Main.tile[x, y].active() || !TileID.Sets.AvoidedByNPCs[Main.tile[x, y].type])
775 {
776 return true;
777 }
778 return false;
779 }
780
781 public static void RainbowLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
782 {
783 color = c_1;
784 switch (stage)
785 {
786 case 0:
787 distCovered = 33f;
788 frame = new Rectangle(0, 0, 26, 22);
789 origin = frame.Size() / 2f;
790 break;
791 case 1:
792 frame = new Rectangle(0, 25, 26, 28);
793 distCovered = frame.Height;
794 origin = new Vector2(frame.Width / 2, 0f);
795 break;
796 case 2:
797 distCovered = 22f;
798 frame = new Rectangle(0, 56, 26, 22);
799 origin = new Vector2(frame.Width / 2, 1f);
800 break;
801 default:
802 distCovered = 9999f;
803 frame = Rectangle.Empty;
804 origin = Vector2.Zero;
805 color = Color.Transparent;
806 break;
807 }
808 }
809
810 public static void TurretLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
811 {
812 color = c_1;
813 switch (stage)
814 {
815 case 0:
816 distCovered = 32f;
817 frame = new Rectangle(0, 0, 22, 20);
818 origin = frame.Size() / 2f;
819 break;
820 case 1:
821 {
822 i_1++;
823 int num = i_1 % 5;
824 frame = new Rectangle(0, 22 * (num + 1), 22, 20);
825 distCovered = frame.Height - 1;
826 origin = new Vector2(frame.Width / 2, 0f);
827 break;
828 }
829 case 2:
830 frame = new Rectangle(0, 154, 22, 30);
831 distCovered = frame.Height;
832 origin = new Vector2(frame.Width / 2, 1f);
833 break;
834 default:
835 distCovered = 9999f;
836 frame = Rectangle.Empty;
837 origin = Vector2.Zero;
838 color = Color.Transparent;
839 break;
840 }
841 }
842
843 public static void LightningLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
844 {
845 color = c_1 * f_1;
846 switch (stage)
847 {
848 case 0:
849 distCovered = 0f;
850 frame = new Rectangle(0, 0, 21, 8);
851 origin = frame.Size() / 2f;
852 break;
853 case 1:
854 frame = new Rectangle(0, 8, 21, 6);
855 distCovered = frame.Height;
856 origin = new Vector2(frame.Width / 2, 0f);
857 break;
858 case 2:
859 distCovered = 8f;
860 frame = new Rectangle(0, 14, 21, 8);
861 origin = new Vector2(frame.Width / 2, 2f);
862 break;
863 default:
864 distCovered = 9999f;
865 frame = Rectangle.Empty;
866 origin = Vector2.Zero;
867 color = Color.Transparent;
868 break;
869 }
870 }
871
872 public static int CompareYReverse(Point a, Point b)
873 {
874 return b.Y.CompareTo(a.Y);
875 }
876
878 {
879 return a.scale.Y.CompareTo(b.scale.Y);
880 }
881}
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static double Cos(double d)
const double PI
Definition Math.cs:16
static void PlaySound(int type, Vector2 position, int style=1)
static void EtsyPet(Projectile proj, bool walking)
static void BerniePet(Projectile proj, bool walking)
static void SlimePet(Projectile proj, bool walking)
static void WormPet(Projectile proj, bool walking)
static void FloatAndRotateForwardWhenWalking(Projectile proj, bool walking)
static void RotateForwardWhenWalking(Projectile proj, bool walking)
static void Float(Projectile proj, bool walking)
static void CompanionCubePet(Projectile proj, bool walking)
static void FloatAndSpinWhenWalking(Projectile proj, bool walking)
static void LandingSoundFart(Player Player, Vector2 Position, int Width, int Height)
static void JumpingSoundFart(Player Player, Vector2 Position, int Width, int Height)
static void SparksMech(Vector2 dustPosition)
static void SparksFart(Vector2 dustPosition)
static void LandingSound(Player Player, Vector2 Position, int Width, int Height)
static void SparksTerraFart(Vector2 dustPosition)
static void SparksMeow(Vector2 dustPosition)
static void BumperSound(Player Player, Vector2 Position, int Width, int Height)
static void Sparks(Vector2 dustPosition)
static void BumperSoundFart(Player Player, Vector2 Position, int Width, int Height)
static void SpawnFartCloud(Player Player, Vector2 Position, int Width, int Height, bool useDelay=true)
static void JumpingSound(Player Player, Vector2 Position, int Width, int Height)
static bool WolfMouthPosition(Player player, out Vector2? position)
static bool NoHandPosition(Player player, out Vector2? position)
static bool SpreadWater(int x, int y)
static bool CheckStopForSolids(int x, int y)
static bool CastLightOpen_StopForSolids_ScaleWithDistance(int x, int y)
static bool SpreadLightOpen_StopForSolids(int x, int y)
static void LightningLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
static Color ColorLerp_HSL_S(float percent)
static bool SpreadLava(int x, int y)
static bool SpreadDry(int x, int y)
static Color ColorLerp_BlackToWhite(float percent)
static Color ColorLerp_HSL_H(float percent)
static bool CastLightOpen_StopForSolids(int x, int y)
static Color ColorLerp_HSL_L(float percent)
static int CompareYReverse(Point a, Point b)
static bool SpreadTest(int x, int y)
static TileCuttingContext tilecut_0
static bool SearchAvoidedByNPCs(int x, int y)
static bool CutTiles(int x, int y)
static bool SpreadDirt(int x, int y)
static void RainbowLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
static bool NotDoorStand(int x, int y)
static bool EmitGolfCartDust_StopForSolids(int x, int y)
static bool SpreadHoney(int x, int y)
static bool TestDust(int x, int y)
static Color ColorLerp_HSL_O(float percent)
static bool CastLight(int x, int y)
static bool CastLightOpen(int x, int y)
static void TurretLaserDraw(int stage, Vector2 currentPosition, float distanceLeft, Rectangle lastFrame, out float distCovered, out Rectangle frame, out Vector2 origin, out Color color)
static int CompareDrawSorterByYScale(DrawData a, DrawData b)
static int dustWater()
Definition Dust.cs:340
static int NewDust(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:73
static Dust NewDustPerfect(Vector2 Position, int Type, Vector2? Velocity=null, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:52
static Dust NewDustDirect(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:63
Vector2 position
Definition Entity.cs:14
static int NewGore(Vector2 Position, Vector2 Velocity, int Type, float Scale=1f)
Definition Gore.cs:1288
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
static readonly LegacySoundStyle Item16
Definition SoundID.cs:446
static readonly LegacySoundStyle Item53
Definition SoundID.cs:520
static readonly LegacySoundStyle Item56
Definition SoundID.cs:526
static bool[] AvoidedByNPCs
Definition TileID.cs:271
static bool[] Platforms
Definition TileID.cs:163
static readonly ushort Count
Definition TileID.cs:1698
static void AddLight(Vector2 position, Vector3 rgb)
Definition Lighting.cs:137
static int maxTilesY
Definition Main.cs:1116
static bool[] tileSolidTop
Definition Main.cs:1469
static bool[] tileCut
Definition Main.cs:1433
static int netMode
Definition Main.cs:2095
static Gore[] gore
Definition Main.cs:1687
static double timeForVisualEffects
Definition Main.cs:1286
static int maxTilesX
Definition Main.cs:1114
static bool[] tileSolid
Definition Main.cs:1471
static Tile[,] tile
Definition Main.cs:1675
static UnifiedRandom rand
Definition Main.cs:1387
static Microsoft.Xna.Framework.Color hslToRgb(Vector3 hslVector)
Definition Main.cs:44913
static Dust[] dust
Definition Main.cs:1677
bool Active
Definition Mount.cs:345
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
int fartKartCloudDelay
Definition Player.cs:1295
Vector2 MountedCenter
Definition Player.cs:2853
Vector2 RotatedRelativePoint(Vector2 pos, bool reverseRotation=false, bool addGfxOffY=true)
Definition Player.cs:3618
float fullRotation
Definition Player.cs:1291
ushort type
Definition Tile.cs:8
bool active()
Definition Tile.cs:565
ushort wall
Definition Tile.cs:10
static float MultiLerp(float percent, params float[] floats)
Definition Utils.cs:180
static bool PlaceLiquid(int x, int y, byte liquidType, byte amount)
Definition WorldGen.cs:1371
static bool SolidTile(Tile testTile)
static void KillTile(int i, int j, bool fail=false, bool effectOnly=false, bool noItem=false)
static bool PlaceTile(int i, int j, int Type, bool mute=false, bool forced=false, int plr=-1, int style=0)
static bool TryKillingReplaceableTile(int x, int y, int tileType)
static bool SlopeTile(int i, int j, int slope=0, bool noEffects=false)
static bool EmptyLiquid(int x, int y)
Definition WorldGen.cs:1342
static bool InWorld(int x, int y, int fluff=0)
Definition WorldGen.cs:5816
static bool CanCutTile(int x, int y, TileCuttingContext context)
static Color Transparent
Definition Color.cs:76
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
static float Distance(Vector2 value1, Vector2 value2)
Definition Vector2.cs:91