ReSharper code reformat to match naming conventions and stuff
This commit is contained in:
parent
1147788154
commit
c6abbfe4d2
45 changed files with 11639 additions and 11342 deletions
|
|
@ -4,32 +4,33 @@ using System.IO.Streams;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
public class BaseMsg : IPackable
|
||||
{
|
||||
public virtual PacketTypes ID
|
||||
{
|
||||
get { throw new NotImplementedException("Msg ID not implemented"); }
|
||||
}
|
||||
public void PackFull(Stream stream)
|
||||
{
|
||||
long start = stream.Position;
|
||||
stream.WriteInt32(1);
|
||||
stream.WriteInt8((byte)ID);
|
||||
Pack(stream);
|
||||
long end = stream.Position;
|
||||
stream.Position = start;
|
||||
stream.WriteInt32((int)(end - start) - 4);
|
||||
stream.Position = end;
|
||||
}
|
||||
public class BaseMsg : IPackable
|
||||
{
|
||||
public virtual PacketTypes ID
|
||||
{
|
||||
get { throw new NotImplementedException("Msg ID not implemented"); }
|
||||
}
|
||||
|
||||
public virtual void Unpack(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void PackFull(Stream stream)
|
||||
{
|
||||
long start = stream.Position;
|
||||
stream.WriteInt32(1);
|
||||
stream.WriteInt8((byte) ID);
|
||||
Pack(stream);
|
||||
long end = stream.Position;
|
||||
stream.Position = start;
|
||||
stream.WriteInt32((int) (end - start) - 4);
|
||||
stream.Position = end;
|
||||
}
|
||||
|
||||
public virtual void Pack(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void Unpack(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void Pack(Stream stream)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,19 +4,18 @@ using System.Text;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
class DisconnectMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return PacketTypes.Disconnect;
|
||||
}
|
||||
}
|
||||
public string Reason {get;set;}
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteBytes(Encoding.ASCII.GetBytes(Reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
internal class DisconnectMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get { return PacketTypes.Disconnect; }
|
||||
}
|
||||
|
||||
public string Reason { get; set; }
|
||||
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteBytes(Encoding.ASCII.GetBytes(Reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,116 +23,127 @@ using Terraria;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
public class NetTile : IPackable
|
||||
{
|
||||
public bool Active { get; set; }
|
||||
public byte Type { get; set; }
|
||||
public short FrameX { get; set; }
|
||||
public short FrameY { get; set; }
|
||||
public byte Wall { get; set; }
|
||||
public byte Liquid { get; set; }
|
||||
public bool Lava { get; set; }
|
||||
public bool Wire { get; set; }
|
||||
public class NetTile : IPackable
|
||||
{
|
||||
public bool Active { get; set; }
|
||||
public byte Type { get; set; }
|
||||
public short FrameX { get; set; }
|
||||
public short FrameY { get; set; }
|
||||
public byte Wall { get; set; }
|
||||
public byte Liquid { get; set; }
|
||||
public bool Lava { get; set; }
|
||||
public bool Wire { get; set; }
|
||||
|
||||
public bool HasWall { get { return Wall > 0; } }
|
||||
public bool HasLiquid { get { return Liquid > 0; } }
|
||||
public bool FrameImportant { get { return Main.tileFrameImportant[Type]; } }
|
||||
public bool HasWall
|
||||
{
|
||||
get { return Wall > 0; }
|
||||
}
|
||||
|
||||
public NetTile()
|
||||
{
|
||||
Active = false;
|
||||
Type = 0;
|
||||
FrameX = -1;
|
||||
FrameY = -1;
|
||||
Wall = 0;
|
||||
Liquid = 0;
|
||||
Lava = false;
|
||||
Wire = false;
|
||||
}
|
||||
public bool HasLiquid
|
||||
{
|
||||
get { return Liquid > 0; }
|
||||
}
|
||||
|
||||
public NetTile(Stream stream)
|
||||
: this()
|
||||
{
|
||||
Unpack(stream);
|
||||
}
|
||||
public bool FrameImportant
|
||||
{
|
||||
get { return Main.tileFrameImportant[Type]; }
|
||||
}
|
||||
|
||||
public void Pack(Stream stream)
|
||||
{
|
||||
var flags = TileFlags.None;
|
||||
public NetTile()
|
||||
{
|
||||
Active = false;
|
||||
Type = 0;
|
||||
FrameX = -1;
|
||||
FrameY = -1;
|
||||
Wall = 0;
|
||||
Liquid = 0;
|
||||
Lava = false;
|
||||
Wire = false;
|
||||
}
|
||||
|
||||
if (Active)
|
||||
flags |= TileFlags.Active;
|
||||
public NetTile(Stream stream)
|
||||
: this()
|
||||
{
|
||||
Unpack(stream);
|
||||
}
|
||||
|
||||
if (HasWall)
|
||||
flags |= TileFlags.Wall;
|
||||
public void Pack(Stream stream)
|
||||
{
|
||||
var flags = TileFlags.None;
|
||||
|
||||
if (HasLiquid)
|
||||
flags |= TileFlags.Liquid;
|
||||
if (Active)
|
||||
flags |= TileFlags.Active;
|
||||
|
||||
if (Wire)
|
||||
flags |= TileFlags.Wire;
|
||||
if (HasWall)
|
||||
flags |= TileFlags.Wall;
|
||||
|
||||
stream.WriteInt8((byte)flags);
|
||||
if (HasLiquid)
|
||||
flags |= TileFlags.Liquid;
|
||||
|
||||
if (Active)
|
||||
{
|
||||
stream.WriteInt8(Type);
|
||||
if (FrameImportant)
|
||||
{
|
||||
stream.WriteInt16(FrameX);
|
||||
stream.WriteInt16(FrameY);
|
||||
}
|
||||
}
|
||||
if (Wire)
|
||||
flags |= TileFlags.Wire;
|
||||
|
||||
if (HasWall)
|
||||
stream.WriteInt8(Wall);
|
||||
stream.WriteInt8((byte) flags);
|
||||
|
||||
if (HasLiquid)
|
||||
{
|
||||
stream.WriteInt8(Liquid);
|
||||
stream.WriteBoolean(Lava);
|
||||
}
|
||||
}
|
||||
if (Active)
|
||||
{
|
||||
stream.WriteInt8(Type);
|
||||
if (FrameImportant)
|
||||
{
|
||||
stream.WriteInt16(FrameX);
|
||||
stream.WriteInt16(FrameY);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unpack(Stream stream)
|
||||
{
|
||||
var flags = (TileFlags)stream.ReadInt8();
|
||||
if (HasWall)
|
||||
stream.WriteInt8(Wall);
|
||||
|
||||
Active = flags.HasFlag(TileFlags.Active);
|
||||
if (Active)
|
||||
{
|
||||
Type = stream.ReadInt8();
|
||||
if (FrameImportant)
|
||||
{
|
||||
FrameX = stream.ReadInt16();
|
||||
FrameY = stream.ReadInt16();
|
||||
}
|
||||
}
|
||||
if (HasLiquid)
|
||||
{
|
||||
stream.WriteInt8(Liquid);
|
||||
stream.WriteBoolean(Lava);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags.HasFlag(TileFlags.Wall))
|
||||
{
|
||||
Wall = stream.ReadInt8();
|
||||
}
|
||||
public void Unpack(Stream stream)
|
||||
{
|
||||
var flags = (TileFlags) stream.ReadInt8();
|
||||
|
||||
if (flags.HasFlag(TileFlags.Liquid))
|
||||
{
|
||||
Liquid = stream.ReadInt8();
|
||||
Lava = stream.ReadBoolean();
|
||||
}
|
||||
Active = flags.HasFlag(TileFlags.Active);
|
||||
if (Active)
|
||||
{
|
||||
Type = stream.ReadInt8();
|
||||
if (FrameImportant)
|
||||
{
|
||||
FrameX = stream.ReadInt16();
|
||||
FrameY = stream.ReadInt16();
|
||||
}
|
||||
}
|
||||
|
||||
if (flags.HasFlag(TileFlags.Wire))
|
||||
Wire = true;
|
||||
}
|
||||
}
|
||||
if (flags.HasFlag(TileFlags.Wall))
|
||||
{
|
||||
Wall = stream.ReadInt8();
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum TileFlags : byte
|
||||
{
|
||||
None = 0,
|
||||
Active = 1,
|
||||
Lighted = 2,
|
||||
Wall = 4,
|
||||
Liquid = 8,
|
||||
Wire = 16
|
||||
}
|
||||
}
|
||||
if (flags.HasFlag(TileFlags.Liquid))
|
||||
{
|
||||
Liquid = stream.ReadInt8();
|
||||
Lava = stream.ReadBoolean();
|
||||
}
|
||||
|
||||
if (flags.HasFlag(TileFlags.Wire))
|
||||
Wire = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum TileFlags : byte
|
||||
{
|
||||
None = 0,
|
||||
Active = 1,
|
||||
Lighted = 2,
|
||||
Wall = 4,
|
||||
Liquid = 8,
|
||||
Wire = 16
|
||||
}
|
||||
}
|
||||
|
|
@ -3,33 +3,30 @@ using System.IO.Streams;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
public class ProjectileRemoveMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return PacketTypes.ProjectileNew;
|
||||
}
|
||||
}
|
||||
public class ProjectileRemoveMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get { return PacketTypes.ProjectileNew; }
|
||||
}
|
||||
|
||||
public short Index { get; set; }
|
||||
public byte Owner { get; set; }
|
||||
public short Index { get; set; }
|
||||
public byte Owner { get; set; }
|
||||
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt16(Index);
|
||||
stream.WriteSingle(-1);
|
||||
stream.WriteSingle(-1);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteInt16(0);
|
||||
stream.WriteByte(Owner);
|
||||
stream.WriteByte(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt16(Index);
|
||||
stream.WriteSingle(-1);
|
||||
stream.WriteSingle(-1);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteInt16(0);
|
||||
stream.WriteByte(Owner);
|
||||
stream.WriteByte(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
stream.WriteSingle(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,25 +3,22 @@ using System.IO.Streams;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
public class SpawnMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return PacketTypes.PlayerSpawn;
|
||||
}
|
||||
}
|
||||
public class SpawnMsg : BaseMsg
|
||||
{
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get { return PacketTypes.PlayerSpawn; }
|
||||
}
|
||||
|
||||
public int TileX { get; set; }
|
||||
public int TileY {get;set;}
|
||||
public byte PlayerIndex { get; set; }
|
||||
public int TileX { get; set; }
|
||||
public int TileY { get; set; }
|
||||
public byte PlayerIndex { get; set; }
|
||||
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt8(PlayerIndex);
|
||||
stream.WriteInt32(TileX);
|
||||
stream.WriteInt32(TileY);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt8(PlayerIndex);
|
||||
stream.WriteInt32(TileX);
|
||||
stream.WriteInt32(TileY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,54 +23,54 @@ using System.Text;
|
|||
|
||||
namespace TShockAPI.Net
|
||||
{
|
||||
[Flags]
|
||||
public enum WorldInfoFlag : byte
|
||||
{
|
||||
None = 0,
|
||||
OrbSmashed = 1,
|
||||
DownedBoss1 = 2,
|
||||
DownedBoss2 = 4,
|
||||
DownedBoss3 = 8,
|
||||
HardMode = 16,
|
||||
DownedClown = 32
|
||||
}
|
||||
public class WorldInfoMsg : BaseMsg
|
||||
{
|
||||
public int Time { get; set; }
|
||||
public bool DayTime { get; set; }
|
||||
public byte MoonPhase { get; set; }
|
||||
public bool BloodMoon { get; set; }
|
||||
public int MaxTilesX { get; set; }
|
||||
public int MaxTilesY { get; set; }
|
||||
public int SpawnX { get; set; }
|
||||
public int SpawnY { get; set; }
|
||||
public int WorldSurface { get; set; }
|
||||
public int RockLayer { get; set; }
|
||||
public int WorldID { get; set; }
|
||||
public WorldInfoFlag WorldFlags { get; set; }
|
||||
public string WorldName { get; set; }
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return PacketTypes.WorldInfo;
|
||||
}
|
||||
}
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt32(Time);
|
||||
stream.WriteBoolean(DayTime);
|
||||
stream.WriteInt8(MoonPhase);
|
||||
stream.WriteBoolean(BloodMoon);
|
||||
stream.WriteInt32(MaxTilesX);
|
||||
stream.WriteInt32(MaxTilesY);
|
||||
stream.WriteInt32(SpawnX);
|
||||
stream.WriteInt32(SpawnY);
|
||||
stream.WriteInt32(WorldSurface);
|
||||
stream.WriteInt32(RockLayer);
|
||||
stream.WriteInt32(WorldID);
|
||||
stream.WriteInt8((byte)WorldFlags);
|
||||
stream.WriteBytes(Encoding.ASCII.GetBytes(WorldName));
|
||||
}
|
||||
}
|
||||
}
|
||||
[Flags]
|
||||
public enum WorldInfoFlag : byte
|
||||
{
|
||||
None = 0,
|
||||
OrbSmashed = 1,
|
||||
DownedBoss1 = 2,
|
||||
DownedBoss2 = 4,
|
||||
DownedBoss3 = 8,
|
||||
HardMode = 16,
|
||||
DownedClown = 32
|
||||
}
|
||||
|
||||
public class WorldInfoMsg : BaseMsg
|
||||
{
|
||||
public int Time { get; set; }
|
||||
public bool DayTime { get; set; }
|
||||
public byte MoonPhase { get; set; }
|
||||
public bool BloodMoon { get; set; }
|
||||
public int MaxTilesX { get; set; }
|
||||
public int MaxTilesY { get; set; }
|
||||
public int SpawnX { get; set; }
|
||||
public int SpawnY { get; set; }
|
||||
public int WorldSurface { get; set; }
|
||||
public int RockLayer { get; set; }
|
||||
public int WorldID { get; set; }
|
||||
public WorldInfoFlag WorldFlags { get; set; }
|
||||
public string WorldName { get; set; }
|
||||
|
||||
public override PacketTypes ID
|
||||
{
|
||||
get { return PacketTypes.WorldInfo; }
|
||||
}
|
||||
|
||||
public override void Pack(Stream stream)
|
||||
{
|
||||
stream.WriteInt32(Time);
|
||||
stream.WriteBoolean(DayTime);
|
||||
stream.WriteInt8(MoonPhase);
|
||||
stream.WriteBoolean(BloodMoon);
|
||||
stream.WriteInt32(MaxTilesX);
|
||||
stream.WriteInt32(MaxTilesY);
|
||||
stream.WriteInt32(SpawnX);
|
||||
stream.WriteInt32(SpawnY);
|
||||
stream.WriteInt32(WorldSurface);
|
||||
stream.WriteInt32(RockLayer);
|
||||
stream.WriteInt32(WorldID);
|
||||
stream.WriteInt8((byte) WorldFlags);
|
||||
stream.WriteBytes(Encoding.ASCII.GetBytes(WorldName));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue