Drone Tweaks (#7024)

This commit is contained in:
Rane
2022-03-13 05:53:01 -04:00
committed by GitHub
parent e3ead6a3ba
commit ec1160c01d
8 changed files with 64 additions and 6 deletions

View File

@@ -8,6 +8,14 @@ namespace Content.Server.Drone.Components
[DataField("tools")] public List<EntitySpawnEntry> Tools = new(); [DataField("tools")] public List<EntitySpawnEntry> Tools = new();
public List<EntityUid> ToolUids = new(); public List<EntityUid> ToolUids = new();
public bool AlreadyAwoken = false; public bool AlreadyAwoken = false;
public float InteractionBlockRange = 2.5f; public float InteractionBlockRange = 2.15f;
/// <summary>
/// If you are using drone component for
/// something that shouldn't have restrictions set this to
/// false.
/// </summary>
[DataField("applyLaws")]
public bool ApplyLaws = true;
} }
} }

View File

@@ -1,5 +1,7 @@
using Content.Shared.Drone; using Content.Shared.Drone;
using Content.Server.Drone.Components; using Content.Server.Drone.Components;
using Content.Shared.Actions;
using Content.Server.Light.Components;
using Content.Shared.MobState; using Content.Shared.MobState;
using Content.Shared.Interaction.Events; using Content.Shared.Interaction.Events;
using Content.Shared.Interaction.Components; using Content.Shared.Interaction.Components;
@@ -16,6 +18,7 @@ using Content.Server.Ghost.Roles.Components;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
using Content.Server.UserInterface; using Content.Server.UserInterface;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Timing;
namespace Content.Server.Drone namespace Content.Server.Drone
{ {
@@ -24,6 +27,9 @@ namespace Content.Server.Drone
[Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
@@ -39,7 +45,9 @@ namespace Content.Server.Drone
private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args) private void OnInteractionAttempt(EntityUid uid, DroneComponent component, InteractionAttemptEvent args)
{ {
if (NonDronesInRange(uid, component)) if (!component.ApplyLaws)
return;
if (args.Target != null && !HasComp<UnremoveableComponent>(args.Target) && NonDronesInRange(uid, component))
args.Cancel(); args.Cancel();
if (HasComp<SharedItemComponent>(args.Target) && !HasComp<UnremoveableComponent>(args.Target)) if (HasComp<SharedItemComponent>(args.Target) && !HasComp<UnremoveableComponent>(args.Target))
@@ -51,6 +59,8 @@ namespace Content.Server.Drone
private void OnActivateUIAttempt(EntityUid uid, DroneComponent component, UserOpenActivatableUIAttemptEvent args) private void OnActivateUIAttempt(EntityUid uid, DroneComponent component, UserOpenActivatableUIAttemptEvent args)
{ {
if (!component.ApplyLaws)
return;
if (!_tagSystem.HasTag(args.Target, "DroneUsable")) if (!_tagSystem.HasTag(args.Target, "DroneUsable"))
{ {
args.Cancel(); args.Cancel();
@@ -109,6 +119,11 @@ namespace Content.Server.Drone
} }
} }
if (TryComp<ActionsComponent>(uid, out var actions) && TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
{
_actionsSystem.AddAction(uid, flashlight.ToggleAction, null, actions);
}
drone.AlreadyAwoken = true; drone.AlreadyAwoken = true;
} }
} }
@@ -145,7 +160,8 @@ namespace Content.Server.Drone
{ {
if (HasComp<MindComponent>(entity) && !HasComp<DroneComponent>(entity) && !HasComp<GhostComponent>(entity)) if (HasComp<MindComponent>(entity) && !HasComp<DroneComponent>(entity) && !HasComp<GhostComponent>(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; return true;
} }
} }

View File

@@ -1,4 +1,4 @@
drone-active = A maintenance drone. It seems totally unconcerned with you. 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-dormant = A dormant maintenance drone. Who knows when it will wake up?
drone-activated = The drone whirrs to life! 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)}.

View File

@@ -27,6 +27,9 @@
whitelist: whitelist:
components: components:
- LightBulb - LightBulb
- type: Tag
tags:
- DroneUsable
- type: entity - type: entity
name: lighttube box name: lighttube box
@@ -47,6 +50,9 @@
whitelist: whitelist:
components: components:
- LightBulb - LightBulb
- type: Tag
tags:
- DroneUsable
- type: entity - type: entity
name: mixed lights box name: mixed lights box
@@ -180,6 +186,9 @@
layers: layers:
- state: box - state: box
- state: writing - state: writing
- type: Tag
tags:
- DroneUsable
- type: entity - type: entity
@@ -229,3 +238,6 @@
layers: layers:
- state: box - state: box
- state: writing - state: writing
- type: Tag
tags:
- DroneUsable

View File

@@ -87,7 +87,7 @@
- type: GhostTakeoverAvailable - type: GhostTakeoverAvailable
makeSentient: true makeSentient: true
name: Maintenance Drone name: Maintenance Drone
description: Maintain the station. Ignore organics. description: Maintain the station. Ignore other beings except drones.
rules: | rules: |
You are bound by these laws both in-game and out-of-character: 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. 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 - type: Repairable
fuelcost: 15 fuelcost: 15
doAfterDelay: 8 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 - type: entity
name: onestar mecha name: onestar mecha
@@ -158,6 +172,7 @@
parent: PlayerSiliconBase parent: PlayerSiliconBase
components: components:
- type: Drone - type: Drone
applyLaws: false
tools: tools:
- id: Minigun - id: Minigun
- id: EnergySword - id: EnergySword
@@ -206,6 +221,6 @@
visuals: visuals:
- type: DamageStateVisualizer - type: DamageStateVisualizer
rotate: true rotate: true
normal: onestar_boss normal: onestar_boss
dead: onestar_boss_wrecked dead: onestar_boss_wrecked
- type: CombatMode - type: CombatMode

View File

@@ -52,6 +52,7 @@
- type: Tag - type: Tag
tags: tags:
- RodMetal1 - RodMetal1
- DroneUsable
- type: Sprite - type: Sprite
state: rods state: rods
- type: Stack - type: Stack

View File

@@ -23,6 +23,9 @@
reagents: reagents:
- ReagentId: Licoxide - ReagentId: Licoxide
Quantity: 5 Quantity: 5
- type: Tag
tags:
- DroneUsable
- type: entity - type: entity
id: PowerCellMediumBase id: PowerCellMediumBase

View File

@@ -19,6 +19,9 @@
Blunt: 10 Blunt: 10
hitSound: hitSound:
path: "/Audio/Weapons/smash.ogg" path: "/Audio/Weapons/smash.ogg"
- type: Tag
tags:
- DroneUsable
- type: entity - type: entity
name: emergency toolbox name: emergency toolbox