ECSatize AlertsSystem (#5559)
This commit is contained in:
@@ -9,7 +9,6 @@ using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Power.NodeGroups;
|
||||
using Content.Server.Window;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Database;
|
||||
@@ -109,8 +108,10 @@ namespace Content.Server.Electrocution
|
||||
|
||||
var actual = _damageableSystem.TryChangeDamage(finished.Electrocuting, damage);
|
||||
if (actual != null)
|
||||
{
|
||||
_logSystem.Add(LogType.Electrocution,
|
||||
$"{ToPrettyString(finished.Owner):entity} received {actual.Total:damage} powered electrocution damage");
|
||||
}
|
||||
}
|
||||
|
||||
EntityManager.DeleteEntity(uid);
|
||||
@@ -232,10 +233,10 @@ namespace Content.Server.Electrocution
|
||||
|
||||
Node? TryNode(string? id)
|
||||
{
|
||||
if (id != null && nodeContainer.TryGetNode<Node>(id, out var node)
|
||||
&& node.NodeGroup is IBasePowerNet { NetworkNode: { LastAvailableSupplySum: >0 } })
|
||||
if (id != null && nodeContainer.TryGetNode<Node>(id, out var tryNode)
|
||||
&& tryNode.NodeGroup is IBasePowerNet { NetworkNode: { LastAvailableSupplySum: >0 } })
|
||||
{
|
||||
return node;
|
||||
return tryNode;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -245,11 +246,10 @@ namespace Content.Server.Electrocution
|
||||
/// <returns>Whether the entity <see cref="uid"/> was stunned by the shock.</returns>
|
||||
public bool TryDoElectrocution(
|
||||
EntityUid uid, EntityUid? sourceUid, int shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f,
|
||||
StatusEffectsComponent? statusEffects = null,
|
||||
SharedAlertsComponent? alerts = null)
|
||||
StatusEffectsComponent? statusEffects = null)
|
||||
{
|
||||
if (!DoCommonElectrocutionAttempt(uid, sourceUid, ref siemensCoefficient)
|
||||
|| !DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects, alerts))
|
||||
|| !DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects))
|
||||
return false;
|
||||
|
||||
RaiseLocalEvent(uid, new ElectrocutedEvent(uid, sourceUid, siemensCoefficient));
|
||||
@@ -266,7 +266,6 @@ namespace Content.Server.Electrocution
|
||||
bool refresh,
|
||||
float siemensCoefficient = 1f,
|
||||
StatusEffectsComponent? statusEffects = null,
|
||||
SharedAlertsComponent? alerts = null,
|
||||
TransformComponent? sourceTransform = null)
|
||||
{
|
||||
if (!DoCommonElectrocutionAttempt(uid, sourceUid, ref siemensCoefficient))
|
||||
@@ -274,9 +273,9 @@ namespace Content.Server.Electrocution
|
||||
|
||||
// Coefficient needs to be higher than this to do a powered electrocution!
|
||||
if(siemensCoefficient <= 0.5f)
|
||||
return DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects, alerts);
|
||||
return DoCommonElectrocution(uid, sourceUid, shockDamage, time, refresh, siemensCoefficient, statusEffects);
|
||||
|
||||
if (!DoCommonElectrocution(uid, sourceUid, null, time, refresh, siemensCoefficient, statusEffects, alerts))
|
||||
if (!DoCommonElectrocution(uid, sourceUid, null, time, refresh, siemensCoefficient, statusEffects))
|
||||
return false;
|
||||
|
||||
if (!Resolve(sourceUid, ref sourceTransform)) // This shouldn't really happen, but just in case...
|
||||
@@ -318,8 +317,7 @@ namespace Content.Server.Electrocution
|
||||
|
||||
private bool DoCommonElectrocution(EntityUid uid, EntityUid? sourceUid,
|
||||
int? shockDamage, TimeSpan time, bool refresh, float siemensCoefficient = 1f,
|
||||
StatusEffectsComponent? statusEffects = null,
|
||||
SharedAlertsComponent? alerts = null)
|
||||
StatusEffectsComponent? statusEffects = null)
|
||||
{
|
||||
if (siemensCoefficient <= 0)
|
||||
return false;
|
||||
@@ -332,21 +330,18 @@ namespace Content.Server.Electrocution
|
||||
return false;
|
||||
}
|
||||
|
||||
// Optional component.
|
||||
Resolve(uid, ref alerts, false);
|
||||
|
||||
if (!Resolve(uid, ref statusEffects, false) ||
|
||||
!_statusEffectsSystem.CanApplyEffect(uid, StatusEffectKey, statusEffects))
|
||||
return false;
|
||||
|
||||
if (!_statusEffectsSystem.TryAddStatusEffect<ElectrocutedComponent>(uid, StatusEffectKey, time, refresh,
|
||||
statusEffects, alerts))
|
||||
statusEffects))
|
||||
return false;
|
||||
|
||||
var shouldStun = siemensCoefficient > 0.5f;
|
||||
|
||||
if (shouldStun)
|
||||
_stunSystem.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects, alerts);
|
||||
_stunSystem.TryParalyze(uid, time * ParalyzeTimeMultiplier, refresh, statusEffects);
|
||||
|
||||
// TODO: Sparks here.
|
||||
|
||||
@@ -356,13 +351,15 @@ namespace Content.Server.Electrocution
|
||||
new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>(DamageType), dmg));
|
||||
|
||||
if (actual != null)
|
||||
{
|
||||
_logSystem.Add(LogType.Electrocution,
|
||||
$"{ToPrettyString(statusEffects.Owner):entity} received {actual.Total:damage} powered electrocution damage");
|
||||
}
|
||||
}
|
||||
|
||||
_stutteringSystem.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects, alerts);
|
||||
_stutteringSystem.DoStutter(uid, time * StutteringTimeMultiplier, refresh, statusEffects);
|
||||
_jitteringSystem.DoJitter(uid, time * JitterTimeMultiplier, refresh, JitterAmplitude, JitterFrequency, true,
|
||||
statusEffects, alerts);
|
||||
statusEffects);
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("electrocuted-component-mob-shocked-popup-player"), uid,
|
||||
Filter.Entities(uid).Unpredicted());
|
||||
|
||||
Reference in New Issue
Block a user