57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
public class NetPackageAddPlayerItem : NetPackage
|
|
{
|
|
public NetPackageAddPlayerItem Setup(string itemName, int _ownerID, int _count, string _soundName)
|
|
{
|
|
this.itemName = itemName;
|
|
this.ownerID = _ownerID;
|
|
this.count = _count;
|
|
this.soundName = _soundName;
|
|
|
|
return this;
|
|
}
|
|
|
|
public override void read(PooledBinaryReader _reader)
|
|
{
|
|
this.itemName = _reader.ReadString();
|
|
this.ownerID = _reader.ReadInt32();
|
|
this.count = _reader.ReadInt32();
|
|
this.soundName = _reader.ReadString();
|
|
}
|
|
|
|
public override void write(PooledBinaryWriter _writer)
|
|
{
|
|
base.write(_writer);
|
|
_writer.Write(this.itemName);
|
|
_writer.Write(this.ownerID);
|
|
_writer.Write(this.count);
|
|
_writer.Write(this.soundName);
|
|
}
|
|
|
|
public override void ProcessPackage(World _world, GameManager _callbacks)
|
|
{
|
|
//Log.Out("NetPackageAddPlayerItem-ProcessPackage 1");
|
|
if (_world == null || !_world.IsRemote())
|
|
{
|
|
//Log.Out("NetPackageAddPlayerItem-ProcessPackage 2");
|
|
return;
|
|
}
|
|
|
|
EntityPlayerLocal playerLocal = _world.GetEntity(this.ownerID) as EntityPlayerLocal;
|
|
|
|
if (playerLocal != null)
|
|
{
|
|
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem(this.itemName, false), playerLocal, this.count, this.soundName);
|
|
}
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 8;
|
|
}
|
|
|
|
private string itemName;
|
|
private int ownerID;
|
|
private int count;
|
|
private string soundName;
|
|
}
|