From ec1160c01de01e3050eb6a4506591db0a8fa94a9 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Sun, 13 Mar 2022 05:53:01 -0400 Subject: [PATCH] Drone Tweaks (#7024) --- .../Drone/Components/DroneComponent.cs | 10 +++++++++- Content.Server/Drone/DroneSystem.cs | 20 +++++++++++++++++-- Resources/Locale/en-US/drone/drone-system.ftl | 2 +- .../Catalog/Fills/Boxes/general.yml | 12 +++++++++++ .../Entities/Mobs/Player/silicon.yml | 19 ++++++++++++++++-- .../Entities/Objects/Materials/parts.yml | 1 + .../Entities/Objects/Power/powercells.yml | 3 +++ .../Entities/Objects/Tools/toolbox.yml | 3 +++ 8 files changed, 64 insertions(+), 6 deletions(-) diff --git a/Content.Server/Drone/Components/DroneComponent.cs b/Content.Server/Drone/Components/DroneComponent.cs index 4bf4129664..c3a4b6780c 100644 --- a/Content.Server/Drone/Components/DroneComponent.cs +++ b/Content.Server/Drone/Components/DroneComponent.cs @@ -8,6 +8,14 @@ namespace Content.Server.Drone.Components [DataField("tools")] public List Tools = new(); public List ToolUids = new(); public bool AlreadyAwoken = false; - public float InteractionBlockRange = 2.5f; + public float InteractionBlockRange = 2.15f; + + /// + /// If you are using drone component for + /// something that shouldn't have restrictions set this to + /// false. + /// + [DataField("applyLaws")] + public bool ApplyLaws = true; } } diff --git a/Content.Server/Drone/DroneSystem.cs b/Content.Server/Drone/DroneSystem.cs index e7be49fba5..516eba3819 100644 --- a/Content.Server/Drone/DroneSystem.cs +++ b/Content.Server/Drone/DroneSystem.cs @@ -1,5 +1,7 @@ using Content.Shared.Drone; using Content.Server.Drone.Components; +using Content.Shared.Actions; +using Content.Server.Light.Components; using Content.Shared.MobState; using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Components; @@ -16,6 +18,7 @@ using Content.Server.Ghost.Roles.Components; using Content.Server.Hands.Components; using Content.Server.UserInterface; using Robust.Shared.Player; +using Robust.Shared.Timing; namespace Content.Server.Drone { @@ -24,6 +27,9 @@ namespace Content.Server.Drone [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; + [Dependency] private readonly IGameTiming _gameTiming = default!; + public override void Initialize() { base.Initialize(); @@ -39,7 +45,9 @@ namespace Content.Server.Drone private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args) { - if (NonDronesInRange(uid, component)) + if (!component.ApplyLaws) + return; + if (args.Target != null && !HasComp(args.Target) && NonDronesInRange(uid, component)) args.Cancel(); if (HasComp(args.Target) && !HasComp(args.Target)) @@ -51,6 +59,8 @@ namespace Content.Server.Drone private void OnActivateUIAttempt(EntityUid uid, DroneComponent component, UserOpenActivatableUIAttemptEvent args) { + if (!component.ApplyLaws) + return; if (!_tagSystem.HasTag(args.Target, "DroneUsable")) { args.Cancel(); @@ -109,6 +119,11 @@ namespace Content.Server.Drone } } + if (TryComp(uid, out var actions) && TryComp(uid, out var flashlight)) + { + _actionsSystem.AddAction(uid, flashlight.ToggleAction, null, actions); + } + drone.AlreadyAwoken = true; } } @@ -145,7 +160,8 @@ namespace Content.Server.Drone { if (HasComp(entity) && !HasComp(entity) && !HasComp(entity)) { - _popupSystem.PopupEntity(Loc.GetString("drone-too-close"), uid, Filter.Entities(uid)); + if (_gameTiming.IsFirstTimePredicted) + _popupSystem.PopupEntity(Loc.GetString("drone-too-close", ("being", entity)), uid, Filter.Entities(uid)); return true; } } diff --git a/Resources/Locale/en-US/drone/drone-system.ftl b/Resources/Locale/en-US/drone/drone-system.ftl index 2a6cb8c165..292f981ecb 100644 --- a/Resources/Locale/en-US/drone/drone-system.ftl +++ b/Resources/Locale/en-US/drone/drone-system.ftl @@ -1,4 +1,4 @@ drone-active = A maintenance drone. It seems totally unconcerned with you. drone-dormant = A dormant maintenance drone. Who knows when it will wake up? drone-activated = The drone whirrs to life! -drone-too-close = Too close to other beings! +drone-too-close = Your laws prevent this action near {THE($being)}. diff --git a/Resources/Prototypes/Catalog/Fills/Boxes/general.yml b/Resources/Prototypes/Catalog/Fills/Boxes/general.yml index 795a97ccf6..6a39bed0b4 100644 --- a/Resources/Prototypes/Catalog/Fills/Boxes/general.yml +++ b/Resources/Prototypes/Catalog/Fills/Boxes/general.yml @@ -27,6 +27,9 @@ whitelist: components: - LightBulb + - type: Tag + tags: + - DroneUsable - type: entity name: lighttube box @@ -47,6 +50,9 @@ whitelist: components: - LightBulb + - type: Tag + tags: + - DroneUsable - type: entity name: mixed lights box @@ -180,6 +186,9 @@ layers: - state: box - state: writing + - type: Tag + tags: + - DroneUsable - type: entity @@ -229,3 +238,6 @@ layers: - state: box - state: writing + - type: Tag + tags: + - DroneUsable diff --git a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml index f8306829ce..48c7d4a6f5 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/silicon.yml @@ -87,7 +87,7 @@ - type: GhostTakeoverAvailable makeSentient: true name: Maintenance Drone - description: Maintain the station. Ignore organics. + description: Maintain the station. Ignore other beings except drones. rules: | You are bound by these laws both in-game and out-of-character: 1. You may not involve yourself in the matters of another being, even if such matters conflict with Law Two or Law Three, unless the other being is another Drone. @@ -151,6 +151,20 @@ - type: Repairable fuelcost: 15 doAfterDelay: 8 + - type: Actions + - type: UnpoweredFlashlight + toggleAction: + name: action-name-toggle-light + description: action-description-toggle-light + icon: Objects/Tools/flashlight.rsi/flashlight.png + iconOn: Objects/Tools/flashlight.rsi/flashlight-on.png + event: !type:ToggleActionEvent + - type: PointLight + enabled: false + radius: 2.5 + softness: 5 + mask: /Textures/Effects/LightMasks/cone.png + autoRot: true - type: entity name: onestar mecha @@ -158,6 +172,7 @@ parent: PlayerSiliconBase components: - type: Drone + applyLaws: false tools: - id: Minigun - id: EnergySword @@ -206,6 +221,6 @@ visuals: - type: DamageStateVisualizer rotate: true - normal: onestar_boss + normal: onestar_boss dead: onestar_boss_wrecked - type: CombatMode diff --git a/Resources/Prototypes/Entities/Objects/Materials/parts.yml b/Resources/Prototypes/Entities/Objects/Materials/parts.yml index fcdfae5aa5..3d09134558 100644 --- a/Resources/Prototypes/Entities/Objects/Materials/parts.yml +++ b/Resources/Prototypes/Entities/Objects/Materials/parts.yml @@ -52,6 +52,7 @@ - type: Tag tags: - RodMetal1 + - DroneUsable - type: Sprite state: rods - type: Stack diff --git a/Resources/Prototypes/Entities/Objects/Power/powercells.yml b/Resources/Prototypes/Entities/Objects/Power/powercells.yml index 1f24bed06b..91d8b07258 100644 --- a/Resources/Prototypes/Entities/Objects/Power/powercells.yml +++ b/Resources/Prototypes/Entities/Objects/Power/powercells.yml @@ -23,6 +23,9 @@ reagents: - ReagentId: Licoxide Quantity: 5 + - type: Tag + tags: + - DroneUsable - type: entity id: PowerCellMediumBase diff --git a/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml b/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml index 832157fdc2..28f10bac27 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/toolbox.yml @@ -19,6 +19,9 @@ Blunt: 10 hitSound: path: "/Audio/Weapons/smash.ogg" + - type: Tag + tags: + - DroneUsable - type: entity name: emergency toolbox