Fixed teleporting

This commit is contained in:
high 2011-08-11 00:27:56 -04:00
parent 2a0bf9036a
commit 3312b769c4
6 changed files with 124 additions and 73 deletions

38
TShockAPI/Net/BaseMsg.cs Normal file
View file

@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TerrariaAPI;
using XNAHelpers;
namespace TShockAPI.Net
{
public class BaseMsg : IPackable
{
public virtual PacketTypes ID
{
get { throw new NotImplementedException("Msg ID not implemented"); }
}
public void PackFull(System.IO.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 Unpack(System.IO.Stream stream)
{
throw new NotImplementedException();
}
public virtual void Pack(System.IO.Stream stream)
{
throw new NotImplementedException();
}
}
}

30
TShockAPI/Net/SpawnMsg.cs Normal file
View file

@ -0,0 +1,30 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using TerrariaAPI;
using XNAHelpers;
namespace TShockAPI.Net
{
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 override void Pack(Stream stream)
{
stream.WriteInt8(PlayerIndex);
stream.WriteInt32(TileX);
stream.WriteInt32(TileY);
}
}
}

View file

@ -33,7 +33,7 @@ namespace TShockAPI.Net
DownedBoss2 = 4,
DownedBoss3 = 8,
}
public class WorldInfoMsg : IPackable
public class WorldInfoMsg : BaseMsg
{
public int Time { get; set; }
public bool DayTime { get; set; }
@ -48,18 +48,14 @@ namespace TShockAPI.Net
public int WorldID { get; set; }
public WorldInfoFlag WorldFlags { get; set; }
public string WorldName { get; set; }
public void PackFull(Stream stream)
public override PacketTypes ID
{
long start = stream.Position;
stream.WriteInt32(1);
stream.WriteInt8((byte)PacketTypes.WorldInfo);
Pack(stream);
long end = stream.Position;
stream.Position = start;
stream.WriteInt32((int)(end - start) - 4);
stream.Position = end;
get
{
return PacketTypes.WorldInfo;
}
}
public void Pack(Stream stream)
public override void Pack(Stream stream)
{
stream.WriteInt32(Time);
stream.WriteBoolean(DayTime);
@ -75,10 +71,5 @@ namespace TShockAPI.Net
stream.WriteInt8((byte)WorldFlags);
stream.WriteBytes(Encoding.ASCII.GetBytes(WorldName));
}
public void Unpack(Stream stream)
{
throw new NotImplementedException();
}
}
}