Trashbag Alt Verb to dump into disposals + Cigars are tagged as trash (#9203)

* cigars are marked as trash

* alt click added to trashbag disposals interaction

* request changes

* remove redundant check and auto refactor

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Profane McBane
2022-06-27 05:19:18 +01:00
committed by GitHub
parent c0216e5caf
commit a73a6042d7
4 changed files with 48 additions and 17 deletions

View File

@@ -7,6 +7,8 @@ using Content.Server.DoAfter;
using Content.Server.Hands.Components;
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.ActionBlocker;
using Content.Shared.Atmos;
using Content.Shared.Construction.Components;
@@ -21,6 +23,7 @@ using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Throwing;
using Content.Shared.Verbs;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
@@ -38,6 +41,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly DumpableSystem _dumpableSystem = default!;
private readonly List<DisposalUnitComponent> _activeDisposals = new();
@@ -65,7 +69,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
// Verbs
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<InteractionVerb>>(AddInsertVerb);
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddFlushEjectVerbs);
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddDisposalAltVerbs);
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<Verb>>(AddClimbInsideVerb);
// Units
@@ -75,11 +79,14 @@ namespace Content.Server.Disposal.Unit.EntitySystems
SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed);
}
private void AddFlushEjectVerbs(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<AlternativeVerb> args)
private void AddDisposalAltVerbs(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract || component.Container.ContainedEntities.Count == 0)
if (!args.CanAccess || !args.CanInteract)
return;
// Behavior for if the disposals bin has items in it
if (component.Container.ContainedEntities.Count > 0)
{
// Verbs to flush the unit
AlternativeVerb flushVerb = new();
flushVerb.Act = () => Engage(component);
@@ -89,13 +96,33 @@ namespace Content.Server.Disposal.Unit.EntitySystems
args.Verbs.Add(flushVerb);
// Verb to eject the contents
AlternativeVerb ejectVerb = new();
ejectVerb.Act = () => TryEjectContents(component);
ejectVerb.Category = VerbCategory.Eject;
ejectVerb.Text = Loc.GetString("disposal-eject-verb-contents");
AlternativeVerb ejectVerb = new()
{
Act = () => TryEjectContents(component),
Category = VerbCategory.Eject,
Text = Loc.GetString("disposal-eject-verb-contents")
};
args.Verbs.Add(ejectVerb);
}
// Behavior if using a trash bag & other dumpable containers
if (args.Using != null
&& TryComp<DumpableComponent>(args.Using.Value, out var dumpable)
&& TryComp<ServerStorageComponent>(args.Using.Value, out var storage)
&& storage.StoredEntities is { Count: > 0 })
{
// Verb to dump held container into disposal unit
AlternativeVerb dumpVerb = new()
{
Act = () => _dumpableSystem.StartDoAfter(args.Using.Value, args.Target, args.User, dumpable, storage),
Text = Loc.GetString("dump-disposal-verb-name", ("unit", args.Target)),
Priority = 2
};
args.Verbs.Add(dumpVerb);
}
}
private void AddClimbInsideVerb(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<Verb> args)
{
// This is not an interaction, activation, or alternative verb type because unfortunately most users are

View File

@@ -102,7 +102,7 @@ namespace Content.Server.Storage.EntitySystems
}
}
private void StartDoAfter(EntityUid storageUid, EntityUid? targetUid, EntityUid userUid, DumpableComponent dumpable, ServerStorageComponent storage, float multiplier = 1)
public void StartDoAfter(EntityUid storageUid, EntityUid? targetUid, EntityUid userUid, DumpableComponent dumpable, ServerStorageComponent storage, float multiplier = 1)
{
if (dumpable.CancelToken != null)
{

View File

@@ -14,6 +14,7 @@
- type: Tag
tags:
- Cigar
- Trash
- type: Clothing
sprite: Objects/Consumable/Smokeables/Cigars/cigar.rsi
Slots: [ mask ]

View File

@@ -25,6 +25,9 @@
- type: Smokable
exposeTemperature: 1173.15
- type: Cigar
- type: Tag
tags:
- Trash
- type: InjectableSolution
solution: smokable
- type: SolutionContainerManager