OverlayManager 2 Electric Boogaloo (#1410)
This commit is contained in:
@@ -69,24 +69,24 @@ namespace Content.Server.GameObjects
|
||||
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Health,
|
||||
"/Textures/Interface/StatusEffects/Human/human" + modifier + ".png");
|
||||
|
||||
overlayComponent?.RemoveOverlay(OverlayType.GradientCircleMaskOverlay);
|
||||
overlayComponent?.RemoveOverlay(OverlayType.CircleMaskOverlay);
|
||||
overlayComponent?.RemoveOverlay(SharedOverlayID.GradientCircleMaskOverlay);
|
||||
overlayComponent?.RemoveOverlay(SharedOverlayID.CircleMaskOverlay);
|
||||
|
||||
return;
|
||||
case ThresholdType.Critical:
|
||||
statusEffectsComponent?.ChangeStatusEffectIcon(
|
||||
StatusEffect.Health,
|
||||
"/Textures/Interface/StatusEffects/Human/humancrit-0.png");
|
||||
overlayComponent?.ClearOverlays();
|
||||
overlayComponent?.AddOverlay(OverlayType.GradientCircleMaskOverlay);
|
||||
overlayComponent?.AddOverlay(SharedOverlayID.GradientCircleMaskOverlay);
|
||||
overlayComponent?.RemoveOverlay(SharedOverlayID.CircleMaskOverlay);
|
||||
|
||||
return;
|
||||
case ThresholdType.Death:
|
||||
statusEffectsComponent?.ChangeStatusEffectIcon(
|
||||
StatusEffect.Health,
|
||||
"/Textures/Interface/StatusEffects/Human/humandead.png");
|
||||
overlayComponent?.ClearOverlays();
|
||||
overlayComponent?.AddOverlay(OverlayType.CircleMaskOverlay);
|
||||
overlayComponent?.RemoveOverlay(SharedOverlayID.GradientCircleMaskOverlay);
|
||||
overlayComponent?.AddOverlay(SharedOverlayID.CircleMaskOverlay);
|
||||
|
||||
return;
|
||||
default:
|
||||
|
||||
@@ -2,7 +2,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Timers;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -12,50 +17,83 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
[ComponentReference(typeof(SharedOverlayEffectsComponent))]
|
||||
public sealed class ServerOverlayEffectsComponent : SharedOverlayEffectsComponent
|
||||
{
|
||||
private readonly List<OverlayContainer> _currentOverlays = new List<OverlayContainer>();
|
||||
public ServerOverlayEffectsComponent()
|
||||
{
|
||||
NetSyncEnabled = false;
|
||||
}
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
private List<OverlayContainer> ActiveOverlays => _currentOverlays;
|
||||
public List<OverlayContainer> ActiveOverlays { get; } = new List<OverlayContainer>();
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null)
|
||||
{
|
||||
return new OverlayEffectComponentState(_currentOverlays);
|
||||
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);
|
||||
Dirty();
|
||||
SyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOverlay(string id) => AddOverlay(new OverlayContainer(id));
|
||||
public void AddOverlay(OverlayType type) => AddOverlay(new OverlayContainer(type));
|
||||
public void RemoveOverlay(SharedOverlayID id) => RemoveOverlay(id.ToString());
|
||||
|
||||
public void RemoveOverlay(string id) => RemoveOverlay(new OverlayContainer(id));
|
||||
|
||||
public void RemoveOverlay(OverlayContainer container)
|
||||
{
|
||||
if (ActiveOverlays.RemoveAll(c => c.Equals(container)) > 0)
|
||||
if (ActiveOverlays.Remove(container))
|
||||
{
|
||||
Dirty();
|
||||
SyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveOverlay(string id)
|
||||
public bool TryModifyOverlay(string id, Action<OverlayContainer> modifications)
|
||||
{
|
||||
if (ActiveOverlays.RemoveAll(container => container.ID == id) > 0)
|
||||
var overlay = ActiveOverlays.Find(c => c.ID == id);
|
||||
if (overlay == null)
|
||||
{
|
||||
Dirty();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveOverlay(OverlayType type) => RemoveOverlay(type.ToString());
|
||||
modifications(overlay);
|
||||
SyncClient();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void ClearOverlays()
|
||||
{
|
||||
if (ActiveOverlays.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActiveOverlays.Clear();
|
||||
Dirty();
|
||||
SyncClient();
|
||||
}
|
||||
|
||||
private void SyncClient()
|
||||
{
|
||||
if (Owner.TryGetComponent(out IActorComponent actor))
|
||||
{
|
||||
if (actor.playerSession.ConnectedClient.IsConnected)
|
||||
{
|
||||
SendNetworkMessage(new OverlayEffectComponentMessage(ActiveOverlays), actor.playerSession.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
public override string Name => "Flash";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)] private int _flashDuration = 5000;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private float _flashFalloffExp = 8f;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private int _uses = 5;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private float _range = 3f;
|
||||
[ViewVariables(VVAccess.ReadWrite)] private int _aoeFlashDuration = 5000 / 3;
|
||||
@@ -55,9 +54,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _flashDuration, "duration", 5000);
|
||||
serializer.DataField(ref _flashFalloffExp, "flashFalloffExp", 8f);
|
||||
serializer.DataField(ref _uses, "uses", 5);
|
||||
serializer.DataField(ref _range, "range", 3f);
|
||||
serializer.DataField(ref _range, "range", 7f);
|
||||
serializer.DataField(ref _aoeFlashDuration, "aoeFlashDuration", _flashDuration / 3);
|
||||
serializer.DataField(ref _slowTo, "slowTo", 0.75f);
|
||||
}
|
||||
@@ -139,9 +137,18 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
{
|
||||
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlayEffectsComponent))
|
||||
{
|
||||
var container = new TimedOverlayContainer(nameof(OverlayType.FlashOverlay), flashDuration);
|
||||
overlayEffectsComponent.AddOverlay(container);
|
||||
container.StartTimer(() => overlayEffectsComponent.RemoveOverlay(container));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out StunnableComponent stunnableComponent))
|
||||
@@ -165,8 +172,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
|
||||
if (inDetailsRange)
|
||||
{
|
||||
message.AddMarkup(_localizationManager.GetString(
|
||||
"The flash has [color=green]{0}[/color] uses remaining.", Uses));
|
||||
message.AddMarkup(
|
||||
_localizationManager.GetString(
|
||||
"The flash has [color=green]{0}[/color] {1} remaining.",
|
||||
Uses,
|
||||
_localizationManager.GetPluralString("use", "uses", Uses)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user