52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using UnityEngine.Scripting;
|
|
|
|
[Preserve]
|
|
public class NetPackageChangeNPCName : NetPackage
|
|
{
|
|
public NetPackageChangeNPCName Setup(int _npcEntityID, string _newName)
|
|
{
|
|
this.npcEntityID = _npcEntityID;
|
|
this.newName = _newName;
|
|
|
|
return this;
|
|
}
|
|
|
|
public override void read(PooledBinaryReader _reader)
|
|
{
|
|
this.npcEntityID = _reader.ReadInt32();
|
|
this.newName = _reader.ReadString();
|
|
}
|
|
|
|
public override void write(PooledBinaryWriter _writer)
|
|
{
|
|
base.write(_writer);
|
|
_writer.Write(this.npcEntityID);
|
|
_writer.Write(this.newName);
|
|
}
|
|
|
|
public override void ProcessPackage(World _world, GameManager _callbacks)
|
|
{
|
|
//Log.Out("NetPackageChangeNPCName-ProcessPackage 1");
|
|
if (_world == null || !_world.IsRemote())
|
|
{
|
|
//Log.Out("NetPackageChangeNPCName-ProcessPackage 2");
|
|
return;
|
|
}
|
|
|
|
EntityNPCRebirth npc = _world.GetEntity(this.npcEntityID) as EntityNPCRebirth;
|
|
|
|
if (npc != null)
|
|
{
|
|
npc.SetEntityName(this.newName);
|
|
}
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 4;
|
|
}
|
|
|
|
private int npcEntityID;
|
|
private string newName;
|
|
}
|