2021-03-08 04:09:59 +11:00
|
|
|
using Content.Shared.Physics;
|
2022-07-14 23:38:39 +12: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;
|
2019-04-17 23:26:00 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
namespace Content.Server.Storage.Components;
|
2020-10-28 22:51:43 +00:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[RegisterComponent]
|
|
|
|
|
public sealed class EntityStorageComponent : Component
|
|
|
|
|
{
|
|
|
|
|
public readonly float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage.
|
2022-04-29 01:03:39 +03:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public static readonly TimeSpan InternalOpenAttemptDelay = TimeSpan.FromSeconds(0.5);
|
|
|
|
|
public TimeSpan LastInternalOpenAttempt;
|
2019-04-17 23:26:00 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Collision masks that get removed when the storage gets opened.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly int MasksToRemove = (int) (
|
|
|
|
|
CollisionGroup.MidImpassable |
|
|
|
|
|
CollisionGroup.HighImpassable |
|
|
|
|
|
CollisionGroup.LowImpassable);
|
2022-05-01 09:27:07 +12:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Collision masks that were removed from ANY layer when the storage was opened;
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("removedMasks")]
|
|
|
|
|
public int RemovedMasks;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[ViewVariables]
|
2022-07-15 09:55:36 +12:00
|
|
|
[DataField("capacity")]
|
|
|
|
|
public int Capacity = 30;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[ViewVariables]
|
2022-07-15 09:55:36 +12:00
|
|
|
[DataField("isCollidableWhenOpen")]
|
2022-07-13 19:11:59 -04:00
|
|
|
public bool IsCollidableWhenOpen;
|
2019-04-17 23:26:00 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
//The offset for where items are emptied/vacuumed for the EntityStorage.
|
|
|
|
|
[DataField("enteringOffset")]
|
|
|
|
|
public Vector2 EnteringOffset = new(0, 0);
|
2021-04-01 18:46:23 +11:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
//The collision groups checked, so that items are depositied or grabbed from inside walls.
|
|
|
|
|
[DataField("enteringOffsetCollisionFlags")]
|
|
|
|
|
public readonly CollisionGroup EnteringOffsetCollisionFlags = CollisionGroup.Impassable | CollisionGroup.MidImpassable;
|
2019-04-17 23:26:00 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[ViewVariables]
|
2022-07-15 09:55:36 +12:00
|
|
|
[DataField("enteringRange")]
|
|
|
|
|
public float EnteringRange = 0.18f;
|
2020-10-28 22:51:43 +00:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("showContents")]
|
|
|
|
|
public bool ShowContents;
|
2020-10-28 22:51:43 +00:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("occludesLight")]
|
|
|
|
|
public bool OccludesLight = true;
|
2020-05-25 13:58:56 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("deleteContentsOnDestruction")]
|
|
|
|
|
public bool DeleteContentsOnDestruction = false;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("open")]
|
|
|
|
|
public bool Open;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("closeSound")]
|
|
|
|
|
public SoundSpecifier CloseSound = new SoundPathSpecifier("/Audio/Effects/closetclose.ogg");
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[DataField("openSound")]
|
|
|
|
|
public SoundSpecifier OpenSound = new SoundPathSpecifier("/Audio/Effects/closetopen.ogg");
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-14 23:38:39 +12:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whitelist for what entities are allowed to be inserted into this container. If this is not null, the
|
|
|
|
|
/// standard requirement that the entity must be an item or mob is waived.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField("whitelist")]
|
|
|
|
|
public EntityWhitelist? Whitelist;
|
|
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[ViewVariables]
|
|
|
|
|
public Container Contents = default!;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool IsWeldedShut;
|
|
|
|
|
}
|
2020-01-03 13:38:58 -08:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public sealed class InsertIntoEntityStorageAttemptEvent : CancellableEntityEventArgs { }
|
|
|
|
|
public sealed class StoreMobInItemContainerAttemptEvent : CancellableEntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public bool Handled = false;
|
|
|
|
|
}
|
|
|
|
|
public sealed class StorageOpenAttemptEvent : CancellableEntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public bool Silent = false;
|
2021-12-29 15:57:20 +11:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public StorageOpenAttemptEvent (bool silent = false)
|
2022-06-24 16:26:56 -03:00
|
|
|
{
|
2022-07-13 19:11:59 -04:00
|
|
|
Silent = silent;
|
2022-06-27 02:37:29 -03:00
|
|
|
}
|
2022-07-13 19:11:59 -04:00
|
|
|
}
|
|
|
|
|
public sealed class StorageAfterOpenEvent : EventArgs { }
|
|
|
|
|
public sealed class StorageCloseAttemptEvent : CancellableEntityEventArgs { }
|
|
|
|
|
public sealed class StorageBeforeCloseEvent : EventArgs
|
|
|
|
|
{
|
|
|
|
|
public EntityUid Container;
|
2022-06-27 02:37:29 -03:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public HashSet<EntityUid> Contents;
|
2021-12-29 15:57:20 +11:00
|
|
|
|
2022-07-14 23:38:39 +12:00
|
|
|
/// <summary>
|
|
|
|
|
/// Entities that will get inserted, regardless of any insertion or whitelist checks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public HashSet<EntityUid> BypassChecks = new();
|
2021-12-29 15:57:20 +11:00
|
|
|
|
2022-07-13 19:11:59 -04:00
|
|
|
public StorageBeforeCloseEvent(EntityUid container, HashSet<EntityUid> contents)
|
2021-12-29 15:57:20 +11:00
|
|
|
{
|
2022-07-13 19:11:59 -04:00
|
|
|
Container = container;
|
|
|
|
|
Contents = contents;
|
2021-12-29 15:57:20 +11:00
|
|
|
}
|
2019-04-17 23:26:00 +02:00
|
|
|
}
|
2022-07-13 19:11:59 -04:00
|
|
|
public sealed class StorageAfterCloseEvent : EventArgs { }
|