Files
zzz_REBIRTH__Utils/Scripts/Network/NetPackageUpdateWaterTankRebirth.cs
2025-06-04 16:44:53 +09:30

91 lines
3.7 KiB
C#

public class NetPackageUpdateWaterTankRebirth : NetPackage
{
int clrIdx = 0;
int contentCount = 0;
Vector3i blockPos;
public NetPackageUpdateWaterTankRebirth Setup(int _clrIdx, Vector3i _blockPos, int _contentCount)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-Setup START");
this.clrIdx = _clrIdx;
this.contentCount = _contentCount;
this.blockPos = _blockPos;
//Log.Out("NetPackageUpdateWaterTankRebirth-Setup this.clrIdx: " + this.clrIdx);
//Log.Out("NetPackageUpdateWaterTankRebirth-Setup this.contentCount: " + this.contentCount);
//Log.Out("NetPackageUpdateWaterTankRebirth-Setup this.blockPos: " + this.blockPos);
return this;
}
public override void read(PooledBinaryReader _br)
{
this.blockPos = new Vector3i((float)_br.ReadInt32(), (float)_br.ReadInt32(), (float)_br.ReadInt32());
this.clrIdx = _br.ReadInt32();
this.contentCount = _br.ReadInt32();
}
public override void write(PooledBinaryWriter _bw)
{
base.write(_bw);
_bw.Write((int)this.blockPos.x);
_bw.Write((int)this.blockPos.y);
_bw.Write((int)this.blockPos.z);
_bw.Write(this.clrIdx);
_bw.Write(this.contentCount);
}
public override int GetLength()
{
return 20;
}
public override void ProcessPackage(World _world, GameManager _callbacks)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage START");
if (_world == null)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 1");
return;
}
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 2");
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage CLIENT this.clrIdx: " + this.clrIdx);
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage CLIENT this.blockPos: " + this.blockPos);
TileEntityWaterTankRebirth tileEntity = _world.GetTileEntity(this.clrIdx, this.blockPos) as TileEntityWaterTankRebirth;
if (tileEntity != null)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 3");
tileEntity.waterCount = this.contentCount;
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage CLIENT tileEntity.waterCount: " + tileEntity.waterCount);
}
else
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 4");
}
}
else
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 5");
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage SERVER this.clrIdx: " + this.clrIdx);
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage SERVER this.blockPos: " + this.blockPos);
TileEntityWaterTankRebirth tileEntity = _world.GetTileEntity(this.clrIdx, this.blockPos) as TileEntityWaterTankRebirth;
if (tileEntity != null)
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 6");
tileEntity.waterCount = this.contentCount;
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageUpdateWaterTankRebirth>().Setup(this.clrIdx, this.blockPos, this.contentCount));
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage SERVER tileEntity.waterCount: " + tileEntity.waterCount);
}
else
{
//Log.Out("NetPackageUpdateWaterTankRebirth-ProcessPackage 7");
}
}
}
}