Reduce vendor thank you message spam and add variety (#23746)
* Moved vendor thank you messages into AdvertisementPack, making them vendor-specific. Wrote a few example messages. * Only display thank yous when closing the UI after a purchase. * Tweaked a few messages * More custom messages * Missed one
This commit is contained in:
@@ -24,6 +24,7 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.VendingMachines
|
||||
{
|
||||
@@ -37,7 +38,7 @@ namespace Content.Server.VendingMachines
|
||||
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
[Dependency] private readonly AdvertiseSystem _advertise = default!;
|
||||
|
||||
private ISawmill _sawmill = default!;
|
||||
|
||||
@@ -56,6 +57,7 @@ namespace Content.Server.VendingMachines
|
||||
|
||||
SubscribeLocalEvent<VendingMachineComponent, ActivatableUIOpenAttemptEvent>(OnActivatableUIOpenAttempt);
|
||||
SubscribeLocalEvent<VendingMachineComponent, BoundUIOpenedEvent>(OnBoundUIOpened);
|
||||
SubscribeLocalEvent<VendingMachineComponent, BoundUIClosedEvent>(OnBoundUIClosed);
|
||||
SubscribeLocalEvent<VendingMachineComponent, VendingMachineEjectMessage>(OnInventoryEjectMessage);
|
||||
|
||||
SubscribeLocalEvent<VendingMachineComponent, VendingMachineSelfDispenseEvent>(OnSelfDispense);
|
||||
@@ -110,6 +112,19 @@ namespace Content.Server.VendingMachines
|
||||
UpdateVendingMachineInterfaceState(uid, component);
|
||||
}
|
||||
|
||||
private void OnBoundUIClosed(EntityUid uid, VendingMachineComponent component, BoundUIClosedEvent args)
|
||||
{
|
||||
if ((VendingMachineUiKey) args.UiKey != VendingMachineUiKey.Key)
|
||||
return;
|
||||
|
||||
// Only vendors that advertise will send message after dispensing
|
||||
if (component.ShouldSayThankYou && TryComp<AdvertiseComponent>(uid, out var advertise))
|
||||
{
|
||||
_advertise.SayThankYou(uid, advertise);
|
||||
component.ShouldSayThankYou = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVendingMachineInterfaceState(EntityUid uid, VendingMachineComponent component)
|
||||
{
|
||||
var state = new VendingMachineInterfaceState(GetAllInventory(uid, component));
|
||||
@@ -387,11 +402,7 @@ namespace Content.Server.VendingMachines
|
||||
_throwingSystem.TryThrow(ent, direction, vendComponent.NonLimitedEjectForce);
|
||||
}
|
||||
|
||||
// Only vendors that advertise will send message after dispensing
|
||||
if (TryComp<AdvertiseComponent>(uid, out var advertise))
|
||||
{
|
||||
_chat.TrySendInGameICMessage(uid, Loc.GetString("vending-machine-thanks", ("name", Name(uid))), InGameICChatType.Speak, true);
|
||||
}
|
||||
vendComponent.ShouldSayThankYou = true;
|
||||
|
||||
vendComponent.NextItemToEject = null;
|
||||
vendComponent.ThrowNextItem = false;
|
||||
|
||||
Reference in New Issue
Block a user