Implement SmartFridge functionality (#38648)

* Add SmartFridge

* my nit so pick

* my access so expanded and my whitelist so both

* list -> hashset
This commit is contained in:
pathetic meowmeow
2025-07-20 23:21:28 -04:00
committed by GitHub
parent 99b431cafd
commit d2ddbcbcda
17 changed files with 719 additions and 71 deletions

View File

@@ -3,11 +3,13 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Storage;
using Content.Shared.Storage.Components;
using Robust.Shared.Random;
namespace Content.Shared.Placeable;
public sealed class PlaceableSurfaceSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
@@ -19,6 +21,8 @@ public sealed class PlaceableSurfaceSystem : EntitySystem
SubscribeLocalEvent<PlaceableSurfaceComponent, StorageInteractUsingAttemptEvent>(OnStorageInteractUsingAttempt);
SubscribeLocalEvent<PlaceableSurfaceComponent, StorageAfterOpenEvent>(OnStorageAfterOpen);
SubscribeLocalEvent<PlaceableSurfaceComponent, StorageAfterCloseEvent>(OnStorageAfterClose);
SubscribeLocalEvent<PlaceableSurfaceComponent, GetDumpableVerbEvent>(OnGetDumpableVerb);
SubscribeLocalEvent<PlaceableSurfaceComponent, DumpEvent>(OnDump);
}
public void SetPlaceable(EntityUid uid, bool isPlaceable, PlaceableSurfaceComponent? surface = null)
@@ -87,4 +91,25 @@ public sealed class PlaceableSurfaceSystem : EntitySystem
{
SetPlaceable(ent.Owner, false, ent.Comp);
}
private void OnGetDumpableVerb(Entity<PlaceableSurfaceComponent> ent, ref GetDumpableVerbEvent args)
{
args.Verb = Loc.GetString("dump-placeable-verb-name", ("surface", ent));
}
private void OnDump(Entity<PlaceableSurfaceComponent> ent, ref DumpEvent args)
{
if (args.Handled)
return;
args.Handled = true;
args.PlaySound = true;
var (targetPos, targetRot) = _transformSystem.GetWorldPositionRotation(ent);
foreach (var entity in args.DumpQueue)
{
_transformSystem.SetWorldPositionRotation(entity, targetPos + _random.NextVector2Box() / 4, targetRot);
}
}
}