93 lines
3.5 KiB
C#
93 lines
3.5 KiB
C#
using UnityEngine.Scripting;
|
|
|
|
[Preserve]
|
|
public class NetPackageCheckPurgeSupplyDrops : NetPackage
|
|
{
|
|
public NetPackageCheckPurgeSupplyDrops 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("NetPackageCheckPurgeSupplyDrops-ProcessPackage START");
|
|
EntityPlayer player = _world.GetEntity(this.entityPlayerID) as EntityPlayer;
|
|
|
|
if (player != null)
|
|
{
|
|
float numSupplyDrops = player.Buffs.GetCustomVar("$numSupplyDrops");
|
|
|
|
if (numSupplyDrops > 0)
|
|
{
|
|
// Reset skipSupplyDrops before calling SpawnAirDrop()
|
|
RebirthVariables.skipSupplyDrops = false;
|
|
|
|
// Spawn the air drop
|
|
bool canSpawn = GameManager.Instance.World.aiDirector.GetComponent<AIDirectorAirDropComponent>().SpawnAirDrop();
|
|
|
|
// Restore skipSupplyDrops to true after the air drop logic
|
|
RebirthVariables.skipSupplyDrops = true;
|
|
|
|
//Log.Out("EntityPlayerLocalPatches-OnUpdateLive canSpawn: " + canSpawn);
|
|
|
|
if (canSpawn)
|
|
{
|
|
RebirthVariables.playerAirDrops.Add(new Vector3(player.position.x, player.position.y, player.position.z));
|
|
|
|
numSupplyDrops--;
|
|
|
|
if (numSupplyDrops < 0)
|
|
{
|
|
numSupplyDrops = 0;
|
|
}
|
|
|
|
float numTotalSupplyDrops = player.Buffs.GetCustomVar("$numTotalSupplyDrops");
|
|
if (numTotalSupplyDrops == 0f)
|
|
{
|
|
//RebirthUtilities.addToPlayerBag(ItemClass.GetItem("FuriousRamsayInfo_Purge3SuppliesUpdate"), player, 1, "");
|
|
if (RebirthUtilities.EnnemiesAround(player) > 0)
|
|
{
|
|
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("FuriousRamsayInfo_Purge3SuppliesUpdate"), player, 1, "");
|
|
}
|
|
else
|
|
{
|
|
GameEventManager.Current.HandleAction("info_purge_suppliesupdate", player, player, false, sequenceLink: "");
|
|
}
|
|
player.Buffs.SetCustomVar("FuriousRamsayInfo_Purge3SuppliesUpdate", 1f);
|
|
}
|
|
numTotalSupplyDrops++;
|
|
player.Buffs.SetCustomVar("$numTotalSupplyDrops", numTotalSupplyDrops);
|
|
|
|
player.Buffs.SetCustomVar("$numSupplyDrops", numSupplyDrops);
|
|
|
|
// Play the sound and show the tooltip
|
|
string message = "[936fbf]PURGE[-] OBJECTIVE REACHED. ADDITIONAL [bfbc7a]SUPPLIES[-] ARE ON THE WAY";
|
|
string soundName = "purge_airdrop";
|
|
|
|
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage((NetPackage)NetPackageManager.GetPackage<NetPackageShowToolbetlMessage>().Setup(message, player.entityId, soundName), false, player.entityId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override int GetLength()
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
private int entityPlayerID;
|
|
}
|