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:
@@ -1,95 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Mobs
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedOverlayEffectsComponent))]
|
||||
public sealed class ServerOverlayEffectsComponent : SharedOverlayEffectsComponent
|
||||
{
|
||||
public ServerOverlayEffectsComponent()
|
||||
{
|
||||
NetSyncEnabled = false;
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public List<OverlayContainer> ActiveOverlays { get; } = new();
|
||||
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null)
|
||||
{
|
||||
if (Owner.TryGetComponent(out IActorComponent actor) && message is ResendOverlaysMessage)
|
||||
{
|
||||
if (actor.playerSession.ConnectedClient == netChannel)
|
||||
{
|
||||
SyncClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOverlay(string id) => AddOverlay(new OverlayContainer(id));
|
||||
|
||||
public void AddOverlay(SharedOverlayID id) => AddOverlay(new OverlayContainer(id));
|
||||
|
||||
public void AddOverlay(OverlayContainer container)
|
||||
{
|
||||
if (!ActiveOverlays.Contains(container))
|
||||
{
|
||||
ActiveOverlays.Add(container);
|
||||
SyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveOverlay(SharedOverlayID id) => RemoveOverlay(id.ToString());
|
||||
|
||||
public void RemoveOverlay(string id) => RemoveOverlay(new OverlayContainer(id));
|
||||
|
||||
public void RemoveOverlay(OverlayContainer container)
|
||||
{
|
||||
if (ActiveOverlays.Remove(container))
|
||||
{
|
||||
SyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryModifyOverlay(string id, Action<OverlayContainer> modifications)
|
||||
{
|
||||
var overlay = ActiveOverlays.Find(c => c.ID == id);
|
||||
if (overlay == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
modifications(overlay);
|
||||
SyncClient();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClearOverlays()
|
||||
{
|
||||
if (ActiveOverlays.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveOverlays.Clear();
|
||||
SyncClient();
|
||||
}
|
||||
|
||||
private void SyncClient()
|
||||
{
|
||||
if (Owner.TryGetComponent(out IActorComponent actor))
|
||||
{
|
||||
if (actor.playerSession.ConnectedClient.IsConnected)
|
||||
{
|
||||
SendNetworkMessage(new OverlayEffectComponentMessage(ActiveOverlays), actor.playerSession.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,6 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
||||
appearance.SetData(DamageStateVisuals.State, DamageState.Critical);
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlay))
|
||||
{
|
||||
overlay.AddOverlay(SharedOverlayID.GradientCircleMaskOverlay);
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out StunnableComponent stun))
|
||||
{
|
||||
stun.CancelAll();
|
||||
@@ -36,11 +31,6 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
||||
public override void ExitState(IEntity entity)
|
||||
{
|
||||
base.ExitState(entity);
|
||||
|
||||
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlay))
|
||||
{
|
||||
overlay.ClearOverlays();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,6 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
||||
status.ShowAlert(AlertType.HumanDead);
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlayComponent))
|
||||
{
|
||||
overlayComponent.AddOverlay(SharedOverlayID.CircleMaskOverlay);
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out StunnableComponent stun))
|
||||
{
|
||||
stun.CancelAll();
|
||||
@@ -52,11 +47,6 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlay))
|
||||
{
|
||||
overlay.ClearOverlays();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,5 @@ namespace Content.Server.GameObjects.Components.Mobs.State
|
||||
[ComponentReference(typeof(IMobStateComponent))]
|
||||
public class MobStateComponent : SharedMobStateComponent
|
||||
{
|
||||
public override void OnRemove()
|
||||
{
|
||||
// TODO: Might want to add an OnRemove() to IMobState since those are where these components are being used
|
||||
if (Owner.TryGetComponent(out ServerOverlayEffectsComponent overlay))
|
||||
{
|
||||
overlay.ClearOverlays();
|
||||
}
|
||||
|
||||
base.OnRemove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user