Adds explosion when attempting to microwave metal / bugfix (#23887)
This commit is contained in:
@@ -3,7 +3,6 @@ using Content.Server.Beam;
|
||||
using Content.Server.Beam.Components;
|
||||
using Content.Server.Lightning.Components;
|
||||
using Content.Shared.Lightning;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Lightning;
|
||||
@@ -22,9 +21,6 @@ public sealed class LightningSystem : SharedLightningSystem
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
|
||||
private List<Entity<LightningTargetComponent>> _lookupTargetsList = new();
|
||||
private HashSet<Entity<LightningTargetComponent>> _lookupTargets = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -48,15 +44,20 @@ public sealed class LightningSystem : SharedLightningSystem
|
||||
/// <param name="user">Where the lightning fires from</param>
|
||||
/// <param name="target">Where the lightning fires to</param>
|
||||
/// <param name="lightningPrototype">The prototype for the lightning to be created</param>
|
||||
public void ShootLightning(EntityUid user, EntityUid target, string lightningPrototype = "Lightning")
|
||||
/// <param name="triggerLightningEvents">if the lightnings being fired should trigger lightning events.</param>
|
||||
public void ShootLightning(EntityUid user, EntityUid target, string lightningPrototype = "Lightning", bool triggerLightningEvents = true)
|
||||
{
|
||||
var spriteState = LightningRandomizer();
|
||||
_beam.TryCreateBeam(user, target, lightningPrototype, spriteState);
|
||||
|
||||
var ev = new HitByLightningEvent(user, target);
|
||||
RaiseLocalEvent(target, ref ev);
|
||||
if (triggerLightningEvents) // we don't want certain prototypes to trigger lightning level events
|
||||
{
|
||||
var ev = new HitByLightningEvent(user, target);
|
||||
RaiseLocalEvent(target, ref ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Looks for objects with a LightningTarget component in the radius, prioritizes them, and hits the highest priority targets with lightning.
|
||||
/// </summary>
|
||||
@@ -65,7 +66,8 @@ public sealed class LightningSystem : SharedLightningSystem
|
||||
/// <param name="boltCount">Number of lightning bolts</param>
|
||||
/// <param name="lightningPrototype">The prototype for the lightning to be created</param>
|
||||
/// <param name="arcDepth">how many times to recursively fire lightning bolts from the target points of the first shot.</param>
|
||||
public void ShootRandomLightnings(EntityUid user, float range, int boltCount, string lightningPrototype = "Lightning", int arcDepth = 0)
|
||||
/// <param name="triggerLightningEvents">if the lightnings being fired should trigger lightning events.</param>
|
||||
public void ShootRandomLightnings(EntityUid user, float range, int boltCount, string lightningPrototype = "Lightning", int arcDepth = 0, bool triggerLightningEvents = true)
|
||||
{
|
||||
//To Do: add support to different priority target tablem for different lightning types
|
||||
//To Do: Remove Hardcode LightningTargetComponent (this should be a parameter of the SharedLightningComponent)
|
||||
@@ -88,10 +90,10 @@ public sealed class LightningSystem : SharedLightningSystem
|
||||
if (!_random.Prob(curTarget.HitProbability)) //Chance to ignore target
|
||||
continue;
|
||||
|
||||
ShootLightning(user, targets[count].Owner, lightningPrototype);
|
||||
ShootLightning(user, targets[count].Owner, lightningPrototype, triggerLightningEvents);
|
||||
if (arcDepth - targets[count].LightningResistance > 0)
|
||||
{
|
||||
ShootRandomLightnings(targets[count].Owner, range, 1, lightningPrototype, arcDepth - targets[count].LightningResistance);
|
||||
ShootRandomLightnings(targets[count].Owner, range, 1, lightningPrototype, arcDepth - targets[count].LightningResistance, triggerLightningEvents);
|
||||
}
|
||||
shootedCount++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user