Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions Content.Client/Decals/DecalPlacementSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ public sealed class DecalPlacementSystem : EntitySystem
private bool _snap;
private int _zIndex;
private bool _cleanable;
// corvax-goob
private bool _glows;
private float _glowTime;
private float _glowEnergy;

private bool _active;
private bool _placing;
private bool _erasing;

public (DecalPrototype? Decal, bool Snap, Angle Angle, Color Color) GetActiveDecal()
public (DecalPrototype? Decal, bool Snap, Angle Angle, Color Color, bool Glows, float glowDuration, float GlowEnergy) GetActiveDecal()
{
return _active && _decalId != null ?
(_protoMan.Index<DecalPrototype>(_decalId), _snap, _decalAngle, _decalColor) :
(null, false, Angle.Zero, Color.Wheat);
(_protoMan.Index<DecalPrototype>(_decalId), _snap, _decalAngle, _decalColor, _glows, _glowDuration: _glowTime, _glowEnergy) :
(null, false, Angle.Zero, Color.Wheat, false, 0, 0);
}

public override void Initialize()
Expand Down Expand Up @@ -75,7 +79,7 @@ public override void Initialize()
if (!coords.IsValid(EntityManager))
return false;

var decal = new Decal(coords.Position, _decalId, _decalColor, _decalAngle, _zIndex, _cleanable);
var decal = new Decal(coords.Position, _decalId, _decalColor, _decalAngle, _zIndex, _cleanable, _glows, _glowTime, _glowEnergy);
RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, GetNetCoordinates(coords)));

return true;
Expand Down Expand Up @@ -133,7 +137,16 @@ private void OnPlaceDecalAction(PlaceDecalActionEvent args)

args.Target = args.Target.Offset(new Vector2(-0.5f, -0.5f));

var decal = new Decal(args.Target.Position, args.DecalId, args.Color, Angle.FromDegrees(args.Rotation), args.ZIndex, args.Cleanable);
var decal = new Decal(args.Target.Position,
args.DecalId,
args.Color,
Angle.FromDegrees(args.Rotation),
args.ZIndex,
args.Cleanable,
// corvax-goob
args.Glows,
args.GlowDuration,
args.GlowEnergy);
RaiseNetworkEvent(new RequestDecalPlacementEvent(decal, GetNetCoordinates(args.Target)));
}

Expand All @@ -156,6 +169,7 @@ private void OnFillSlot(FillActionSlotEvent ev)
Snap = _snap,
ZIndex = _zIndex,
Cleanable = _cleanable,
Glows = _glows,
};

var actionId = Spawn(DecalAction);
Expand All @@ -178,14 +192,17 @@ public override void Shutdown()
CommandBinds.Unregister<DecalPlacementSystem>();
}

public void UpdateDecalInfo(string id, Color color, float rotation, bool snap, int zIndex, bool cleanable)
public void UpdateDecalInfo(string id, Color color, float rotation, bool snap, int zIndex, bool cleanable, bool glows, float glowTime, float glowEnergy)
{
_decalId = id;
_decalColor = color;
_decalAngle = Angle.FromDegrees(rotation);
_snap = snap;
_zIndex = zIndex;
_cleanable = cleanable;
_glows = glows;
_glowTime = glowTime;
_glowEnergy = glowEnergy;
}

