2020-07-06 16:37:39 -05:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-10-31 02:37:22 +11:00
|
|
|
using Content.Shared.GameObjects.Components.Mobs;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-07-06 16:37:39 -05:00
|
|
|
using Robust.Shared.Timers;
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
2019-10-31 02:37:22 +11:00
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.Mobs
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
|
|
|
|
[ComponentReference(typeof(SharedOverlayEffectsComponent))]
|
|
|
|
|
public sealed class ServerOverlayEffectsComponent : SharedOverlayEffectsComponent
|
|
|
|
|
{
|
2020-07-06 16:37:39 -05:00
|
|
|
private readonly List<OverlayContainer> _currentOverlays = new List<OverlayContainer>();
|
|
|
|
|
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
private List<OverlayContainer> ActiveOverlays => _currentOverlays;
|
2019-10-31 02:37:22 +11:00
|
|
|
|
|
|
|
|
public override ComponentState GetComponentState()
|
|
|
|
|
{
|
2020-07-06 16:37:39 -05:00
|
|
|
return new OverlayEffectComponentState(_currentOverlays);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddOverlay(OverlayContainer container)
|
|
|
|
|
{
|
|
|
|
|
if (!ActiveOverlays.Contains(container))
|
|
|
|
|
{
|
|
|
|
|
ActiveOverlays.Add(container);
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddOverlay(string id) => AddOverlay(new OverlayContainer(id));
|
|
|
|
|
public void AddOverlay(OverlayType type) => AddOverlay(new OverlayContainer(type));
|
|
|
|
|
|
|
|
|
|
public void RemoveOverlay(OverlayContainer container)
|
|
|
|
|
{
|
|
|
|
|
if (ActiveOverlays.RemoveAll(c => c.Equals(container)) > 0)
|
|
|
|
|
{
|
|
|
|
|
Dirty();
|
|
|
|
|
}
|
2019-10-31 02:37:22 +11:00
|
|
|
}
|
|
|
|
|
|
2020-07-06 16:37:39 -05:00
|
|
|
public void RemoveOverlay(string id)
|
2019-10-31 02:37:22 +11:00
|
|
|
{
|
2020-07-06 16:37:39 -05:00
|
|
|
if (ActiveOverlays.RemoveAll(container => container.ID == id) > 0)
|
2019-10-31 02:37:22 +11:00
|
|
|
{
|
2020-07-06 16:37:39 -05:00
|
|
|
Dirty();
|
2019-10-31 02:37:22 +11:00
|
|
|
}
|
2020-07-06 16:37:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveOverlay(OverlayType type) => RemoveOverlay(type.ToString());
|
|
|
|
|
|
|
|
|
|
public void ClearOverlays()
|
|
|
|
|
{
|
|
|
|
|
ActiveOverlays.Clear();
|
2019-10-31 02:37:22 +11:00
|
|
|
Dirty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|