Шейдер ударной волны для взрывов (#633)
* Adds shock wave shader (#2631) Co-authored-by: DOOM <N/A> Co-authored-by: Whisper <121047731+QuietlyWhisper@users.noreply.github.com> * add explosive shockwave * add shockwave to fireball * wd edit * cleanup * remove exgreande beeping sound --------- Co-authored-by: Vero <73014819+vero5123@users.noreply.github.com> Co-authored-by: Whisper <121047731+QuietlyWhisper@users.noreply.github.com>
This commit is contained in:
36
Content.Shared/_White/Explosion/SharedCMExplosionSystem.cs
Normal file
36
Content.Shared/_White/Explosion/SharedCMExplosionSystem.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared._White.Explosion;
|
||||
|
||||
public sealed class SharedExplosionSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<ExplosionEffectComponent, ExplosiveTriggeredEvent>(OnExplosionEffectTriggered);
|
||||
}
|
||||
|
||||
private void OnExplosionEffectTriggered(EntityUid uid, ExplosionEffectComponent component, ref ExplosiveTriggeredEvent args)
|
||||
{
|
||||
SpawnNextToOrDrop(component.ShockWave, uid);
|
||||
SpawnNextToOrDrop(component.Explosion, uid);
|
||||
|
||||
if (component.MaxShrapnel <= 0)
|
||||
return;
|
||||
|
||||
foreach (var effect in component.ShrapnelEffects)
|
||||
{
|
||||
var shrapnelCount = _random.Next(component.MinShrapnel, component.MaxShrapnel);
|
||||
for (var i = 0; i < shrapnelCount; i++)
|
||||
{
|
||||
var angle = _random.NextAngle();
|
||||
var direction = angle.ToVec().Normalized() * 10;
|
||||
var shrapnel = SpawnNextToOrDrop(effect, uid);
|
||||
_throwing.TryThrow(shrapnel, direction, component.ShrapnelSpeed / 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user