-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #402 from Mnemotechnician/floof/feat/partial-merge…
…-2024-12-04 Partial Merge Up to 2024-11-17
- Loading branch information
Showing
165 changed files
with
63,468 additions
and
53,462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using Content.Shared.FootPrint; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Client.FootPrint; | ||
|
||
public sealed class FootPrintsVisualizerSystem : VisualizerSystem<FootPrintComponent> | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FootPrintComponent, ComponentInit>(OnInitialized); | ||
SubscribeLocalEvent<FootPrintComponent, ComponentShutdown>(OnShutdown); | ||
} | ||
|
||
private void OnInitialized(EntityUid uid, FootPrintComponent comp, ComponentInit args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
sprite.LayerMapReserveBlank(FootPrintVisualLayers.Print); | ||
UpdateAppearance(uid, comp, sprite); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, FootPrintComponent comp, ComponentShutdown args) | ||
{ | ||
if (TryComp<SpriteComponent>(uid, out var sprite) | ||
&& sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer)) | ||
sprite.RemoveLayer(layer); | ||
} | ||
|
||
private void UpdateAppearance(EntityUid uid, FootPrintComponent component, SpriteComponent sprite) | ||
{ | ||
if (!sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer) | ||
|| !TryComp<FootPrintsComponent>(component.PrintOwner, out var printsComponent) | ||
|| !TryComp<AppearanceComponent>(uid, out var appearance) | ||
|| !_appearance.TryGetData<FootPrintVisuals>(uid, FootPrintVisualState.State, out var printVisuals, appearance)) | ||
return; | ||
|
||
sprite.LayerSetState(layer, new RSI.StateId(printVisuals switch | ||
{ | ||
FootPrintVisuals.BareFootPrint => printsComponent.RightStep ? printsComponent.RightBarePrint : printsComponent.LeftBarePrint, | ||
FootPrintVisuals.ShoesPrint => printsComponent.ShoesPrint, | ||
FootPrintVisuals.SuitPrint => printsComponent.SuitPrint, | ||
FootPrintVisuals.Dragging => _random.Pick(printsComponent.DraggingPrint), | ||
_ => throw new ArgumentOutOfRangeException($"Unknown {printVisuals} parameter.") | ||
}), printsComponent.RsiPath); | ||
|
||
if (_appearance.TryGetData<Color>(uid, FootPrintVisualState.Color, out var printColor, appearance)) | ||
sprite.LayerSetColor(layer, printColor); | ||
} | ||
|
||
protected override void OnAppearanceChange (EntityUid uid, FootPrintComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite is not { } sprite) | ||
return; | ||
|
||
UpdateAppearance(uid, component, sprite); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Robust.Client.GameObjects; | ||
using static Robust.Client.GameObjects.SpriteComponent; | ||
using Content.Shared.Clothing; | ||
using Content.Shared.Hands; | ||
using Content.Shared.Paint; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Paint; | ||
|
||
public sealed class PaintedVisualizerSystem : VisualizerSystem<PaintedComponent> | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; | ||
[Dependency] private readonly IPrototypeManager _protoMan = default!; | ||
|
||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<PaintedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated); | ||
SubscribeLocalEvent<PaintedComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<PaintedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated); | ||
} | ||
|
||
|
||
protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null | ||
|| !_appearance.TryGetData(uid, PaintVisuals.Painted, out bool isPainted)) | ||
return; | ||
|
||
var shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance(); | ||
foreach (var spriteLayer in args.Sprite.AllLayers) | ||
{ | ||
if (spriteLayer is not Layer layer) | ||
continue; | ||
|
||
if (layer.Shader == null || layer.Shader == shader) | ||
{ | ||
layer.Shader = shader; | ||
layer.Color = component.Color; | ||
} | ||
} | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, PaintedComponent component, ref ComponentShutdown args) | ||
{ | ||
if (!TryComp(uid, out SpriteComponent? sprite)) | ||
return; | ||
component.BeforeColor = sprite.Color; | ||
|
||
if (Terminating(uid)) | ||
return; | ||
|
||
foreach (var spriteLayer in sprite.AllLayers) | ||
{ | ||
if (spriteLayer is not Layer layer | ||
|| layer.Shader != _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance()) | ||
continue; | ||
|
||
layer.Shader = null; | ||
if (layer.Color == component.Color) | ||
layer.Color = component.BeforeColor; | ||
} | ||
} | ||
|
||
private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args) => | ||
UpdateVisuals(component, args); | ||
private void OnEquipmentVisualsUpdated(EntityUid uid, PaintedComponent component, EquipmentVisualsUpdatedEvent args) => | ||
UpdateVisuals(component, args); | ||
private void UpdateVisuals(PaintedComponent component, EntityEventArgs args) | ||
{ | ||
var layers = new HashSet<string>(); | ||
var entity = EntityUid.Invalid; | ||
|
||
switch (args) | ||
{ | ||
case HeldVisualsUpdatedEvent hgs: | ||
layers = hgs.RevealedLayers; | ||
entity = hgs.User; | ||
break; | ||
case EquipmentVisualsUpdatedEvent eqs: | ||
layers = eqs.RevealedLayers; | ||
entity = eqs.Equipee; | ||
break; | ||
} | ||
|
||
if (layers.Count == 0 || !TryComp(entity, out SpriteComponent? sprite)) | ||
return; | ||
|
||
foreach (var revealed in layers) | ||
{ | ||
if (!sprite.LayerMapTryGet(revealed, out var layer)) | ||
continue; | ||
|
||
sprite.LayerSetShader(layer, component.ShaderName); | ||
sprite.LayerSetColor(layer, component.Color); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.