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

◆ NewGore()

static int Terraria.Gore.NewGore ( Vector2 Position,
Vector2 Velocity,
int Type,
float Scale = 1f )
inlinestatic

Definition at line 1288 of file Gore.cs.

1289 {
1290 if (Main.netMode == 2)
1291 {
1292 return 600;
1293 }
1294 if (Main.gamePaused)
1295 {
1296 return 600;
1297 }
1298 if (WorldGen.gen)
1299 {
1300 return 600;
1301 }
1302 if (Main.rand == null)
1303 {
1304 Main.rand = new UnifiedRandom();
1305 }
1306 if (Type == -1)
1307 {
1308 return 600;
1309 }
1310 int num = 600;
1311 for (int i = 0; i < 600; i++)
1312 {
1313 if (!Main.gore[i].active)
1314 {
1315 num = i;
1316 break;
1317 }
1318 }
1319 if (num == 600)
1320 {
1321 return num;
1322 }
1323 Main.gore[num].Frame = new SpriteFrame(1, 1);
1324 Main.gore[num].frameCounter = 0;
1325 Main.gore[num].behindTiles = false;
1326 Main.gore[num].light = 0f;
1327 Main.gore[num].position = Position;
1328 Main.gore[num].velocity = Velocity;
1329 Main.gore[num].velocity.Y -= (float)Main.rand.Next(10, 31) * 0.1f;
1330 Main.gore[num].velocity.X += (float)Main.rand.Next(-20, 21) * 0.1f;
1331 Main.gore[num].type = Type;
1332 Main.gore[num].active = true;
1333 Main.gore[num].alpha = 0;
1334 Main.gore[num].rotation = 0f;
1335 Main.gore[num].scale = Scale;
1337 {
1338 Main.gore[num].type = Main.rand.Next(11, 14);
1339 Main.gore[num].scale = Main.rand.NextFloat() * 0.5f + 0.5f;
1340 Main.gore[num].velocity /= 2f;
1341 }
1342 if (goreTime == 0 || Type == 11 || Type == 12 || Type == 13 || Type == 16 || Type == 17 || Type == 61 || Type == 62 || Type == 63 || Type == 99 || Type == 220 || Type == 221 || Type == 222 || Type == 435 || Type == 436 || Type == 437 || (Type >= 861 && Type <= 862))
1343 {
1344 Main.gore[num].sticky = false;
1345 }
1346 else if (Type >= 375 && Type <= 377)
1347 {
1348 Main.gore[num].sticky = false;
1349 Main.gore[num].alpha = 100;
1350 }
1351 else
1352 {
1353 Main.gore[num].sticky = true;
1354 Main.gore[num].timeLeft = goreTime;
1355 }
1356 if ((Type >= 706 && Type <= 717) || Type == 943 || Type == 1147 || (Type >= 1160 && Type <= 1162))
1357 {
1358 Main.gore[num].numFrames = 15;
1359 Main.gore[num].behindTiles = true;
1360 Main.gore[num].timeLeft = goreTime * 3;
1361 }
1362 if (Type == 16 || Type == 17)
1363 {
1364 Main.gore[num].alpha = 100;
1365 Main.gore[num].scale = 0.7f;
1366 Main.gore[num].light = 1f;
1367 }
1368 if (Type >= 570 && Type <= 572)
1369 {
1370 Main.gore[num].velocity = Velocity;
1371 }
1372 if (Type == 1201 || Type == 1208)
1373 {
1374 Main.gore[num].Frame = new SpriteFrame(1, 4);
1375 }
1376 if (Type == 1217 || Type == 1218)
1377 {
1378 Main.gore[num].Frame = new SpriteFrame(1, 3);
1379 }
1380 if (Type == 1225)
1381 {
1382 Main.gore[num].Frame = new SpriteFrame(1, 3);
1383 Main.gore[num].timeLeft = 10 + Main.rand.Next(6);
1384 Main.gore[num].sticky = false;
1385 if (TextureAssets.Gore[Type].IsLoaded)
1386 {
1387 Main.gore[num].position.X = Position.X - (float)(TextureAssets.Gore[Type].Width() / 2) * Scale;
1388 Main.gore[num].position.Y = Position.Y - (float)TextureAssets.Gore[Type].Height() * Scale / 2f;
1389 }
1390 }
1391 int num2 = GoreID.Sets.SpecialAI[Type];
1392 if (num2 == 3)
1393 {
1394 Main.gore[num].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 1f, Main.rand.NextFloat() * ((float)Math.PI * 2f));
1395 bool flag = (Type >= 910 && Type <= 925) || (Type >= 1113 && Type <= 1121) || (Type >= 1248 && Type <= 1255) || Type == 1257 || Type == 1278;
1396 Gore obj = Main.gore[num];
1397 SpriteFrame spriteFrame = new SpriteFrame((byte)((!flag) ? 1u : 32u), 8)
1398 {
1399 CurrentRow = (byte)Main.rand.Next(8)
1400 };
1401 obj.Frame = spriteFrame;
1402 Main.gore[num].frameCounter = (byte)Main.rand.Next(8);
1403 }
1404 if (num2 == 1)
1405 {
1406 Main.gore[num].velocity = new Vector2((Main.rand.NextFloat() - 0.5f) * 3f, Main.rand.NextFloat() * ((float)Math.PI * 2f));
1407 }
1408 if (Type >= 411 && Type <= 430 && TextureAssets.Gore[Type].IsLoaded)
1409 {
1410 Main.gore[num].position.X = Position.X - (float)(TextureAssets.Gore[Type].Width() / 2) * Scale;
1411 Main.gore[num].position.Y = Position.Y - (float)TextureAssets.Gore[Type].Height() * Scale;
1412 Main.gore[num].velocity.Y *= (float)Main.rand.Next(90, 150) * 0.01f;
1413 Main.gore[num].velocity.X *= (float)Main.rand.Next(40, 90) * 0.01f;
1414 int num3 = Main.rand.Next(4) * 5;
1415 Main.gore[num].type += num3;
1416 Main.gore[num].timeLeft = Main.rand.Next(goreTime / 2, goreTime * 2);
1417 Main.gore[num].sticky = true;
1418 if (goreTime == 0)
1419 {
1420 Main.gore[num].timeLeft = Main.rand.Next(150, 600);
1421 }
1422 }
1423 if (Type >= 907 && Type <= 909)
1424 {
1425 Main.gore[num].sticky = true;
1426 Main.gore[num].numFrames = 3;
1427 Main.gore[num].frame = (byte)Main.rand.Next(3);
1428 Main.gore[num].frameCounter = (byte)Main.rand.Next(5);
1429 Main.gore[num].rotation = 0f;
1430 }
1431 if (num2 == 2)
1432 {
1433 Main.gore[num].sticky = false;
1434 if (TextureAssets.Gore[Type].IsLoaded)
1435 {
1436 Main.gore[num].alpha = 150;
1437 Main.gore[num].velocity = Velocity;
1438 Main.gore[num].position.X = Position.X - (float)(TextureAssets.Gore[Type].Width() / 2) * Scale;
1439 Main.gore[num].position.Y = Position.Y - (float)TextureAssets.Gore[Type].Height() * Scale / 2f;
1440 Main.gore[num].timeLeft = Main.rand.Next(goreTime / 2, goreTime + 1);
1441 }
1442 }
1443 if (num2 == 4)
1444 {
1445 Main.gore[num].alpha = 254;
1446 Main.gore[num].timeLeft = 300;
1447 }
1448 if (num2 == 5)
1449 {
1450 Main.gore[num].alpha = 254;
1451 Main.gore[num].timeLeft = 240;
1452 }
1453 if (num2 == 6)
1454 {
1455 Main.gore[num].alpha = 254;
1456 Main.gore[num].timeLeft = 480;
1457 }
1458 if (Main.gore[num].DeactivateIfOutsideOfWorld())
1459 {
1460 return 600;
1461 }
1462 return num;
1463 }
const double PI
Definition Math.cs:16
static bool DangerousGore(int id)
static Asset< Texture2D >[] Gore
static int goreTime
Definition Gore.cs:15
static int[] SpecialAI
Definition GoreID.cs:9

