- /// Triggers an EMP pulse at the given location, by first raising an <see cref="EmpAttemptEvent"/>, then a raising <see cref="EmpPulseEvent"/> on all entities in range.
- /// </summary>
- /// <param name="coordinates">The location to trigger the EMP pulse at.</param>
- /// <param name="range">The range of the EMP pulse.</param>
- /// <param name="energyConsumption">The amount of energy consumed by the EMP pulse.</param>
- /// <param name="duration">The duration of the EMP effects.</param>
- /// Attempts to apply the effects of an EMP pulse onto an entity by first raising an <see cref="EmpAttemptEvent"/>, followed by raising a <see cref="EmpPulseEvent"/> on it.
- /// </summary>
- /// <param name="uid">The entity to apply the EMP effects on.</param>
- /// <param name="energyConsumption">The amount of energy consumed by the EMP.</param>
- /// <param name="duration">The duration of the EMP effects.</param>
- public void TryEmpEffects(EntityUid uid, float energyConsumption, float duration)
- {
- var attemptEv = new EmpAttemptEvent();
- RaiseLocalEvent(uid, attemptEv);
- if (attemptEv.Cancelled)
- return;
-
- DoEmpEffects(uid, energyConsumption, duration);
- }
-
- /// <summary>
- /// Applies the effects of an EMP pulse onto an entity by raising a <see cref="EmpPulseEvent"/> on it.
- /// </summary>
- /// <param name="uid">The entity to apply the EMP effects on.</param>
- /// <param name="energyConsumption">The amount of energy consumed by the EMP.</param>
- /// <param name="duration">The duration of the EMP effects.</param>
- public void DoEmpEffects(EntityUid uid, float energyConsumption, float duration)
- {
- var ev = new EmpPulseEvent(energyConsumption, false, false, TimeSpan.FromSeconds(duration));
+ public static readonly EntProtoId EmpPulseEffectPrototype = "EffectEmpPulse";
+ public static readonly EntProtoId EmpDisabledEffectPrototype = "EffectEmpDisabled";
+ public static readonly SoundSpecifier EmpSound = new SoundPathSpecifier("/Audio/Effects/Lightning/lightningbolt.ogg");
+
+ /// <summary>
+ /// Triggers an EMP pulse at the given location, by first raising an <see cref="EmpAttemptEvent"/>, then by raising <see cref="EmpPulseEvent"/> on all entities in range.
+ /// </summary>
+ /// <param name="coordinates">The location to trigger the EMP pulse at.</param>
+ /// <param name="range">The range of the EMP pulse.</param>
+ /// <param name="energyConsumption">The amount of energy consumed by the EMP pulse. In Joule.</param>
+ /// <param name="duration">The duration of the EMP effects.</param>
+ /// <param name="user">The player that caused the effect. Used for predicted audio.</param>
+ public void EmpPulse(MapCoordinates mapCoordinates, float range, float energyConsumption, TimeSpan duration, EntityUid? user = null)
+ {
+ foreach (var uid in _lookup.GetEntitiesInRange(mapCoordinates, range))
/// Triggers an EMP pulse at the given location, by first raising an <see cref="EmpAttemptEvent"/>, then a raising <see cref="EmpPulseEvent"/> on all entities in range.
@@ -24,12+61,119 @@ public abstract class SharedEmpSystem : EntitySystem
/// <param name="range">The range of the EMP pulse.</param>
/// <param name="energyConsumption">The amount of energy consumed by the EMP pulse.</param>
/// <param name="duration">The duration of the EMP effects.</param>
+ /// Attempts to apply the effects of an EMP pulse onto an entity by first raising an <see cref="EmpAttemptEvent"/>, followed by raising a <see cref="EmpPulseEvent"/> on it.
+ /// </summary>
+ /// <param name="uid">The entity to apply the EMP effects on.</param>
+ /// <param name="energyConsumption">The amount of energy consumed by the EMP.</param>
+ /// <param name="duration">The duration of the EMP effects.</param>
+ /// <param name="user">The player that caused the EMP. For prediction purposes.</param>
+ /// <returns>If the entity was affected by the EMP.</returns>
+ public bool TryEmpEffects(EntityUid uid, float energyConsumption, TimeSpan duration, EntityUid? user = null)
/// Attached to APC powered entities that possess a rechargeable internal battery.
/// If external power is interrupted, the entity will draw power from this battery instead.
-/// Requires <see cref="Content.Server.Power.Components.ApcPowerReceiverComponent"/> and <see cref="Content.Server.Power.Components.BatteryComponent"/> to function.
+/// Requires <see cref="Content.Server.Power.Components.ApcPowerReceiverComponent"/> and <see cref="BatteryComponent"/> to function.