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

59 lines
2.1 KiB
C#

using static SleeperVolume;
public class NetPackageMoveToBedroll : NetPackage
{
private int entityID;
public Vector3 position;
public NetPackageMoveToBedroll Setup(int _entityID, Vector3 _position)
{
this.entityID = _entityID;
this.position = _position;
return this;
}
public override void read(PooledBinaryReader _br)
{
this.entityID = _br.ReadInt32();
this.position = StreamUtils.ReadVector3(_br);
}
public override void write(PooledBinaryWriter _bw)
{
base.write(_bw);
_bw.Write(this.entityID);
StreamUtils.Write(_bw, this.position);
}
public override int GetLength()
{
return 6;
}
public override void ProcessPackage(World _world, GameManager _callbacks)
{
//Log.Out("NetPackageTeleporTo-ProcessPackage START");
if (_world == null)
{
//Log.Out("NetPackageTeleporTo-ProcessPackage 1");
return;
}
Entity myEntity = _world.GetEntity(this.entityID);
if (myEntity is EntityNPCRebirth hiredNPC)
{
hiredNPC.HideNPC(false);
hiredNPC.guardPosition = Vector3.zero;
hiredNPC.attackTarget = null;
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "order", "stay", position.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
hiredNPC.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Stay);
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "reSpawnPosition", "", Vector3.zero.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "spawnPosition", "", position.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "order", "guard", Vector3.zero.ToString(), Vector3.zero.ToString());
hiredNPC.SetPosition(new Vector3(position.x, position.y + 1f, position.z));
GameManager.Instance.StartCoroutine(RebirthUtilities.pauseSleep(hiredNPC, 1f));
}
}
}