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

◆ Draw()

static void Terraria.GameInput.LockOnHelper.Draw ( SpriteBatch spriteBatch)
inlinestatic

Definition at line 413 of file LockOnHelper.cs.

414 {
415 if (Main.gameMenu)
416 {
417 return;
418 }
420 Rectangle rectangle = new Rectangle(0, 0, value.Width, 12);
421 Rectangle rectangle2 = new Rectangle(0, 16, value.Width, 12);
422 Color t = Main.OurFavoriteColor.MultiplyRGBA(new Color(0.75f, 0.75f, 0.75f, 1f));
423 t.A = 220;
424 Color t2 = Main.OurFavoriteColor;
425 t2.A = 220;
426 float num = 0.94f + (float)Math.Sin(Main.GlobalTimeWrappedHourly * ((float)Math.PI * 2f)) * 0.06f;
427 t2 *= num;
428 t *= num;
429 Utils.Swap(ref t, ref t2);
430 Color color = t.MultiplyRGBA(new Color(0.8f, 0.8f, 0.8f, 0.8f));
431 Color color2 = t.MultiplyRGBA(new Color(0.8f, 0.8f, 0.8f, 0.8f));
432 float gravDir = Main.player[Main.myPlayer].gravDir;
433 float num2 = 1f;
434 float num3 = 0.1f;
435 float num4 = 0.8f;
436 float num5 = 1f;
437 float num6 = 10f;
438 float num7 = 10f;
439 bool flag = false;
440 for (int i = 0; i < _drawProgress.GetLength(0); i++)
441 {
442 int num8 = 0;
443 if (_pickedTarget != -1 && _targets.Count > 0 && i == _targets[_pickedTarget])
444 {
445 num8 = 2;
446 }
447 else if ((flag && _targets.Contains(i)) || (UseMode == LockOnMode.ThreeDS && _threeDSTarget == i) || (UseMode == LockOnMode.TargetClosest && _targetClosestTarget == i))
448 {
449 num8 = 1;
450 }
451 _drawProgress[i, 0] = MathHelper.Clamp(_drawProgress[i, 0] + ((num8 == 1) ? num3 : (0f - num3)), 0f, 1f);
452 _drawProgress[i, 1] = MathHelper.Clamp(_drawProgress[i, 1] + ((num8 == 2) ? num3 : (0f - num3)), 0f, 1f);
453 float num9 = _drawProgress[i, 0];
454 if (num9 > 0f)
455 {
456 float num10 = 1f - num9 * num9;
457 Vector2 pos = Main.npc[i].Top + new Vector2(0f, 0f - num7 - num10 * num6) * gravDir - Main.screenPosition;
458 pos = Main.ReverseGravitySupport(pos, Main.npc[i].height);
459 spriteBatch.Draw(value, pos, rectangle, color * num9, 0f, rectangle.Size() / 2f, new Vector2(0.58f, 1f) * num2 * num4 * (1f + num9) / 2f, SpriteEffects.None, 0f);
460 spriteBatch.Draw(value, pos, rectangle2, color2 * num9 * num9, 0f, rectangle2.Size() / 2f, new Vector2(0.58f, 1f) * num2 * num4 * (1f + num9) / 2f, SpriteEffects.None, 0f);
461 }
462 float num11 = _drawProgress[i, 1];
463 if (num11 > 0f)
464 {
465 int num12 = Main.npc[i].width;
466 if (Main.npc[i].height > num12)
467 {
468 num12 = Main.npc[i].height;
469 }
470 num12 += 20;
471 if ((float)num12 < 70f)
472 {
473 num5 *= (float)num12 / 70f;
474 }
475 float num13 = 3f;
476 Vector2 vector = Main.npc[i].Center;
477 if (_targets.Count >= 0 && _pickedTarget >= 0 && _pickedTarget < _targets.Count && i == _targets[_pickedTarget] && NPC.GetNPCLocation(i, seekHead: true, averageDirection: false, out var _, out var pos2))
478 {
479 vector = pos2;
480 }
481 for (int j = 0; (float)j < num13; j++)
482 {
483 float num14 = (float)Math.PI * 2f / num13 * (float)j + Main.GlobalTimeWrappedHourly * ((float)Math.PI * 2f) * 0.25f;
484 Vector2 vector2 = new Vector2(0f, num12 / 2).RotatedBy(num14);
485 Vector2 pos3 = vector + vector2 - Main.screenPosition;
486 pos3 = Main.ReverseGravitySupport(pos3);
487 float rotation = num14 * (float)((gravDir == 1f) ? 1 : (-1)) + (float)Math.PI * (float)((gravDir == 1f) ? 1 : 0);
488 spriteBatch.Draw(value, pos3, rectangle, t * num11, rotation, rectangle.Size() / 2f, new Vector2(0.58f, 1f) * num2 * num5 * (1f + num11) / 2f, SpriteEffects.None, 0f);
489 spriteBatch.Draw(value, pos3, rectangle2, t2 * num11 * num11, rotation, rectangle2.Size() / 2f, new Vector2(0.58f, 1f) * num2 * num5 * (1f + num11) / 2f, SpriteEffects.None, 0f);
490 }
491 }
492 }
493 }
void Draw(Texture2D texture, Vector2 position, Color color)
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static double Sin(double a)
const double PI
Definition Math.cs:16
static Asset< Texture2D > LockOnCursor

References Terraria.GameInput.LockOnHelper._drawProgress, Terraria.GameInput.LockOnHelper._pickedTarget, Terraria.GameInput.LockOnHelper._targetClosestTarget, Terraria.GameInput.LockOnHelper._targets, Terraria.GameInput.LockOnHelper._threeDSTarget, Microsoft.Xna.Framework.MathHelper.Clamp(), Microsoft.Xna.Framework.Graphics.Color, Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(), Terraria.Main.gameMenu, Terraria.NPC.GetNPCLocation(), Terraria.Main.GlobalTimeWrappedHourly, Terraria.GameContent.TextureAssets.LockOnCursor, Terraria.Main.myPlayer, Terraria.Main.npc, Terraria.Main.OurFavoriteColor, System.Math.PI, Terraria.Main.player, Terraria.Main.ReverseGravitySupport(), Terraria.Main.screenPosition, System.Math.Sin(), Terraria.GameInput.LockOnHelper.UseMode, System.value, and Microsoft.Xna.Framework.Graphics.Vector2.

Referenced by Terraria.Main.DrawInterface_5_GamepadLockOn().