Upload from upload_mods.ps1
This commit is contained in:
61
Scripts/Network/NetPackageAddCompanion.cs
Normal file
61
Scripts/Network/NetPackageAddCompanion.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class NetPackageAddCompanion : NetPackage
|
||||
{
|
||||
public NetPackageAddCompanion Setup(int _npcEntityID, int _ownerID)
|
||||
{
|
||||
this.npcEntityID = _npcEntityID;
|
||||
this.ownerID = _ownerID;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public override void read(PooledBinaryReader _reader)
|
||||
{
|
||||
this.npcEntityID = _reader.ReadInt32();
|
||||
this.ownerID = _reader.ReadInt32();
|
||||
}
|
||||
|
||||
public override void write(PooledBinaryWriter _writer)
|
||||
{
|
||||
base.write(_writer);
|
||||
_writer.Write(this.npcEntityID);
|
||||
_writer.Write(this.ownerID);
|
||||
}
|
||||
|
||||
public override void ProcessPackage(World _world, GameManager _callbacks)
|
||||
{
|
||||
//Log.Out("NetPackageAddCompanion-ProcessPackage 1");
|
||||
if (_world == null || !_world.IsRemote())
|
||||
{
|
||||
//Log.Out("NetPackageAddCompanion-ProcessPackage 2");
|
||||
return;
|
||||
}
|
||||
|
||||
EntityNPCRebirth npc = _world.GetEntity(this.npcEntityID) as EntityNPCRebirth;
|
||||
|
||||
if (npc != null)
|
||||
{
|
||||
//Log.Out("NetPackageAddCompanion-ProcessPackage 3, ownerID: " + ownerID);
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null && ownerID == primaryPlayer.entityId)
|
||||
{
|
||||
//Log.Out("NetPackageAddCompanion-ProcessPackage 4");
|
||||
npc.Buffs.SetCustomVar("$Leader", primaryPlayer.entityId);
|
||||
npc.Buffs.SetCustomVar("$delayedPickup", 1f);
|
||||
|
||||
npc.LeaderUtils.AddCompanion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetLength()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
private int npcEntityID;
|
||||
private int ownerID;
|
||||
}
|
||||
Reference in New Issue
Block a user