Electrified grille sparks effect (#15178)
* use file namespace * shorter systems name * replace SoundSystem with AudioSystem * refactor update function * refactor * refactor 2 * remove setters * uh oh * remove getters * active checks * refactor 3 * better way * update state * have to remove this for now * move electrified component to shared * forgot this * fix airlocks * add effect * Revert "move electrified component to shared" This reverts commit 6457e8fc9c3b674a705a61034831ce6f084e2b01. * Revert "forgot this" This reverts commit ed361cee2d5b8b958830ba0af07fcc2627eb7845. * functioning effects * use animation by Aleksh * make effect part of grille * optimisation? * remove timing * file name * only activate when touched * refactor electrocution comp too * make it 1 sec * formatting * replace all entity query with enumerator * queue del
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
namespace Content.Server.Electrocution;
|
||||
|
||||
/// <summary>
|
||||
/// Updates every frame for short duration to check if electrifed entity is powered when activated, e.g to play animation
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class ActivatedElectrifiedComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// How long electrified entity will remain active
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public float TimeLeft = 1f;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Electrocution
|
||||
{
|
||||
namespace Content.Server.Electrocution;
|
||||
|
||||
/// <summary>
|
||||
/// Component for things that shock users on touch.
|
||||
/// </summary>
|
||||
@@ -9,69 +9,68 @@ namespace Content.Server.Electrocution
|
||||
public sealed class ElectrifiedComponent : Component
|
||||
{
|
||||
[DataField("enabled")]
|
||||
public bool Enabled { get; set; } = true;
|
||||
public bool Enabled = true;
|
||||
|
||||
[DataField("onBump")]
|
||||
public bool OnBump { get; set; } = true;
|
||||
public bool OnBump = true;
|
||||
|
||||
[DataField("onAttacked")]
|
||||
public bool OnAttacked { get; set; } = true;
|
||||
public bool OnAttacked = true;
|
||||
|
||||
[DataField("noWindowInTile")]
|
||||
public bool NoWindowInTile { get; set; } = false;
|
||||
public bool NoWindowInTile = false;
|
||||
|
||||
[DataField("onHandInteract")]
|
||||
public bool OnHandInteract { get; set; } = true;
|
||||
public bool OnHandInteract = true;
|
||||
|
||||
[DataField("onInteractUsing")]
|
||||
public bool OnInteractUsing { get; set; } = true;
|
||||
public bool OnInteractUsing = true;
|
||||
|
||||
[DataField("requirePower")]
|
||||
public bool RequirePower { get; } = true;
|
||||
public bool RequirePower = true;
|
||||
|
||||
[DataField("usesApcPower")]
|
||||
public bool UsesApcPower { get; } = false;
|
||||
public bool UsesApcPower = false;
|
||||
|
||||
[DataField("highVoltageNode")]
|
||||
public string? HighVoltageNode { get; }
|
||||
public string? HighVoltageNode;
|
||||
|
||||
[DataField("mediumVoltageNode")]
|
||||
public string? MediumVoltageNode { get; }
|
||||
public string? MediumVoltageNode;
|
||||
|
||||
[DataField("lowVoltageNode")]
|
||||
public string? LowVoltageNode { get; }
|
||||
public string? LowVoltageNode;
|
||||
|
||||
[DataField("highVoltageDamageMultiplier")]
|
||||
public float HighVoltageDamageMultiplier { get; } = 3f;
|
||||
public float HighVoltageDamageMultiplier = 3f;
|
||||
|
||||
[DataField("highVoltageTimeMultiplier")]
|
||||
public float HighVoltageTimeMultiplier { get; } = 1.5f;
|
||||
public float HighVoltageTimeMultiplier = 1.5f;
|
||||
|
||||
[DataField("mediumVoltageDamageMultiplier")]
|
||||
public float MediumVoltageDamageMultiplier { get; } = 2f;
|
||||
public float MediumVoltageDamageMultiplier = 2f;
|
||||
|
||||
[DataField("mediumVoltageTimeMultiplier")]
|
||||
public float MediumVoltageTimeMultiplier { get; } = 1.25f;
|
||||
public float MediumVoltageTimeMultiplier = 1.25f;
|
||||
|
||||
[DataField("shockDamage")]
|
||||
public int ShockDamage { get; } = 20;
|
||||
public int ShockDamage = 20;
|
||||
|
||||
/// <summary>
|
||||
/// Shock time, in seconds.
|
||||
/// </summary>
|
||||
[DataField("shockTime")]
|
||||
public float ShockTime { get; } = 8f;
|
||||
public float ShockTime = 8f;
|
||||
|
||||
[DataField("siemensCoefficient")]
|
||||
public float SiemensCoefficient { get; } = 1f;
|
||||
public float SiemensCoefficient = 1f;
|
||||
|
||||
[DataField("shockNoises")]
|
||||
public SoundSpecifier ShockNoises { get; } = new SoundCollectionSpecifier("sparks");
|
||||
public SoundSpecifier ShockNoises = new SoundCollectionSpecifier("sparks");
|
||||
|
||||
[DataField("playSoundOnShock")]
|
||||
public bool PlaySoundOnShock { get; } = true;
|
||||
public bool PlaySoundOnShock = true;
|
||||
|
||||
[DataField("shockVolume")]
|
||||
public float ShockVolume { get; } = 20;
|
||||
}
|
||||
public float ShockVolume = 20;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
namespace Content.Server.Electrocution
|
||||
{
|
||||
namespace Content.Server.Electrocution;
|
||||
|
||||
/// <summary>
|
||||
/// Component for virtual electrocution entities (representing an in-progress shock).
|
||||
/// </summary>
|
||||
@@ -7,10 +7,15 @@
|
||||
[Access(typeof(ElectrocutionSystem))]
|
||||
public sealed class ElectrocutionComponent : Component
|
||||
{
|
||||
[DataField("timeLeft")] public float TimeLeft { get; set; }
|
||||
[DataField("electrocuting")] public EntityUid Electrocuting { get; set; }
|
||||
[DataField("accumDamage")] public float AccumulatedDamage { get; set; }
|
||||
[DataField("source")] public EntityUid Source { get; set; }
|
||||
[DataField("timeLeft")]
|
||||
public float TimeLeft;
|
||||
|
||||
}
|
||||
[DataField("electrocuting")]
|
||||
public EntityUid Electrocuting;
|
||||
|
||||
[DataField("accumDamage")]
|
||||
public float AccumulatedDamage;
|
||||
|
||||
[DataField("source")]
|
||||
public EntityUid Source;
|
||||
}
|
||||
|
||||
@@ -23,29 +23,29 @@ using Content.Shared.Tag;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Electrocution
|
||||
{
|
||||
namespace Content.Server.Electrocution;
|
||||
|
||||
public sealed class ElectrocutionSystem : SharedElectrocutionSystem
|
||||
{
|
||||
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
|
||||
[Dependency] private readonly SharedJitteringSystem _jitteringSystem = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly SharedStutteringSystem _stutteringSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly NodeGroupSystem _nodeGroupSystem = default!;
|
||||
[Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
|
||||
[Dependency] private readonly SharedJitteringSystem _jittering = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedStutteringSystem _stuttering = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||
[Dependency] private readonly NodeGroupSystem _nodeGroup = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly TagSystem _tagSystem = default!;
|
||||
[Dependency] private readonly TagSystem _tag = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
private const string StatusEffectKey = "Electrocution";
|
||||
private const string DamageType = "Shock";
|
||||
@@ -79,49 +79,80 @@ namespace Content.Server.Electrocution
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
// Update "in progress" electrocutions
|
||||
|
||||
RemQueue<ElectrocutionComponent> finishedElectrocutionsQueue = new();
|
||||
foreach (var (electrocution, consumer) in EntityManager
|
||||
.EntityQuery<ElectrocutionComponent, PowerConsumerComponent>())
|
||||
{
|
||||
var ftAdjusted = Math.Min(frameTime, electrocution.TimeLeft);
|
||||
|
||||
electrocution.TimeLeft -= ftAdjusted;
|
||||
electrocution.AccumulatedDamage += consumer.ReceivedPower * ElectrifiedDamagePerWatt * ftAdjusted;
|
||||
|
||||
if (MathHelper.CloseTo(electrocution.TimeLeft, 0))
|
||||
finishedElectrocutionsQueue.Add(electrocution);
|
||||
UpdateElectrocutions(frameTime);
|
||||
UpdateState(frameTime);
|
||||
}
|
||||
|
||||
foreach (var finished in finishedElectrocutionsQueue)
|
||||
private void UpdateElectrocutions(float frameTime)
|
||||
{
|
||||
var uid = finished.Owner;
|
||||
if (EntityManager.EntityExists(finished.Electrocuting))
|
||||
var query = EntityQueryEnumerator<ElectrocutionComponent, PowerConsumerComponent>();
|
||||
while (query.MoveNext(out var uid, out var electrocution, out var consumer))
|
||||
{
|
||||
var timePassed = Math.Min(frameTime, electrocution.TimeLeft);
|
||||
|
||||
electrocution.TimeLeft -= timePassed;
|
||||
electrocution.AccumulatedDamage += consumer.ReceivedPower * ElectrifiedDamagePerWatt * timePassed;
|
||||
|
||||
if (!MathHelper.CloseTo(electrocution.TimeLeft, 0))
|
||||
continue;
|
||||
|
||||
if (EntityManager.EntityExists(electrocution.Electrocuting))
|
||||
{
|
||||
// TODO: damage should be scaled by shock damage multiplier
|
||||
// TODO: better paralyze/jitter timing
|
||||
var damage = new DamageSpecifier(
|
||||
_prototypeManager.Index<DamageTypePrototype>(DamageType),
|
||||
(int) finished.AccumulatedDamage);
|
||||
var damage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), (int) electrocution.AccumulatedDamage);
|
||||
|
||||
var actual = _damageableSystem.TryChangeDamage(finished.Electrocuting, damage, origin: finished.Source);
|
||||
var actual = _damageable.TryChangeDamage(electrocution.Electrocuting, damage, origin: electrocution.Source);
|
||||
if (actual != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.Electrocution,
|
||||
$"{ToPrettyString(finished.Electrocuting):entity} received {actual.Total:damage} powered electrocution damage from {ToPrettyString(finished.Source):source}");
|
||||
$"{ToPrettyString(electrocution.Electrocuting):entity} received {actual.Total:damage} powered electrocution damage from {ToPrettyString(electrocution.Source):source}");
|
||||
}
|
||||
}
|
||||
QueueDel(uid);
|
||||
}
|
||||
}
|
||||
|
||||
EntityManager.DeleteEntity(uid);
|
||||
private void UpdateState(float frameTime)
|
||||
{
|
||||
var query = EntityQueryEnumerator<ActivatedElectrifiedComponent, ElectrifiedComponent, TransformComponent>();
|
||||
while (query.MoveNext(out var uid, out var activated, out var electrified, out var transform))
|
||||
{
|
||||
activated.TimeLeft -= frameTime;
|
||||
if (activated.TimeLeft <= 0 || !IsPowered(uid, electrified, transform))
|
||||
{
|
||||
_appearance.SetData(uid, ElectrifiedVisuals.IsPowered, false);
|
||||
RemComp<ActivatedElectrifiedComponent>(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsPowered(EntityUid uid, ElectrifiedComponent electrified, TransformComponent transform)
|
||||
{
|
||||
if (!electrified.Enabled)
|
||||
return false;
|
||||
if (electrified.NoWindowInTile)
|
||||
{
|
||||
foreach (var entity in transform.Coordinates.GetEntitiesInTile(LookupFlags.Approximate | LookupFlags.Static, _entityLookup))
|
||||
{
|
||||
if (_tag.HasTag(entity, "Window"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (electrified.UsesApcPower)
|
||||
{
|
||||
if (!this.IsPowered(uid, EntityManager))
|
||||
return false;
|
||||
}
|
||||
else if (electrified.RequirePower && PoweredNode(uid, electrified) == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnElectrifiedStartCollide(EntityUid uid, ElectrifiedComponent electrified, ref StartCollideEvent args)
|
||||
{
|
||||
if (!electrified.OnBump)
|
||||
return;
|
||||
|
||||
if (electrified.OnBump)
|
||||
TryDoElectrifiedAct(uid, args.OtherFixture.Body.Owner, 1, electrified);
|
||||
}
|
||||
|
||||
@@ -142,9 +173,7 @@ namespace Content.Server.Electrocution
|
||||
|
||||
private void OnElectrifiedHandInteract(EntityUid uid, ElectrifiedComponent electrified, InteractHandEvent args)
|
||||
{
|
||||
if (!electrified.OnHandInteract)
|
||||
return;
|
||||
|
||||
if (electrified.OnHandInteract)
|
||||
TryDoElectrifiedAct(uid, args.User, 1, electrified);
|
||||
}
|
||||
|
||||
@@ -153,7 +182,7 @@ namespace Content.Server.Electrocution
|
||||
if (!electrified.OnInteractUsing)
|
||||
return;
|
||||
|
||||
var siemens = TryComp(args.Used, out InsulatedComponent? insulation)
|
||||
var siemens = TryComp<InsulatedComponent>(args.Used, out var insulation)
|
||||
? insulation.SiemensCoefficient
|
||||
: 1;
|
||||
|
||||
@@ -169,35 +198,20 @@ namespace Content.Server.Electrocution
|
||||
if (!Resolve(uid, ref electrified, ref transform, false))
|
||||
return false;
|
||||
|
||||
if (!electrified.Enabled)
|
||||
if (!IsPowered(uid, electrified, transform))
|
||||
return false;
|
||||
|
||||
if (electrified.NoWindowInTile)
|
||||
{
|
||||
foreach (var entity in transform.Coordinates.GetEntitiesInTile(
|
||||
LookupFlags.Approximate | LookupFlags.Static, _entityLookup))
|
||||
{
|
||||
if (_tagSystem.HasTag(entity, "Window"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
EnsureComp<ActivatedElectrifiedComponent>(uid);
|
||||
_appearance.SetData(uid, ElectrifiedVisuals.IsPowered, true);
|
||||
|
||||
siemens *= electrified.SiemensCoefficient;
|
||||
if (!DoCommonElectrocutionAttempt(targetUid, uid, ref siemens) || siemens <= 0)
|
||||
if (siemens <= 0 || !DoCommonElectrocutionAttempt(targetUid, uid, ref siemens))
|
||||
return false; // If electrocution would fail, do nothing.
|
||||
|
||||
var targets = new List<(EntityUid entity, int depth)>();
|
||||
GetChainedElectrocutionTargets(targetUid, targets);
|
||||
if (!electrified.RequirePower || electrified.UsesApcPower)
|
||||
{
|
||||
// Does it use APC power for its electrification check? Check if it's powered, and then
|
||||
// attempt an electrocution if all the checks succeed.
|
||||
|
||||
if (electrified.UsesApcPower && !this.IsPowered(uid, EntityManager))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var lastRet = true;
|
||||
for (var i = targets.Count - 1; i >= 0; i--)
|
||||
{
|
||||
@@ -206,28 +220,22 @@ namespace Content.Server.Electrocution
|
||||
entity,
|
||||
uid,
|
||||
(int) (electrified.ShockDamage * MathF.Pow(RecursiveDamageMultiplier, depth)),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth)), true,
|
||||
electrified.SiemensCoefficient);
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth)),
|
||||
true,
|
||||
electrified.SiemensCoefficient
|
||||
);
|
||||
}
|
||||
|
||||
return lastRet;
|
||||
}
|
||||
|
||||
if (!Resolve(uid, ref nodeContainer, false))
|
||||
return false;
|
||||
|
||||
var node = TryNode(electrified.HighVoltageNode) ??
|
||||
TryNode(electrified.MediumVoltageNode) ??
|
||||
TryNode(electrified.LowVoltageNode);
|
||||
|
||||
var node = PoweredNode(uid, electrified, nodeContainer);
|
||||
if (node == null)
|
||||
return false;
|
||||
|
||||
var (damageMult, timeMult) = node.NodeGroupID switch
|
||||
{
|
||||
NodeGroupID.HVPower => (electrified.HighVoltageDamageMultiplier, electrified.HighVoltageTimeMultiplier),
|
||||
NodeGroupID.MVPower => (electrified.MediumVoltageDamageMultiplier,
|
||||
electrified.MediumVoltageTimeMultiplier),
|
||||
NodeGroupID.MVPower => (electrified.MediumVoltageDamageMultiplier, electrified.MediumVoltageTimeMultiplier),
|
||||
_ => (1f, 1f)
|
||||
};
|
||||
|
||||
@@ -241,23 +249,29 @@ namespace Content.Server.Electrocution
|
||||
uid,
|
||||
node,
|
||||
(int) (electrified.ShockDamage * MathF.Pow(RecursiveDamageMultiplier, depth) * damageMult),
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth) *
|
||||
timeMult), true,
|
||||
TimeSpan.FromSeconds(electrified.ShockTime * MathF.Pow(RecursiveTimeMultiplier, depth) * timeMult),
|
||||
true,
|
||||
electrified.SiemensCoefficient);
|
||||
}
|
||||
|
||||
return lastRet;
|
||||
}
|
||||
}
|
||||
|
||||
private Node? PoweredNode(EntityUid uid, ElectrifiedComponent electrified, NodeContainerComponent? nodeContainer = null)
|
||||
{
|
||||
if (!Resolve(uid, ref nodeContainer, false))
|
||||
return null;
|
||||
|
||||
return TryNode(electrified.HighVoltageNode) ?? TryNode(electrified.MediumVoltageNode) ?? TryNode(electrified.LowVoltageNode);
|
||||
|
||||
Node? TryNode(string? id)
|
||||
{
|
||||
if (id != null && nodeContainer.TryGetNode<Node>(id, out var tryNode)
|
||||
&& tryNode.NodeGroup is IBasePowerNet { NetworkNode: { LastCombinedSupply: >0 } })
|
||||
if (id != null &&
|
||||
nodeContainer.TryGetNode<Node>(id, out var tryNode) &&
|
||||
tryNode.NodeGroup is IBasePowerNet { NetworkNode: { LastCombinedSupply: > 0 } })
|
||||
{
|
||||
return tryNode;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -307,18 +321,14 @@ namespace Content.Server.Electrocution
|
||||
if (!Resolve(sourceUid, ref sourceTransform)) // This shouldn't really happen, but just in case...
|
||||
return true;
|
||||
|
||||
var electrocutionEntity = EntityManager.SpawnEntity(
|
||||
$"VirtualElectrocutionLoad{node.NodeGroupID}", sourceTransform.Coordinates);
|
||||
|
||||
var electrocutionNode = EntityManager.GetComponent<NodeContainerComponent>(electrocutionEntity)
|
||||
.GetNode<ElectrocutionNode>("electrocution");
|
||||
|
||||
var electrocutionComponent = EntityManager.GetComponent<ElectrocutionComponent>(electrocutionEntity);
|
||||
var electrocutionEntity = Spawn($"VirtualElectrocutionLoad{node.NodeGroupID}", sourceTransform.Coordinates);
|
||||
var electrocutionNode = Comp<NodeContainerComponent>(electrocutionEntity).GetNode<ElectrocutionNode>("electrocution");
|
||||
var electrocutionComponent = Comp<ElectrocutionComponent>(electrocutionEntity);
|
||||
|
||||
electrocutionNode.CableEntity = sourceUid;
|
||||
electrocutionNode.NodeName = node.Name;
|
||||
|
||||
_nodeGroupSystem.QueueReflood(electrocutionNode);
|
||||
_nodeGroup.QueueReflood(electrocutionNode);
|
||||
|
||||
electrocutionComponent.TimeLeft = 1f;
|
||||
electrocutionComponent.Electrocuting = uid;
|
||||
@@ -360,50 +370,50 @@ namespace Content.Server.Electrocution
|
||||
}
|
||||
|
||||
if (!Resolve(uid, ref statusEffects, false) ||
|
||||
!_statusEffectsSystem.CanApplyEffect(uid, StatusEffectKey, statusEffects))
|
||||
!_statusEffects.CanApplyEffect(uid, StatusEffectKey, statusEffects))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_statusEffectsSystem.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh,
|
||||
statusEffects))
|
||||
if (!_statusEffects.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh, statusEffects))
|
||||
return false;
|
||||
|
||||
var shouldStun = siemensCoefficient > 0.5f;
|
||||
|
||||
if (shouldStun)
|
||||
_stunSystem.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects);
|
||||
_stun.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects);
|
||||
|
||||
// TODO: Sparks here.
|
||||
|
||||
if (shockDamage is { } dmg)
|
||||
{
|
||||
var actual = _damageableSystem.TryChangeDamage(uid,
|
||||
var actual = _damageable.TryChangeDamage(uid,
|
||||
new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), dmg), origin: sourceUid);
|
||||
|
||||
if (actual != null)
|
||||
{
|
||||
_adminLogger.Add(LogType.Electrocution,
|
||||
$"{ToPrettyString(statusEffects.Owner):entity} received {actual.Total:damage} powered electrocution damage{(sourceUid != null ? " from " + ToPrettyString(sourceUid.Value) : ""):source}");
|
||||
$"{ToPrettyString(uid):entity} received {actual.Total:damage} powered electrocution damage{(sourceUid != null ? " from " + ToPrettyString(sourceUid.Value) : ""):source}");
|
||||
}
|
||||
}
|
||||
|
||||
_stutteringSystem.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects);
|
||||
_jitteringSystem.DoJitter(uid, time * JitterTimeMultiplier, refresh, JitterAmplitude, JitterFrequency, true,
|
||||
statusEffects);
|
||||
_stuttering.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects);
|
||||
_jittering.DoJitter(uid, time * JitterTimeMultiplier, refresh, JitterAmplitude, JitterFrequency, true, statusEffects);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-player"), uid, uid);
|
||||
_popup.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-player"), uid, uid);
|
||||
|
||||
var filter = Filter.PvsExcept(uid, entityManager: EntityManager);
|
||||
|
||||
// TODO: Allow being able to pass EntityUid to Loc...
|
||||
if (sourceUid != null)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-by-source-popup-others",
|
||||
_popup.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-by-source-popup-others",
|
||||
("mob", uid), ("source", (sourceUid.Value))), uid, filter, true);
|
||||
PlayElectrocutionSound(uid, sourceUid.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-others",
|
||||
_popup.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-others",
|
||||
("mob", uid)), uid, filter, true);
|
||||
}
|
||||
|
||||
@@ -426,16 +436,16 @@ namespace Content.Server.Electrocution
|
||||
all.Add((entity, depth));
|
||||
visited.Add(entity);
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out SharedPullableComponent? pullable)
|
||||
&& pullable.Puller is {Valid: true} pullerId
|
||||
&& !visited.Contains(pullerId))
|
||||
if (TryComp<SharedPullableComponent>(entity, out var pullable) &&
|
||||
pullable.Puller is { Valid: true } pullerId &&
|
||||
!visited.Contains(pullerId))
|
||||
{
|
||||
GetChainedElectrocutionTargetsRecurse(pullerId, depth + 1, visited, all);
|
||||
}
|
||||
|
||||
if (EntityManager.TryGetComponent(entity, out SharedPullerComponent? puller)
|
||||
&& puller.Pulling is {Valid: true} pullingId
|
||||
&& !visited.Contains(pullingId))
|
||||
if (TryComp<SharedPullerComponent>(entity, out var puller) &&
|
||||
puller.Pulling is { Valid: true } pullingId &&
|
||||
!visited.Contains(pullingId))
|
||||
{
|
||||
GetChainedElectrocutionTargetsRecurse(pullingId, depth + 1, visited, all);
|
||||
}
|
||||
@@ -444,7 +454,7 @@ namespace Content.Server.Electrocution
|
||||
private void OnRandomInsulationMapInit(EntityUid uid, RandomInsulationComponent randomInsulation,
|
||||
MapInitEvent args)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(uid, out InsulatedComponent? insulated))
|
||||
if (!TryComp<InsulatedComponent>(uid, out var insulated))
|
||||
return;
|
||||
|
||||
if (randomInsulation.List.Length == 0)
|
||||
@@ -459,8 +469,6 @@ namespace Content.Server.Electrocution
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SoundSystem.Play(electrified.ShockNoises.GetSound(), Filter.Pvs(targetUid), targetUid, AudioParams.Default.WithVolume(electrified.ShockVolume));
|
||||
}
|
||||
_audio.PlayPvs(electrified.ShockNoises, targetUid, AudioParams.Default.WithVolume(electrified.ShockVolume));
|
||||
}
|
||||
}
|
||||
|
||||
15
Content.Shared/Electrocution/SharedElectrocution.cs
Normal file
15
Content.Shared/Electrocution/SharedElectrocution.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Electrocution;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ElectrifiedLayers : byte
|
||||
{
|
||||
Powered
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ElectrifiedVisuals : byte
|
||||
{
|
||||
IsPowered
|
||||
}
|
||||
@@ -17,7 +17,13 @@
|
||||
netsync: false
|
||||
drawdepth: Walls
|
||||
sprite: Structures/Walls/grille.rsi
|
||||
state: grille
|
||||
layers:
|
||||
- state: grille
|
||||
- state: electrified
|
||||
sprite: Effects/electricity.rsi
|
||||
map: ["enum.ElectrifiedLayers.Powered"]
|
||||
shader: unshaded
|
||||
visible: false
|
||||
- type: Icon
|
||||
sprite: Structures/Walls/grille.rsi
|
||||
state: grille
|
||||
@@ -71,6 +77,14 @@
|
||||
node: grilleBroken
|
||||
- !type:DoActsBehavior
|
||||
acts: ["Breakage"]
|
||||
- type: Appearance
|
||||
- type: GenericVisualizer
|
||||
visuals:
|
||||
enum.ElectrifiedVisuals.IsPowered:
|
||||
enum.ElectrifiedLayers.Powered:
|
||||
True: { visible: True }
|
||||
False: { visible: False }
|
||||
- type: AnimationPlayer
|
||||
|
||||
- type: entity
|
||||
id: GrilleBroken
|
||||
|
||||
BIN
Resources/Textures/Effects/electricity.rsi/electrified.png
Normal file
BIN
Resources/Textures/Effects/electricity.rsi/electrified.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
24
Resources/Textures/Effects/electricity.rsi/meta.json
Normal file
24
Resources/Textures/Effects/electricity.rsi/meta.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"version": 1,
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "made by Aleksh#7552 (Discord) / Alekshhh (Github) for SS14",
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"states": [
|
||||
{
|
||||
"name": "electrified",
|
||||
"delays": [
|
||||
[
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user