the boxening (#22643)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Server.Storage.EntitySystems;
|
using Content.Server.Storage.EntitySystems;
|
||||||
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.CardboardBox;
|
using Content.Shared.CardboardBox;
|
||||||
using Content.Shared.CardboardBox.Components;
|
using Content.Shared.CardboardBox.Components;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
@@ -33,7 +34,8 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterOpenEvent>(AfterStorageOpen);
|
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterOpenEvent>(AfterStorageOpen);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, StorageBeforeOpenEvent>(BeforeStorageOpen);
|
SubscribeLocalEvent<CardboardBoxComponent, StorageBeforeOpenEvent>(BeforeStorageOpen);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
|
SubscribeLocalEvent<CardboardBoxComponent, StorageAfterCloseEvent>(AfterStorageClosed);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, ActivateInWorldEvent>(OnInteracted);
|
SubscribeLocalEvent<CardboardBoxComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
|
||||||
|
SubscribeLocalEvent<CardboardBoxComponent, ActivateInWorldEvent>(OnInteracted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
|
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||||
@@ -41,19 +43,19 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(OnDamage);
|
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(OnDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args)
|
private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (!TryComp<EntityStorageComponent>(uid, out var box))
|
if (!TryComp<EntityStorageComponent>(uid, out var box))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
_storage.ToggleOpen(args.User, uid, box);
|
_storage.ToggleOpen(args.User, uid, box);
|
||||||
|
|
||||||
if (box.Contents.Contains(args.User) && !box.Open)
|
if (box.Contents.Contains(args.User) && !box.Open)
|
||||||
{
|
{
|
||||||
_mover.SetRelay(args.User, uid);
|
_mover.SetRelay(args.User, uid);
|
||||||
component.Mover = args.User;
|
component.Mover = args.User;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args)
|
private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args)
|
||||||
@@ -65,10 +67,17 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
_storage.OpenStorage(uid);
|
_storage.OpenStorage(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGetAdditionalAccess(EntityUid uid, CardboardBoxComponent component, ref GetAdditionalAccessEvent args)
|
||||||
|
{
|
||||||
|
if (component.Mover == null)
|
||||||
|
return;
|
||||||
|
args.Entities.Add(component.Mover.Value);
|
||||||
|
}
|
||||||
|
|
||||||
private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args)
|
private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args)
|
||||||
{
|
{
|
||||||
if (component.Quiet)
|
if (component.Quiet)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Play effect & sound
|
//Play effect & sound
|
||||||
if (component.Mover != null)
|
if (component.Mover != null)
|
||||||
@@ -115,7 +124,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
if (component.Mover == null)
|
if (component.Mover == null)
|
||||||
{
|
{
|
||||||
_mover.SetRelay(args.Entity, uid);
|
_mover.SetRelay(args.Entity, uid);
|
||||||
component.Mover = args.Entity;
|
component.Mover = args.Entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user