Skip to content

Commit

Permalink
Merge pull request #416 from Fansana/master
Browse files Browse the repository at this point in the history
Floof Station Release V9
  • Loading branch information
Fansana authored Dec 15, 2024
2 parents e388dac + f32ca82 commit 027c038
Show file tree
Hide file tree
Showing 209 changed files with 64,086 additions and 53,626 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ csharp_style_expression_bodied_constructors = false:suggestion
#csharp_style_expression_bodied_indexers = true:silent
#csharp_style_expression_bodied_lambdas = true:silent
#csharp_style_expression_bodied_local_functions = false:silent
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_methods = true:suggestion
#csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:suggestion

Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Clothing/ClientClothingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot
if (layerData.State is not null && inventory.SpeciesId is not null && layerData.State.EndsWith(inventory.SpeciesId))
continue;

_displacement.TryAddDisplacement(displacementData, sprite, index, key, revealedLayers);
if (_displacement.TryAddDisplacement(displacementData, sprite, index, key, revealedLayers))
index++;
}
}

Expand Down
89 changes: 89 additions & 0 deletions Content.Client/Floofstation/Leash/LeashVisualsOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.Numerics;
using Content.Shared.Floofstation.Leash.Components;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.Enums;

namespace Content.Client.Floofstation.Leash;

public sealed class LeashVisualsOverlay : Overlay
{
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;

private readonly IEntityManager _entMan;
private readonly SpriteSystem _sprites;
private readonly SharedTransformSystem _xform;
private readonly EntityQuery<TransformComponent> _xformQuery;
private readonly EntityQuery<SpriteComponent> _spriteQuery;

public LeashVisualsOverlay(IEntityManager entMan)
{
_entMan = entMan;
_sprites = _entMan.System<SpriteSystem>();
_xform = _entMan.System<SharedTransformSystem>();
_xformQuery = _entMan.GetEntityQuery<TransformComponent>();
_spriteQuery = _entMan.GetEntityQuery<SpriteComponent>();
}

protected override void Draw(in OverlayDrawArgs args)
{
var worldHandle = args.WorldHandle;
worldHandle.SetTransform(Vector2.Zero, Angle.Zero);

var query = _entMan.EntityQueryEnumerator<LeashedVisualsComponent>();
while (query.MoveNext(out var visualsComp))
{
if (visualsComp.Source is not {Valid: true} source
|| visualsComp.Target is not {Valid: true} target
|| !_xformQuery.TryGetComponent(source, out var xformComp)
|| !_xformQuery.TryGetComponent(target, out var otherXformComp)
|| xformComp.MapID != args.MapId
|| otherXformComp.MapID != xformComp.MapID)
continue;

var texture = _sprites.Frame0(visualsComp.Sprite);
var width = texture.Width / (float) EyeManager.PixelsPerMeter;

var coordsA = xformComp.Coordinates;
var coordsB = otherXformComp.Coordinates;

// If both coordinates are in the same spot (e.g. the leash is being held by the leashed), don't render anything
if (coordsA.TryDistance(_entMan, _xform, coordsB, out var dist) && dist < 0.01f)
continue;

var rotA = xformComp.LocalRotation;
var rotB = otherXformComp.LocalRotation;
var offsetA = visualsComp.OffsetSource;
var offsetB = visualsComp.OffsetTarget;

// Sprite rotation is the rotation along the Z axis
// Which is different from transform rotation for all mobs that are seen from the side (instead of top-down)
if (_spriteQuery.TryGetComponent(source, out var spriteA))
{
offsetA *= spriteA.Scale;
rotA = spriteA.Rotation;
}
if (_spriteQuery.TryGetComponent(target, out var spriteB))
{
offsetB *= spriteB.Scale;
rotB = spriteB.Rotation;
}

coordsA = coordsA.Offset(rotA.RotateVec(offsetA));
coordsB = coordsB.Offset(rotB.RotateVec(offsetB));

var posA = _xform.ToMapCoordinates(coordsA).Position;
var posB = _xform.ToMapCoordinates(coordsB).Position;
var diff = (posB - posA);
var length = diff.Length();

// So basically, we find the midpoint, then create a box that describes the sprite boundaries, then rotate it
var midPoint = diff / 2f + posA;
var angle = (posB - posA).ToWorldAngle();
var box = new Box2(-width / 2f, -length / 2f, width / 2f, length / 2f);
var rotate = new Box2Rotated(box.Translated(midPoint), angle, midPoint);

worldHandle.DrawTextureRect(texture, rotate);
}
}
}
21 changes: 21 additions & 0 deletions Content.Client/Floofstation/Leash/LeashVisualsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Client.Physics;
using Robust.Client.Graphics;

namespace Content.Client.Floofstation.Leash;

