64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
public class NetPackageDespawnBackpackRebirth : NetPackage
|
|
{
|
|
private int entityToUpdate;
|
|
|
|
public NetPackageDespawnBackpackRebirth Setup(int _entityToUpdate)
|
|
{
|
|
this.entityToUpdate = _entityToUpdate;
|
|
return this;
|
|
}
|
|
|
|
public override void read(PooledBinaryReader _br)
|
|
{
|
|
this.entityToUpdate = _br.ReadInt32();
|
|
}
|
|
|
|
public override void write(PooledBinaryWriter _bw)
|
|
{
|
|
base.write(_bw);
|
|
_bw.Write(this.entityToUpdate);
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 4;
|
|
}
|
|
|
|
public override void ProcessPackage(World _world, GameManager _callbacks)
|
|
{
|
|
//Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage START");
|
|
if (_world == null)
|
|
{
|
|
//Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage 1");
|
|
return;
|
|
}
|
|
|
|
/*if (!_world.IsRemote())
|
|
{
|
|
Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage 2");
|
|
return;
|
|
}*/
|
|
|
|
Entity myEntity = _world.GetEntity(this.entityToUpdate);
|
|
if (myEntity != null)
|
|
{
|
|
//Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage FOUND THE ENTITY");
|
|
ItemStack[] items = myEntity.lootContainer.items;
|
|
|
|
for (int k = 0; k < items.Length; k++)
|
|
{
|
|
if (!items[k].IsEmpty())
|
|
{
|
|
//Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage remove item");
|
|
myEntity.lootContainer.UpdateSlot(k, ItemStack.Empty.Clone());
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("NetPackageDespawnBackpackRebirth-ProcessPackage CAN'T FIND THE ENTITY");
|
|
}
|
|
}
|
|
}
|
|
|