2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Storage;
|
2021-07-25 08:41:50 -07:00
|
|
|
using Content.Shared.Whitelist;
|
2022-07-29 14:13:12 +12:00
|
|
|
using Robust.Shared.Audio;
|
2021-03-01 15:24:46 -08:00
|
|
|
using Robust.Shared.Containers;
|
2022-04-28 06:11:15 -06:00
|
|
|
using System.Threading;
|
2018-04-22 06:11:38 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Storage.Components
|
2018-04-22 06:11:38 -05:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Storage component for containing entities within this one, matches a UI on the client which shows stored entities
|
|
|
|
|
/// </summary>
|
2019-07-31 15:02:36 +02:00
|
|
|
[RegisterComponent]
|
2022-01-05 02:23:01 +13:00
|
|
|
[ComponentReference(typeof(SharedStorageComponent))]
|
2022-04-28 06:11:15 -06:00
|
|
|
public sealed class ServerStorageComponent : SharedStorageComponent
|
2018-04-22 06:11:38 -05:00
|
|
|
{
|
2022-04-28 06:11:15 -06:00
|
|
|
public string LoggerName = "Storage";
|
2018-04-22 06:11:38 -05:00
|
|
|
|
2021-11-29 12:25:22 +13:00
|
|
|
public Container? Storage;
|
2021-12-03 11:11:52 +01:00
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
public readonly Dictionary<EntityUid, int> SizeCache = new();
|
2018-04-22 06:11:38 -05:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
private bool _occludesLight = true;
|
2021-07-25 08:41:50 -07:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("quickInsert")]
|
2022-04-28 06:11:15 -06:00
|
|
|
public bool QuickInsert = false; // Can insert storables by "attacking" them with the storage entity
|
2021-07-25 08:41:50 -07:00
|
|
|
|
2021-11-03 14:33:36 -07:00
|
|
|
[DataField("clickInsert")]
|
2022-04-28 06:11:15 -06:00
|
|
|
public bool ClickInsert = true; // Can insert stuff by clicking the storage entity with it
|
2021-11-03 14:33:36 -07:00
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("areaInsert")]
|
2022-04-28 06:11:15 -06:00
|
|
|
public bool AreaInsert = false; // "Attacking" with the storage entity causes it to insert all nearby storables after a delay
|
|
|
|
|
|
2021-10-24 02:34:29 +00:00
|
|
|
[DataField("areaInsertRadius")]
|
2022-04-28 06:11:15 -06:00
|
|
|
public int AreaInsertRadius = 1;
|
2021-07-25 08:41:50 -07:00
|
|
|
|
|
|
|
|
[DataField("whitelist")]
|
2022-04-28 06:11:15 -06:00
|
|
|
public EntityWhitelist? Whitelist = null;
|
2022-04-12 02:21:15 +03:00
|
|
|
[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;
|
2021-07-25 08:41:50 -07:00
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
/// <summary>
|
|
|
|
|
/// This storage has an open UI
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsOpen = false;
|
2022-03-23 16:14:23 +03:00
|
|
|
public int StorageUsed;
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("capacity")]
|
2022-03-23 16:14:23 +03:00
|
|
|
public int StorageCapacityMax = 10000;
|
2020-05-05 00:39:15 +02:00
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
[DataField("storageOpenSound")]
|
|
|
|
|
public SoundSpecifier? StorageOpenSound { get; set; } = new SoundCollectionSpecifier("storageRustle");
|
|
|
|
|
|
|
|
|
|
[DataField("storageInsertSound")]
|
|
|
|
|
public SoundSpecifier? StorageInsertSound { get; set; } = new SoundCollectionSpecifier("storageRustle");
|
|
|
|
|
|
|
|
|
|
[DataField("storageRemoveSound")]
|
|
|
|
|
public SoundSpecifier? StorageRemoveSound { get; set; }
|
|
|
|
|
[DataField("storageCloseSound")]
|
|
|
|
|
public SoundSpecifier? StorageCloseSound { get; set; }
|
2021-01-05 05:34:53 +00:00
|
|
|
|
2020-09-08 13:30:22 +02:00
|
|
|
[ViewVariables]
|
2021-12-05 18:09:01 +01:00
|
|
|
public override IReadOnlyList<EntityUid>? StoredEntities => Storage?.ContainedEntities;
|
2020-07-17 11:03:07 +02:00
|
|
|
|
2020-09-14 00:04:00 +12:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2022-04-28 06:11:15 -06:00
|
|
|
[DataField("occludesLight")]
|
2020-07-26 08:25:53 -04:00
|
|
|
public bool OccludesLight
|
|
|
|
|
{
|
|
|
|
|
get => _occludesLight;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_occludesLight = value;
|
2021-11-29 12:25:22 +13:00
|
|
|
if (Storage != null) Storage.OccludesLight = value;
|
2020-07-26 08:25:53 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 06:11:15 -06:00
|
|
|
// neccesary for abstraction, should be deleted on complete storage ECS
|
2021-12-05 18:09:01 +01:00
|
|
|
public override bool Remove(EntityUid entity)
|
2018-04-22 06:11:38 -05:00
|
|
|
{
|
2021-02-03 22:07:13 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2018-04-22 06:11:38 -05:00
|
|
|
}
|
|
|
|
|
}
|