Skip to content

Commit fa190cb

Browse files
authored
Merge branch 'starlight-dev' into crystal-edge-nature
2 parents 233c3f3 + 6bab688 commit fa190cb

567 files changed

Lines changed: 393783 additions & 120914 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Content.Client/Construction/ConstructionSystem.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ public bool TrySpawnGhost(
317317
var targetSprite = EnsureComp<SpriteComponent>(dummy);
318318
EntityManager.System<AppearanceSystem>().OnChangeData(dummy, targetSprite);
319319

320+
var destIndex = 0; // Starlight: Track how many layers we've actually added
320321
for (var i = 0; i < targetSprite.AllLayers.Count(); i++)
321322
{
322323
if (!targetSprite[i].Visible || !targetSprite[i].RsiState.IsValid)
@@ -327,12 +328,21 @@ public bool TrySpawnGhost(
327328
state.StateId.Name is null)
328329
continue;
329330

330-
_sprite.AddBlankLayer((ghost.Value, sprite), i);
331-
_sprite.LayerSetSprite((ghost.Value, sprite), i, new SpriteSpecifier.Rsi(rsi.Path, state.StateId.Name));
332-
sprite.LayerSetShader(i, "unshaded");
333-
_sprite.LayerSetVisible((ghost.Value, sprite), i, true);
334-
_sprite.LayerSetOffset((ghost.Value, sprite), i, // Starlight: Fix offset not being copied
335-
targetSprite.Offset + ((SpriteComponent.Layer)targetSprite[i]).Offset); // Starlight
331+
// Starlight START
332+
// Most of these lines only changed i => destIndex. By counting how many layers we add we prevent
333+
// empty layers since empty/missing layer indices causes bugs *elsewhere*. Yay.
334+
_sprite.AddBlankLayer((ghost.Value, sprite), destIndex);
335+
_sprite.LayerSetSprite((ghost.Value, sprite), destIndex, new SpriteSpecifier.Rsi(rsi.Path, state.StateId.Name));
336+
sprite.LayerSetShader(destIndex, "unshaded");
337+
_sprite.LayerSetVisible((ghost.Value, sprite), destIndex, true);
338+
339+
// This is new: Fix offset not being copied
340+
_sprite.LayerSetOffset((ghost.Value, sprite), destIndex,
341+
targetSprite.Offset + ((SpriteComponent.Layer)targetSprite[i]).Offset);
342+
343+
// Count the added layer
344+
destIndex++;
345+
// Starlight END
336346
}
337347

338348
sprite.NoRotation = targetSprite.NoRotation; // Starlight: Fix NoRotation also being ignored.

Content.Client/Drunk/DrunkOverlay.cs

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
using Content.Shared.Drunk;
2-
using Content.Shared.StatusEffect;
32
using Content.Shared.StatusEffectNew;
43
using Robust.Client.Graphics;
54
using Robust.Client.Player;
65
using Robust.Shared.Enums;
76
using Robust.Shared.Prototypes;
87
using Robust.Shared.Timing;
8+
using Content.Shared._Starlight.CCVar;
9+
using Robust.Shared.Configuration;
910

1011
namespace Content.Client.Drunk;
1112

1213
public sealed partial class DrunkOverlay : Overlay
1314
{
1415
private static readonly ProtoId<ShaderPrototype> Shader = "Drunk";
16+
private static readonly TimeSpan _screenCaptureInterval = TimeSpan.FromSeconds(1.0 / 30.0); // Starlight
1517

1618
[Dependency] private IEntityManager _entityManager = default!;
1719
[Dependency] private IPrototypeManager _prototypeManager = default!;
1820
[Dependency] private IPlayerManager _playerManager = default!;
1921
[Dependency] private IEntitySystemManager _sysMan = default!;
2022
[Dependency] private IGameTiming _timing = default!;
23+
[Dependency] private IConfigurationManager _cfg = default!; // Starlight
2124

2225
public override OverlaySpace Space => OverlaySpace.WorldSpace;
2326
public override bool RequestScreenTexture => true;
27+
// Starlight Start
2428
private readonly ShaderInstance _drunkShader;
29+
private readonly StatusEffectsSystem _statusEffects;
30+
// Starlight End
2531

2632
public float CurrentBoozePower = 0.0f;
2733

@@ -39,11 +45,33 @@ public sealed partial class DrunkOverlay : Overlay
3945

4046
private float _visualScale = 0;
4147

48+
// Starlight Start
49+
private bool _drunkRenderFix;
50+
private TimeSpan _nextScreenCapture;
51+
private Texture? _cachedScreenTexture;
52+
// Starlight End
53+
4254
public DrunkOverlay()
4355
{
4456
IoCManager.InjectDependencies(this);
4557
_drunkShader = _prototypeManager.Index(Shader).InstanceUnique();
58+
// Starlight Start: cache status effect system and register cvar listener
59+
_statusEffects = _sysMan.GetEntitySystem<StatusEffectsSystem>();
60+
_cfg.OnValueChanged(StarlightCCVars.DrunkRenderFix, OnDrunkRenderFixChanged, invokeImmediately: true);
61+
// Starlight End
62+
}
63+
64+
// Starlight Start
65+
private void OnDrunkRenderFixChanged(bool enabled)
66+
{
67+
_drunkRenderFix = enabled;
68+
69+
if (!enabled)
70+
{
71+
_cachedScreenTexture = null;
72+
}
4673
}
74+
// Starlight End
4775

4876
protected override void FrameUpdate(FrameEventArgs args)
4977
{
@@ -53,8 +81,7 @@ protected override void FrameUpdate(FrameEventArgs args)
5381
if (playerEntity == null)
5482
return;
5583

56-
var statusSys = _sysMan.GetEntitySystem<Shared.StatusEffectNew.StatusEffectsSystem>();
57-
if (!statusSys.TryGetMaxTime<DrunkStatusEffectComponent>(playerEntity.Value, out var status))
84+
if (!_statusEffects.TryGetMaxTime<DrunkStatusEffectComponent>(playerEntity.Value, out var status)) // Starlight Edit: use cached status system
5885
return;
5986

6087
var time = status.Item2;
@@ -78,11 +105,26 @@ protected override bool BeforeDraw(in OverlayDrawArgs args)
78105

79106
protected override void Draw(in OverlayDrawArgs args)
80107
{
81-
if (ScreenTexture == null)
108+
// Starlight edit Start: capture frame update every 30Hz if render fix on, otherwise everyframe
109+
var screen = ScreenTexture;
110+
111+
if (_drunkRenderFix)
112+
{
113+
if (_cachedScreenTexture == null || _timing.RealTime >= _nextScreenCapture)
114+
{
115+
_cachedScreenTexture = ScreenTexture;
116+
_nextScreenCapture = _timing.RealTime + _screenCaptureInterval;
117+
}
118+
119+
screen = _cachedScreenTexture;
120+
}
121+
122+
if (screen == null)
123+
// Starlight edit End
82124
return;
83125

84126
var handle = args.WorldHandle;
85-
_drunkShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
127+
_drunkShader.SetParameter("SCREEN_TEXTURE", screen); // Starlight Edit: ScreenTexture -> screen
86128
_drunkShader.SetParameter("boozePower", _visualScale);
87129
handle.UseShader(_drunkShader);
88130
handle.DrawRect(args.WorldBounds, Color.White);

Content.Client/Toggleable/ToggleableVisualsComponent.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,26 @@ public sealed partial class ToggleableVisualsComponent : Component
2727
/// </summary>
2828
[DataField]
2929
public Dictionary<string, List<PrototypeLayerData>> ClothingVisuals = new();
30+
31+
#region Starlight
32+
33+
/// <summary>
34+
/// Additional layers to toggle.
35+
/// </summary>
36+
/// <remarks>
37+
/// Added to avoid needing to alter several dozen prototypes.
38+
/// </remarks>
39+
[DataField] public List<string> AdditionalLayers = [];
40+
41+
/// <summary>
42+
/// List of layers to ignore when modulating color with appearance data.
43+
/// </summary>
44+
[DataField] public List<string> ModulateIgnoreLayers = [];
45+
46+
/// <summary>
47+
/// Toggleable visuals for when wielding item.
48+
/// </summary>
49+
[DataField] public Dictionary<HandLocation, List<PrototypeLayerData>> WieldingVisuals = [];
50+
51+
#endregion
3052
}

Content.Client/Toggleable/ToggleableVisualsSystem.cs

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using Content.Shared.Item;
88
using Content.Shared.Light.Components;
99
using Content.Shared.Toggleable;
10+
using Content.Shared.Wieldable;
11+
using Content.Shared.Wieldable.Components;
1012
using Robust.Client.GameObjects;
1113
using Robust.Shared.Utility;
1214

@@ -30,6 +32,10 @@ public override void Initialize()
3032
after: [typeof(ItemSystem)]);
3133
SubscribeLocalEvent<ToggleableVisualsComponent, GetEquipmentVisualsEvent>(OnGetEquipmentVisuals,
3234
after: [typeof(ClientClothingSystem)]);
35+
// Starlight begin
36+
SubscribeLocalEvent<ToggleableVisualsComponent, ItemWieldedEvent>(OnItemWielded);
37+
SubscribeLocalEvent<ToggleableVisualsComponent, ItemUnwieldedEvent>(OnItemUnwielded);
38+
// Starlight end
3339
}
3440

3541
protected override void OnAppearanceChange(EntityUid uid,
@@ -47,10 +53,20 @@ protected override void OnAppearanceChange(EntityUid uid,
4753
SpriteSystem.LayerMapTryGet((uid, args.Sprite), component.SpriteLayer, out var layer, false))
4854
{
4955
SpriteSystem.LayerSetVisible((uid, args.Sprite), layer, enabled);
50-
if (modulateColor)
56+
if (modulateColor && !component.ModulateIgnoreLayers.Contains(component.SpriteLayer)) // Starlight edit
5157
SpriteSystem.LayerSetColor((uid, args.Sprite), component.SpriteLayer, color);
5258
}
5359

60+
// Starlight begin
61+
foreach (var spriteLayer in component.AdditionalLayers)
62+
if (SpriteSystem.LayerMapTryGet((uid, args.Sprite), spriteLayer, out var idx, false))
63+
{
64+
SpriteSystem.LayerSetVisible((uid, args.Sprite), idx, enabled);
65+
if (modulateColor && !component.ModulateIgnoreLayers.Contains(spriteLayer))
66+
SpriteSystem.LayerSetColor((uid, args.Sprite), idx, color);
67+
}
68+
// Starlight end
69+
5470
// If there's a `ItemTogglePointLightComponent` that says to apply the color to attached lights, do so.
5571
if (TryComp<ItemTogglePointLightComponent>(uid, out var toggleLights) &&
5672
TryComp(uid, out PointLightComponent? light))
@@ -101,7 +117,7 @@ private void OnGetEquipmentVisuals(EntityUid uid,
101117
i++;
102118
}
103119

104-
if (modulateColor)
120+
if (modulateColor && !component.ModulateIgnoreLayers.Contains(key)) // Starlight edit
105121
layer.Color = color;
106122

107123
args.Layers.Add((key, layer));
@@ -115,8 +131,22 @@ private void OnGetHeldVisuals(EntityUid uid, ToggleableVisualsComponent componen
115131
|| !enabled)
116132
return;
117133

118-
if (!component.InhandVisuals.TryGetValue(args.Location, out var layers))
134+
// Starlight begin
135+
List<PrototypeLayerData>? layers;
136+
137+
if (TryComp<WieldableComponent>(uid, out var wieldable))
138+
{
139+
if (wieldable.Wielded && component.WieldingVisuals.Count > 0)
140+
{
141+
if (!component.WieldingVisuals.TryGetValue(args.Location, out layers))
142+
return;
143+
}
144+
else if (!component.InhandVisuals.TryGetValue(args.Location, out layers))
145+
return;
146+
}
147+
else if (!component.InhandVisuals.TryGetValue(args.Location, out layers))
119148
return;
149+
// Starlight end
120150

121151
var modulateColor = AppearanceSystem.TryGetData<Color>(uid, ToggleableVisuals.Color, out var color, appearance);
122152

@@ -131,10 +161,20 @@ private void OnGetHeldVisuals(EntityUid uid, ToggleableVisualsComponent componen
131161
i++;
132162
}
133163

134-
if (modulateColor)
164+
if (modulateColor && !component.ModulateIgnoreLayers.Contains(key)) // Starlight edit
135165
layer.Color = color;
136166

137167
args.Layers.Add((key, layer));
138168
}
139169
}
170+
171+
#region Starlight
172+
173+
private void OnItemWielded(Entity<ToggleableVisualsComponent> ent, ref ItemWieldedEvent args) =>
174+
_item.VisualsChanged(ent);
175+
176+
private void OnItemUnwielded(Entity<ToggleableVisualsComponent> ent, ref ItemUnwieldedEvent args) =>
177+
_item.VisualsChanged(ent);
178+
179+
#endregion
140180
}

