mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
Emp Flashlight (#5)
* EmpFlashlight added * Using namespace cleared * Code Review problems solved
This commit is contained in:
24
Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs
Normal file
24
Content.Server/_White/EmpFlashlight/EmpOnHitComponent.cs
Normal file
@@ -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(EmpOnHitSystem))]
|
||||
|
||||
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;
|
||||
}
|
||||
52
Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs
Normal file
52
Content.Server/_White/EmpFlashlight/EmpOnHitSystem.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Content.Server.Emp;
|
||||
using Content.Shared.Charges.Systems;
|
||||
using Content.Shared.Charges.Components;
|
||||
|
||||
namespace Content.Server._White.EmpFlashlight;
|
||||
|
||||
public sealed class EmpOnHitSystem : EntitySystem
|
||||
{
|
||||
|
||||
[Dependency] private readonly EmpSystem _emp = default!;
|
||||
[Dependency] private readonly SharedChargesSystem _charges = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<EmpOnHitComponent, MeleeHitEvent>(HandleEmpHit);
|
||||
}
|
||||
|
||||
public bool TryEmpHit(EntityUid uid, EmpOnHitComponent comp, MeleeHitEvent args)
|
||||
{
|
||||
|
||||
if (!TryComp<LimitedChargesComponent>(uid, out LimitedChargesComponent? charges))
|
||||
return false;
|
||||
|
||||
if (_charges.IsEmpty(uid, charges))
|
||||
return false;
|
||||
|
||||
if (args.HitEntities.Count > 0)
|
||||
{
|
||||
_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.GetMapCoordinates(affected), comp.Range, comp.EnergyConsumption, comp.DisableDuration);
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
2
Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Normal file
2
Resources/Locale/en-US/_white/store/uplink-catalog.ftl
Normal file
@@ -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.
|
||||
@@ -0,0 +1,2 @@
|
||||
ent-FlashlightEmp = Фонарик
|
||||
.desc = Он озаряет путь к свободе.
|
||||
2
Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Normal file
2
Resources/Locale/ru-RU/_white/store/uplink-catalog.ftl
Normal file
@@ -0,0 +1,2 @@
|
||||
uplink-emp-flashlight-name = Электромагнитный фонарик
|
||||
uplink-emp-flashlight-desc = Замаскированное под фонарик устройство. При ударе выпускает ЭМИ, поражающий электрические устройства.
|
||||
9
Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Normal file
9
Resources/Prototypes/_White/Catalog/uplink_catalog.yml
Normal file
@@ -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
|
||||
@@ -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: 12
|
||||
angle: 60
|
||||
animation: WeaponArcThrust
|
||||
- type: EmpOnHit
|
||||
range: 0.1
|
||||
energyConsumption: 100000
|
||||
disableDuration: 100
|
||||
- type: LimitedCharges
|
||||
- type: AutoRecharge
|
||||
rechargeDuration: 60
|
||||
Reference in New Issue
Block a user