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.Hands.Components;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Content.Server.Storage.Components;
using Content.Server.Storage.EntitySystems;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Construction.Components; using Content.Shared.Construction.Components;
@@ -21,6 +23,7 @@ using Content.Shared.Movement;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -38,6 +41,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly DumpableSystem _dumpableSystem = default!;
private readonly List<DisposalUnitComponent> _activeDisposals = new(); private readonly List<DisposalUnitComponent> _activeDisposals = new();
@@ -65,7 +69,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
// Verbs // Verbs
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<InteractionVerb>>(AddInsertVerb); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<InteractionVerb>>(AddInsertVerb);
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddFlushEjectVerbs); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddDisposalAltVerbs);
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<Verb>>(AddClimbInsideVerb); SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<Verb>>(AddClimbInsideVerb);
// Units // Units
@@ -75,25 +79,48 @@ namespace Content.Server.Disposal.Unit.EntitySystems
SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed); 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; return;
// Verbs to flush the unit // Behavior for if the disposals bin has items in it
AlternativeVerb flushVerb = new(); if (component.Container.ContainedEntities.Count > 0)
flushVerb.Act = () => Engage(component); {
flushVerb.Text = Loc.GetString("disposal-flush-verb-get-data-text"); // Verbs to flush the unit
flushVerb.IconTexture = "/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png"; AlternativeVerb flushVerb = new();
flushVerb.Priority = 1; flushVerb.Act = () => Engage(component);
args.Verbs.Add(flushVerb); flushVerb.Text = Loc.GetString("disposal-flush-verb-get-data-text");
flushVerb.IconTexture = "/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png";
flushVerb.Priority = 1;
args.Verbs.Add(flushVerb);
// Verb to eject the 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);
}
// Verb to eject the contents
AlternativeVerb ejectVerb = new();
ejectVerb.Act = () => TryEjectContents(component);
ejectVerb.Category = VerbCategory.Eject;
ejectVerb.Text = Loc.GetString("disposal-eject-verb-contents");
args.Verbs.Add(ejectVerb);
} }
private void AddClimbInsideVerb(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<Verb> args) private void AddClimbInsideVerb(EntityUid uid, DisposalUnitComponent component, GetVerbsEvent<Verb> args)

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) if (dumpable.CancelToken != null)
{ {

View File

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

View File

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