Universal weldable component (#7955)

* Weldable component for door

* Content update

* Examine message

* Universal visualizer

* Small fix

* Entity storage

* Content

* Fixed test

* Update Content.Shared/Storage/SharedStorageComponent.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Fixed loc string

* Add public API to change welding time

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Alex Evgrashin
2022-05-09 08:51:52 +03:00
committed by GitHub
parent 02de328d9c
commit df49c2fd57
29 changed files with 367 additions and 215 deletions

View File

@@ -1,18 +1,47 @@
using System.Linq;
using Content.Server.Popups;
using Content.Server.Storage.Components;
using Content.Server.Tools.Systems;
using Content.Shared.Destructible;
using Content.Shared.Interaction;
using Robust.Shared.Physics;
using Robust.Shared.Player;
namespace Content.Server.Storage.EntitySystems;
public sealed class EntityStorageSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EntityStorageComponent, WeldableAttemptEvent>(OnWeldableAttempt);
SubscribeLocalEvent<EntityStorageComponent, WeldableChangedEvent>(OnWelded);
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestroy);
}
private void OnWeldableAttempt(EntityUid uid, EntityStorageComponent component, WeldableAttemptEvent args)
{
if (component.Open)
{
args.Cancel();
return;
}
if (component.Contents.Contains(args.User))
{
var msg = Loc.GetString("entity-storage-component-already-contains-user-message");
_popupSystem.PopupEntity(msg, args.User, Filter.Entities(args.User));
args.Cancel();
}
}
private void OnWelded(EntityUid uid, EntityStorageComponent component, WeldableChangedEvent args)
{
component.IsWeldedShut = args.IsWelded;
}
private void OnDestroy(EntityUid uid, EntityStorageComponent component, DestructionEventArgs args)
{
component.Open = true;