Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Gore_UpdateLeaf()

void Terraria.Gore.Gore_UpdateLeaf ( )
inlineprivate

Definition at line 1086 of file Gore.cs.

1087 {
1088 Vector2 vector = position + new Vector2(12f) / 2f - new Vector2(4f) / 2f;
1089 vector.Y -= 4f;
1090 Vector2 vector2 = position - vector;
1091 if (velocity.Y < 0f)
1092 {
1093 Vector2 vector3 = new Vector2(velocity.X, -0.2f);
1094 int num = 4;
1095 num = (int)((float)num * 0.9f);
1096 Point point = (new Vector2(num, num) / 2f + vector).ToTileCoordinates();
1097 if (!WorldGen.InWorld(point.X, point.Y))
1098 {
1099 active = false;
1100 return;
1101 }
1102 Tile tile = Main.tile[point.X, point.Y];
1103 if (tile == null)
1104 {
1105 active = false;
1106 return;
1107 }
1108 int num2 = 6;
1109 Rectangle rectangle = new Rectangle(point.X * 16, point.Y * 16 + tile.liquid / 16, 16, 16 - tile.liquid / 16);
1110 Rectangle value = new Rectangle((int)vector.X, (int)vector.Y + num2, num, num);
1111 bool flag = tile != null && tile.liquid > 0 && rectangle.Intersects(value);
1112 if (flag)
1113 {
1114 if (tile.honey())
1115 {
1116 vector3.X = 0f;
1117 }
1118 else if (tile.lava())
1119 {
1120 active = false;
1121 for (int i = 0; i < 5; i++)
1122 {
1123 Dust.NewDust(position, num, num, 31, 0f, -0.2f);
1124 }
1125 }
1126 else
1127 {
1128 vector3.X = Main.WindForVisuals;
1129 }
1130 if ((double)position.Y > Main.worldSurface * 16.0)
1131 {
1132 vector3.X = 0f;
1133 }
1134 }
1135 if (!WorldGen.SolidTile(point.X, point.Y + 1) && !flag)
1136 {
1137 velocity.Y = 0.1f;
1138 timeLeft = 0;
1139 alpha += 20;
1140 }
1141 vector3 = Collision.TileCollision(vector, vector3, num, num);
1142 if (flag)
1143 {
1144 rotation = vector3.ToRotation() + (float)Math.PI / 2f;
1145 }
1146 vector3.X *= 0.94f;
1147 if (!flag || ((double)vector3.X > -0.01 && (double)vector3.X < 0.01))
1148 {
1149 vector3.X = 0f;
1150 }
1151 if (timeLeft > 0)
1152 {
1154 }
1155 else
1156 {
1158 }
1159 velocity.X = vector3.X;
1160 position.X += velocity.X;
1161 return;
1162 }
1163 velocity.Y += (float)Math.PI / 180f;
1164 Vector2 vector4 = new Vector2(Vector2.UnitY.RotatedBy(velocity.Y).X * 1f, Math.Abs(Vector2.UnitY.RotatedBy(velocity.Y).Y) * 1f);
1165 int num3 = 4;
1166 if ((double)position.Y < Main.worldSurface * 16.0)
1167 {
1168 vector4.X += Main.WindForVisuals * 4f;
1169 }
1170 Vector2 vector5 = vector4;
1171 vector4 = Collision.TileCollision(vector, vector4, num3, num3);
1172 Vector4 vector6 = Collision.SlopeCollision(vector, vector4, num3, num3, 1f);
1173 position.X = vector6.X;
1174 position.Y = vector6.Y;
1175 vector4.X = vector6.Z;
1176 vector4.Y = vector6.W;
1177 position += vector2;
1178 if (vector4 != vector5)
1179 {
1180 velocity.Y = -1f;
1181 }
1182 Point point2 = (new Vector2(Width, Height) * 0.5f + position).ToTileCoordinates();
1183 if (!WorldGen.InWorld(point2.X, point2.Y))
1184 {
1185 active = false;
1186 return;
1187 }
1188 Tile tile2 = Main.tile[point2.X, point2.Y];
1189 if (tile2 == null)
1190 {
1191 active = false;
1192 return;
1193 }
1194 int num4 = 6;
1195 Rectangle rectangle2 = new Rectangle(point2.X * 16, point2.Y * 16 + tile2.liquid / 16, 16, 16 - tile2.liquid / 16);
1196 Rectangle value2 = new Rectangle((int)vector.X, (int)vector.Y + num4, num3, num3);
1197 if (tile2 != null && tile2.liquid > 0 && rectangle2.Intersects(value2))
1198 {
1199 velocity.Y = -1f;
1200 }
1201 position += vector4;
1202 rotation = vector4.ToRotation() + (float)Math.PI / 2f;
1203 if (timeLeft > 0)
1204 {
1206 }
1207 else
1208 {
1210 }
1211 }
static double Abs(double value)
const double PI
Definition Math.cs:16
Vector2 velocity
Definition Gore.cs:19
Vector2 position
Definition Gore.cs:17
int type
Definition Gore.cs:27
float Height
Definition Gore.cs:56
bool active
Definition Gore.cs:31
int alpha
Definition Gore.cs:25
float Width
Definition Gore.cs:44
float rotation
Definition Gore.cs:21
int timeLeft
Definition Gore.cs:35
static int[] DisappearSpeed
Definition GoreID.cs:11
static int[] DisappearSpeedAlpha
Definition GoreID.cs:13
bool Intersects(Rectangle value)
Definition Rectangle.cs:129

References System.Math.Abs(), Terraria.Gore.active, Terraria.Gore.alpha, Terraria.ID.GoreID.Sets.DisappearSpeed, Terraria.ID.GoreID.Sets.DisappearSpeedAlpha, Terraria.Gore.Height, Terraria.Tile.honey(), Microsoft.Xna.Framework.Rectangle.Intersects(), Terraria.WorldGen.InWorld(), Terraria.Tile.lava(), Terraria.Tile.liquid, Terraria.Dust.NewDust(), System.Math.PI, Terraria.Gore.position, Terraria.Gore.rotation, Terraria.Collision.SlopeCollision(), Terraria.WorldGen.SolidTile(), Terraria.Main.tile, Terraria.Collision.TileCollision(), Terraria.Gore.timeLeft, Terraria.Gore.type, Microsoft.Xna.Framework.Vector2.UnitY, System.value, Terraria.Gore.velocity, Microsoft.Xna.Framework.Vector4.W, Terraria.Gore.Width, Terraria.Main.WindForVisuals, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Point.X, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector4.X, Microsoft.Xna.Framework.Point.Y, Microsoft.Xna.Framework.Vector2.Y, Microsoft.Xna.Framework.Vector4.Y, and Microsoft.Xna.Framework.Vector4.Z.

Referenced by Terraria.Gore.Update().