From 5c5d1092bd60e906844708029f3dd56a22d7532d Mon Sep 17 00:00:00 2001 From: Spatison <137375981+Spatison@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:48:03 +1000 Subject: [PATCH] =?UTF-8?q?[Tweak]=20Holoprojector=20/=20=D0=93=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D1=80=20(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tweak * local * tweak * tweak --- .../Holosign/HolosignProjectorComponent.cs | 15 ++-- Content.Server/Holosign/HolosignSystem.cs | 76 ++++++++++++------- .../_White/Holosign/HolosignComponent.cs | 8 ++ .../_White/Holosign/HolosignSystem.cs | 21 +++++ .../_white/holoprojector/holoprojector.ftl | 3 + .../_white/holoprojector/holoprojector.ftl | 3 + Resources/Migrations/migration.yml | 9 ++- .../Objects/Devices/holoprojectors.yml | 69 +---------------- .../Specific/Robotics/borg_modules.yml | 2 +- .../Structures/Holographic/projections.yml | 18 ++--- .../Objects/Devices/holoprojectors.yml | 6 -- .../Prototypes/Recipes/Lathes/janitorial.yml | 2 +- .../Prototypes/Recipes/Lathes/security.yml | 2 +- Resources/Prototypes/Recipes/Lathes/tools.yml | 4 +- 14 files changed, 117 insertions(+), 121 deletions(-) create mode 100644 Content.Server/_White/Holosign/HolosignComponent.cs create mode 100644 Content.Server/_White/Holosign/HolosignSystem.cs create mode 100644 Resources/Locale/en-US/_white/holoprojector/holoprojector.ftl create mode 100644 Resources/Locale/ru-RU/_white/holoprojector/holoprojector.ftl diff --git a/Content.Server/Holosign/HolosignProjectorComponent.cs b/Content.Server/Holosign/HolosignProjectorComponent.cs index b1d2456221..0c324b5568 100644 --- a/Content.Server/Holosign/HolosignProjectorComponent.cs +++ b/Content.Server/Holosign/HolosignProjectorComponent.cs @@ -10,10 +10,15 @@ public sealed partial class HolosignProjectorComponent : Component [DataField("signProto", customTypeSerializer:typeof(PrototypeIdSerializer))] public string SignProto = "HolosignWetFloor"; - /// - /// How much charge a single use expends. - /// - [ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")] - public float ChargeUse = 50f; + // WD EDIT START + [DataField] + public int MaxUses = 6; + + [DataField] + public int Uses = 6; + + [ViewVariables(VVAccess.ReadOnly)] + public List Signs = new(); + // WD EDIT END } } diff --git a/Content.Server/Holosign/HolosignSystem.cs b/Content.Server/Holosign/HolosignSystem.cs index 58a0bf0d5f..cc559504bb 100644 --- a/Content.Server/Holosign/HolosignSystem.cs +++ b/Content.Server/Holosign/HolosignSystem.cs @@ -1,53 +1,68 @@ +using System.Linq; +using Content.Server._White.Holosign; +using Content.Server.Popups; using Content.Shared.Examine; using Content.Shared.Coordinates.Helpers; -using Content.Server.Power.Components; -using Content.Server.PowerCell; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; +using Content.Shared.Popups; using Content.Shared.Storage; namespace Content.Server.Holosign; public sealed class HolosignSystem : EntitySystem { - [Dependency] private readonly PowerCellSystem _powerCell = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - + [Dependency] private readonly PopupSystem _popup = default!; // WD EDIT public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnBeforeInteract); SubscribeLocalEvent(OnExamine); + SubscribeLocalEvent(OnUse); // WD EDIT } private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args) { - // TODO: This should probably be using an itemstatus - // TODO: I'm too lazy to do this rn but it's literally copy-paste from emag. - _powerCell.TryGetBatteryFromSlot(uid, out var battery); - var charges = UsesRemaining(component, battery); - var maxCharges = MaxUses(component, battery); + // WD EDIT START + var charges = component.Uses; + var maxCharges = component.MaxUses; + var activeholo = component.Signs.Count; + // WD EDIT END using (args.PushGroup(nameof(HolosignProjectorComponent))) { args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges))); + args.PushMarkup(Loc.GetString("holoprojector-active-holo", ("activeholo", activeholo))); // WD EDIT if (charges > 0 && charges == maxCharges) - { args.PushMarkup(Loc.GetString("limited-charges-max-charges")); - } } } private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args) { - if (args.Handled || !args.CanReach // prevent placing out of range - || HasComp(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored - || !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work - ) + || HasComp(args.Target)) // if it's a storage component like a bag, we ignore usage so it can be stored + return; + + // WD EDIT START + if (component.Signs.Contains(args.Target)) + { + ++component.Uses; + component.Signs.Remove(args.Target); + QueueDel(args.Target); + return; + } + + if (component.Uses == 0) + { + _popup.PopupEntity(Loc.GetString("holoprojector-uses-limit"), args.User, args.User, PopupType.Medium); return; + } + // WD EDIT END // places the holographic sign at the click location, snapped to grid. // overlapping of the same holo on one tile remains allowed to allow holofan refreshes @@ -56,22 +71,31 @@ private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent componen if (!xform.Anchored) _transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it) + // WD EDIT START + EnsureComp(holoUid, out var holosign); + --component.Uses; + component.Signs.Add(holoUid); + holosign.Projector = uid; + // WD EDIT END + args.Handled = true; } - private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null) + // WD EDIT START + private void OnUse(EntityUid uid, HolosignProjectorComponent component, UseInHandEvent args) { - if (battery == null || - component.ChargeUse == 0f) return 0; - - return (int) (battery.CurrentCharge / component.ChargeUse); - } + if (args.Handled) + return; - private int MaxUses(HolosignProjectorComponent component, BatteryComponent? battery = null) - { - if (battery == null || - component.ChargeUse == 0f) return 0; + foreach (var sign in component.Signs.ToList()) + { + component.Signs.Remove(sign); + QueueDel(sign); + } - return (int) (battery.MaxCharge / component.ChargeUse); + args.Handled = true; + component.Uses = component.MaxUses; + _popup.PopupEntity(Loc.GetString("holoprojector-delete-signs"), args.User, args.User, PopupType.Medium); } + // WD EDIT START } diff --git a/Content.Server/_White/Holosign/HolosignComponent.cs b/Content.Server/_White/Holosign/HolosignComponent.cs new file mode 100644 index 0000000000..cce8f27539 --- /dev/null +++ b/Content.Server/_White/Holosign/HolosignComponent.cs @@ -0,0 +1,8 @@ +namespace Content.Server._White.Holosign; + +[RegisterComponent] +public sealed partial class HolosignComponent : Component +{ + [ViewVariables(VVAccess.ReadOnly)] + public EntityUid? Projector; +} diff --git a/Content.Server/_White/Holosign/HolosignSystem.cs b/Content.Server/_White/Holosign/HolosignSystem.cs new file mode 100644 index 0000000000..f765453ea6 --- /dev/null +++ b/Content.Server/_White/Holosign/HolosignSystem.cs @@ -0,0 +1,21 @@ +using Content.Server.Holosign; +using Content.Shared.Destructible; + +namespace Content.Server._White.Holosign; + +public sealed class HolosignSystem : EntitySystem +{ + public override void Initialize() + { + SubscribeLocalEvent(OnDestruction); + } + + private void OnDestruction(EntityUid uid, HolosignComponent component, DestructionEventArgs args) + { + if (!TryComp(component.Projector, out var holosignProjector)) + return; + + holosignProjector.Signs.Remove(uid); + ++holosignProjector.Uses; + } +} diff --git a/Resources/Locale/en-US/_white/holoprojector/holoprojector.ftl b/Resources/Locale/en-US/_white/holoprojector/holoprojector.ftl new file mode 100644 index 0000000000..b7d2384057 --- /dev/null +++ b/Resources/Locale/en-US/_white/holoprojector/holoprojector.ftl @@ -0,0 +1,3 @@ +holoprojector-active-holo = Active projections: [color=fuchsia]{ $activeholo }[/color] +holoprojector-uses-limit = The maximum number of projections was used! +holoprojector-delete-signs = All projections have been deleted! \ No newline at end of file diff --git a/Resources/Locale/ru-RU/_white/holoprojector/holoprojector.ftl b/Resources/Locale/ru-RU/_white/holoprojector/holoprojector.ftl new file mode 100644 index 0000000000..d6a8cde40f --- /dev/null +++ b/Resources/Locale/ru-RU/_white/holoprojector/holoprojector.ftl @@ -0,0 +1,3 @@ +holoprojector-active-holo = Активные проекции: [color=fuchsia]{ $activeholo }[/color] +holoprojector-uses-limit = Было использовано максимальное количество проекций! +holoprojector-delete-signs = Все проекции были удалены! \ No newline at end of file diff --git a/Resources/Migrations/migration.yml b/Resources/Migrations/migration.yml index 6205291754..2321aeabc1 100644 --- a/Resources/Migrations/migration.yml +++ b/Resources/Migrations/migration.yml @@ -246,4 +246,11 @@ ReinforcementRadioSyndicateMonkeyNukeops: ReinforcementRadioSyndicateAncestorNuk DrinkBottleGoldschlager: DrinkBottleGildlager # 2024-11-10 WD EDIT -VendingMachinePride: RandomVending \ No newline at end of file +VendingMachinePride: RandomVending + +# 2024-30-10 WD EDIT +HoloprojectorEmpty: Holoprojector +HoloprojectorBorg: Holoprojector +HolofanProjectorEmpty: HolofanProjector +HoloprojectorFieldEmpty: HoloprojectorField +HoloprojectorSecurityEmpty: HoloprojectorSecurity \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml index b7ad8ddd6a..134201a937 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml @@ -8,16 +8,7 @@ storedRotation: -90 - type: HolosignProjector - type: UseDelay - - type: ContainerContainer - containers: - cell_slot: !type:ContainerSlot {} - - type: PowerCellSlot - cellSlotId: cell_slot - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - startingItem: PowerCellMedium + delay: 0.5 # WD EDIT - type: Sprite sprite: Objects/Devices/Holoprojectors/custodial.rsi state: icon @@ -25,31 +16,6 @@ tags: - HolosignProjector -- type: entity - parent: Holoprojector - id: HoloprojectorEmpty - suffix: Empty - components: - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - -- type: entity - parent: Holoprojector - id: HoloprojectorBorg - suffix: borg - components: - - type: HolosignProjector - chargeUse: 240 - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - startingItem: PowerCellMicroreactor - disableEject: true - swap: false - - type: entity parent: Holoprojector id: HolofanProjector @@ -58,7 +24,6 @@ components: - type: HolosignProjector signProto: HoloFan - chargeUse: 120 - type: Sprite sprite: Objects/Devices/Holoprojectors/atmos.rsi state: icon @@ -72,16 +37,6 @@ recipes: - HolofanProjector -- type: entity - parent: HolofanProjector - id: HolofanProjectorEmpty - suffix: Empty - components: - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - - type: entity parent: Holoprojector id: HoloprojectorField @@ -90,7 +45,6 @@ components: - type: HolosignProjector signProto: HolosignForcefield - chargeUse: 120 - type: Sprite sprite: Objects/Devices/Holoprojectors/field.rsi state: icon @@ -104,16 +58,6 @@ recipes: - HoloprojectorField -- type: entity - parent: HoloprojectorField - id: HoloprojectorFieldEmpty - suffix: Empty - components: - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - - type: entity parent: Holoprojector id: HoloprojectorSecurity @@ -122,7 +66,6 @@ components: - type: HolosignProjector signProto: HolosignSecurity - chargeUse: 120 - type: Sprite sprite: Objects/Devices/Holoprojectors/security.rsi state: icon @@ -131,13 +74,3 @@ - HolofanProjector - type: StaticPrice price: 50 - -- type: entity - parent: HoloprojectorSecurity - id: HoloprojectorSecurityEmpty - suffix: Empty - components: - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default diff --git a/Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml b/Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml index 960e37a6cc..e14901f642 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml @@ -343,7 +343,7 @@ - type: ItemBorgModule items: - AdvMopItem - - HoloprojectorBorg + - Holoprojector # WD EDIT - SprayBottleSpaceCleaner - Dropper - TrashBag diff --git a/Resources/Prototypes/Entities/Structures/Holographic/projections.yml b/Resources/Prototypes/Entities/Structures/Holographic/projections.yml index f9bf81695e..005d528e3f 100644 --- a/Resources/Prototypes/Entities/Structures/Holographic/projections.yml +++ b/Resources/Prototypes/Entities/Structures/Holographic/projections.yml @@ -13,8 +13,6 @@ - type: Sprite sprite: Structures/Holo/wetfloor.rsi state: icon - - type: TimedDespawn - lifetime: 90 - type: Damageable damageContainer: Inorganic - type: Destructible @@ -25,6 +23,14 @@ behaviors: - !type:DoActsBehavior acts: [ "Destruction" ] + # WD EDIT START + - type: Clickable + - type: MeleeSound + soundGroups: + Brute: + path: + "/Audio/Weapons/egloves.ogg" + # WD EDIT END - type: entity id: HoloFan @@ -41,8 +47,6 @@ shape: !type:PhysShapeAabb bounds: "-0.5,-0.5,0.5,0.5" - - type: TimedDespawn - lifetime: 180 - type: Airtight noAirWhenFullyAirBlocked: false @@ -68,14 +72,11 @@ - TableMask layer: - TableLayer - - type: TimedDespawn - lifetime: 180 - type: PointLight enabled: true radius: 3 color: red - type: Climbable - - type: Clickable - type: entity id: HolosignForcefield @@ -99,13 +100,10 @@ - FullTileMask layer: - GlassLayer - - type: TimedDespawn - lifetime: 180 - type: PointLight enabled: true radius: 3 color: blue - - type: Clickable - type: ContainmentField throwForce: 0 - type: Destructible diff --git a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Devices/holoprojectors.yml b/Resources/Prototypes/Nyanotrasen/Entities/Objects/Devices/holoprojectors.yml index a288e4eb7b..793fe6ef2a 100644 --- a/Resources/Prototypes/Nyanotrasen/Entities/Objects/Devices/holoprojectors.yml +++ b/Resources/Prototypes/Nyanotrasen/Entities/Objects/Devices/holoprojectors.yml @@ -9,9 +9,3 @@ - type: Sprite sprite: Nyanotrasen/Objects/Devices/Holoprojectors/eng.rsi state: icon - - type: ItemSlots - slots: - cell_slot: - name: power-cell-slot-component-slot-name-default - startingItem: PowerCellMedium - locked: true diff --git a/Resources/Prototypes/Recipes/Lathes/janitorial.yml b/Resources/Prototypes/Recipes/Lathes/janitorial.yml index 9ba7dfa188..3aba423e73 100644 --- a/Resources/Prototypes/Recipes/Lathes/janitorial.yml +++ b/Resources/Prototypes/Recipes/Lathes/janitorial.yml @@ -66,7 +66,7 @@ - type: latheRecipe id: Holoprojector - result: HoloprojectorEmpty + result: Holoprojector # WD EDIT completetime: 3 materials: Plastic: 250 diff --git a/Resources/Prototypes/Recipes/Lathes/security.yml b/Resources/Prototypes/Recipes/Lathes/security.yml index 04c2ad1ec1..0957df4572 100644 --- a/Resources/Prototypes/Recipes/Lathes/security.yml +++ b/Resources/Prototypes/Recipes/Lathes/security.yml @@ -114,7 +114,7 @@ - type: latheRecipe id: HoloprojectorSecurity - result: HoloprojectorSecurityEmpty + result: HoloprojectorSecurity # WD EDIT completetime: 2 materials: Steel: 300 diff --git a/Resources/Prototypes/Recipes/Lathes/tools.yml b/Resources/Prototypes/Recipes/Lathes/tools.yml index 03d8a8511e..852c062ed9 100644 --- a/Resources/Prototypes/Recipes/Lathes/tools.yml +++ b/Resources/Prototypes/Recipes/Lathes/tools.yml @@ -189,7 +189,7 @@ - type: latheRecipe id: HolofanProjector - result: HolofanProjectorEmpty + result: HolofanProjector # WD EDIT category: Tools completetime: 8 materials: @@ -238,7 +238,7 @@ - type: latheRecipe id: HoloprojectorField - result: HoloprojectorFieldEmpty + result: HoloprojectorField # WD EDIT category: Tools completetime: 3 materials: