Janitor cart (#7367)

This commit is contained in:
Alex Evgrashin
2022-04-12 02:21:15 +03:00
committed by GitHub
parent c4ebfc22e3
commit 9c65f4b324
20 changed files with 320 additions and 25 deletions

View File

@@ -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);