Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
DRKV333 committed May 13, 2018
2 parents 4a25515 + dc89613 commit b37e67d
Show file tree
Hide file tree
Showing 30 changed files with 772 additions and 121 deletions.
12 changes: 4 additions & 8 deletions ChestPlacementFix.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ModLoader;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MechTransfer
{
class ChestPlacementFix : GlobalTile
internal class ChestPlacementFix : GlobalTile
{
private List<int> noChestTiles = new List<int>();

Expand All @@ -31,4 +27,4 @@ public void AddNoChestTile(int type)
noChestTiles.Add(type);
}
}
}
}
16 changes: 13 additions & 3 deletions ContainerAdapters/ChestAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MechTransfer.ContainerAdapters
{
internal class ChestAdapter
internal class ChestAdapter : INetHandler
{
private Mod mod;

public ChestAdapter(Mod mod)
{
this.mod = mod;
NetRouter.AddHandler(this);
}

private int FindChest(int x, int y)
Expand Down Expand Up @@ -43,9 +46,9 @@ private void HandleChestItemChange(int chest)
{
if (Main.netMode == 2)
{
ModPacket packet = mod.GetPacket();
packet.Write((byte)MechTransfer.ModMessageID.KickFromChest);
ModPacket packet = NetRouter.GetPacketTo(this, mod);
packet.Send(targetPlayer);
Main.player[targetPlayer].chest = -1;
}
else if (Main.netMode == 0)
Recipe.FindRecipes();
Expand Down Expand Up @@ -139,5 +142,12 @@ public void TakeItem(int x, int y, object slot, int amount)

HandleChestItemChange(c);
}

public void HandlePacket(BinaryReader reader, int WhoAmI)
{
Main.LocalPlayer.chest = -1;
Recipe.FindRecipes();
Main.PlaySound(SoundID.MenuClose);
}
}
}
22 changes: 19 additions & 3 deletions ContainerAdapters/OmniTurretAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace MechTransfer.ContainerAdapters
{
internal class OmniTurretAdapter
internal class OmniTurretAdapter : INetHandler
{
private Mod mod;

Expand All @@ -18,6 +19,7 @@ internal class OmniTurretAdapter
public OmniTurretAdapter(Mod mod)
{
this.mod = mod;
NetRouter.AddHandler(this);
}

public void TakeItem(int x, int y, object slot, int amount)
Expand Down Expand Up @@ -70,8 +72,7 @@ public bool InjectItem(int x, int y, Item item)

if (Main.netMode == 2)
{
ModPacket packet = mod.GetPacket();
packet.Write((byte)MechTransfer.ModMessageID.ProjectileMakeHostile);
ModPacket packet = NetRouter.GetPacketTo(this, mod);
packet.Write((Int16)proj.identity);
packet.Write((byte)proj.owner);
packet.Send();
Expand All @@ -82,5 +83,20 @@ public bool InjectItem(int x, int y, Item item)

return true;
}

public void HandlePacket(BinaryReader reader, int WhoAmI)
{
int identity = reader.ReadInt16();
int owner = reader.ReadByte();
for (int i = 0; i < 1000; i++)
{
Projectile proj = Main.projectile[i];
if (proj.owner == owner && proj.identity == identity && proj.active)
{
proj.hostile = true;
break;
}
}
}
}
}
Loading

0 comments on commit b37e67d

Please sign in to comment.