forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
620 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,83 @@ | ||
using Content.Shared.Body.Systems; | ||
using Content.Shared.Body.Part; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Humanoid.Markings; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Utility; | ||
using Content.Shared.Body.Components; | ||
|
||
namespace Content.Client.Body.Systems; | ||
|
||
public sealed class BodySystem : SharedBodySystem | ||
{ | ||
[Dependency] private readonly MarkingManager _markingManager = default!; | ||
|
||
private void ApplyMarkingToPart(MarkingPrototype markingPrototype, | ||
IReadOnlyList<Color>? colors, | ||
bool visible, | ||
SpriteComponent sprite) | ||
{ | ||
for (var j = 0; j < markingPrototype.Sprites.Count; j++) | ||
{ | ||
var markingSprite = markingPrototype.Sprites[j]; | ||
|
||
if (markingSprite is not SpriteSpecifier.Rsi rsi) | ||
{ | ||
continue; | ||
} | ||
|
||
var layerId = $"{markingPrototype.ID}-{rsi.RsiState}"; | ||
|
||
if (!sprite.LayerMapTryGet(layerId, out _)) | ||
{ | ||
var layer = sprite.AddLayer(markingSprite, j + 1); | ||
sprite.LayerMapSet(layerId, layer); | ||
sprite.LayerSetSprite(layerId, rsi); | ||
} | ||
|
||
sprite.LayerSetVisible(layerId, visible); | ||
|
||
if (!visible) | ||
{ | ||
continue; | ||
} | ||
|
||
// Okay so if the marking prototype is modified but we load old marking data this may no longer be valid | ||
// and we need to check the index is correct. | ||
// So if that happens just default to white? | ||
if (colors != null && j < colors.Count) | ||
{ | ||
sprite.LayerSetColor(layerId, colors[j]); | ||
} | ||
else | ||
{ | ||
sprite.LayerSetColor(layerId, Color.White); | ||
} | ||
} | ||
} | ||
|
||
protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceComponent component) | ||
{ | ||
if (!TryComp(target, out SpriteComponent? sprite)) | ||
return; | ||
|
||
if (component.Color != null) | ||
sprite.Color = component.Color.Value; | ||
|
||
foreach (var (visualLayer, markingList) in component.Markings) | ||
{ | ||
foreach (var marking in markingList) | ||
{ | ||
if (!_markingManager.TryGetMarking(marking, out var markingPrototype)) | ||
continue; | ||
|
||
ApplyMarkingToPart(markingPrototype, marking.MarkingColors, marking.Visible, sprite); | ||
} | ||
} | ||
} | ||
|
||
protected override void RemovePartMarkings(EntityUid target, BodyPartAppearanceComponent partAppearance, HumanoidAppearanceComponent bodyAppearance) | ||
{ | ||
return; | ||
} | ||
} |
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
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.