public void SetActive(bool active)
Expand Down
44 changes: 42 additions & 2 deletions Content.Client/Decals/Overlays/DecalOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,28 @@
using Robust.Shared.Map;
using Robust.Shared.Map.Enumerators;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client.Decals.Overlays
{
public sealed class DecalOverlay : GridOverlay
{
// corvax-goob
private static readonly ProtoId<ShaderPrototype> EmissiveShader = "Emissive";

private readonly SpriteSystem _sprites;
private readonly IEntityManager _entManager;
private readonly IPrototypeManager _prototypeManager;
private readonly IGameTiming _timing = default!; // corvax-goob

private readonly Dictionary<string, (Texture Texture, bool SnapCardinals)> _cachedTextures = new(64);

private readonly List<(uint Id, Decal Decal)> _decals = new();

// corvax-goob
private readonly ShaderInstance _emissiveShader;
private readonly Dictionary<uint, ShaderInstance> _glowingDecalsShaders = new();

public DecalOverlay(
SpriteSystem sprites,
IEntityManager entManager,
Expand All @@ -28,6 +37,9 @@ public DecalOverlay(
_sprites = sprites;
_entManager = entManager;
_prototypeManager = prototypeManager;
// corvax-goob
_emissiveShader = _prototypeManager.Index(EmissiveShader).InstanceUnique();
_timing = IoCManager.Resolve<IGameTiming>();
}

protected override void Draw(in OverlayDrawArgs args)
Expand Down Expand Up @@ -85,7 +97,10 @@ protected override void Draw(in OverlayDrawArgs args)
var (_, worldRot, worldMatrix) = xformSystem.GetWorldPositionRotationMatrix(xform);
handle.SetTransform(worldMatrix);

foreach (var (_, decal) in _decals)
// corvax-goob
var defShader = handle.GetShader();

foreach (var (decalId, decal) in _decals)
{
if (!_cachedTextures.TryGetValue(decal.Id, out var cache))
{
Expand All @@ -109,13 +124,38 @@ protected override void Draw(in OverlayDrawArgs args)

var angle = decal.Angle - cardinal;

//corvax-goob start
var timeRemained = (decal.GlowUntil - _timing.CurTime).TotalSeconds;
if (decal.Glows && decal.GlowTime > 0)
{
var glowEnergy = Math.Clamp(
(float)(timeRemained / decal.GlowTime) * decal.GlowEnergy,
0f,
decal.GlowEnergy);
if (timeRemained > 0.01)
{
var decalShader = _glowingDecalsShaders.GetValueOrDefault(decalId, _emissiveShader.Duplicate());
_glowingDecalsShaders.TryAdd(decalId, decalShader);
handle.UseShader(decalShader);
decalShader.SetParameter("glowEnergy", glowEnergy);
}
else
{
_glowingDecalsShaders.Remove(decalId);
decal.Glows = false;
}
}
//corvax-goob end

if (angle.Equals(Angle.Zero))
handle.DrawTexture(cache.Texture, decal.Coordinates, decal.Color);
else
handle.DrawTexture(cache.Texture, decal.Coordinates, angle, decal.Color);

handle.UseShader(defShader);
}

handle.SetTransform(Matrix3x2.Identity);
}
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Decals/Overlays/DecalPlacementOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public DecalPlacementOverlay(DecalPlacementSystem placement, SharedTransformSyst

protected override void Draw(in OverlayDrawArgs args)
{
var (decal, snap, rotation, color) = _placement.GetActiveDecal();
var (decal, snap, rotation, color, _, _, _) = _placement.GetActiveDecal();

if (decal == null)
return;
Expand Down
13 changes: 11 additions & 2 deletions Content.Client/Decals/UI/DecalPlacerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ SPDX-License-Identifier: MIT

<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'decal-placer-window-title'}"
MinSize="250 500"
SetSize="250 500">
MinSize="250 550"
SetSize="250 550">
<BoxContainer Orientation="Vertical">
<LineEdit Name="Search" />
<ScrollContainer VerticalExpand="True">
Expand All @@ -23,6 +23,15 @@ SPDX-License-Identifier: MIT
<CheckBox Name="EnableColor" Text="{Loc 'decal-placer-window-use-color'}" />
<CheckBox Name="EnableSnap" Text="{Loc 'decal-placer-window-enable-snap'}" />
<CheckBox Name="EnableCleanable" Text="{Loc 'decal-placer-window-enable-cleanable'}" />
<CheckBox Name="EnableGlow" Text="{Loc 'decal-placer-window-enable-glow'}" /><!-- CorvaxGoob -->
<BoxContainer Orientation="Horizontal"><!-- CorvaxGoob -->
<Label Text="{Loc 'decal-placer-window-glow-time'}" Margin="0 0 0 1" />
<SpinBox Name="GlowTime" HorizontalExpand ="True" />
</BoxContainer>
<BoxContainer Orientation="Horizontal"><!-- CorvaxGoob -->
<Label Text="{Loc 'decal-placer-window-glow-energy'}" Margin="0 0 0 1" />
<Slider Name="GlowEnergy" HorizontalExpand ="True" />
</BoxContainer>
<BoxContainer Name="SpinBoxContainer" Orientation="Horizontal">
<Label Text="{Loc 'decal-placer-window-rotation'}" Margin="0 0 0 1" />
</BoxContainer>
Expand Down
24 changes: 23 additions & 1 deletion Content.Client/Decals/UI/DecalPlacerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public sealed partial class DecalPlacerWindow : DefaultWindow
private float _rotation;
private bool _cleanable;
private int _zIndex;
// corvax-goob start
private bool _glows;
private float _glowTime;
private float _glowEnergy;
// corvax-goob end

private bool _auto;

Expand Down Expand Up @@ -134,6 +139,23 @@ public DecalPlacerWindow()
_zIndex = args.Value;
UpdateDecalPlacementInfo();
};
// corvax-goob start
EnableGlow.OnToggled += args =>
{
_glows = args.Pressed;
UpdateDecalPlacementInfo();
};
GlowTime.ValueChanged += args =>
{
_glowTime = args.Value;
UpdateDecalPlacementInfo();
};
GlowEnergy.OnValueChanged += args =>
{
_glowEnergy = args.Value / 100;
UpdateDecalPlacementInfo();
};
// corvax-goob end
}

private void OnColorPicked(Color color)
Expand All @@ -149,7 +171,7 @@ private void UpdateDecalPlacementInfo()
return;

var color = _useColor ? _color : Color.White;
_decalPlacementSystem.UpdateDecalInfo(_selected, color, _rotation, _snap, _zIndex, _cleanable);
_decalPlacementSystem.UpdateDecalInfo(_selected, color, _rotation, _snap, _zIndex, _cleanable, _glows, _glowTime, _glowEnergy);
}

private void RefreshList()
Expand Down
10 changes: 10 additions & 0 deletions Content.Client/Mapping/MappingScreen.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ SPDX-License-Identifier: AGPL-3.0-or-later
Text="{Loc decal-placer-window-enable-snap}" />
<CheckBox Name="DecalEnableCleanable"
Text="{Loc decal-placer-window-enable-cleanable}" />
<CheckBox Name="DecalEnableGlow"
Text="{Loc 'decal-placer-window-enable-glow'}" /><!-- CorvaxGoob -->
<BoxContainer Orientation="Horizontal"><!-- CorvaxGoob -->
<Label Text="{Loc 'decal-placer-window-glow-time'}" Margin="0 0 0 1" />
<SpinBox Name="DecalGlowTime" HorizontalExpand ="True" />
</BoxContainer>
<BoxContainer Orientation="Horizontal"><!-- CorvaxGoob -->
<Label Text="{Loc 'decal-placer-window-glow-energy'}" Margin="0 0 0 1" />
<Slider Name="DecalGlowEnergy" HorizontalExpand ="True" />
</BoxContainer>
<BoxContainer Name="DecalSpinBoxContainer" Orientation="Horizontal">
<Label Text="{Loc decal-placer-window-rotation}" Margin="0 0 0 1" />
</BoxContainer>
Expand Down
25 changes: 23 additions & 2 deletions Content.Client/Mapping/MappingScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public sealed partial class MappingScreen : InGameScreen
private bool _decalSnap;
private int _decalZIndex;
private bool _decalCleanable;
// corvax-goob start
private bool _decalGlows;
private float _decalGlowTime;
private float _decalGlowEnergy;
// corvax-goob end

private bool _decalAuto;

Expand Down Expand Up @@ -90,7 +95,23 @@ public MappingScreen()
_decalZIndex = args.Value;
UpdateDecal();
};

