1
1
using MechTransfer . Tiles ;
2
2
using Microsoft . Xna . Framework ;
3
3
using Microsoft . Xna . Framework . Graphics ;
4
+ using System ;
4
5
using Terraria ;
5
6
using Terraria . GameContent . UI ;
6
7
using Terraria . ModLoader ;
@@ -9,11 +10,19 @@ namespace MechTransfer
9
10
{
10
11
internal class MechTransferAssemblerWorld : ModWorld
11
12
{
12
- public override void PostDrawTiles ( )
13
+ private Texture2D pixel ;
14
+
15
+ public override void Initialize ( )
13
16
{
14
- if ( ! WiresUI . Settings . DrawWires )
15
- return ;
17
+ if ( ! Main . dedServ )
18
+ {
19
+ pixel = new Texture2D ( Main . graphics . GraphicsDevice , 1 , 1 ) ;
20
+ pixel . SetData ( new Color [ ] { Color . White } ) ;
21
+ }
22
+ }
16
23
24
+ public override void PostDrawTiles ( )
25
+ {
17
26
Main . spriteBatch . Begin ( SpriteSortMode . Immediate , BlendState . AlphaBlend ) ;
18
27
19
28
int screenLeft = ( int ) ( ( Main . screenPosition . X ) / 16f - 1f ) ;
@@ -33,16 +42,47 @@ public override void PostDrawTiles()
33
42
{
34
43
for ( int y = screenTop ; y < screenBottom ; y ++ )
35
44
{
36
- if ( Main . tile [ x , y ] != null && Main . tile [ x , y ] . active ( ) && Main . tile [ x , y ] . type == mod . TileType < TransferAssemblerTile > ( ) )
45
+ if ( Main . tile [ x , y ] != null && Main . tile [ x , y ] . active ( ) )
37
46
{
38
- Vector2 start = new Vector2 ( x * 16 - 81 , y * 16 - 81 ) ;
39
- Vector2 end = new Vector2 ( x * 16 + 97 , y * 16 + 97 ) ;
40
- Utils . DrawRectangle ( Main . spriteBatch , start , end , Color . LightSeaGreen , Color . LightSeaGreen , 2f ) ;
47
+ if ( Main . tile [ x , y ] . type == mod . TileType < TransferInjectorTile > ( ) || Main . tile [ x , y ] . type == mod . TileType < TransferExtractorTile > ( ) || Main . tile [ x , y ] . type == mod . TileType < StackExtractorTile > ( ) || Main . tile [ x , y ] . type == mod . TileType < TransferAssemblerTile > ( ) )
48
+ {
49
+ DrawTransition ( x , y - 1 , mod . GetTexture ( "Tiles/Transitions/Top" ) ) ;
50
+ DrawTransition ( x , y + 1 , mod . GetTexture ( "Tiles/Transitions/Bottom" ) ) ;
51
+ DrawTransition ( x - 1 , y , mod . GetTexture ( "Tiles/Transitions/Left" ) ) ;
52
+ DrawTransition ( x + 1 , y , mod . GetTexture ( "Tiles/Transitions/Right" ) ) ;
53
+ }
54
+
55
+ if ( WiresUI . Settings . DrawWires && Main . tile [ x , y ] . type == mod . TileType < TransferAssemblerTile > ( ) )
56
+ {
57
+ DrawRectFast ( x * 16 - 80 - ( int ) Main . screenPosition . X , y * 16 - 80 - ( int ) Main . screenPosition . Y , 176 , 176 ) ;
58
+ }
41
59
}
42
60
}
43
61
}
44
62
45
63
Main . spriteBatch . End ( ) ;
46
64
}
65
+
66
+ private void DrawRectFast ( int left , int top , int height , int width )
67
+ {
68
+ if ( Main . LocalPlayer . gravDir == - 1 )
69
+ top = Main . screenHeight - top - height ;
70
+
71
+ Main . spriteBatch . Draw ( pixel , new Rectangle ( left , top , width , 2 ) , null , Color . LightSeaGreen ) ;
72
+ Main . spriteBatch . Draw ( pixel , new Rectangle ( left , top + height , width , 2 ) , null , Color . LightSeaGreen ) ;
73
+ Main . spriteBatch . Draw ( pixel , new Rectangle ( left , top , 2 , height ) , null , Color . LightSeaGreen ) ;
74
+ Main . spriteBatch . Draw ( pixel , new Rectangle ( left + width , top , 2 , height ) , null , Color . LightSeaGreen ) ;
75
+ }
76
+
77
+ private void DrawTransition ( int x , int y , Texture2D texture )
78
+ {
79
+ if ( mod . GetModWorld < TransferAgent > ( ) . IsContainer ( x , y ) )
80
+ {
81
+ if ( Main . LocalPlayer . gravDir == 1 )
82
+ Main . spriteBatch . Draw ( texture , new Vector2 ( x * 16 - Main . screenPosition . X , y * 16 - Main . screenPosition . Y ) , Lighting . GetColor ( x , y ) ) ;
83
+ else
84
+ Main . spriteBatch . Draw ( texture , new Vector2 ( x * 16 - Main . screenPosition . X , Main . screenHeight - y * 16 + Main . screenPosition . Y - 16 ) , null , Lighting . GetColor ( x , y ) , 0 , Vector2 . Zero , 1 , SpriteEffects . FlipVertically , 0 ) ;
85
+ }
86
+ }
47
87
}
48
88
}
0 commit comments