Add AdvertiseComponent and add it to vending machines (#3756)

* WIP AdvertiseComponent

* Add AdvertiseComponent and add it to vending machines

* Add snacks.yml

* Capitalise C in cigarette machine

* Update Content.Server/GameObjects/Components/AdvertiseComponent.cs

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Update Content.Server/GameObjects/Components/AdvertiseComponent.cs

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>

* Fix most problems

* Add localisation + exception for illegal prototype values

* Add ads for smart fridge, discount dan's, youtool and mining

* Oops

* Fix style

* Make dependencies local

* Remove some ads, increase wait

* Increase wait, allow full initial wait width

* Fix error

* Update sovietsoda.ftl

* Update sovietsoda.ftl

Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Visne
2021-04-21 12:00:14 +02:00
committed by GitHub
parent 2250926457
commit 75a8833b2c
58 changed files with 558 additions and 59 deletions

View File

@@ -17,7 +17,6 @@ using Robust.Shared.Localization;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -129,6 +128,18 @@ namespace Content.Server.GameObjects.Components.VendingMachines
{
var state = args.Powered ? VendingMachineVisualState.Normal : VendingMachineVisualState.Off;
TrySetVisualState(state);
// Pause/resume advertising if advertising component exists and not broken
if (!Owner.TryGetComponent(out AdvertiseComponent? advertiseComponent) || _broken) return;
if (Powered)
{
advertiseComponent.Resume();
}
else
{
advertiseComponent.Pause();
}
}
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg)
@@ -244,6 +255,11 @@ namespace Content.Server.GameObjects.Components.VendingMachines
{
_broken = true;
TrySetVisualState(VendingMachineVisualState.Broken);
if (Owner.TryGetComponent(out AdvertiseComponent? advertiseComponent))
{
advertiseComponent.Pause();
}
}
public enum Wires