// corvax-goob start
DecalEnableGlow.OnToggled += args =>
{
_decalGlows = args.Pressed;
UpdateDecal();
};
DecalGlowTime.ValueChanged += args =>
{
_decalGlowTime = args.Value;
UpdateDecal();
};
DecalGlowEnergy.OnValueChanged += args =>
{
_decalGlowEnergy = args.Value / 100;
UpdateDecal();
};
// corvax-goob end
for (var i = 0; i < EntitySpawnWindow.InitOpts.Length; i++)
{
EntityPlacementMode.AddItem(EntitySpawnWindow.InitOpts[i], i);
Expand Down Expand Up @@ -149,7 +170,7 @@ private void UpdateDecal()
if (_id is not { } id)
return;

DecalSystem.UpdateDecalInfo(id, _decalColor, _decalRotation, _decalSnap, _decalZIndex, _decalCleanable);
DecalSystem.UpdateDecalInfo(id, _decalColor, _decalRotation, _decalSnap, _decalZIndex, _decalCleanable, _decalGlows, _decalGlowTime, _decalGlowEnergy);
}

public void SelectDecal(string decalId)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Mapping/MappingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ private void OnSelected(MappingSpawnButton button, IPrototype? prototype)
_placement.Clear();

_decal.SetActive(true);
_decal.UpdateDecalInfo(decal.ID, Color.White, 0, true, 0, false);
_decal.UpdateDecalInfo(decal.ID, Color.White, 0, true, 0, false, false, 0, 0);
Screen.DecalContainer.Visible = true;
break;
case ContentTileDefinition tile:
Expand Down
5 changes: 4 additions & 1 deletion Content.Client/_CorvaxGoob/Decals/UI/DecalCopySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public override void Initialize()
rotation: (float)decal.Angle.Degrees,
snap: _decalPlacementSystem.GetCurrentSnap(),
zIndex: decal.ZIndex,
cleanable: decal.Cleanable
cleanable: decal.Cleanable,
glows: decal.Glows,
glowTime: decal.GlowTime,
glowEnergy: decal.GlowEnergy
);

if (decal.Color != null)
Expand Down
8 changes: 7 additions & 1 deletion Content.Server/Crayon/CrayonSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ private void OnCrayonAfterInteract(EntityUid uid, CrayonComponent component, Aft
return;
}

if (!_decals.TryAddDecal(component.SelectedState, args.ClickLocation.Offset(new Vector2(-0.5f, -0.5f)), out _, component.Color, cleanable: true))
if (!_decals.TryAddDecal(component.SelectedState,
args.ClickLocation.Offset(new Vector2(-0.5f, -0.5f)),
out _,
component.Color,
cleanable: true,
// corvax-goob
glows: component.Glows))
return;

if (component.UseSound != null)
Expand Down
Loading
Loading