Make item slot containers nullable (#6198)

This commit is contained in:
Leon Friedrich
2022-01-18 08:22:35 +13:00
committed by GitHub
parent 167e6e5cb6
commit 5679f1e4fb
4 changed files with 21 additions and 15 deletions

View File

@@ -43,7 +43,7 @@ namespace Content.Server.Cabinet
private void OnComponentStartup(EntityUid uid, ItemCabinetComponent cabinet, ComponentStartup args)
{
UpdateAppearance(uid, cabinet);
_itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot.ID, !cabinet.Opened);
_itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot, !cabinet.Opened);
}
private void UpdateAppearance(EntityUid uid,
@@ -105,7 +105,7 @@ namespace Content.Server.Cabinet
cabinet.Opened = !cabinet.Opened;
SoundSystem.Play(Filter.Pvs(uid), cabinet.DoorSound.GetSound(), uid, AudioHelpers.WithVariation(0.15f));
_itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot.ID, !cabinet.Opened);
_itemSlotsSystem.SetLock(uid, cabinet.CabinetSlot, !cabinet.Opened);
UpdateAppearance(uid, cabinet);
}

View File

@@ -27,7 +27,7 @@ namespace Content.Server.Containers
foreach (var slot in component.Slots.Values)
{
if (slot.EjectOnDeconstruct && slot.Item != null)
slot.ContainerSlot.Remove(slot.Item.Value);
slot.ContainerSlot?.Remove(slot.Item.Value);
}
}