Files
7d2dXG/Mods/zzz_REBIRTH__Utils/Scripts/Network/NetPackageGetLightLevelsRebirth.cs
Nathaniel Cosford 062dfab2cd Patched
2025-05-30 01:04:40 +09:30

78 lines
2.7 KiB
C#

public class NetPackageGetLightLevelsRebirth : NetPackage
{
int clrIdx = 0;
Vector3i blockPos;
public NetPackageGetLightLevelsRebirth Setup(int _clrIdx, Vector3i _blockPos)
{
//Log.Out("NetPackageGetLightLevelsRebirth-Setup START");
this.clrIdx = _clrIdx;
this.blockPos = _blockPos;
//Log.Out("NetPackageGetLightLevelsRebirth-Setup this.clrIdx: " + this.clrIdx);
//Log.Out("NetPackageGetLightLevelsRebirth-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();
}
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);
}
public override int GetLength()
{
return 16;
}
public override void ProcessPackage(World _world, GameManager _callbacks)
{
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage START");
if (_world == null)
{
////Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage 1");
return;
}
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
{
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage 1");
BlockValue block = GameManager.Instance.World.GetBlock(this.clrIdx, this.blockPos);
ChunkCluster chunkCluster = _world.ChunkClusters[this.clrIdx];
if (chunkCluster != null)
{
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage 2");
byte light = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.SUN);
byte light2 = chunkCluster.GetLight(blockPos, Chunk.LIGHT_TYPE.BLOCK);
BlockPlantGrowingRebirth plant = (BlockPlantGrowingRebirth)block.Block;
if (plant != null)
{
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage 3");
plant.sunLight = light;
plant.blockLight = light2;
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage CLIENT plant.sunLight: " + plant.sunLight);
////Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage CLIENT plant.blockLight: " + plant.blockLight);
}
}
}
else
{
//Log.Out("NetPackageGetLightLevelsRebirth-ProcessPackage 4");
}
}
}