diff --git a/Content.Server/_White/Stunprod/SnatcherprodSystem.cs b/Content.Server/_White/Stunprod/SnatcherprodSystem.cs index bf09a8d484..2f38b1de13 100644 --- a/Content.Server/_White/Stunprod/SnatcherprodSystem.cs +++ b/Content.Server/_White/Stunprod/SnatcherprodSystem.cs @@ -10,6 +10,7 @@ public sealed class SnatcherprodSystem : EntitySystem { [Dependency] private readonly SharedHandsSystem _hands = default!; [Dependency] private readonly SharedItemToggleSystem _itemToggle = default!; + [Dependency] private readonly SharedHandsSystem _handsSystem = default!; public override void Initialize() { @@ -18,7 +19,6 @@ public sealed class SnatcherprodSystem : EntitySystem SubscribeLocalEvent(OnHit); } - private void OnHit(EntityUid uid, SnatcherprodComponent component, StaminaMeleeHitEvent args) { if (!_itemToggle.IsActivated(uid) || args.HitList.Count == 0) @@ -29,28 +29,13 @@ public sealed class SnatcherprodSystem : EntitySystem if (entity == uid || !TryComp(entity, out HandsComponent? hands)) return; - EntityUid? heldEntity = null; - - if (hands.ActiveHandEntity != null) - heldEntity = hands.ActiveHandEntity; - else + foreach (var heldEntity in _handsSystem.EnumerateHeld(entity, hands)) { - foreach (var hand in hands.Hands) - { - if (hand.Value.HeldEntity == null) - continue; + if (!_hands.TryDrop(entity, heldEntity, null, false, false, handsComp: hands)) + continue; - heldEntity = hand.Value.HeldEntity; - break; - } - - if (heldEntity == null) - return; + _hands.PickupOrDrop(args.User, heldEntity, false); + break; } - - if (!_hands.TryDrop(entity, heldEntity.Value, null, false, false, handsComp: hands)) - return; - - _hands.PickupOrDrop(args.User, heldEntity.Value, false); } } diff --git a/Content.Server/_White/Stunprod/StunprodSystem.cs b/Content.Server/_White/Stunprod/StunprodSystem.cs index 95c0e76fe4..8e36fda39a 100644 --- a/Content.Server/_White/Stunprod/StunprodSystem.cs +++ b/Content.Server/_White/Stunprod/StunprodSystem.cs @@ -33,16 +33,20 @@ public sealed class StunprodSystem : EntitySystem SubscribeLocalEvent(OnEntInserted); SubscribeLocalEvent(TryTurnOn); SubscribeLocalEvent(ToggleDone); + SubscribeLocalEvent(OnStartup, + after: new[] {typeof(SharedItemToggleSystem)}); + } + + private void OnStartup(Entity ent, ref ComponentStartup args) + { + _appearance.SetData(ent, ToggleVisuals.Toggled, "nocell"); } private void OnEntInserted(EntityUid uid, StunprodComponent component, EntInsertedIntoContainerMessage args) { _itemToggle.TryDeactivate(uid, predicted: false); - if (TryComp(uid, out var appearance)) - { - _appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance); - } + _appearance.SetData(uid, ToggleVisuals.Toggled, false); } private void OnEntRemoved(EntityUid uid, StunprodComponent component, EntRemovedFromContainerMessage args) @@ -50,15 +54,9 @@ public sealed class StunprodSystem : EntitySystem if (TerminatingOrDeleted(uid)) return; - if (!_itemToggle.IsActivated(uid)) - { - if (TryComp(uid, out var appearance)) - { - _appearance.SetData(uid, ToggleVisuals.Toggled, "nocell", appearance); - } - } - else - _itemToggle.TryDeactivate(uid, predicted: false); + _itemToggle.TryDeactivate(uid, predicted: false); + + _appearance.SetData(uid, ToggleVisuals.Toggled, "nocell"); } private void OnStaminaHitAttempt(EntityUid uid, StunprodComponent component, @@ -72,9 +70,7 @@ public sealed class StunprodSystem : EntitySystem } if (battery.CurrentCharge < component.EnergyPerUse) - { _itemToggle.TryDeactivate(uid, predicted: false); - } } private void OnExamined(EntityUid uid, StunprodComponent comp, ExaminedEvent args) @@ -90,10 +86,8 @@ public sealed class StunprodSystem : EntitySystem if (entity.Comp.HasHeldPrefix && TryComp(entity, out var item)) _item.SetHeldPrefix(entity.Owner, args.Activated ? "on" : "off", component: item); - if (TryGetBatteryComponent(entity, out _, out _) || !TryComp(entity, out var appearance)) - return; - - _appearance.SetData(entity, ToggleVisuals.Toggled, "nocell", appearance); + if (!TryGetBatteryComponent(entity, out _, out _)) + _appearance.SetData(entity, ToggleVisuals.Toggled, "nocell"); } private void TryTurnOn(Entity entity, ref ItemToggleActivateAttemptEvent args) @@ -104,10 +98,7 @@ public sealed class StunprodSystem : EntitySystem args.Cancelled = true; - if (TryComp(entity, out var appearance)) - { - _appearance.SetData(entity, ToggleVisuals.Toggled, battery == null ? "nocell" : false, appearance); - } + _appearance.SetData(entity, ToggleVisuals.Toggled, battery == null ? "nocell" : false); if (args.User != null) { diff --git a/Content.Shared/Changeling/SharedTentacleGun.cs b/Content.Shared/Changeling/SharedTentacleGun.cs index 17be944a95..98324a59ad 100644 --- a/Content.Shared/Changeling/SharedTentacleGun.cs +++ b/Content.Shared/Changeling/SharedTentacleGun.cs @@ -143,8 +143,8 @@ public abstract class SharedTentacleGun : EntitySystem if(!TryComp(activeItem, out var physicsComponent)) continue; - var coords = Transform(args.Embedded).Coordinates; - _handsSystem.TryDrop(args.Embedded, activeItem, coords); + if (!_handsSystem.TryDrop(args.Embedded, activeItem)) + continue; var force = physicsComponent.Mass * 2.5f / 2; diff --git a/Resources/Prototypes/_White/Entities/Objects/Weapons/snatcherprod.yml b/Resources/Prototypes/_White/Entities/Objects/Weapons/snatcherprod.yml index 4d634c31eb..2b6e497ebc 100644 --- a/Resources/Prototypes/_White/Entities/Objects/Weapons/snatcherprod.yml +++ b/Resources/Prototypes/_White/Entities/Objects/Weapons/snatcherprod.yml @@ -42,6 +42,7 @@ sound: /Audio/Weapons/egloves.ogg - type: UseDelay - type: Item + heldPrefix: off size: Normal - type: Clothing quickEquip: false @@ -70,7 +71,6 @@ cell_slot: !type:ContainerSlot {} - type: Snatcherprod - type: Stunprod - hasHeldPrefix: false - type: Construction deconstructionTarget: cuffs graph: StunprodGraph diff --git a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/meta.json b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/meta.json index ae24ae8e94..4bfc73fa27 100644 --- a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/meta.json +++ b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/meta.json @@ -1,7 +1,7 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Taken from tgstation at https://github.com/tgstation/ at d0dffe7ca643db2624424fdcebf45863f85c0448", + "copyright": "Taken from tgstation at https://github.com/tgstation/ at d0dffe7ca643db2624424fdcebf45863f85c0448, on inhand sprites by Aviu", "size": { "x": 32, "y": 32 @@ -23,12 +23,56 @@ ] }, { - "name": "inhand-left", + "name": "off-inhand-left", "directions": 4 }, { - "name": "inhand-right", + "name": "off-inhand-right", "directions": 4 + }, + { + "name": "on-inhand-left", + "directions": 4, + "delays": [ + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ] + ] + }, + { + "name": "on-inhand-right", + "directions": 4, + "delays": [ + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ], + [ + 0.1, + 0.1 + ] + ] } ] } diff --git a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/inhand-left.png b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/off-inhand-left.png similarity index 100% rename from Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/inhand-left.png rename to Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/off-inhand-left.png diff --git a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/inhand-right.png b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/off-inhand-right.png similarity index 100% rename from Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/inhand-right.png rename to Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/off-inhand-right.png diff --git a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-left.png b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-left.png new file mode 100644 index 0000000000..ba9bfd4df3 Binary files /dev/null and b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-left.png differ diff --git a/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-right.png b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-right.png new file mode 100644 index 0000000000..c0586fa9cc Binary files /dev/null and b/Resources/Textures/White/Objects/Weapons/snatcherprod.rsi/on-inhand-right.png differ