-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
931 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using MagicStorage; | ||
using MagicStorage.Components; | ||
using System; | ||
using System.Collections.Generic; | ||
using Terraria; | ||
using Terraria.DataStructures; | ||
|
||
namespace MechTransfer.ContainerAdapters | ||
{ | ||
internal class MagicStorageInterfaceAdapter | ||
{ | ||
private TEStorageHeart FindHeart(int x, int y) | ||
{ | ||
Point16 center = TEStorageComponent.FindStorageCenter(new Point16(x, y)); | ||
if (center.X == -1 && center.Y == -1) | ||
return null; | ||
|
||
TEStorageHeart heart = ((TEStorageCenter)TileEntity.ByPosition[center]).GetHeart(); | ||
|
||
return heart; | ||
} | ||
|
||
private void HandleStorageItemChange(TEStorageHeart heart) | ||
{ | ||
if (Main.netMode == 2) | ||
{ | ||
NetHelper.SendRefreshNetworkItems(heart.ID); | ||
} | ||
else if (Main.netMode == 0) | ||
{ | ||
StorageGUI.RefreshItems(); | ||
} | ||
} | ||
|
||
public void KickMe() | ||
{ | ||
Main.LocalPlayer.GetModPlayer<StoragePlayer>().CloseStorage(); | ||
} | ||
|
||
public bool InjectItem(int x, int y, Item item) | ||
{ | ||
int oldstack = item.stack; | ||
|
||
TEStorageHeart targetHeart = FindHeart(x, y); | ||
targetHeart.DepositItem(item); | ||
|
||
if (oldstack != item.stack) | ||
{ | ||
HandleStorageItemChange(targetHeart); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public IEnumerable<Tuple<Item, object>> EnumerateItems(int x, int y) | ||
{ | ||
TEStorageHeart targetHeart = FindHeart(x, y); | ||
foreach (var item in targetHeart.GetStoredItems()) | ||
{ | ||
yield return new Tuple<Item, object>(item, item.type); | ||
} | ||
} | ||
|
||
public void TakeItem(int x, int y, object slot, int amount) | ||
{ | ||
TEStorageHeart targetHeart = FindHeart(x, y); | ||
|
||
Item toWithdraw = new Item(); | ||
toWithdraw.SetDefaults((int)slot); | ||
toWithdraw.stack = amount; | ||
|
||
targetHeart.TryWithdraw(toWithdraw); | ||
|
||
HandleStorageItemChange(targetHeart); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Terraria; | ||
using Terraria.DataStructures; | ||
|
||
namespace MechTransfer | ||
{ | ||
public interface ITransferTarget | ||
{ | ||
ushort Type { get; } | ||
|
||
bool Receive(TransferUtils agent, Point16 location, Item item); | ||
} | ||
|
||
public interface ITransferPassthrough | ||
{ | ||
ushort Type { get; } | ||
|
||
bool ShouldPassthrough(TransferUtils agent, Point16 location, Item item); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.