Janitor cart (#7367)
This commit is contained in:
@@ -71,6 +71,15 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
[DataField("whitelist")]
|
||||
private EntityWhitelist? _whitelist = null;
|
||||
[DataField("blacklist")]
|
||||
public EntityWhitelist? Blacklist = null;
|
||||
|
||||
/// <summary>
|
||||
/// If true, storage will show popup messages to the player after failed interactions.
|
||||
/// Usually this is message that item doesn't fit inside container.
|
||||
/// </summary>
|
||||
[DataField("popup")]
|
||||
public bool ShowPopup = true;
|
||||
|
||||
private bool _storageInitialCalculated;
|
||||
public int StorageUsed;
|
||||
@@ -165,6 +174,11 @@ namespace Content.Server.Storage.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Blacklist != null && Blacklist.IsValid(entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_entityManager.GetComponent<TransformComponent>(entity).Anchored)
|
||||
{
|
||||
return false;
|
||||
@@ -256,14 +270,14 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
if (!handSys.TryDrop(player, toInsert.Value, handsComp: hands))
|
||||
{
|
||||
Owner.PopupMessage(player, Loc.GetString("comp-storage-cant-insert"));
|
||||
Popup(player, "comp-storage-cant-insert");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Insert(toInsert.Value))
|
||||
{
|
||||
handSys.PickupOrDrop(player, toInsert.Value, handsComp: hands);
|
||||
Owner.PopupMessage(player, Loc.GetString("comp-storage-cant-insert"));
|
||||
Popup(player, "comp-storage-cant-insert");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -282,7 +296,7 @@ namespace Content.Server.Storage.Components
|
||||
|
||||
if (!Insert(toInsert))
|
||||
{
|
||||
Owner.PopupMessage(player, Loc.GetString("comp-storage-cant-insert"));
|
||||
Popup(player, "comp-storage-cant-insert");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -482,7 +496,7 @@ namespace Content.Server.Storage.Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(player, Owner, popup: true))
|
||||
if (!EntitySystem.Get<SharedInteractionSystem>().InRangeUnobstructed(player, Owner, popup: ShowPopup))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -638,6 +652,13 @@ namespace Content.Server.Storage.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void Popup(EntityUid player, string message)
|
||||
{
|
||||
if (!ShowPopup) return;
|
||||
|
||||
Owner.PopupMessage(player, Loc.GetString(message));
|
||||
}
|
||||
|
||||
private void PlaySoundCollection()
|
||||
{
|
||||
SoundSystem.Play(Filter.Pvs(Owner), StorageSoundCollection.GetSound(), Owner, AudioParams.Default);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.Storage.Components;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
@@ -12,32 +13,27 @@ namespace Content.Server.Storage.EntitySystems
|
||||
[UsedImplicitly]
|
||||
public sealed class ItemMapperSystem : SharedItemMapperSystem
|
||||
{
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
|
||||
protected override bool TryGetLayers(ContainerModifiedMessage msg,
|
||||
ItemMapperComponent itemMapper,
|
||||
out IReadOnlyList<string> showLayers)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component))
|
||||
{
|
||||
var containedLayers = component.StoredEntities ?? new List<EntityUid>();
|
||||
var list = new List<string>();
|
||||
foreach (var mapLayerData in itemMapper.MapLayers.Values)
|
||||
{
|
||||
foreach (var entity in containedLayers)
|
||||
{
|
||||
if (mapLayerData.ServerWhitelist.IsValid(entity))
|
||||
{
|
||||
list.Add(mapLayerData.Layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var containedLayers = _containerSystem.GetAllContainers(msg.Container.Owner)
|
||||
.SelectMany(cont => cont.ContainedEntities).ToArray();
|
||||
|
||||
showLayers = list;
|
||||
return true;
|
||||
var list = new List<string>();
|
||||
foreach (var mapLayerData in itemMapper.MapLayers.Values)
|
||||
{
|
||||
var count = containedLayers.Count(uid => mapLayerData.ServerWhitelist.IsValid(uid));
|
||||
if (count >= mapLayerData.MinCount && count <= mapLayerData.MaxCount)
|
||||
{
|
||||
list.Add(mapLayerData.Layer);
|
||||
}
|
||||
}
|
||||
|
||||
showLayers = new List<string>();
|
||||
return false;
|
||||
showLayers = list;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user