big cardboard box improvements (#16418)
This commit is contained in:
@@ -31,12 +31,28 @@ 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, InteractedNoHandEvent>(OnNoHandInteracted);
|
SubscribeLocalEvent<CardboardBoxComponent, InteractedNoHandEvent>(OnNoHandInteracted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
SubscribeLocalEvent<CardboardBoxComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
SubscribeLocalEvent<CardboardBoxComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||||
|
|
||||||
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(OnDamage);
|
SubscribeLocalEvent<CardboardBoxComponent, DamageChangedEvent>(OnDamage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args)
|
||||||
|
{
|
||||||
|
if (!TryComp<EntityStorageComponent>(uid, out var box))
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
|
_storage.ToggleOpen(args.User, uid, box);
|
||||||
|
|
||||||
|
if (box.Contents.Contains(args.User) && !box.Open)
|
||||||
|
{
|
||||||
|
_mover.SetRelay(args.User, uid);
|
||||||
|
component.Mover = args.User;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args)
|
private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args)
|
||||||
{
|
{
|
||||||
@@ -49,6 +65,9 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
|
|
||||||
private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args)
|
private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args)
|
||||||
{
|
{
|
||||||
|
if (component.Quiet)
|
||||||
|
return;
|
||||||
|
|
||||||
//Play effect & sound
|
//Play effect & sound
|
||||||
if (component.Mover != null)
|
if (component.Mover != null)
|
||||||
{
|
{
|
||||||
@@ -91,17 +110,11 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
|
|||||||
if (!TryComp(args.Entity, out MobMoverComponent? mover))
|
if (!TryComp(args.Entity, out MobMoverComponent? mover))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (component.Mover != null)
|
if (component.Mover == null)
|
||||||
{
|
{
|
||||||
// player movers take priority
|
_mover.SetRelay(args.Entity, uid);
|
||||||
if (HasComp<ActorComponent>(component.Mover) || !HasComp<ActorComponent>(args.Entity))
|
component.Mover = args.Entity;
|
||||||
return;
|
|
||||||
|
|
||||||
RemComp<RelayInputMoverComponent>(component.Mover.Value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_mover.SetRelay(args.Entity, uid);
|
|
||||||
component.Mover = args.Entity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ public sealed class CardboardBoxComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
[DataField("effectSound")]
|
[DataField("effectSound")]
|
||||||
public SoundSpecifier? EffectSound;
|
public SoundSpecifier? EffectSound;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to prevent the box from making the sound and effect
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
[DataField("quiet")]
|
||||||
|
public bool Quiet = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How far should the box opening effect go?
|
/// How far should the box opening effect go?
|
||||||
|
|||||||
Reference in New Issue
Block a user