From 20481a0bb1b2305b52eeb46c8681798a52f6815b Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 23 Apr 2020 00:58:43 +0200 Subject: [PATCH] Bar signs implemented. --- Content.Client/EntryPoint.cs | 1 + .../Components/BarSign/BarSignComponent.cs | 115 +++++++++++ .../Components/BarSign/BarSignPrototype.cs | 40 ++++ Resources/Prototypes/BarSigns.yml | 191 ++++++++++++++++++ .../Prototypes/Entities/Buildings/barSign.yml | 25 +++ 5 files changed, 372 insertions(+) create mode 100644 Content.Server/GameObjects/Components/BarSign/BarSignComponent.cs create mode 100644 Content.Server/GameObjects/Components/BarSign/BarSignPrototype.cs create mode 100644 Resources/Prototypes/BarSigns.yml create mode 100644 Resources/Prototypes/Entities/Buildings/barSign.yml diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index a13ef741be..c8ab1376c7 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -163,6 +163,7 @@ namespace Content.Client prototypes.RegisterIgnore("material"); prototypes.RegisterIgnore("reaction"); //Chemical reactions only needed by server. Reactions checks are server-side. + prototypes.RegisterIgnore("barSign"); ClientContentIoC.Register(); diff --git a/Content.Server/GameObjects/Components/BarSign/BarSignComponent.cs b/Content.Server/GameObjects/Components/BarSign/BarSignComponent.cs new file mode 100644 index 0000000000..03ee21c5f5 --- /dev/null +++ b/Content.Server/GameObjects/Components/BarSign/BarSignComponent.cs @@ -0,0 +1,115 @@ +using System.Linq; +using Content.Server.GameObjects.Components.Power; +using Robust.Server.GameObjects; +using Robust.Server.Interfaces.GameObjects; +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.Random; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Log; +using Robust.Shared.Prototypes; +using Robust.Shared.Random; +using Robust.Shared.Serialization; +using Robust.Shared.ViewVariables; + +namespace Content.Server.GameObjects.Components.BarSign +{ + [RegisterComponent] + public class BarSignComponent : Component, IMapInit + { + public override string Name => "BarSign"; + +#pragma warning disable 649 + [Dependency] private readonly IPrototypeManager _prototypeManager; + [Dependency] private readonly IRobustRandom _robustRandom; +#pragma warning restore 649 + + private string _currentSign; + + private PowerDeviceComponent _power; + private SpriteComponent _sprite; + + [ViewVariables(VVAccess.ReadWrite)] + public string CurrentSign + { + get => _currentSign; + set + { + _currentSign = value; + UpdateSignInfo(); + } + } + + private void UpdateSignInfo() + { + if (_currentSign == null) + { + return; + } + + if (!_prototypeManager.TryIndex(_currentSign, out BarSignPrototype prototype)) + { + Logger.ErrorS("barSign", $"Invalid bar sign prototype: \"{_currentSign}\""); + return; + } + + if (!_power.Powered) + { + _sprite.LayerSetState(0, "empty"); + } + else + { + _sprite.LayerSetState(0, prototype.Icon); + } + + if (!string.IsNullOrEmpty(prototype.Name)) + { + Owner.Name = prototype.Name; + } + else + { + Owner.Name = Loc.GetString("bar sign"); + } + + Owner.Description = prototype.Description; + } + + public override void Initialize() + { + base.Initialize(); + + _power = Owner.GetComponent(); + _sprite = Owner.GetComponent(); + + _power.OnPowerStateChanged += PowerOnOnPowerStateChanged; + + UpdateSignInfo(); + } + + private void PowerOnOnPowerStateChanged(object sender, PowerStateEventArgs e) + { + UpdateSignInfo(); + } + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + + serializer.DataField(ref _currentSign, "current", null); + } + + public void MapInit() + { + if (_currentSign != null) + { + return; + } + + var prototypes = _prototypeManager.EnumeratePrototypes().Where(p => !p.Hidden) + .ToList(); + var prototype = _robustRandom.Pick(prototypes); + + CurrentSign = prototype.ID; + } + } +} diff --git a/Content.Server/GameObjects/Components/BarSign/BarSignPrototype.cs b/Content.Server/GameObjects/Components/BarSign/BarSignPrototype.cs new file mode 100644 index 0000000000..7026d7b8b5 --- /dev/null +++ b/Content.Server/GameObjects/Components/BarSign/BarSignPrototype.cs @@ -0,0 +1,40 @@ +using Robust.Shared.Localization; +using Robust.Shared.Prototypes; +using Robust.Shared.Utility; +using YamlDotNet.RepresentationModel; + +namespace Content.Server.GameObjects.Components.BarSign +{ + [Prototype("barSign")] + public class BarSignPrototype : IPrototype, IIndexedPrototype + { + public string ID { get; private set; } + public string Icon { get; private set; } + public string Name { get; private set; } + public string Description { get; private set; } + public bool RenameArea { get; private set; } = true; + public bool Hidden { get; private set; } + + public void LoadFrom(YamlMappingNode mapping) + { + ID = mapping.GetNode("id").AsString(); + Name = Loc.GetString(mapping.GetNode("name").AsString()); + Icon = mapping.GetNode("icon").AsString(); + + if (mapping.TryGetNode("hidden", out var node)) + { + Hidden = node.AsBool(); + } + + if (mapping.TryGetNode("renameArea", out node)) + { + RenameArea = node.AsBool(); + } + + if (mapping.TryGetNode("description", out node)) + { + Description = Loc.GetString(node.AsString()); + } + } + } +} diff --git a/Resources/Prototypes/BarSigns.yml b/Resources/Prototypes/BarSigns.yml new file mode 100644 index 0000000000..db75bec5f7 --- /dev/null +++ b/Resources/Prototypes/BarSigns.yml @@ -0,0 +1,191 @@ +- type: barSign + id: MalteseFalcon + name: "Maltese Falcon" + icon: "maltesefalcon" + description: "The Maltese Falcon, Space Bar and Grill." + +- type: barSign + id: TheBark + name: "The Bark" + icon: "thebark" + description: "Ian's bar of choice." + +- type: barSign + id: Harmbaton + name: "The Harmbaton" + icon: "theharmbaton" + description: "A great dining experience for both security members and assistants." + +- type: barSign + id: TheSingulo + name: "The Singulo" + icon: "thesingulo" + description: "Where people go that'd rather not be called by their name." + +- type: barSign + id: TheDrunkCarp + name: "The Drunk Carp" + icon: "thedrunkcarp" + description: "Don't drink and swim." + +- type: barSign + id: ScotchServinWill + name: "Scotch Servin Willy's" + icon: "scotchservinwill" + description: "Willy sure moved up in the world from clown to bartender." + +- type: barSign + id: OfficerBeersky + name: "Officer Beersky's" + icon: "officerbeersky" + description: "Man eat a dong, these drinks are great." + +- type: barSign + id: TheCavern + name: "The Cavern" + icon: "thecavern" + description: "Fine drinks while listening to some fine tunes." + +- type: barSign + id: TheOuterSpess + name: "The Outer Spess" + icon: "theouterspess" + description: "This bar isn't actually located in outer space." + +- type: barSign + id: SlipperyShots + name: "Slippery Shots" + icon: "slipperyshots" + description: "Slippery slope to drunkeness with our shots!" + +- type: barSign + id: TheGreyTide + name: "The Grey Tide" + icon: "thegreytide" + description: "Abandon your toolboxing ways and enjoy a lazy beer!" + +- type: barSign + id: HonkednLoaded + name: "Honked 'n' Loaded" + icon: "honkednloaded" + description: "Honk." + +- type: barSign + id: TheNest + name: "The Nest" + icon: "thenest" + description: "A good place to retire for a drink after a long night of crime fighting." + +- type: barSign + id: TheCoderbus + name: "The Coderbus" + icon: "thecoderbus" + description: "A very controversial bar known for its wide variety of constantly-changing drinks." + +- type: barSign + id: TheAdminbus + name: "The Adminbus" + icon: "theadminbus" + description: "An establishment visited mainly by space-judges. It isn't bombed nearly as much as court hearings." + +- type: barSign + id: OldCockInn + name: "The Old Cock Inn" + icon: "oldcockinn" + description: "Something about this sign fills you with despair." + +- type: barSign + id: TheWretchedHive + name: "The Wretched Hive" + icon: "thewretchedhive" + description: "Legally obligated to instruct you to check your drinks for acid before consumption." + +- type: barSign + id: RobustaCafe + name: "The Robusta Cafe" + icon: "robustacafe" + description: "Holder of the 'Most Lethal Barfights' record 5 years uncontested." + +- type: barSign + id: EmergencyRumParty + name: "The Emergency Rum Party" + icon: "emergencyrumparty" + description: "Recently relicensed after a long closure." + +- type: barSign + id: ComboCafe + name: "The Combo Cafe" + icon: "combocafe" + description: "Renowned system-wide for their utterly uncreative drink combinations." + +- type: barSign + id: VladsSaladBar + name: "Vlad's Salad Bar" + icon: "vladssaladbar" + description: "Under new management. Vlad was always a bit too trigger happy with that shotgun." + +- type: barSign + id: TheShaken + name: "The Shaken" + icon: "theshaken" + description: "This establishment does not serve stirred drinks." + +- type: barSign + id: TheAleNath + name: "The Ale' Nath" + icon: "thealenath" + description: "All right, buddy. I think you've had EI NATH. Time to get a cab." + +- type: barSign + id: TheAlohaAnackbar + name: "The Aloha Snackbar" + icon: "alohasnackbar" + description: "A tasteful, inoffensive tiki bar sign." + +- type: barSign + id: TheNet + name: "The Net" + icon: "thenet" + description: "You just seem to get caught up in it for hours." + +- type: barSign + id: MaidCafe + name: "Maid Cafe" + icon: "maidcafe" + description: "Welcome back, master!" + +- type: barSign + id: TheLightbulb + name: "The Lightbulb" + icon: "the_lightbulb" + description: "A cafe popular among moths and moffs. Once shut down for a week after the bartender used mothballs to protect her spare uniforms." + +- type: barSign + id: Goose + name: "The Loose Goose" + icon: "goose" + description: "Drink till you puke and/or break the laws of reality!" + +# Hidden signs list below this point +- type: barSign + id: EmpBarSign + name: "" + icon: "empbarsign" + description: "Something has gone very wrong." + rename_area: false + hidden: true + +- type: barSign + id: SyndiBarSign + name: "Syndi Cat" + icon: "syndibarsign" + description: "Syndicate or die." + hidden: true + +- type: barSign + id: SignOff + name: "" + icon: "empty" + description: "This sign doesn't seem to be on." + rename_area: false + hidden: true diff --git a/Resources/Prototypes/Entities/Buildings/barSign.yml b/Resources/Prototypes/Entities/Buildings/barSign.yml new file mode 100644 index 0000000000..211ccd07b6 --- /dev/null +++ b/Resources/Prototypes/Entities/Buildings/barSign.yml @@ -0,0 +1,25 @@ +- type: entity + id: BarSign + name: bar sign + components: + - type: Clickable + - type: InteractionOutline + - type: Collidable + - type: Sprite + drawdepth: WallTops + sprite: Buildings/barsign.rsi + state: empty + - type: Icon + sprite: Buildings/barsign.rsi + state: empty + - type: PowerDevice + - type: BarSign + + +- type: entity + id: BarSignMalteseFalcon + name: Maltese Falcon + parent: BarSign + components: + - type: BarSign + current: MalteseFalcon