62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
public class NetPackageUpdateChickenHomeRebirth : NetPackage
|
|
{
|
|
private Vector3i position;
|
|
private int entityToUpdate;
|
|
|
|
public NetPackageUpdateChickenHomeRebirth Setup(Vector3i _position, int _entityToUpdate)
|
|
{
|
|
this.position = _position;
|
|
this.entityToUpdate = _entityToUpdate;
|
|
return this;
|
|
}
|
|
|
|
public override void read(PooledBinaryReader _br)
|
|
{
|
|
this.position = new Vector3i((float)_br.ReadInt32(), (float)_br.ReadInt32(), (float)_br.ReadInt32());
|
|
this.entityToUpdate = _br.ReadInt32();
|
|
}
|
|
|
|
public override void write(PooledBinaryWriter _bw)
|
|
{
|
|
base.write(_bw);
|
|
_bw.Write((int)this.position.x);
|
|
_bw.Write((int)this.position.y);
|
|
_bw.Write((int)this.position.z);
|
|
_bw.Write(this.entityToUpdate);
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 16;
|
|
}
|
|
|
|
public override void ProcessPackage(World _world, GameManager _callbacks)
|
|
{
|
|
//Log.Out("NetPackageUpdateChickenHomeRebirth-ProcessPackage START");
|
|
if (_world == null)
|
|
{
|
|
//Log.Out("NetPackageUpdateChickenHomeRebirth-ProcessPackage 1");
|
|
return;
|
|
}
|
|
|
|
if (!_world.IsRemote())
|
|
{
|
|
//Log.Out("NetPackageUpdateChickenHomeRebirth-ProcessPackage 2");
|
|
return;
|
|
}
|
|
|
|
Entity myEntity = _world.GetEntity(this.entityToUpdate);
|
|
if (myEntity != null)
|
|
{
|
|
EntityAnimalChickenRebirth chicken = (EntityAnimalChickenRebirth)myEntity;
|
|
chicken.homePos = this.position;
|
|
//Log.Out("NetPackageUpdateChickenHomeRebirth-ProcessPackage FOUND THE ENTITY");
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("NetPackageUpdateChickenHomeRebirth-ProcessPackage CAN'T FIND THE ENTITY");
|
|
}
|
|
}
|
|
}
|
|
|