Skip to content

Commit 1e0222c

Browse files
authored
Merge branch 'starlight-dev' into WIZARD
2 parents 6f3eb23 + 05eb5d7 commit 1e0222c

105 files changed

Lines changed: 1056 additions & 414 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/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/_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
}

Content.Server/Shuttles/Events/DockEvent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ namespace Content.Server.Shuttles.Events;
77
/// </summary>
88
public sealed class DockEvent : EntityEventArgs
99
{
10-
public DockingComponent DockA = default!;
11-
public DockingComponent DockB = default!;
10+
// Starlight-start
11+
public Entity<DockingComponent> DockA = default!;
12+
public Entity<DockingComponent> DockB = default!;
13+
// Starlight-end
1214

1315
public EntityUid GridAUid = default!;
1416
public EntityUid GridBUid = default!;

Content.Server/Shuttles/Events/UndockEvent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ namespace Content.Server.Shuttles.Events;
77
/// </summary>
88
public sealed class UndockEvent : EntityEventArgs
99
{
10-
public DockingComponent DockA = default!;
11-
public DockingComponent DockB = default!;
10+
// Starlight-start
11+
public Entity<DockingComponent> DockA = default!;
12+
public Entity<DockingComponent> DockB = default!;
13+
// Starlight-end
1214

1315
public EntityUid GridAUid = default!;
1416
public EntityUid GridBUid = default!;

Content.Server/Shuttles/Systems/DockingSystem.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ private void Cleanup(EntityUid dockAUid, DockingComponent dockA)
142142

143143
var msg = new UndockEvent
144144
{
145-
DockA = dockA,
146-
DockB = dockB,
145+
// Starlight-start
146+
DockA = (dockAUid, dockA),
147+
DockB = (dockBUid.Value, dockB),
148+
// Starlight-end
147149
GridAUid = gridAUid!.Value,
148150
GridBUid = gridBUid!.Value,
149151
};

Content.Server/Store/Systems/StoreSystem.Listings.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ public sealed partial class StoreSystem
1313
/// Refreshes all listings on a store.
1414
/// Do not use if you don't know what you're doing.
1515
/// </summary>
16-
/// <param name="component">The store to refresh</param>
17-
public void RefreshAllListings(StoreComponent component)
16+
/// <param name="ent">The store to refresh</param>
17+
public void RefreshAllListings(Entity<StoreComponent> ent)
1818
{
19-
var previousState = component.FullListingsCatalog;
19+
var previousState = ent.Comp.FullListingsCatalog;
2020
var newState = GetAllListings();
2121
// if we refresh list with existing cost modifiers - they will be removed,
2222
// need to restore them
@@ -37,11 +37,13 @@ public void RefreshAllListings(StoreComponent component)
3737
}
3838
}
3939

40-
component.FullListingsCatalog = newState;
40+
// Starlight-start
41+
ent.Comp.FullListingsCatalog = newState;
4142

4243
// STARLIGHT: Check if a rift has been destroyed and update the listing accordingly
4344
// This ensures the rift listing remains unavailable even after reopening the uplink
44-
_revSupplyRift.CheckRiftDestroyedAndUpdateListing(component);
45+
_revSupplyRift.CheckRiftDestroyedAndUpdateListing(ent);
46+
// Starlight-end
4547
}
4648

4749
/// <summary>

Content.Server/Store/Systems/StoreSystem.Ui.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void UpdateUserInterface(EntityUid? user, EntityUid store, StoreComponent
110110

111111
// STARLIGHT: Check if a rift has been destroyed and update the listing accordingly
112112
// This ensures the rift listing remains unavailable even when the UI is refreshed
113-
_revSupplyRift.CheckRiftDestroyedAndUpdateListing(component);
113+
_revSupplyRift.CheckRiftDestroyedAndUpdateListing((store, component));
114114

115115
//this is the person who will be passed into logic for all listing filtering.
116116
if (user != null) //if we have no "buyer" for this update, then don't update the listings
@@ -391,7 +391,9 @@ public void UpdateAllUSSPUplinkUIs()
391391
continue;
392392

393393
// Refresh all listings to ensure they have the latest stock count and last purchaser information
394-
RefreshAllListings(storeComp);
394+
// Starlight-start
395+
RefreshAllListings((uid, storeComp));
396+
// Starlight-end
395397

396398
// Force a refresh of the available listings
397399
if (storeComp.AccountOwner != null)
@@ -543,7 +545,9 @@ private void OnRequestRefund(EntityUid uid, StoreComponent component, StoreReque
543545
}
544546

545547
// Reset store back to its original state
546-
RefreshAllListings(component);
548+
// Starlight-start
549+
RefreshAllListings((uid, component));
550+
// Starlight-end
547551
component.BalanceSpent = new();
548552
UpdateUserInterface(buyer, uid, component);
549553
}

Content.Server/Store/Systems/StoreSystem.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ private void OnStoreOpenAttempt(Entity<AccessReaderComponent> ent, ref Activatab
6060

6161
private void OnMapInit(EntityUid uid, StoreComponent component, MapInitEvent args)
6262
{
63-
// STARLIGHT: Ensure the store has a StockLimitedProcessingComponent
63+
// Starlight-start: Ensure the store has a StockLimitedProcessingComponent
6464
EnsureComp<StockLimitedProcessingComponent>(uid);
6565

66-
RefreshAllListings(component);
66+
RefreshAllListings((uid, component));
67+
// Starlight-end
6768
component.StartingMap = Transform(uid).MapUid;
6869
}
6970

@@ -72,7 +73,9 @@ private void OnStartup(EntityUid uid, StoreComponent component, ComponentStartup
7273
// for traitors, because the StoreComponent for the PDA can be added at any time.
7374
if (MetaData(uid).EntityLifeStage == EntityLifeStage.MapInitialized)
7475
{
75-
RefreshAllListings(component);
76+
// Starlight-start
77+
RefreshAllListings((uid, component));
78+
// Starlight-end
7679
}
7780

7881
var ev = new StoreAddedEvent();

Content.Server/_Starlight/Antags/Vampires/Systems/VampireSystem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,7 @@ private void OnVampireClassChosen(EntityUid uid, VampireComponent comp, VampireC
784784
var classComp = _componentFactory.GetComponent(reg.Type);
785785
EntityManager.AddComponent(uid, classComp);
786786

787-
if (classProto.ID == "Umbrae")
788-
EnsureComp<NightVisionComponent>(uid);
787+
EnsureComp<NightVisionComponent>(uid);
789788

790789
comp.ChosenClassId = classProto.ID;
791790
_vampireClasses.WithLabels(classProto.ID).Inc();

0 commit comments

Comments
 (0)