References Terraria.GameContent.ChildSafety.DangerousGore(), Terraria.GameContent.ChildSafety.Disabled, Terraria.Main.gamePaused, Terraria.WorldGen.gen, Terraria.GameContent.TextureAssets.Gore, Terraria.Main.gore, Terraria.Gore.goreTime, Terraria.Main.netMode, System.obj, System.Math.PI, Terraria.Main.rand, Microsoft.Xna.Framework.Scale, and Terraria.ID.GoreID.Sets.SpecialAI.

Referenced by Terraria.NPC.AI(), Terraria.Projectile.AI(), Terraria.Projectile.AI_026(), Terraria.NPC.AI_045_Golem(), Terraria.Projectile.AI_067_FreakingPirates(), Terraria.NPC.AI_107_ImprovedWalkers(), Terraria.NPC.AI_108_DivingFlyer(), Terraria.NPC.AI_121_QueenSlime(), Terraria.Projectile.AI_147_Explosion(), Terraria.Projectile.AI_151_SuperStar(), Terraria.Projectile.AI_178_FireExplosion(), Terraria.NPC.BigMimicSpawnSmoke(), Terraria.DataStructures.PlayerDrawSet.BoringSetup(), Terraria.WorldGen.Check3x3(), Terraria.WorldGen.CheckPot(), Terraria.Player.DashMovement(), Terraria.Item.DespawnIfMeetingConditions(), Terraria.Mount.DoSpawnDust(), Terraria.Player.DoubleJumpVisuals(), Terraria.GameContent.Drawing.TileDrawing.DrawTiles_EmitParticles(), Terraria.Projectile.EmitEnchantmentVisualsAt(), Terraria.GameContent.Drawing.TileDrawing.EmitLiquidDrops(), Terraria.NPC.FindFrame(), Terraria.NPC.HitEffect(), Terraria.Player.ItemCheck_ApplyUseStyle(), Terraria.Player.ItemCheck_EmitUseVisuals(), Terraria.Player.ItemCheck_GetMeleeHitbox(), Terraria.Player.JumpMovement(), Terraria.Projectile.Kill(), Terraria.Player.KillMe(), Terraria.Gore.NewGoreDirect(), Terraria.Player.NinjaDodge(), Terraria.Utils.PoofOfSmoke(), Terraria.GameContent.Drawing.ParticleOrchestrator.Spawn_Digestion(), Terraria.DelegateMethods.Minecart.SpawnFartCloud(), Terraria.NPC.StrikeNPC(), Terraria.NPC.TransformVisuals(), Terraria.WorldGen.TreeGrowFX(), Terraria.Gore.Update(), Terraria.Player.UpdateHairDyeDust(), and Terraria.NPC.UpdateNPC_BuffApplyVFX().