Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DRKV333 committed Oct 7, 2018
2 parents b37e67d + ab2c8ad commit 94df965
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 10 deletions.
3 changes: 2 additions & 1 deletion MechTransfer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MechTransfer</RootNamespace>
<AssemblyName>MechTransfer</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down
54 changes: 47 additions & 7 deletions MechTransferAssemblerWorld.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MechTransfer.Tiles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.GameContent.UI;
using Terraria.ModLoader;
Expand All @@ -9,11 +10,19 @@ namespace MechTransfer
{
internal class MechTransferAssemblerWorld : ModWorld
{
public override void PostDrawTiles()
private Texture2D pixel;

public override void Initialize()
{
if (!WiresUI.Settings.DrawWires)
return;
if (!Main.dedServ)
{
pixel = new Texture2D(Main.graphics.GraphicsDevice, 1, 1);
pixel.SetData(new Color[] { Color.White });
}
}

public override void PostDrawTiles()
{
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

int screenLeft = (int)((Main.screenPosition.X) / 16f - 1f);
Expand All @@ -33,16 +42,47 @@ public override void PostDrawTiles()
{
for (int y = screenTop; y < screenBottom; y++)
{
if (Main.tile[x, y] != null && Main.tile[x, y].active() && Main.tile[x, y].type == mod.TileType<TransferAssemblerTile>())
if (Main.tile[x, y] != null && Main.tile[x, y].active())
{
Vector2 start = new Vector2(x * 16 - 81, y * 16 - 81);
Vector2 end = new Vector2(x * 16 + 97, y * 16 + 97);
Utils.DrawRectangle(Main.spriteBatch, start, end, Color.LightSeaGreen, Color.LightSeaGreen, 2f);
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>())
{
DrawTransition(x, y - 1, mod.GetTexture("Tiles/Transitions/Top"));
DrawTransition(x, y + 1, mod.GetTexture("Tiles/Transitions/Bottom"));
DrawTransition(x - 1, y, mod.GetTexture("Tiles/Transitions/Left"));
DrawTransition(x + 1, y, mod.GetTexture("Tiles/Transitions/Right"));
}

if (WiresUI.Settings.DrawWires && Main.tile[x, y].type == mod.TileType<TransferAssemblerTile>())
{
DrawRectFast(x * 16 - 80 - (int)Main.screenPosition.X, y * 16 - 80 - (int)Main.screenPosition.Y, 176, 176);
}
}
}
}

Main.spriteBatch.End();
}

private void DrawRectFast(int left, int top, int height, int width)
{
if (Main.LocalPlayer.gravDir == -1)
top = Main.screenHeight - top - height;

Main.spriteBatch.Draw(pixel, new Rectangle(left, top, width, 2), null, Color.LightSeaGreen);
Main.spriteBatch.Draw(pixel, new Rectangle(left, top + height, width, 2), null, Color.LightSeaGreen);
Main.spriteBatch.Draw(pixel, new Rectangle(left, top, 2, height), null, Color.LightSeaGreen);
Main.spriteBatch.Draw(pixel, new Rectangle(left + width, top, 2, height), null, Color.LightSeaGreen);
}

private void DrawTransition(int x, int y, Texture2D texture)
{
if(mod.GetModWorld<TransferAgent>().IsContainer(x, y))
{
if(Main.LocalPlayer.gravDir == 1)
Main.spriteBatch.Draw(texture, new Vector2(x * 16 - Main.screenPosition.X, y * 16 - Main.screenPosition.Y), Lighting.GetColor(x,y));
else
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);
}
}
}
}
Binary file added Tiles/Transitions/Bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tiles/Transitions/Left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tiles/Transitions/Right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tiles/Transitions/Top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Tiles/Transitions/Transitions.xcf
Binary file not shown.
6 changes: 6 additions & 0 deletions TransferAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public ContainerAdapter FindContainer(int x, int y)
return null;
}

public bool IsContainer(int x, int y)
{
Tile tile = Main.tile[x, y];
return (tile != null && tile.active() && ContainerAdapters.ContainsKey(tile.type));
}

//trigger wire on the new update, to stop infinite wire loops
public void TripWireDelayed(int x, int y, int width, int height)
{
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = DRKV
version = 1.6.1
version = 1.6.2
displayName = MechTransfer
includePDB = false
weakReferences = [email protected]
Expand Down
6 changes: 5 additions & 1 deletion description.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ v1.6.1
- Fixed filterable tile save/load with modded items
- Fixed buttons in multiplayer
- New net packet handling system
- Added player interface
- Added player interface

v1.6.2
- Improved assembler area drawing
- Added transition markers

0 comments on commit 94df965

Please sign in to comment.