Upload from upload_mods.ps1
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
public class NetPackageEntityLootContainerWriteRebirth : NetPackage
|
||||
{
|
||||
private int entityId;
|
||||
private ItemStack[] items;
|
||||
|
||||
public NetPackageEntityLootContainerWriteRebirth Setup(int _lootEntityId, ItemStack[] _items)
|
||||
{
|
||||
this.entityId = _lootEntityId;
|
||||
this.items = _items;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void read(PooledBinaryReader _reader)
|
||||
{
|
||||
this.entityId = _reader.ReadInt32();
|
||||
this.items = GameUtils.ReadItemStack(_reader);
|
||||
}
|
||||
|
||||
public override void write(PooledBinaryWriter _writer)
|
||||
{
|
||||
base.write(_writer);
|
||||
_writer.Write(this.entityId);
|
||||
_writer.Write((ushort)this.items.Length);
|
||||
for (int i = 0; i < this.items.Length; i++)
|
||||
{
|
||||
this.items[i].Write(_writer);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ProcessPackage(World _world, GameManager _callbacks)
|
||||
{
|
||||
if (_world == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.Out("NetPackageEntityLootContainerWriteRebirth-ProcessPackage this.entityId: " + this.entityId);
|
||||
|
||||
Entity entity = GameManager.Instance.World.GetEntity(this.entityId);
|
||||
|
||||
if (entity != null && entity is EntityNPCRebirth)
|
||||
{
|
||||
EntityNPCRebirth entityAlive = (EntityNPCRebirth)entity;
|
||||
|
||||
if (entityAlive != null && entityAlive.lootContainer != null && this.items.Length > 0)
|
||||
{
|
||||
//Log.Out("NetPackageEntityLootContainerWriteRebirth-ProcessPackage entityAlive: " + entityAlive.EntityName);
|
||||
|
||||
for (int i = 0; i < this.items.Length; i++)
|
||||
{
|
||||
if (this.items[i].count > 0)
|
||||
{
|
||||
entityAlive.lootContainer.items[i] = this.items[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
entityAlive.lootContainer.items[i] = ItemStack.Empty.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
PooledBinaryWriter stream = new PooledBinaryWriter();
|
||||
TileEntity.StreamModeWrite _eStreamMode = new TileEntity.StreamModeWrite();
|
||||
entityAlive.lootContainer.write(stream, _eStreamMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override int GetLength()
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user