Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network overhaul, fixes multiplayer. #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,4 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/todo_mv.txt
140 changes: 70 additions & 70 deletions Components/TEAbstractStorageUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,88 +11,88 @@

namespace MagicStorage.Components
{
public abstract class TEAbstractStorageUnit : TEStorageComponent
{
private bool inactive;
private Point16 center;
public abstract class TEAbstractStorageUnit : TEStorageComponent
{
private bool inactive;
private Point16 center;

public bool Inactive
{
get
{
return inactive;
}
set
{
inactive = value;
}
}
public bool Inactive
{
get
{
return inactive;
}
set
{
inactive = value;
}
}

public abstract bool IsFull
{
get;
}
public abstract bool IsFull
{
get;
}

public bool Link(Point16 pos)
{
bool changed = pos != center;
center = pos;
return changed;
}
public bool Link(Point16 pos)
{
bool changed = pos != center;
center = pos;
return changed;
}

public bool Unlink()
{
return Link(new Point16(-1, -1));
}
public bool Unlink()
{
return Link(new Point16(-1, -1));
}

public TEStorageHeart GetHeart()
{
if (center != new Point16(-1, -1) && TileEntity.ByPosition.ContainsKey(center) && TileEntity.ByPosition[center] is TEStorageCenter)
{
return ((TEStorageCenter)TileEntity.ByPosition[center]).GetHeart();
}
return null;
}
public TEStorageHeart GetHeart()
{
if (center != new Point16(-1, -1) && TileEntity.ByPosition.ContainsKey(center) && TileEntity.ByPosition[center] is TEStorageCenter)
{
return ((TEStorageCenter)TileEntity.ByPosition[center]).GetHeart();
}
return null;
}

public abstract bool HasSpaceInStackFor(Item check, bool locked = false);
public abstract bool HasSpaceInStackFor(Item check);

public abstract bool HasItem(Item check, bool locked = false);
public abstract bool HasItem(Item check);

public abstract IEnumerable<Item> GetItems();
public abstract IEnumerable<Item> GetItems();

public abstract void DepositItem(Item toDeposit, bool locked = false);
public abstract void DepositItem(Item toDeposit);

public abstract Item TryWithdraw(Item lookFor, bool locked = false);
public abstract Item TryWithdraw(Item lookFor, bool keepOneIfFavorite = false);

public override TagCompound Save()
{
TagCompound tag = new TagCompound();
tag.Set("Inactive", inactive);
TagCompound tagCenter = new TagCompound();
tagCenter.Set("X", center.X);
tagCenter.Set("Y", center.Y);
tag.Set("Center", tagCenter);
return tag;
}
public override TagCompound Save()
{
TagCompound tag = new TagCompound();
tag.Set("Inactive", inactive);
TagCompound tagCenter = new TagCompound();
tagCenter.Set("X", center.X);
tagCenter.Set("Y", center.Y);
tag.Set("Center", tagCenter);
return tag;
}

public override void Load(TagCompound tag)
{
inactive = tag.GetBool("Inactive");
TagCompound tagCenter = tag.GetCompound("Center");
center = new Point16(tagCenter.GetShort("X"), tagCenter.GetShort("Y"));
}
public override void Load(TagCompound tag)
{
inactive = tag.GetBool("Inactive");
TagCompound tagCenter = tag.GetCompound("Center");
center = new Point16(tagCenter.GetShort("X"), tagCenter.GetShort("Y"));
}

public override void NetSend(BinaryWriter writer, bool lightSend)
{
writer.Write(inactive);
writer.Write(center.X);
writer.Write(center.Y);
}
public override void NetSend(BinaryWriter writer, bool lightSend)
{
writer.Write(inactive);
writer.Write(center.X);
writer.Write(center.Y);
}

public override void NetReceive(BinaryReader reader, bool lightReceive)
{
inactive = reader.ReadBoolean();
center = new Point16(reader.ReadInt16(), reader.ReadInt16());
}
}
public override void NetReceive(BinaryReader reader, bool lightReceive)
{
inactive = reader.ReadBoolean();
center = new Point16(reader.ReadInt16(), reader.ReadInt16());
}
}
}
Loading