From c99e94a24530b4bf20db660f569f1c1fb0554fba Mon Sep 17 00:00:00 2001 From: aada Date: Fri, 20 Sep 2024 00:16:27 -0500 Subject: [PATCH 1/3] commit squish yml --- .../Prototypes/Catalog/Fills/Items/misc.yml | 1 - .../Entities/Clothing/Eyes/glasses.yml | 49 ++++++++++++++----- .../Prototypes/Entities/Clothing/Eyes/hud.yml | 16 +++--- .../Entities/Clothing/Eyes/specific.yml | 2 +- .../Entities/Clothing/base_clothing.yml | 14 ++++++ .../Prototypes/Entities/Clothing/lens.yml | 36 ++++++++++++++ Resources/Prototypes/Traits/disabilities.yml | 2 +- Resources/Prototypes/tags.yml | 3 ++ 8 files changed, 99 insertions(+), 24 deletions(-) create mode 100644 Resources/Prototypes/Entities/Clothing/lens.yml diff --git a/Resources/Prototypes/Catalog/Fills/Items/misc.yml b/Resources/Prototypes/Catalog/Fills/Items/misc.yml index 1585fd692c38a9..dc79e6e43f2c24 100644 --- a/Resources/Prototypes/Catalog/Fills/Items/misc.yml +++ b/Resources/Prototypes/Catalog/Fills/Items/misc.yml @@ -66,4 +66,3 @@ containers: item: - ThrowingKnife - diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml index 467bbf873f23d2..9965cb17205060 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml @@ -53,7 +53,7 @@ Blunt: 10 - type: entity - parent: [ClothingEyesBase, BaseEngineeringContraband] + parent: [ClothingEyesBase, BaseLensSlot, BaseEngineeringContraband] id: ClothingEyesGlassesMeson name: engineering goggles #less confusion description: Green-tinted goggles using a proprietary polymer that provides protection from eye damage of all types. @@ -67,23 +67,46 @@ coverage: EYES - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlasses name: glasses - description: A pair of spectacular spectacles with prescription lenses. + description: A pair of spectacular spectacles with removable prescription lenses. components: - type: Sprite sprite: Clothing/Eyes/Glasses/glasses.rsi - type: Clothing sprite: Clothing/Eyes/Glasses/glasses.rsi - - type: VisionCorrection + - type: ItemSlots + slots: + lens_slot: + startingItem: PrescriptionLens + whitelist: + tags: + - Lens - type: Tag tags: - HamsterWearable - WhitelistChameleon +# Given to near-sighted trait - type: entity - parent: ClothingEyesBase + parent: ClothingEyesGlasses + id: ClothingEyesGlassesStrong + suffix: Strong + components: + - type: ItemSlots + slots: + lens_slot: + startingItem: PrescriptionLensStrong + whitelist: + tags: + - Lens + - type: Tag + tags: + - HamsterWearable + +- type: entity + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlassesJensen name: jensen glasses description: A pair of yellow tinted folding glasses. You never asked for these. @@ -107,13 +130,14 @@ - type: Clothing sprite: Clothing/Eyes/Glasses/jamjar.rsi - type: VisionCorrection + correctionPower: 4 # Jam Jars fix your eyes better - type: Tag tags: - HamsterWearable - WhitelistChameleon - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlassesOutlawGlasses name: outlaw glasses description: A must for every self-respecting undercover agent. @@ -122,7 +146,6 @@ sprite: Clothing/Eyes/Glasses/outlawglasses.rsi - type: Clothing sprite: Clothing/Eyes/Glasses/outlawglasses.rsi - - type: VisionCorrection - type: IdentityBlocker - type: entity @@ -158,7 +181,7 @@ - WhitelistChameleon - type: entity - parent: [ClothingEyesBase, ShowSecurityIcons, BaseRestrictedContraband] + parent: [ClothingEyesBase, BaseLensSlot, ShowSecurityIcons, BaseRestrictedContraband] id: ClothingEyesGlassesSecurity name: security glasses description: Upgraded sunglasses that provide flash immunity and a security HUD. @@ -185,10 +208,10 @@ coverage: EYES - type: entity - parent: [ClothingEyesBase, BaseCommandContraband] + parent: [ClothingEyesBase, BaseLensSlot, BaseCommandContraband] id: ClothingEyesGlassesCommand name: administration glasses - description: Upgraded sunglasses that provide flash immunity and show ID card status. + description: Upgraded sunglasses that provide flash immunity and show ID card status. components: - type: Sprite sprite: Clothing/Eyes/Glasses/commandglasses.rsi @@ -206,7 +229,7 @@ - type: ShowJobIcons - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlassesMercenary name: mercenary glasses description: Glasses made for combat, to protect the eyes from bright blinding flashes. @@ -223,7 +246,7 @@ #Make a scanner category when these actually function and we get the trayson - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlassesThermal name: optical thermal scanner description: Thermals in the shape of glasses. @@ -241,7 +264,7 @@ coverage: EYES - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesGlassesChemical name: chemical analysis goggles description: Goggles that can scan the chemical composition of a solution. diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml index 7b9021feea9f49..06660e2ea80d4e 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/hud.yml @@ -20,7 +20,7 @@ - Biological - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesHudDiagnostic name: diagnostic hud description: A heads-up display capable of analyzing the integrity and status of robotics and exosuits. Made out of see-borg-ium. @@ -35,7 +35,7 @@ - Silicon - type: entity - parent: [ClothingEyesBase, ShowMedicalIcons] + parent: [ClothingEyesBase, BaseLensSlot, ShowMedicalIcons] id: ClothingEyesHudMedical name: medical hud description: A heads-up display that scans the humanoids in view and provides accurate data about their health status. @@ -49,7 +49,7 @@ - HudMedical - type: entity - parent: [ClothingEyesBase, ShowSecurityIcons, BaseRestrictedContraband] + parent: [ClothingEyesBase, BaseLensSlot, ShowSecurityIcons, BaseRestrictedContraband] id: ClothingEyesHudSecurity name: security hud description: A heads-up display that scans the humanoids in view and provides accurate data about their ID status and security records. @@ -63,7 +63,7 @@ - HudSecurity - type: entity - parent: [ClothingEyesBase, BaseCommandContraband] + parent: [ClothingEyesBase, BaseLensSlot, BaseCommandContraband] id: ClothingEyesHudCommand name: administration hud description: A heads-up display that scans the humanoids in view and provides accurate data about their ID status. @@ -75,7 +75,7 @@ - type: ShowJobIcons - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesHudBeer name: beer goggles description: A pair of sunHud outfitted with apparatus to scan reagents, as well as providing an innate understanding of liquid viscosity while in motion. @@ -152,7 +152,7 @@ - type: ShowThirstIcons - type: entity - parent: [ClothingEyesBase, ShowSecurityIcons, ShowMedicalIcons, BaseSecurityCommandContraband] + parent: [ClothingEyesBase, BaseLensSlot, ShowSecurityIcons, ShowMedicalIcons, BaseSecurityCommandContraband] id: ClothingEyesHudMedSec name: medsec hud description: An eye display that looks like a mixture of medical and security huds. @@ -166,7 +166,7 @@ node: medsecHud - type: entity - parent: [ClothingEyesBase, ShowSecurityIcons, ShowMedicalIcons] + parent: [ClothingEyesBase, BaseLensSlot, ShowSecurityIcons, ShowMedicalIcons] id: ClothingEyesHudMultiversal name: multiversal hud description: Filler @@ -182,7 +182,7 @@ - type: ShowSyndicateIcons - type: entity - parent: [ClothingEyesBase, ShowSecurityIcons, ShowMedicalIcons] + parent: [ClothingEyesBase, BaseLensSlot, ShowSecurityIcons, ShowMedicalIcons] id: ClothingEyesHudOmni name: omni hud description: Filler diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/specific.yml b/Resources/Prototypes/Entities/Clothing/Eyes/specific.yml index fa87ed398ed6fb..be941239e71183 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/specific.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/specific.yml @@ -1,5 +1,5 @@ - type: entity - parent: ClothingEyesBase + parent: [ClothingEyesBase, BaseLensSlot] id: ClothingEyesChameleon # no flash immunity, sorry name: sun glasses description: Useful both for security and cargonia. diff --git a/Resources/Prototypes/Entities/Clothing/base_clothing.yml b/Resources/Prototypes/Entities/Clothing/base_clothing.yml index da9a7f8b1a904c..7d0d6adbc0ac92 100644 --- a/Resources/Prototypes/Entities/Clothing/base_clothing.yml +++ b/Resources/Prototypes/Entities/Clothing/base_clothing.yml @@ -69,3 +69,17 @@ - type: ItemToggle onUse: false # can't really wear it like that - type: ToggleClothing + +# for clothing that updates functionality from items inside it +- type: entity + abstract: true + id: BaseLensSlot + components: + - type: LensSlot + LensSlotId: lens_slot + - type: ItemSlots + slots: + lens_slot: + whitelist: + tags: + - Lens diff --git a/Resources/Prototypes/Entities/Clothing/lens.yml b/Resources/Prototypes/Entities/Clothing/lens.yml new file mode 100644 index 00000000000000..9ef7c7051eb52e --- /dev/null +++ b/Resources/Prototypes/Entities/Clothing/lens.yml @@ -0,0 +1,36 @@ +- type: entity + parent: ClothingEyesBase + id: PrescriptionLens + name: perscription lens + description: Adaptive lenses that fit inside frames or your face. + components: + - type: Sprite + layers: + - sprite: Clothing/Eyes/Misc/lenses.rsi + state: large + - type: VisionCorrection + correctionPower: 2 + - type: Tag + tags: + - Lens + +- type: entity + parent: PrescriptionLens + id: PrescriptionLensStrong + name: strong perscription lens + components: + - type: Sprite + layers: + - sprite: Clothing/Eyes/Misc/lenses.rsi + state: small + - type: VisionCorrection + correctionPower: 4 + +# admeme right now +- type: entity + parent: PrescriptionLens + id: AntiPrescriptionLens + suffix: Inverse + components: + - type: VisionCorrection + visionBonus: 2 diff --git a/Resources/Prototypes/Traits/disabilities.yml b/Resources/Prototypes/Traits/disabilities.yml index c562c2fec0e36a..3fccf809691508 100644 --- a/Resources/Prototypes/Traits/disabilities.yml +++ b/Resources/Prototypes/Traits/disabilities.yml @@ -14,7 +14,7 @@ id: PoorVision name: trait-poor-vision-name description: trait-poor-vision-desc - traitGear: ClothingEyesGlasses + traitGear: ClothingEyesGlassesStrong category: Disabilities whitelist: components: diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml index c9599ae9f63887..1375c5e30d41e2 100644 --- a/Resources/Prototypes/tags.yml +++ b/Resources/Prototypes/tags.yml @@ -896,6 +896,9 @@ - type: Tag id: LightBulb +- type: Tag + id: Lens + - type: Tag id: Lime From dc4ec6f1a41b8505a8c672171bde7b8bc96ee566 Mon Sep 17 00:00:00 2001 From: aada Date: Fri, 20 Sep 2024 00:17:36 -0500 Subject: [PATCH 2/3] commit squish cs + ftl --- .../Blinding/Systems/BlurryVisionSystem.cs | 39 +++++++++++- Content.Shared/Lens/LensSlotComponent.cs | 27 +++++++++ Content.Shared/Lens/LensSlotSystem.cs | 59 +++++++++++++++++++ Resources/Locale/en-US/lens/lens.ftl | 2 + 4 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Content.Shared/Lens/LensSlotComponent.cs create mode 100644 Content.Shared/Lens/LensSlotSystem.cs create mode 100644 Resources/Locale/en-US/lens/lens.ftl diff --git a/Content.Shared/Eye/Blinding/Systems/BlurryVisionSystem.cs b/Content.Shared/Eye/Blinding/Systems/BlurryVisionSystem.cs index 099753d51e0628..f802462f3fbfb8 100644 --- a/Content.Shared/Eye/Blinding/Systems/BlurryVisionSystem.cs +++ b/Content.Shared/Eye/Blinding/Systems/BlurryVisionSystem.cs @@ -1,11 +1,16 @@ +using Content.Shared.Containers.ItemSlots; using Content.Shared.Eye.Blinding.Components; -using Content.Shared.Inventory.Events; using Content.Shared.Inventory; +using Content.Shared.Inventory.Events; +using Content.Shared.Lens; namespace Content.Shared.Eye.Blinding.Systems; public sealed class BlurryVisionSystem : EntitySystem { + + [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; + public override void Initialize() { base.Initialize(); @@ -13,6 +18,11 @@ public override void Initialize() SubscribeLocalEvent(OnGlassesEquipped); SubscribeLocalEvent(OnGlassesUnequipped); SubscribeLocalEvent>(OnGetBlur); + + SubscribeLocalEvent(OnLensEquipped); + SubscribeLocalEvent(OnLensUnequipped); + SubscribeLocalEvent(OnLensChanged); + SubscribeLocalEvent>(OnGetBlurLens); } private void OnGetBlur(Entity glasses, ref InventoryRelayedEvent args) @@ -21,6 +31,18 @@ private void OnGetBlur(Entity glasses, ref InventoryR args.Args.CorrectionPower *= glasses.Comp.CorrectionPower; } + private void OnGetBlurLens(Entity glasses, ref InventoryRelayedEvent args) + { + if (!_itemSlots.TryGetSlot(glasses.Owner, glasses.Comp.LensSlotId, out var itemSlot)) + return; + + if (!TryComp(itemSlot.Item, out var component)) + return; + + args.Args.Blur += component.VisionBonus; + args.Args.CorrectionPower *= component.CorrectionPower; + } + public void UpdateBlurMagnitude(Entity ent) { if (!Resolve(ent.Owner, ref ent.Comp, false)) @@ -51,6 +73,21 @@ private void OnGlassesUnequipped(Entity glasses, ref { UpdateBlurMagnitude(args.Equipee); } + + private void OnLensEquipped(Entity glasses, ref GotEquippedEvent args) + { + UpdateBlurMagnitude(args.Equipee); + } + + private void OnLensUnequipped(Entity glasses, ref GotUnequippedEvent args) + { + UpdateBlurMagnitude(args.Equipee); + } + + private void OnLensChanged(Entity glasses, ref LensChangedEvent args) + { + UpdateBlurMagnitude(Transform(glasses.Owner).ParentUid); + } } public sealed class GetBlurEvent : EntityEventArgs, IInventoryRelayEvent diff --git a/Content.Shared/Lens/LensSlotComponent.cs b/Content.Shared/Lens/LensSlotComponent.cs new file mode 100644 index 00000000000000..35ab0011c48368 --- /dev/null +++ b/Content.Shared/Lens/LensSlotComponent.cs @@ -0,0 +1,27 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Lens; + +/// +/// This component is used alongside to find a specific container. +/// Enables clothing to change functionality based on items inside of it. +/// +[RegisterComponent] +public sealed partial class LensSlotComponent : Component +{ + [DataField("LensSlotId", required: true)] + public string LensSlotId = string.Empty; +} + +/// +/// Raised directed at an entity with a lens slot when the lens is ejected/inserted. +/// +public sealed class LensChangedEvent : EntityEventArgs +{ + public readonly bool Ejected; + + public LensChangedEvent(bool ejected) + { + Ejected = ejected; + } +} diff --git a/Content.Shared/Lens/LensSlotSystem.cs b/Content.Shared/Lens/LensSlotSystem.cs new file mode 100644 index 00000000000000..513b6a9f01ca50 --- /dev/null +++ b/Content.Shared/Lens/LensSlotSystem.cs @@ -0,0 +1,59 @@ +using Content.Shared.Containers.ItemSlots; +using Content.Shared.Examine; +using Robust.Shared.Containers; +using Robust.Shared.GameObjects; +using Robust.Shared.Utility; + +namespace Content.Shared.Lens; + +public sealed class LensSlotSystem : EntitySystem +{ + [Dependency] private readonly ItemSlotsSystem _itemSlots = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnExamine); + + SubscribeLocalEvent(OnLensInserted); + SubscribeLocalEvent(OnLensRemoved); + } + + private void OnExamine(EntityUid glasses, LensSlotComponent component, ref ExaminedEvent args) + { + if (!_itemSlots.TryGetSlot(glasses, component.LensSlotId, out var itemSlot)) + return; + + var msg = new FormattedMessage(); + + if (itemSlot.Item == null) + msg.AddMarkupOrThrow(Loc.GetString("lens-empty")); + else + { + var metadata = MetaData(itemSlot.Item.Value); + msg.AddMarkupOrThrow(Loc.GetString("lens-filled") + " [color=white]" + metadata.EntityName + "[/color]."); + } + + args.PushMessage(msg); + } + + private void OnLensInserted(EntityUid glasses, LensSlotComponent component, EntInsertedIntoContainerMessage args) + { + if (!component.Initialized) + return; + + if (args.Container.ID != component.LensSlotId) + return; + + RaiseLocalEvent(glasses, new LensChangedEvent(false)); + } + + private void OnLensRemoved(EntityUid glasses, LensSlotComponent component, EntRemovedFromContainerMessage args) + { + if (args.Container.ID != component.LensSlotId) + return; + + RaiseLocalEvent(glasses, new LensChangedEvent(true)); + } +} diff --git a/Resources/Locale/en-US/lens/lens.ftl b/Resources/Locale/en-US/lens/lens.ftl new file mode 100644 index 00000000000000..1d343666fdead5 --- /dev/null +++ b/Resources/Locale/en-US/lens/lens.ftl @@ -0,0 +1,2 @@ +lens-empty = Contains no special lens. +lens-filled = Contains a From 1fa842cbb1302128e85f372eca11801ccc123ece Mon Sep 17 00:00:00 2001 From: aada Date: Fri, 20 Sep 2024 00:18:10 -0500 Subject: [PATCH 3/3] commit squish rsi --- .../Clothing/Eyes/Misc/lenses.rsi/large.png | Bin 0 -> 166 bytes .../Clothing/Eyes/Misc/lenses.rsi/meta.json | 17 +++++++++++++++++ .../Clothing/Eyes/Misc/lenses.rsi/small.png | Bin 0 -> 159 bytes 3 files changed, 17 insertions(+) create mode 100644 Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/large.png create mode 100644 Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/meta.json create mode 100644 Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/small.png diff --git a/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/large.png b/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/large.png new file mode 100644 index 0000000000000000000000000000000000000000..46e34c280aa02a42a8d84045cb1d48403cdd4700 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyLIFM@u0XnA^3>L~8>b#RK4H&+ z?yb98b6I17qHHBWe!&d?L7=Mg!9Spgt*47)h(+())1F)m3Ovq%mmmHM-_~^D(S@x} z_s#6rPL*$LC`otr^w2rP@z5(F{A0o5$1COJxP%YwmYnvyB>g+X&i|hJH-QE*c)I$z JtaD0e0sz?bK7#-N literal 0 HcmV?d00001 diff --git a/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/meta.json b/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/meta.json new file mode 100644 index 00000000000000..6fb9a3f247a1c6 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/meta.json @@ -0,0 +1,17 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "by iaada (GitHub)", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "small" + }, + { + "name": "large" + } + ] + } diff --git a/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/small.png b/Resources/Textures/Clothing/Eyes/Misc/lenses.rsi/small.png new file mode 100644 index 0000000000000000000000000000000000000000..2c9a2f386f874df9f80026a8531eb5185d61e102 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyLIFM@u0XnA;?&la8>j9+K4Is9 z?oGQ=^z>VRqHHBWe!&d?|2zKwzjdea6QGEhr;B5VMQ?I~1go>4fsvunqp9hPOlme< zGaa}jCW