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

◆ UseDrill()

void Terraria.Mount.UseDrill ( Player mountedPlayer)
inline

Definition at line 2520 of file Mount.cs.

2521 {
2522 if (_type != 8 || !_abilityActive)
2523 {
2524 return;
2525 }
2526 DrillMountData drillMountData = (DrillMountData)_mountSpecificData;
2527 bool flag = mountedPlayer.whoAmI == Main.myPlayer;
2528 if (mountedPlayer.controlUseItem)
2529 {
2530 for (int i = 0; i < amountOfBeamsAtOnce; i++)
2531 {
2532 if (drillMountData.beamCooldown != 0)
2533 {
2534 break;
2535 }
2536 for (int j = 0; j < drillMountData.beams.Length; j++)
2537 {
2538 DrillBeam drillBeam = drillMountData.beams[j];
2539 if (drillBeam.cooldown != 0)
2540 {
2541 continue;
2542 }
2544 if (point == Point16.NegativeOne)
2545 {
2546 continue;
2547 }
2548 drillBeam.curTileTarget = point;
2550 if (flag)
2551 {
2552 bool flag2 = true;
2553 if (WorldGen.InWorld(point.X, point.Y) && Main.tile[point.X, point.Y] != null && Main.tile[point.X, point.Y].type == 26 && !Main.hardMode)
2554 {
2555 flag2 = false;
2556 mountedPlayer.Hurt(PlayerDeathReason.ByOther(4), mountedPlayer.statLife / 2, -mountedPlayer.direction);
2557 }
2558 if (mountedPlayer.noBuilding)
2559 {
2560 flag2 = false;
2561 }
2562 if (flag2)
2563 {
2564 mountedPlayer.PickTile(point.X, point.Y, pickPower);
2565 }
2566 }
2567 Vector2 vector = new Vector2((float)(point.X << 4) + 8f, (float)(point.Y << 4) + 8f);
2568 float num = (vector - mountedPlayer.Center).ToRotation();
2569 for (int k = 0; k < 2; k++)
2570 {
2571 float num2 = num + ((Main.rand.Next(2) == 1) ? (-1f) : 1f) * ((float)Math.PI / 2f);
2572 float num3 = (float)Main.rand.NextDouble() * 2f + 2f;
2573 Vector2 vector2 = new Vector2((float)Math.Cos(num2) * num3, (float)Math.Sin(num2) * num3);
2574 int num4 = Dust.NewDust(vector, 0, 0, 230, vector2.X, vector2.Y);
2575 Main.dust[num4].noGravity = true;
2576 Main.dust[num4].customData = mountedPlayer;
2577 }
2578 if (flag)
2579 {
2580 Tile.SmoothSlope(point.X, point.Y, applyToNeighbors: true, sync: true);
2581 }
2582 drillBeam.cooldown = drillPickTime;
2583 drillBeam.lastPurpose = 0;
2584 break;
2585 }
2586 }
2587 }
2588 if (!mountedPlayer.controlUseTile)
2589 {
2590 return;
2591 }
2592 for (int l = 0; l < amountOfBeamsAtOnce; l++)
2593 {
2594 if (drillMountData.beamCooldown != 0)
2595 {
2596 break;
2597 }
2598 for (int m = 0; m < drillMountData.beams.Length; m++)
2599 {
2600 DrillBeam drillBeam2 = drillMountData.beams[m];
2601 if (drillBeam2.cooldown != 0)
2602 {
2603 continue;
2604 }
2606 if (point2 == Point16.NegativeOne)
2607 {
2608 continue;
2609 }
2610 drillBeam2.curTileTarget = point2;
2611 int damage = drillPickPower;
2612 if (flag)
2613 {
2614 bool flag3 = true;
2615 if (mountedPlayer.noBuilding)
2616 {
2617 flag3 = false;
2618 }
2619 if (flag3)
2620 {
2621 mountedPlayer.PickWall(point2.X, point2.Y, damage);
2622 }
2623 }
2624 Vector2 vector3 = new Vector2((float)(point2.X << 4) + 8f, (float)(point2.Y << 4) + 8f);
2625 float num5 = (vector3 - mountedPlayer.Center).ToRotation();
2626 for (int n = 0; n < 2; n++)
2627 {
2628 float num6 = num5 + ((Main.rand.Next(2) == 1) ? (-1f) : 1f) * ((float)Math.PI / 2f);
2629 float num7 = (float)Main.rand.NextDouble() * 2f + 2f;
2630 Vector2 vector4 = new Vector2((float)Math.Cos(num6) * num7, (float)Math.Sin(num6) * num7);
2631 int num8 = Dust.NewDust(vector3, 0, 0, 230, vector4.X, vector4.Y);
2632 Main.dust[num8].noGravity = true;
2633 Main.dust[num8].customData = mountedPlayer;
2634 }
2635 drillBeam2.cooldown = drillPickTime;
2636 drillBeam2.lastPurpose = 1;
2637 break;
2638 }
2639 }
2640 }
static double Cos(double d)
static double Sin(double a)
static PlayerDeathReason ByOther(int type)
static int drillPickPower
Definition Mount.cs:277
object _mountSpecificData
Definition Mount.cs:329
static int drillPickTime
Definition Mount.cs:279
static int amountOfBeamsAtOnce
Definition Mount.cs:281
Point16 DrillSmartCursor_Walls(Player mountedPlayer, DrillMountData data)
Definition Mount.cs:2678
bool _abilityActive
Definition Mount.cs:321
Point16 DrillSmartCursor_Blocks(Player mountedPlayer, DrillMountData data)
Definition Mount.cs:2642

References Terraria.Mount._abilityActive, Terraria.Mount._mountSpecificData, Terraria.Mount._type, Terraria.Mount.amountOfBeamsAtOnce, Terraria.DataStructures.PlayerDeathReason.ByOther(), System.Math.Cos(), Terraria.Mount.drillPickPower, Terraria.Mount.drillPickTime, Terraria.Mount.DrillSmartCursor_Blocks(), Terraria.Mount.DrillSmartCursor_Walls(), Terraria.Main.dust, Terraria.Main.hardMode, Terraria.WorldGen.InWorld(), Terraria.Main.myPlayer, Terraria.DataStructures.Point16.NegativeOne, Terraria.Dust.NewDust(), Terraria.Main.rand, System.Math.Sin(), Terraria.Tile.SmoothSlope(), Terraria.Main.tile, Microsoft.Xna.Framework.Graphics.Vector2, Terraria.DataStructures.Point16.X, and Terraria.DataStructures.Point16.Y.