Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros
ShimmerHelper.cs
Go to the documentation of this file.
2
4
5public class ShimmerHelper
6{
7 public static Vector2? FindSpotWithoutShimmer(Entity entity, int startX, int startY, int expand, bool allowSolidTop)
8 {
9 Vector2 vector = new Vector2(-entity.width / 2, -entity.height);
10 for (int i = 0; i < expand; i++)
11 {
12 int num = startX - i;
13 int num2 = startY - expand;
14 Vector2 vector2 = new Vector2(num * 16, num2 * 16) + vector;
15 if (IsSpotShimmerFree(entity, vector2, allowSolidTop))
16 {
17 return vector2;
18 }
19 vector2 = new Vector2((startX + i) * 16, num2 * 16) + vector;
20 if (IsSpotShimmerFree(entity, vector2, allowSolidTop))
21 {
22 return vector2;
23 }
24 int num3 = startX - i;
25 num2 = startY + expand;
26 vector2 = new Vector2(num3 * 16, num2 * 16) + vector;
27 if (IsSpotShimmerFree(entity, vector2, allowSolidTop))
28 {
29 return vector2;
30 }
31 vector2 = new Vector2((startX + i) * 16, num2 * 16) + vector;
32 if (IsSpotShimmerFree(entity, vector2, allowSolidTop))
33 {
34 return vector2;
35 }
36 }
37 for (int j = 0; j < expand; j++)
38 {
39 int num4 = startX - expand;
40 int num5 = startY - j;
41 Vector2 vector3 = new Vector2(num4 * 16, num5 * 16) + vector;
42 if (IsSpotShimmerFree(entity, vector3, allowSolidTop))
43 {
44 return vector3;
45 }
46 vector3 = new Vector2((startX + expand) * 16, num5 * 16) + vector;
47 if (IsSpotShimmerFree(entity, vector3, allowSolidTop))
48 {
49 return vector3;
50 }
51 int num6 = startX - expand;
52 num5 = startY + j;
53 vector3 = new Vector2(num6 * 16, num5 * 16) + vector;
54 if (IsSpotShimmerFree(entity, vector3, allowSolidTop))
55 {
56 return vector3;
57 }
58 vector3 = new Vector2((startX + expand) * 16, num5 * 16) + vector;
59 if (IsSpotShimmerFree(entity, vector3, allowSolidTop))
60 {
61 return vector3;
62 }
63 }
64 return null;
65 }
66
67 private static bool IsSpotShimmerFree(Entity entity, Vector2 landingPosition, bool allowSolidTop)
68 {
69 if (Collision.SolidCollision(landingPosition, entity.width, entity.height))
70 {
71 return false;
72 }
73 if (!Collision.SolidCollision(landingPosition + new Vector2(0f, entity.height), entity.width, 100, allowSolidTop))
74 {
75 return false;
76 }
77 if (Collision.WetCollision(landingPosition, entity.width, entity.height + 100) && Collision.shimmer)
78 {
79 return false;
80 }
81 return true;
82 }
83}
static bool WetCollision(Vector2 Position, int Width, int Height)
static bool shimmer
Definition Collision.cs:26
static bool SolidCollision(Vector2 Position, int Width, int Height)
static ? Vector2 FindSpotWithoutShimmer(Entity entity, int startX, int startY, int expand, bool allowSolidTop)
static bool IsSpotShimmerFree(Entity entity, Vector2 landingPosition, bool allowSolidTop)