Content.Client/_Funkystation/ContentWarning/ContentWarningPopup.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<controls:FancyWindow xmlns="https://spacestation14.io"
22
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
33
Title="{Loc 'content-warning-title'}"
4-
MinSize="520 750"
5-
MaxSize="520 750">
4+
MinSize="520 775"
5+
MaxSize="520 775"><!-- Starlight: Changed size -->
66
<BoxContainer Orientation="Vertical" Margin="20">
77
<Label Name="TitleLabel1"
88
StyleClasses="LabelBig"

Content.Client/_Moffstation/Antags/UI/AntagEntry.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
HorizontalAlignment="Center"
2727
SetSize="20 20"
2828
Stretch="KeepAspectCentered"
29+
MouseFilter="Stop"
2930
TexturePath="/Textures/Interface/VerbIcons/lock.svg.192dpi.png"
30-
Visible="False"/>
31+
Visible="False"/> <!-- Starlight, enable unlock requirements again -->
3132
</BoxContainer>
3233

3334
<!-- Trait Info -->

Content.Client/_Moffstation/Antags/UI/AntagEntry.xaml.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Content.Shared.Roles;
88
using Robust.Client.AutoGenerated;
99
using Robust.Client.UserInterface.Controls;
10+
using Robust.Client.UserInterface.CustomControls;
1011
using Robust.Client.UserInterface.XAML;
1112
using Robust.Shared.Prototypes;
1213

