Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions EXILED/Exiled.API/Features/Lockers/Locker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,23 @@ public void AddItem(Pickup item)
Chamber chamber = Chambers.GetRandomValue();

// Determine the parent transform where the item will be placed.
Transform parentTransform = chamber.UseMultipleSpawnpoints && chamber.Spawnpoints.Count() > 0
Transform parentTransform = chamber.UseMultipleSpawnpoints && chamber.Spawnpoints.Any()
? chamber.Spawnpoints.GetRandomValue()
: chamber.Spawnpoint;

// If the chamber is open, immediately set the item's parent and spawn it.
if (chamber.IsOpen)
{
item.Transform.SetParent(parentTransform);
item.Spawn();

if(!item.IsSpawned)
item.Spawn();
}
else
{
// If the item is already spawned on the network, unspawn it before proceeding.
if (NetworkServer.spawned.ContainsKey(item.Base.netId))
NetworkServer.UnSpawn(item.GameObject);
if (item.IsSpawned)
item.UnSpawn();

// Set the item's parent transform.
item.Transform.SetParent(parentTransform);
Expand Down
10 changes: 5 additions & 5 deletions EXILED/Exiled.CustomItems/API/Features/CustomItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ namespace Exiled.CustomItems.API.Features
using Exiled.Events.EventArgs.Scp914;
using Exiled.Loader;

using InventorySystem.Items.Firearms;
using InventorySystem.Items.Pickups;

using MapGeneration.Distributors;

using MEC;

using PlayerRoles;
Expand Down Expand Up @@ -651,8 +648,11 @@ public virtual uint Spawn(IEnumerable<SpawnPoint> spawnPoints, uint limit)
if (pickup == null)
continue;

if (spawnPoint is LockerSpawnPoint)
pickup.IsLocked = true;
if (spawnPoint is LockerSpawnPoint { UseChamber: true } lockerSpawnPoint)
{
Exiled.API.Features.Lockers.Locker? foundLocker = Exiled.API.Features.Lockers.Locker.Random(lockerSpawnPoint.Zone, lockerSpawnPoint.Type);
foundLocker?.AddItem(pickup);
}

if (pickup.Is(out Exiled.API.Features.Pickups.FirearmPickup firearmPickup) && this is CustomWeapon customWeapon)
{
Expand Down