Upload from upload_mods.ps1
This commit is contained in:
40
Harmony/Harmony_DroneManager.cs
Normal file
40
Harmony/Harmony_DroneManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmony.DroneManagerPatches
|
||||
{
|
||||
[HarmonyPatch(typeof(DroneManager), "RemoveAllDronesFromMap")]
|
||||
public class RemoveAllVehiclesFromMapPatch
|
||||
{
|
||||
public static bool Prefix(DroneManager __instance)
|
||||
{
|
||||
GameManager instance = GameManager.Instance;
|
||||
PersistentPlayerList persistentPlayerList = instance.GetPersistentPlayerList();
|
||||
World world = instance.World;
|
||||
|
||||
foreach (KeyValuePair<PlatformUserIdentifierAbs, PersistentPlayerData> player in persistentPlayerList.Players)
|
||||
{
|
||||
EntityPlayer entity = world.GetEntity(player.Value.EntityId) as EntityPlayer;
|
||||
|
||||
if (entity != null)
|
||||
{
|
||||
OwnedEntityData[] ownedEntities = entity.GetOwnedEntities();
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ownedEntities.Length: " + ownedEntities.Length);
|
||||
|
||||
for (int i = 0; i < ownedEntities.Length; ++i)
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap ___dronesActive.Count: " + ___dronesActive.Count);
|
||||
EntityDrone entityDrone = __instance.dronesActive.Find(v => v.entityId == ownedEntities[i].Id);
|
||||
|
||||
if (entityDrone != null && entity.HasOwnedEntity(entityDrone.entityId))
|
||||
{
|
||||
//Log.Out("DroneManagerPatches-RemoveAllVehiclesFromMap entityDrone.entityId: " + entityDrone.entityId);
|
||||
GameManager.Instance.World.RemoveEntityFromMap(entityDrone, EnumRemoveEntityReason.Unloaded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user