2022-09-16 11:46:09 -07:00
|
|
|
using Content.Server.Atmos;
|
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]
|
2022-09-16 11:46:09 -07:00
|
|
|
public sealed class EntityStorageComponent : Component, IGasMixtureHolder
|
2022-07-13 19:11:59 -04:00
|
|
|
{
|
|
|
|
|
public readonly float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage.
|
2022-09-16 11:46:09 -07:00
|
|
|
public const float GasMixVolume = 70f;
|
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-15 09:55:36 +12:00
|
|
|
[DataField("capacity")]
|
|
|
|
|
public int Capacity = 30;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
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-10-09 18:17:53 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// If true, it opens the storage when the entity inside of it moves
|
|
|
|
|
/// If false, it prevents the storage from opening when the entity inside of it moves.
|
|
|
|
|
/// This is for objects that you want the player to move while inside, like large cardboard boxes, without opening the storage.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
[DataField("openOnMove")]
|
|
|
|
|
public bool OpenOnMove = true;
|
|
|
|
|
|
2022-09-16 11:46:09 -07:00
|
|
|
//The offset for where items are emptied/vacuumed for the EntityStorage.
|
2022-07-13 19:11:59 -04:00
|
|
|
[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-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-12-19 22:45:03 -05:00
|
|
|
[DataField("deleteContentsOnDestruction"), ViewVariables(VVAccess.ReadWrite)]
|
2022-07-13 19:11:59 -04:00
|
|
|
public bool DeleteContentsOnDestruction = false;
|
2019-05-05 18:52:06 +02:00
|
|
|
|
2022-09-29 20:49:43 -04:00
|
|
|
/// <summary>
|
|
|
|
|
/// Whether or not the container is sealed and traps air inside of it
|
|
|
|
|
/// </summary>
|
2022-10-18 19:04:47 -04:00
|
|
|
[DataField("airtight"), ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public bool Airtight = true;
|
2022-09-29 20:49:43 -04: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;
|
2022-09-16 11:46:09 -07:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gas currently contained in this entity storage.
|
|
|
|
|
/// None while open. Grabs gas from the atmosphere when closed, and exposes any entities inside to it.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
public GasMixture Air { get; set; } = new (GasMixVolume);
|
2022-07-13 19:11:59 -04:00
|
|
|
}
|
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
|
|
|
}
|
2022-12-19 21:47:37 -06:00
|
|
|
public sealed class StorageBeforeOpenEvent : EventArgs { }
|
2022-07-13 19:11:59 -04:00
|
|
|
public sealed class StorageAfterOpenEvent : EventArgs { }
|
|
|
|
|
public sealed class StorageCloseAttemptEvent : CancellableEntityEventArgs { }
|
|
|
|
|
public sealed class StorageBeforeCloseEvent : EventArgs
|
|
|
|
|
{
|
|
|
|
|
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-12-20 16:33:59 +13:00
|
|
|
public StorageBeforeCloseEvent(HashSet<EntityUid> contents)
|
2021-12-29 15:57:20 +11:00
|
|
|
{
|
2022-07-13 19:11:59 -04:00
|
|
|
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 { }
|