Skip to content

Commit

Permalink
Merge branch 'master' into translate-upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay authored Nov 13, 2024
2 parents 403876a + 4dc38ac commit e26baed
Show file tree
Hide file tree
Showing 227 changed files with 17,929 additions and 4,954 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,4 @@ Resources/MapImages

# Direnv stuff
.direnv/
.idea/
33 changes: 25 additions & 8 deletions Content.Client/Vampire/VampireSystem.cs
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}");
}
}
17 changes: 17 additions & 0 deletions Content.Client/_Sunrise/ChoiceControl.xaml
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>
27 changes: 27 additions & 0 deletions Content.Client/_Sunrise/ChoiceControl.xaml.cs
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 Content.Client/_Sunrise/Footprints/FootPrintsVisualizerSystem.cs
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);
}
}
Loading

0 comments on commit e26baed

Please sign in to comment.