-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into translate-upstream
- Loading branch information
Showing
227 changed files
with
17,929 additions
and
4,954 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 |
---|---|---|
|
@@ -306,3 +306,4 @@ Resources/MapImages | |
|
||
# Direnv stuff | ||
.direnv/ | ||
.idea/ |
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,25 +1,42 @@ | ||
using System.Linq; | ||
using Content.Client.Alerts; | ||
using Content.Client.UserInterface.Systems.Alerts.Controls; | ||
using Content.Shared.StatusIcon; | ||
using Content.Shared.StatusIcon.Components; | ||
using Content.Shared.Vampire; | ||
using Content.Shared.Vampire.Components; | ||
using Content.Shared.StatusIcon.Components; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Vampire; | ||
|
||
public sealed partial class VampireSystem : EntitySystem | ||
public sealed class VampireSystem : EntitySystem | ||
{ | ||
|
||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<VampireComponent, GetStatusIconsEvent>(GetVampireIcon); | ||
SubscribeLocalEvent<VampireIconComponent, GetStatusIconsEvent>(GetVampireIcon); | ||
SubscribeLocalEvent<VampireAlertComponent, UpdateAlertSpriteEvent>(OnUpdateAlert); | ||
} | ||
|
||
private void GetVampireIcon(Entity<VampireComponent> ent, ref GetStatusIconsEvent args) | ||
{ | ||
var iconPrototype = _prototype.Index(ent.Comp.StatusIcon); | ||
private void GetVampireIcon(EntityUid uid, VampireIconComponent component, ref GetStatusIconsEvent args) | ||
{ | ||
var iconPrototype = _prototype.Index(component.StatusIcon); | ||
args.StatusIcons.Add(iconPrototype); | ||
} | ||
|
||
private void OnUpdateAlert(EntityUid uid, VampireAlertComponent component, ref UpdateAlertSpriteEvent args) | ||
{ | ||
if (args.Alert.ID != component.BloodAlert) | ||
return; | ||
|
||
var sprite = args.SpriteViewEnt.Comp; | ||
var blood = Math.Clamp(component.BloodAmount, 0, 999); | ||
sprite.LayerSetState(VampireVisualLayers.Digit1, $"{(blood / 100) % 10}"); | ||
sprite.LayerSetState(VampireVisualLayers.Digit2, $"{(blood / 10) % 10}"); | ||
sprite.LayerSetState(VampireVisualLayers.Digit3, $"{blood % 10}"); | ||
} | ||
} |
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,17 @@ | ||
<ui:ChoiceControl | ||
xmlns="https://spacestation14.io" | ||
xmlns:ui="clr-namespace:Content.Client._Sunrise"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Button Name="Button" Access="Public" | ||
HorizontalExpand="True" VerticalExpand="False" | ||
StyleClasses="ButtonSquare" Margin="0"> | ||
<BoxContainer Orientation="Horizontal" Margin="0"> | ||
<TextureRect Name="Texture" Access="Public" | ||
HorizontalExpand="False" VerticalExpand="False" | ||
Margin="1"/> | ||
<Control MinWidth="5"/> | ||
<RichTextLabel Name="NameLabel" Access="Public" VerticalAlignment="Center"/> | ||
</BoxContainer> | ||
</Button> | ||
</BoxContainer> | ||
</ui:ChoiceControl> |
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,27 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Utility; | ||
// Taken from RMC14 build. | ||
// https://github.com/RMC-14/RMC-14 | ||
namespace Content.Client._Sunrise; | ||
|
||
[GenerateTypedNameReferences] | ||
[Virtual] | ||
public partial class ChoiceControl : Control | ||
{ | ||
public ChoiceControl() => RobustXamlLoader.Load(this); | ||
|
||
public void Set(string name, Texture? texture) | ||
{ | ||
NameLabel.SetMessage(name); | ||
Texture.Texture = texture; | ||
} | ||
|
||
public void Set(FormattedMessage msg, Texture? texture) | ||
{ | ||
NameLabel.SetMessage(msg); | ||
Texture.Texture = texture; | ||
} | ||
} |
148 changes: 148 additions & 0 deletions
148
Content.Client/_Sunrise/Footprints/FootPrintsVisualizerSystem.cs
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,148 @@ | ||
using Content.Shared._Sunrise.Footprints; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Client._Sunrise.Footprints; | ||
|
||
/// <summary> | ||
/// Handles the visual appearance and updates of footprint entities on the client | ||
/// </summary> | ||
public sealed class FootprintVisualizerSystem : VisualizerSystem<FootprintComponent> | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<FootprintComponent, ComponentInit>(OnFootprintInitialized); | ||
SubscribeLocalEvent<FootprintComponent, ComponentShutdown>(OnFootprintShutdown); | ||
} | ||
|
||
/// <summary> | ||
/// Initializes the visual appearance of a new footprint | ||
/// </summary> | ||
private void OnFootprintInitialized(EntityUid uid, FootprintComponent component, ComponentInit args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
InitializeSpriteLayers(sprite); | ||
UpdateFootprintVisuals(uid, component, sprite); | ||
} | ||
|
||
/// <summary> | ||
/// Cleans up the visual elements when a footprint is removed | ||
/// </summary> | ||
private void OnFootprintShutdown(EntityUid uid, FootprintComponent component, ComponentShutdown args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
RemoveSpriteLayers(sprite); | ||
} | ||
|
||
/// <summary> | ||
/// Sets up the initial sprite layers for the footprint | ||
/// </summary> | ||
private void InitializeSpriteLayers(SpriteComponent sprite) | ||
{ | ||
sprite.LayerMapReserveBlank(FootprintSpriteLayer.MainLayer); | ||
} | ||
|
||
/// <summary> | ||
/// Removes sprite layers when cleaning up footprint | ||
/// </summary> | ||
private void RemoveSpriteLayers(SpriteComponent sprite) | ||
{ | ||
if (sprite.LayerMapTryGet(FootprintSpriteLayer.MainLayer, out var layer)) | ||
{ | ||
sprite.RemoveLayer(layer); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Updates the visual appearance of a footprint based on its current state | ||
/// </summary> | ||
private void UpdateFootprintVisuals(EntityUid uid, FootprintComponent footprint, SpriteComponent sprite) | ||
{ | ||
if (!sprite.LayerMapTryGet(FootprintSpriteLayer.MainLayer, out var layer) | ||
|| !TryComp<FootprintEmitterComponent>(footprint.CreatorEntity, out var emitterComponent) | ||
|| !TryComp<AppearanceComponent>(uid, out var appearance)) | ||
return; | ||
|
||
if (!_appearanceSystem.TryGetData<FootprintVisualType>( | ||
uid, | ||
FootprintVisualParameter.VisualState, | ||
out var visualType, | ||
appearance)) | ||
return; | ||
|
||
UpdateSpriteState(sprite, layer, visualType, emitterComponent); | ||
UpdateSpriteColor(sprite, layer, uid, appearance); | ||
} | ||
|
||
/// <summary> | ||
/// Updates the sprite state based on the footprint type | ||
/// </summary> | ||
private void UpdateSpriteState( | ||
SpriteComponent sprite, | ||
int layer, | ||
FootprintVisualType visualType, | ||
FootprintEmitterComponent emitter) | ||
{ | ||
var stateId = new RSI.StateId(GetStateId(visualType, emitter)); | ||
sprite.LayerSetState(layer, stateId, emitter.SpritePath); | ||
} | ||
|
||
/// <summary> | ||
/// Determines the appropriate state ID for the footprint based on its type | ||
/// </summary> | ||
private string GetStateId(FootprintVisualType visualType, FootprintEmitterComponent emitter) | ||
{ | ||
return visualType switch | ||
{ | ||
FootprintVisualType.BareFootprint => emitter.IsRightStep | ||
? emitter.RightBareFootState | ||
: emitter.LeftBareFootState, | ||
FootprintVisualType.ShoeFootprint => emitter.ShoeFootState, | ||
FootprintVisualType.SuitFootprint => emitter.PressureSuitFootState, | ||
FootprintVisualType.DragMark => _random.Pick(emitter.DraggingStates), | ||
_ => throw new ArgumentOutOfRangeException( | ||
$"Unknown footprint visual type: {visualType}") | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Updates the sprite color based on appearance data | ||
/// </summary> | ||
private void UpdateSpriteColor( | ||
SpriteComponent sprite, | ||
int layer, | ||
EntityUid uid, | ||
AppearanceComponent appearance) | ||
{ | ||
if (_appearanceSystem.TryGetData<Color>(uid, | ||
FootprintVisualParameter.TrackColor, | ||
out var color, | ||
appearance)) | ||
{ | ||
sprite.LayerSetColor(layer, color); | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void OnAppearanceChange( | ||
EntityUid uid, | ||
FootprintComponent component, | ||
ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite is not { } sprite) | ||
return; | ||
|
||
UpdateFootprintVisuals(uid, component, sprite); | ||
} | ||
} |
Oops, something went wrong.