diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 4150612d96..a7864593f1 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -97,7 +97,7 @@ namespace Content.Client.Entry "PresetIdCard", "SolarControlConsole", "FlashExplosive", - "FlashProjectile", + "FlashAreaOnCollide", "Utensil", "UnarmedCombat", "TimedSpawner", diff --git a/Content.Server/Flash/Components/FlashAreaOnCollide.cs b/Content.Server/Flash/Components/FlashAreaOnCollide.cs new file mode 100644 index 0000000000..9f7e7145ec --- /dev/null +++ b/Content.Server/Flash/Components/FlashAreaOnCollide.cs @@ -0,0 +1,19 @@ +using Robust.Shared.GameObjects; +using Robust.Shared.Serialization.Manager.Attributes; + +namespace Content.Server.Flash.Components +{ + /// + /// Upon colliding with an object this will flash in an area around it + /// + [RegisterComponent] + internal sealed class FlashAreaOnCollide : Component + { + public override string Name => "FlashAreaOnCollide"; + + [DataField("range")] internal float Range = 1.0f; + [DataField("duration")] internal float Duration = 8.0f; + + internal bool Flashed; + } +} diff --git a/Content.Server/Flash/Components/FlashProjectileComponent.cs b/Content.Server/Flash/Components/FlashProjectileComponent.cs deleted file mode 100644 index 75be83afb4..0000000000 --- a/Content.Server/Flash/Components/FlashProjectileComponent.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Content.Server.Projectiles.Components; -using Robust.Shared.GameObjects; -using Robust.Shared.Physics.Collision; -using Robust.Shared.Physics.Dynamics; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Server.Flash.Components -{ - /// - /// Upon colliding with an object this will flash in an area around it - /// - [RegisterComponent] - public class FlashProjectileComponent : Component, IStartCollide - { - public override string Name => "FlashProjectile"; - - [DataField("range")] - private float _range = 1.0f; - [DataField("duration")] - private float _duration = 8.0f; - - private bool _flashed; - - protected override void Initialize() - { - base.Initialize(); - // Shouldn't be using this without a ProjectileComponent because it will just immediately collide with thrower - Owner.EnsureComponent(); - } - - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - if (_flashed) return; - - FlashableComponent.FlashAreaHelper(Owner, _range, _duration); - _flashed = true; - } - } -} diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 80995e48a3..d569c9e294 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -10,11 +10,12 @@ using Robust.Shared.Audio; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; +using Robust.Shared.Physics.Dynamics; using Robust.Shared.Player; namespace Content.Server.Flash { - public class FlashSystem : EntitySystem + internal sealed class FlashSystem : EntitySystem { public override void Initialize() { @@ -25,6 +26,15 @@ namespace Content.Server.Flash SubscribeLocalEvent(OnUseInHand); SubscribeLocalEvent(OnExamined); + SubscribeLocalEvent(HandleCollide); + } + + private void HandleCollide(EntityUid uid, FlashAreaOnCollide component, StartCollideEvent args) + { + if (component.Flashed) return; + + FlashableComponent.FlashAreaHelper(component.Owner, component.Range, component.Duration); + component.Flashed = true; } public void OnMeleeHit(EntityUid uid, FlashComponent comp, MeleeHitEvent args) diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml index 756de9f0cb..a4f92cf195 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml @@ -38,7 +38,7 @@ soundHit: /Audio/Weapons/Guns/Hits/snap.ogg damages: Piercing: 10 - - type: FlashProjectile + - type: FlashAreaOnCollide range: 1 - type: entity @@ -212,7 +212,7 @@ - type: Projectile deleteOnCollide: false soundHit: /Audio/Effects/flash_bang.ogg - - type: FlashProjectile + - type: FlashAreaOnCollide range: 7 # This is supposed to spawn shrapnel and stuff so uhh... TODO?