@@ -63,9 +64,19 @@ private void SetupRequirements(HumanoidCharacterProfile? profile) // Starlight
6364
AntagCheckbox.Visible = !locked;
6465
AntagCheckbox.Disabled = locked;
6566
LockIcon.Visible = locked;
66-
LockIcon.TooltipSupplier = reason != null
67+
#region Starlight
68+
/*LockIcon.TooltipSupplier = reason != null
6769
? _ => new RichTextLabel { Text = reason.ToString() }
68-
: null;
70+
: null;*/
71+
72+
if (!reason.IsEmpty)
73+
{
74+
var tooltip = new Tooltip();
75+
tooltip.SetMessage(reason);
76+
AntagCheckbox.TooltipSupplier = _ => tooltip;
77+
LockIcon.TooltipSupplier = _ => tooltip;
78+
}
79+
#endregion
6980

7081
if (locked)
7182
{

Content.Client/_Starlight/Overlay/Trail/TrailOverlay.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ protected override void Draw(in OverlayDrawArgs args)
3939

4040
var drawn = 0;
4141
var query = _entMan.EntityQueryEnumerator<TrailComponent, SpriteComponent>();
42-
while (query.MoveNext(out var comp, out var sprite))
42+
while (query.MoveNext(out var uid, out var comp, out var sprite))
4343
{
4444
if (comp.Mode == TrailMode.SpriteGhost)
4545
{
4646
if (comp.Samples.Count < 2)
4747
continue;
48-
DrawGhostTrail(handle, comp, sprite, args);
48+
DrawGhostTrail(handle, (uid, comp, sprite), args);
4949
}
5050
else
5151
{
@@ -171,39 +171,37 @@ private void DrawTrail(DrawingHandleWorld handle, TrailComponent comp, in Overla
171171
handle.UseShader(null);
172172
}
173173

174-
private void DrawGhostTrail(DrawingHandleWorld handle, TrailComponent comp, SpriteComponent sprite, in OverlayDrawArgs args)
174+
private void DrawGhostTrail(DrawingHandleWorld handle, Entity<TrailComponent, SpriteComponent> ent, in OverlayDrawArgs args)
175175
{
176-
var samples = comp.Samples;
176+
var samples = ent.Comp1.Samples;
177177
var count = samples.Count;
178178

179-
var oldColor = sprite.Color;
179+
var oldColor = ent.Comp2.Color;
180180

181-
if (sprite.Icon == null || count == 0)
181+
if (ent.Comp2.Icon == null || count == 0)
182182
return;
183183

184-
for (int i = 0; i < count; i++)
184+
for (var i = 0; i < count; i++)
185185
{
186-
if (comp.SkipSamples > 0 && (i % (comp.SkipSamples + 1)) != 0)
186+
if (ent.Comp1.SkipSamples > 0 && (i % (ent.Comp1.SkipSamples + 1)) != 0)
187187
continue;
188188

189189
var sample = samples[i];
190-
float t = i / (float)(count - 1);
190+
var t = i / (float)(count - 1);
191191

192-
float alpha = t * t * (3f - 2f * t);
193-
alpha *= comp.TrailColor.A;
192+
var alpha = t * t * (3f - 2f * t);
193+
alpha *= ent.Comp1.TrailColor.A;
194194

195195
if (alpha < 0.05f)
196196
continue;
197197

198-
var color = Color.InterpolateBetween(comp.FadeColor, comp.TrailColor, t).WithAlpha(alpha);
198+
var color = Color.InterpolateBetween(ent.Comp1.FadeColor, ent.Comp1.TrailColor, t).WithAlpha(alpha);
199199

200-
var ent = (sprite.Owner, sprite);
200+
_spriteSys.SetColor((ent, ent.Comp2), color);
201201

202-
ent.sprite.Color = color;
202+
_spriteSys.RenderSprite((ent, ent.Comp2), handle, sample.EyeRotation, sample.Rotation, sample.Position, null);
203203

204-
_spriteSys.RenderSprite(ent, handle, sample.EyeRotation, sample.Rotation, sample.Position, null);
205-
206-
ent.sprite.Color = oldColor;
204+
_spriteSys.SetColor((ent, ent.Comp2), oldColor);
207205
}
208206
}
209207
}

0 commit comments

Comments
 (0)