5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
15 internal sealed
class MysteriousWorkbench :
ModTile 17 private const int Size = 16;
18 private const int Padding = 2;
20 public override void SetDefaults()
22 Main.tileLighted[Type] =
true;
23 Main.tileNoAttach[Type] =
true;
24 Main.tileFrameImportant[Type] =
true;
25 Main.tileSpelunker[Type] =
true;
26 Main.tileShine2[Type] =
true;
27 Main.tileShine[Type] = 1200;
30 TileObjectData.newTile.Width = 4;
31 TileObjectData.newTile.Height = 3;
32 TileObjectData.newTile.AnchorBottom =
new AnchorData(AnchorType.SolidTile, TileObjectData.newTile.Width, 0);
33 TileObjectData.newTile.UsesCustomCanPlace =
true;
34 TileObjectData.newTile.CoordinateWidth = Size;
35 TileObjectData.newTile.CoordinatePadding = Padding;
36 TileObjectData.newTile.CoordinateHeights =
new int[] {Size, Size, Size};
38 TileObjectData.newTile.Origin =
new Point16(2, 2);
39 TileObjectData.newTile.DrawYOffset = 2;
40 TileObjectData.newTile.LavaDeath =
false;
42 TileObjectData.addTile(Type);
45 ModTranslation name = CreateMapEntryName();
46 name.SetDefault(
"MysteriousWorkbench");
47 AddMapEntry(
new Color(50, 50, 50), name);
49 disableSmartCursor =
true;
52 public override void MouseOver(
int i,
int j)
54 if (Main.LocalPlayer.mouseInterface)
return;
55 Player player = Main.LocalPlayer;
56 Tile tile = Main.tile[i, j];
58 player.showItemIcon =
true;
60 player.showItemIcon2 = ModContent.ItemType<MysteriousWorkbenchItem>();
63 public override void MouseOverFar(
int i,
int j)
66 Player player = Main.LocalPlayer;
67 if (player.showItemIconText ==
"")
69 player.showItemIcon =
false;
70 player.showItemIcon2 = 0;
74 public override bool NewRightClick(
int i,
int j)
76 Tile tile = Main.tile[i, j];
77 Main.mouseRightRelease =
false;
79 if (tile.type == Type && Main.LocalPlayer.Distance(
new Point16(i, j).ToWorldCoordinates()) <= 15 * 16f)
81 Loot.Instance.GuiState.ToggleUI(
Loot.Instance.GuiInterface);
88 public override void ModifyLight(
int i,
int j, ref
float r, ref
float g, ref
float b)
90 Color useColor = Color.White;
91 Tile tile = Main.tile[i, j];
93 if (tile.type == Type)
95 var sine = (float) Math.Sin(Main.essScale * 0.50f);
96 r = 0.05f + 0.35f * sine * useColor.R * 0.01f;
97 g = 0.05f + 0.35f * sine * useColor.G * 0.01f;
98 b = 0.05f + 0.35f * sine * useColor.B * 0.01f;
102 public override void DrawEffects(
int i,
int j, SpriteBatch spriteBatch, ref Color drawColor, ref
int nextSpecialDrawIndex)
104 if (
Loot.Instance.GuiState.Visible && Main.LocalPlayer.Distance(
new Point16(i, j).ToWorldCoordinates()) > 15 * 16f)
106 Loot.Instance.GuiState.ToggleUI(
Loot.Instance.GuiInterface);
110 public override void KillMultiTile(
int i,
int j,
int frameX,
int frameY)
112 if (!Main.dedServ &&
Loot.Instance.GuiState.Visible)
115 Loot.Instance.GuiState.ToggleUI(
Loot.Instance.GuiInterface);
118 Item.NewItem(i * 16, j * 16, 20, 28, ModContent.ItemType<MysteriousWorkbenchItem>());
124 public override void PostDraw(
int i,
int j, SpriteBatch spriteBatch)
126 var tile = Main.tile[i, j];
128 if (tile.type == Type
129 && tile.IsTopLeftFrame())
131 var top = tile.GetTopLeftFrame(i, j, Size, Padding);
133 if (
Loot.Instance.GuiState.Visible
134 &&
Loot.Instance.GuiState.GetCurrentTab() is GuiCubingTab tab
135 && !tab.ComponentButton.Item.IsAir)
137 Vector2 zero = Main.drawToScreen
139 :
new Vector2(Main.offScreenRange, Main.offScreenRange);
141 Texture2D animTexture = Assets.Textures.GUI.LunarCubeTexture;
142 const int frameWidth = 20;
143 const int frameHeight = 28;
144 Vector2 offset =
new Vector2(36f, 8f);
145 Vector2 position =
new Vector2(i, j) * 16f - Main.screenPosition + offset;
146 Vector2 origin =
new Vector2(frameHeight, frameWidth) * 0.5f;
148 frame = (frame + 0.75f) % 8;
149 spriteBatch.Draw(animTexture, position + zero,
150 new Rectangle(0, frameHeight * (
int) frame, frameWidth, frameHeight), Color.White, 0f, origin, 1f,
151 SpriteEffects.None, 0f);