public sealed class LeashVisualsSystem : EntitySystem
{
[Dependency] private readonly IOverlayManager _overlay = default!;

public override void Initialize()
{
base.Initialize();
_overlay.AddOverlay(new LeashVisualsOverlay(EntityManager));
}

public override void Shutdown()
{
base.Shutdown();
_overlay.RemoveOverlay<LeashVisualsOverlay>();
}
}
65 changes: 65 additions & 0 deletions Content.Client/FootPrint/FootPrintsVisualizerSystem.cs
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);
}
}
6 changes: 4 additions & 2 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Orientation="Vertical">
<BoxContainer Orientation="Horizontal" Margin="0 0 0 5">
<SpriteView OverrideDirection="South" Scale="2 2" Name="SpriteView" Access="Public" SetSize="64 64" />
<TextureRect Name="NoDataTex" Access="Public" SetSize="64 64" Visible="false" Stretch="KeepAspectCentered" TexturePath="/Textures/Interface/Misc/health_analyzer_out_of_range.png"/>
<BoxContainer Margin="5 0 0 0" Orientation="Vertical" VerticalAlignment="Top">
<RichTextLabel Name="NameLabel" SetWidth="150" />
<Label Name="SpeciesLabel" VerticalAlignment="Top" StyleClasses="LabelSubText" />
Expand All @@ -35,6 +36,8 @@
<GridContainer Margin="0 5 0 0" Columns="2">
<Label Text="{Loc 'health-analyzer-window-entity-status-text'}" />
<Label Name="StatusLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-mass-text'}" />
<Label Name="MassLabel" /> <!-- Floof: Health scanners show body mass -->
<Label Text="{Loc 'health-analyzer-window-entity-temperature-text'}" />
<Label Name="TemperatureLabel" />
<Label Text="{Loc 'health-analyzer-window-entity-blood-level-text'}" />
Expand All @@ -46,8 +49,7 @@

<PanelContainer Name="AlertsDivider" Visible="False" StyleClasses="LowDivider" />

<BoxContainer Name="AlertsContainer" Visible="False" Margin="0 5" Orientation="Horizontal"
HorizontalExpand="True" HorizontalAlignment="Center">
<BoxContainer Name="AlertsContainer" Visible="False" Margin="0 5" Orientation="Vertical" HorizontalAlignment="Center">

</BoxContainer>

Expand Down
41 changes: 32 additions & 9 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
// Patient Information

SpriteView.SetEntity(target.Value);
SpriteView.Visible = msg.ScanMode.HasValue && msg.ScanMode.Value;
NoDataTex.Visible = !SpriteView.Visible;

var name = new FormattedMessage();
name.PushColor(Color.White);
Expand All @@ -89,6 +91,10 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)

// Basic Diagnostic

MassLabel.Text = !float.IsNaN(msg.Mass) // Floof: Health scanners show body mass
? $"{msg.Mass:F1} kg"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");

TemperatureLabel.Text = !float.IsNaN(msg.Temperature)
? $"{msg.Temperature - Atmospherics.T0C:F1} °C ({msg.Temperature:F1} K)"
: Loc.GetString("health-analyzer-window-entity-unknown-value-text");
Expand All @@ -108,17 +114,34 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)

// Alerts

AlertsDivider.Visible = msg.Bleeding == true;
AlertsContainer.Visible = msg.Bleeding == true;
var showAlerts = msg.Unrevivable == true || msg.Bleeding == true;

AlertsDivider.Visible = showAlerts;
AlertsContainer.Visible = showAlerts;

if (showAlerts)
AlertsContainer.DisposeAllChildren();

if (msg.Unrevivable == true) // Right now this does nothing, but we have it just for parity :)
{
var unrevivableLabel = new RichTextLabel
{
Margin = new Thickness(0, 4),
MaxWidth = 300
};
unrevivableLabel.SetMessage(Loc.GetString("health-analyzer-window-entity-unrevivable-text"), defaultColor: Color.Red);
AlertsContainer.AddChild(unrevivableLabel);
}

if (msg.Bleeding == true)
{
AlertsContainer.DisposeAllChildren();
AlertsContainer.AddChild(new Label
var bleedingLabel = new RichTextLabel
{
Text = Loc.GetString("health-analyzer-window-entity-bleeding-text"),
FontColorOverride = Color.Red,
});
Margin = new Thickness(0, 4),
MaxWidth = 300
};
bleedingLabel.SetMessage(Loc.GetString("health-analyzer-window-entity-bleeding-text"), defaultColor: Color.Red);
AlertsContainer.AddChild(bleedingLabel);
}

// Damage Groups
Expand Down Expand Up @@ -180,11 +203,11 @@ private void DrawDiagnosticGroups(

var damageString = Loc.GetString(
"health-analyzer-window-damage-type-text",
("damageType", Loc.GetString("damage-type-" + type.ToLower())),
("damageType", Loc.GetString("health-analyzer-window-damage-type-" + type)),
("amount", typeAmount)
);

groupContainer.AddChild(CreateDiagnosticItemLabel(damageString.Insert(0, "- ")));
groupContainer.AddChild(CreateDiagnosticItemLabel(damageString.Insert(0, " · ")));
}
}
}
Expand Down
Loading

0 comments on commit 027c038

Please sign in to comment.