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:
committed by
GitHub
parent
99b431cafd
commit
d2ddbcbcda
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user