From 6879e37ce001ea3db09817b49877c8ff6dcfb56f Mon Sep 17 00:00:00 2001 From: rosieposie <52761126+rosieposieeee@users.noreply.github.com> Date: Thu, 6 Feb 2025 03:16:13 -0500 Subject: [PATCH] SOS app for the PDA (#2812) * Merge pull request #1450 from Saeko-44/master SOS app for the PDA * fix PDAs * untouch * Revert "untouch" This reverts commit 5c08a2972d31c1edaa7f73bfba1f07a171a52f33. * untouch the right guy * Update pda.yml * removed unnecessary using that caused an error * add feedback popup * Update SOSCartridgeSystem.cs * add cart sprite * review changes * Update cartridges.yml * remove app from shitter roles * fine * display seconds * Update cartridges.ftl * upped cooldown to 90 seconds * use imp namespace * Update pda.yml --------- Co-authored-by: mqole <113324899+mqole@users.noreply.github.com> --- .../Cartridges/SOSCartridgeComponent.cs | 43 ++++++++++ .../Cartridges/SOSCartridgeSystem.cs | 78 ++++++++++++++++++ .../cartridge-loader/cartridges.ftl | 5 ++ .../Catalog/Fills/Lockers/heads.yml | 1 + .../Entities/Objects/Devices/pda.yml | 15 ++++ .../_DV/Entities/Objects/Devices/pda.yml | 3 + .../Entities/Objects/Devices/cartridges.yml | 20 +++++ .../Devices/cartridge.rsi/cart-sos.png | Bin 0 -> 382 bytes .../Objects/Devices/cartridge.rsi/meta.json | 5 +- .../Objects/Devices/sos.rsi/icon.png | Bin 0 -> 346 bytes .../Objects/Devices/sos.rsi/meta.json | 14 ++++ 11 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeComponent.cs create mode 100644 Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeSystem.cs create mode 100644 Resources/Locale/en-US/_Impstation/cartridge-loader/cartridges.ftl create mode 100644 Resources/Prototypes/_Impstation/Entities/Objects/Devices/cartridges.yml create mode 100644 Resources/Textures/_DV/Objects/Devices/cartridge.rsi/cart-sos.png create mode 100644 Resources/Textures/_Impstation/Objects/Devices/sos.rsi/icon.png create mode 100644 Resources/Textures/_Impstation/Objects/Devices/sos.rsi/meta.json diff --git a/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeComponent.cs b/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeComponent.cs new file mode 100644 index 00000000000..62d541e1c6f --- /dev/null +++ b/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeComponent.cs @@ -0,0 +1,43 @@ +using Content.Shared.CartridgeLoader.Cartridges; +using Content.Shared.Containers.ItemSlots; +using Content.Shared.Radio; +using Robust.Shared.Prototypes; + +namespace Content.Server._Impstation.CartridgeLoader.Cartridges; + +[RegisterComponent] +public sealed partial class SOSCartridgeComponent : Component +{ + [DataField] + //Path to the id container + public const string PDAIdContainer = "PDA-id"; + + [DataField] + //Name to use if no id is found + public string DefaultName = "sos-caller-defaultname"; + + [ViewVariables(VVAccess.ReadOnly)] + public string LocalizedDefaultName => Loc.GetString(DefaultName); + + [DataField] + //Notification message + public string HelpMessage = "sos-message"; + + [ViewVariables(VVAccess.ReadOnly)] + public string LocalizedHelpMessage => Loc.GetString(HelpMessage); + + [DataField] + //Channel to notify + public ProtoId HelpChannel = "Security"; + + [DataField] + //Timeout between calls + public const float TimeOut = 90; + + [DataField] + //Countdown until next call is allowed + public float Timer = 0; + + [ViewVariables(VVAccess.ReadOnly)] + public bool CanCall => Timer <= 0; +} diff --git a/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeSystem.cs b/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeSystem.cs new file mode 100644 index 00000000000..c35e07db157 --- /dev/null +++ b/Content.Server/_Impstation/CartridgeLoader/Cartridges/SOSCartridgeSystem.cs @@ -0,0 +1,78 @@ +using Content.Server.Radio.EntitySystems; +using Content.Shared.Access.Components; +using Content.Shared.CartridgeLoader; +using Content.Shared.PDA; +using Content.Shared.Popups; +using Robust.Server.Containers; +using Robust.Shared.Containers; + +namespace Content.Server._Impstation.CartridgeLoader.Cartridges; + +public sealed class SOSCartridgeSystem : EntitySystem +{ + [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] private readonly SharedPopupSystem _popupSystem = default!; + [Dependency] private readonly RadioSystem _radio = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnActivated); + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var uid, out var comp)) + { + if (comp.Timer > 0) + { + comp.Timer -= frameTime; + } + } + } + + private void OnActivated(EntityUid uid, SOSCartridgeComponent component, CartridgeActivatedEvent args) + { + if (component.CanCall) + { + //Get the PDA + if (!TryComp(args.Loader, out var pda)) + return; + + //Get the id container + if (_container.TryGetContainer(args.Loader, SOSCartridgeComponent.PDAIdContainer, out var idContainer)) + { + //If theres nothing in id slot, send message anonymously + if (idContainer.ContainedEntities.Count == 0) + { + _radio.SendRadioMessage(uid, component.LocalizedDefaultName + " " + component.LocalizedHelpMessage, component.HelpChannel, uid); + } + else + { + //Otherwise, send a message with the full name of every id in there + foreach (var idCard in idContainer.ContainedEntities) + { + if (!TryComp(idCard, out var idCardComp)) + return; + + _radio.SendRadioMessage(uid, idCardComp.FullName + " " + component.LocalizedHelpMessage, component.HelpChannel, uid); + } + } + + component.Timer = SOSCartridgeComponent.TimeOut; + // DeltaV - send feedback that you succeeded + _popupSystem.PopupEntity(Loc.GetString("sos-message-sent-success"), uid, PopupType.Medium); + } + } + // DeltaV - send feedback that you failed + else + { + var seconds = Math.Round(component.Timer); + _popupSystem.PopupEntity(Loc.GetString("sos-message-sent-cooldown", ("count", seconds)), uid, PopupType.MediumCaution); + } + } +} diff --git a/Resources/Locale/en-US/_Impstation/cartridge-loader/cartridges.ftl b/Resources/Locale/en-US/_Impstation/cartridge-loader/cartridges.ftl new file mode 100644 index 00000000000..e8f80b7c3d1 --- /dev/null +++ b/Resources/Locale/en-US/_Impstation/cartridge-loader/cartridges.ftl @@ -0,0 +1,5 @@ +sos-program-name = SOS +sos-caller-defaultname = Unknown +sos-message = is requesting help! +sos-message-sent-success = SOS sent successfully. +sos-message-sent-cooldown = Please wait {$count} second(s) to send another SOS. diff --git a/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml b/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml index 3547e200c54..d9698fc36f3 100644 --- a/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml +++ b/Resources/Prototypes/Catalog/Fills/Lockers/heads.yml @@ -140,6 +140,7 @@ - id: RubberStampHop #- id: WeaponDisabler # DeltaV - There is no reason for the service head to have a disabler. - id: ClothingEyesHudCommand + - id: SOSCartridge # DeltaV - adds SOS app https://github.com/DeltaV-Station/Delta-v/pull/2812 - type: entity id: LockerHeadOfPersonnelFilled diff --git a/Resources/Prototypes/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/Entities/Objects/Devices/pda.yml index 55504776e24..50cbdb622ce 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/pda.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/pda.yml @@ -86,6 +86,7 @@ - NotekeeperCartridge - NewsReaderCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp cartridgeSlot: priority: -1 name: device-pda-slot-component-slot-name-cartridge @@ -139,6 +140,7 @@ - CrimeAssistCartridge # DeltaV - SecWatchCartridge # DeltaV: SecWatch replaces WantedList - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -153,6 +155,7 @@ - NewsReaderCartridge - MedTekCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -468,6 +471,7 @@ - MailMetricsCartridge # DeltaV - MailMetrics courier tracker - StockTradingCartridge # DeltaV - StockTrading - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -493,6 +497,7 @@ - NewsReaderCartridge - StockTradingCartridge # DeltaV - StockTrading - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -520,6 +525,7 @@ - NewsReaderCartridge - AstroNavCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -832,6 +838,7 @@ - NewsReaderCartridge - GlimmerMonitorCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -858,6 +865,7 @@ - NewsReaderCartridge - GlimmerMonitorCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BaseSecurityPDA @@ -886,6 +894,7 @@ - SecWatchCartridge # DeltaV: SecWatch replaces WantedList - LogProbeCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BaseSecurityPDA @@ -957,6 +966,7 @@ - LogProbeCartridge - AstroNavCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: CentcomPDA @@ -984,6 +994,7 @@ - AstroNavCartridge - StockTradingCartridge # Delta-V - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: Tag # Ignore Chameleon tags tags: - DoorBumpOpener @@ -1141,6 +1152,7 @@ - LogProbeCartridge - AstroNavCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: ERTLeaderPDA @@ -1254,6 +1266,7 @@ - NewsReaderCartridge - StockTradingCartridge # DeltaV - StockTrading - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BasePDA @@ -1318,6 +1331,7 @@ - SecWatchCartridge # DeltaV: SecWatch replaces WantedList - LogProbeCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: BaseMedicalPDA @@ -1347,6 +1361,7 @@ - SecWatchCartridge # DeltaV: SecWatch replaces WantedList - MedTekCartridge - NanoChatCartridge # DeltaV + - SOSCartridge # Imp - type: entity parent: ClownPDA diff --git a/Resources/Prototypes/_DV/Entities/Objects/Devices/pda.yml b/Resources/Prototypes/_DV/Entities/Objects/Devices/pda.yml index 82184622b98..6b7fdc1b895 100644 --- a/Resources/Prototypes/_DV/Entities/Objects/Devices/pda.yml +++ b/Resources/Prototypes/_DV/Entities/Objects/Devices/pda.yml @@ -14,6 +14,7 @@ - CrimeAssistCartridge - SecWatchCartridge - NanoChatCartridge + - SOSCartridge # Imp - MedTekCartridge - type: Pda id: BrigmedicIDCard @@ -84,6 +85,7 @@ - CrimeAssistCartridge - SecWatchCartridge - NanoChatCartridge + - SOSCartridge # Imp - type: entity parent: BaseJusticePDA @@ -198,6 +200,7 @@ - NewsReaderCartridge - MailMetricsCartridge - NanoChatCartridge + - SOSCartridge # Imp - type: entity parent: CourierPDA diff --git a/Resources/Prototypes/_Impstation/Entities/Objects/Devices/cartridges.yml b/Resources/Prototypes/_Impstation/Entities/Objects/Devices/cartridges.yml new file mode 100644 index 00000000000..15249354779 --- /dev/null +++ b/Resources/Prototypes/_Impstation/Entities/Objects/Devices/cartridges.yml @@ -0,0 +1,20 @@ +- type: entity + parent: BaseItem + id: SOSCartridge + name: SOS cartridge + description: A program to call for help. + components: + # Begin Delta-V Section - added cartridge sprite + - type: Sprite + sprite: _DV/Objects/Devices/cartridge.rsi + state: cart-sos + - type: Icon + sprite: _DV/Objects/Devices/cartridge.rsi + state: cart-sos + # End Delta-V Section + - type: Cartridge + programName: sos-program-name + icon: + sprite: _Impstation/Objects/Devices/sos.rsi + state: icon + - type: SOSCartridge diff --git a/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/cart-sos.png b/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/cart-sos.png new file mode 100644 index 0000000000000000000000000000000000000000..d88c5f8373b862bc105749b48acc5d51f7af95c7 GIT binary patch literal 382 zcmV-^0fGLBP)YAX9X8WNB|8RBvx=!KdMT0003A zNklv1-FG6ouj6lLW%p(Uf`!UHceWL+DWYCfzz^>ee?Y9ZKoi$H-bTIGG#^ zBd{iSaY|}Jk|q|RptA`C=R^0RsA(E5nJ54PAOHg3UjVe$Cn<}fh|UIRt(z>%u-5*m zTq#AK=LZo-0g@zPwpb9yG0r*CmsbEjrxO6i?;ik^_jd>(sH%$DXoNAQKfv>P&6hFU zv}L;h0Q2dD>m=b}Fz6TXv|6#O>tBGk7I51ETuI5}aOfYfE8YN`5dc4k?hDM@vzHNU zFX6s;Tf$S)J3vZ_QflvgYb|wM_X`k0kf!Ou@@+&}mN@6m2W${WHFwg>SL{0h5C8!X c02c>*1CmYw&_Y1u{Qv*}07*qoM6N<$g4%nSK>z>% literal 0 HcmV?d00001 diff --git a/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/meta.json b/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/meta.json index 87232274a87..eb49ebdecd1 100644 --- a/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/meta.json +++ b/Resources/Textures/_DV/Objects/Devices/cartridge.rsi/meta.json @@ -1,7 +1,7 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "cart-chat made by kushbreth (discord), cart-cri, cart-mail, cart-psi, cart-stonk made by Monotheonist (github), edited from cart-log, cart-nav & cart-med cartridges; cart-log made by Skarletto (github), cart-nav, cart-med made by ArchRBX (github)", + "copyright": "cart-chat made by kushbreth (discord), cart-cri, cart-mail, cart-psi, cart-stonk made by Monotheonist (github), edited from cart-log, cart-nav & cart-med cartridges; cart-log made by Skarletto (github), cart-nav, cart-med made by ArchRBX (github), cart-sos modified from cart-chat by rosieposieeee (github)", "size": { "x": 32, "y": 32 @@ -21,6 +21,9 @@ }, { "name": "cart-chat" + }, + { + "name": "cart-sos" } ] } diff --git a/Resources/Textures/_Impstation/Objects/Devices/sos.rsi/icon.png b/Resources/Textures/_Impstation/Objects/Devices/sos.rsi/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..8150829e02703133dafacdf7770260624ae35f35 GIT binary patch literal 346 zcmV-g0j2(lP)Px$6iGxuR9J=Wl|2rEFdW67#>s?*#Kg_Tgh9^15xj#eB)XY8*%%g0Snv)Wfpg$M z;=)YA!U1q9sS4N@l%>D1Y2JJMKMJ7HXa;5^dU3s6l`_J&$6ZK!B5LkW=Q94l5~WCp zv7BoEbPiy6?*9WcnW}{O8lbNKMG(U9T%=hJ07$bOhUcOP!s?DcoeK@FatmTYVN(JC zuqi=IsFIG*7Vxk#+i&MA41kwP^d5kTr&<1D8WW1e%#@XDZ$aDs^JVAT!6PyU%3Dwb zVfDp}nOO~{EJ^{IdMwlXP64`_@-)8Hj^mW4;Mz%?vG+EJqNvuZ_RzAda(g`YV$Qf6 sc1V)s!*B4PQDX&uVOCcGjYgw+0)J~*oQL!kegFUf07*qoM6N<$g0Z-ncmMzZ literal 0 HcmV?d00001 diff --git a/Resources/Textures/_Impstation/Objects/Devices/sos.rsi/meta.json b/Resources/Textures/_Impstation/Objects/Devices/sos.rsi/meta.json new file mode 100644 index 00000000000..ea3d9f1b97d --- /dev/null +++ b/Resources/Textures/_Impstation/Objects/Devices/sos.rsi/meta.json @@ -0,0 +1,14 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "impstation at https://github.com/impstation/imp-station-14/pull/1450", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "icon" + } + ] +}