Get rid of the OverlayEffectsComponent stuff (#3010)

* Get rid of the OverlayEffectsComponent stuff because it just ended up creating workarounds for it's bugs, without removing any functionality

* Flashes and Flashbangs use the same code now (the Flashable path because it's better)
This commit is contained in:
20kdc
2021-01-24 08:17:45 +00:00
committed by GitHub
parent 329d599107
commit e53ae365a3
21 changed files with 65 additions and 659 deletions

View File

@@ -4,13 +4,17 @@ using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Network.NetMessages;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Timers;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
@@ -128,22 +132,12 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
}
// TODO: Check if target can be flashed (e.g. things like sunglasses would block a flash)
// TODO: Merge with the code in FlashableComponent
private void Flash(IEntity entity, IEntity user, int flashDuration)
{
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlayEffectsComponent))
if (entity.TryGetComponent(out FlashableComponent flashable))
{
if (!overlayEffectsComponent.TryModifyOverlay(nameof(SharedOverlayID.FlashOverlay),
overlay =>
{
if (overlay.TryGetOverlayParameter<TimedOverlayParameter>(out var timed))
{
timed.Length += flashDuration;
}
}))
{
var container = new OverlayContainer(SharedOverlayID.FlashOverlay, new TimedOverlayParameter(flashDuration));
overlayEffectsComponent.AddOverlay(container);
}
flashable.Flash(flashDuration / 1000d);
}
if (entity.TryGetComponent(out StunnableComponent stunnableComponent))