Files
OldThink/Content.Server/Storage/Components/EntityStorageComponent.cs

135 lines
4.6 KiB
C#
Raw Normal View History

2022-09-16 11:46:09 -07:00
using Content.Server.Atmos;
Physics (#3485) * Content side new physics structure * BroadPhase outline done * But we need to fix WorldAABB * Fix static pvs AABB * Fix import * Rando fixes * B is for balloon * Change human mob hitbox to circle * Decent movement * Start adding friction to player controller I think it's the best way to go about it to keep other objects somewhat consistent for physics. * This baby can fit so many physics bugs in it. * Slight mob mover optimisations. * Player mover kinda works okay. * Beginnings of testbed * More testbed * Circlestack bed * Namespaces * BB fixes * Pull WorldAABB * Joint pulling * Semi-decent movement I guess. * Pulling better * Bullet controller + old movement * im too dumb for this shit * Use kinematic mob controller again It's probably for the best TBH * Stashed shitcode * Remove SlipController * In which movement code is entirely refactored * Singularity fix * Fix ApplyLinearImpulse * MoveRelay fix * Fix door collisions * Disable subfloor collisions Saves on broadphase a fair bit * Re-implement ClimbController * Zumzum's pressure * Laggy item throwing * Minor atmos change * Some caching * Optimise controllers * Optimise CollideWith to hell and back * Re-do throwing and tile friction * Landing too * Optimise controllers * Move CCVars and other stuff swept is beautiful * Cleanup a bunch of controllers * Fix shooting and high pressure movement controller * Flashing improvements * Stuff and things * Combat collisions * Combat mode collisions * Pulling distance joint again * Cleanup physics interfaces * More like scuffedularity * Shit's fucked * Haha tests go green * Bigmoneycrab * Fix dupe pulling * Zumzum's based fix * Don't run tile friction for non-predicted bodies * Experimental pulling improvement * Everything's a poly now * Optimise AI region debugging a bit Could still be better but should improve default performance a LOT * Mover no updater * Crazy kinematic body idea * Good collisions * KinematicController * Fix aghost * Throwing refactor * Pushing cleanup * Fix throwing and footstep sounds * Frametime in ICollideBehavior * Fix stuff * Actually fix weightlessness * Optimise collision behaviors a lot * Make open lockers still collide with walls * powwweeerrrrr * Merge master proper * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA * Ch ch ch changesss * SHIP IT * Fix #if DEBUG * Fix vaulting and item locker collision * Fix throwing * Editing yaml by hand what can go wrong * on * Last yaml fixes * Okay now it's fixed * Linter Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com> Co-authored-by: Vera Aguilera Puerto <zddm@outlook.es>
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;
using Robust.Shared.Containers;
2022-07-13 19:11:59 -04:00
namespace Content.Server.Storage.Components;
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-07-13 19:11:59 -04:00
public static readonly TimeSpan InternalOpenAttemptDelay = TimeSpan.FromSeconds(0.5);
public TimeSpan LastInternalOpenAttempt;
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;
[DataField("capacity")]
public int Capacity = 30;
[DataField("isCollidableWhenOpen")]
2022-07-13 19:11:59 -04:00
public bool IsCollidableWhenOpen;
/// <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;
[DataField("enteringRange")]
public float EnteringRange = 0.18f;
2022-07-13 19:11:59 -04:00
[DataField("showContents")]
public bool ShowContents;
2022-07-13 19:11:59 -04:00
[DataField("occludesLight")]
public bool OccludesLight = true;
2020-05-25 13:58:56 +02:00
[DataField("deleteContentsOnDestruction"), ViewVariables(VVAccess.ReadWrite)]
2022-07-13 19:11:59 -04:00
public bool DeleteContentsOnDestruction = false;
/// <summary>
/// Whether or not the container is sealed and traps air inside of it
/// </summary>
[DataField("airtight"), ViewVariables(VVAccess.ReadWrite)]
public bool Airtight = true;
2022-07-13 19:11:59 -04:00
[DataField("open")]
public bool Open;
2022-07-13 19:11:59 -04:00
[DataField("closeSound")]
public SoundSpecifier CloseSound = new SoundPathSpecifier("/Audio/Effects/closetclose.ogg");
2022-07-13 19:11:59 -04:00
[DataField("openSound")]
public SoundSpecifier OpenSound = new SoundPathSpecifier("/Audio/Effects/closetopen.ogg");
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!;
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
}
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-07-13 19:11:59 -04:00
Silent = silent;
}
2022-07-13 19:11:59 -04: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
}
}
2022-07-13 19:11:59 -04:00
public sealed class StorageAfterCloseEvent : EventArgs { }