Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emp Flashlight #5

Merged
merged 3 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Content.Server/_White/EmpFlashlight/EmpHitSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Content.Server.Power;
using Content.Shared.Emp;
using Robust.Shared.GameObjects;
using Content.Shared.Weapons.Melee.Events;
using Content.Server._White.EmpFlashlight;
using Content.Server.Emp;
using Robust.Shared.IoC;
using Content.Shared.Charges.Systems;
using Content.Shared.Charges.Components;
HellCatten marked this conversation as resolved.
Show resolved Hide resolved

namespace Content.Server._White.EmpFlashlight;

public sealed class EmpHitSystem : EntitySystem
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
[Dependency] private readonly EmpSystem _emp = default!;
[Dependency] private readonly SharedChargesSystem _charges = default!;
public override void Initialize()
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
{
base.Initialize();
SubscribeLocalEvent<EmpOnHitComponent, MeleeHitEvent>(HandleEmpHit);
}

public bool TryEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args)
{
LimitedChargesComponent? charges;
if (!TryComp<LimitedChargesComponent>(uid, out charges))
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
return false;

if (_charges.IsEmpty(uid, charges))
return false;

if (charges != null && args.HitEntities.Count > 0)
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
{
_charges.UseCharge(uid,charges);
return true;
}

return false;
}

private void HandleEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args)
{
if (!TryEmpHit(uid, comp, args))
return;

foreach (var affected in args.HitEntities)
{
_emp.EmpPulse(Transform(affected).MapPosition, comp.Range, comp.EnergyConsumption, comp.DisableDuration);
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
}

args.Handled = true;
}
}

24 changes: 24 additions & 0 deletions Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
using Content.Server._White.EmpFlashlight;
using Content.Server.Emp;

namespace Content.Server._White.EmpFlashlight;

/// <summary>
/// Upon being triggered will EMP target.
/// </summary>
[RegisterComponent]
[Access(typeof(EmpHitSystem))]

public sealed partial class EmpOnHitComponent: Component
{
[DataField("range"), ViewVariables(VVAccess.ReadWrite)]
public float Range = 1.0f;

[DataField("energyConsumption"), ViewVariables(VVAccess.ReadWrite)]
public float EnergyConsumption;

[DataField("disableDuration"), ViewVariables(VVAccess.ReadWrite)]
public float DisableDuration = 60f;
}
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uplink-emp-flashlight-name = Emp Flashlight
uplink-emp-flashlight-desc = A rechargeable device disguised as a flashlight designed to disrupt electronic systems. Useful for disrupting communications, security's energy weapons, and APCs when you're in a tight spot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-FlashlightEmp = Фонарик
.desc = Он озаряет путь к свободе.
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uplink-emp-flashlight-name = Электромагнитный фонарик
uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства.
9 changes: 9 additions & 0 deletions Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- type: listing
id: UplinkEmpFlashlight
name: uplink-emp-flashlight-name
description: uplink-emp-flashlight-desc
productEntity: FlashlightEmp
cost:
Telecrystal: 3
categories:
- UplinkUtility
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
- type: entity
parent: FlashlightLantern
id: FlashlightEmp
name: flashlight
description: It lights the way to freedom.
suffix: EMP
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-clot-component-spot-name-default
startingItem: PowerCellHigh
- type: MeleeWeapon
wideAnimationRotation: -135
damage:
types:
Blunt: 0
HellCatten marked this conversation as resolved.
Show resolved Hide resolved
angle: 60
animation: WeaponArcThrust
- type: EmpOnHit
range: 0.1
energyConsumption: 100000
disableDuration: 100
- type: LimitedCharges
- type: AutoRecharge
rechargeDuration: 30
Loading