75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using UnityEngine.Scripting;
|
|
|
|
[Preserve]
|
|
public class NetPackageGetHeatMapValue : NetPackage
|
|
{
|
|
public NetPackageGetHeatMapValue Setup(int _entityPlayerID)
|
|
{
|
|
this.entityPlayerID = _entityPlayerID;
|
|
|
|
return this;
|
|
}
|
|
|
|
public override void read(PooledBinaryReader _reader)
|
|
{
|
|
this.entityPlayerID = _reader.ReadInt32();
|
|
}
|
|
|
|
public override void write(PooledBinaryWriter _writer)
|
|
{
|
|
base.write(_writer);
|
|
_writer.Write(this.entityPlayerID);
|
|
}
|
|
|
|
public override void ProcessPackage(World _world, GameManager _callbacks)
|
|
{
|
|
//Log.Out("NetPackageGetHeatMapValue-ProcessPackage 1");
|
|
/*if (_world == null || !_world.IsRemote())
|
|
{
|
|
Log.Out("NetPackageGetHeatMapValue-ProcessPackage 2");
|
|
return;
|
|
}*/
|
|
|
|
EntityPlayer player = _world.GetEntity(this.entityPlayerID) as EntityPlayer;
|
|
|
|
if (player != null)
|
|
{
|
|
//Log.Out("NetPackageGetHeatMapValue-ProcessPackage 3");
|
|
if (GameManager.Instance.World.aiDirector != null)
|
|
{
|
|
//Log.Out("NetPackageGetHeatMapValue-ProcessPackage 4");
|
|
AIDirectorChunkEventComponent component = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorChunkEventComponent>();
|
|
|
|
AIDirectorChunkData dataFromPosition = component.GetChunkDataFromPosition(new Vector3i(player.position.x, player.position.y, player.position.z), false);
|
|
|
|
float percentage = 0f;
|
|
float cooldown = 0f;
|
|
|
|
if (dataFromPosition != null)
|
|
{
|
|
//Log.Out("NetPackageGetHeatMapValue-ProcessPackage 5");
|
|
percentage = dataFromPosition.ActivityLevel;
|
|
if (dataFromPosition.cooldownDelay > 0.0)
|
|
{
|
|
cooldown = dataFromPosition.cooldownDelay;
|
|
}
|
|
}
|
|
|
|
player.Buffs.SetCustomVar("$ModHeatMapDetectionValue", percentage);
|
|
player.Buffs.SetCustomVar("$ModHeatMapDetectionCooldown", cooldown);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Log.Out("NetPackageGetHeatMapValue-ProcessPackage 6");
|
|
}
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
private int entityPlayerID;
|
|
}
|