Skip to content

Commit

Permalink
Merge pull request #402 from Mnemotechnician/floof/feat/partial-merge…
Browse files Browse the repository at this point in the history
…-2024-12-04

Partial Merge Up to 2024-11-17
  • Loading branch information
Fansana authored Dec 15, 2024
2 parents 0d35854 + 33f8509 commit b48a44e
Show file tree
Hide file tree
Showing 165 changed files with 63,468 additions and 53,462 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
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);
}
}
4 changes: 2 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 @@ -46,8 +47,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
37 changes: 28 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 Down Expand Up @@ -108,17 +110,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 +199,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
101 changes: 101 additions & 0 deletions Content.Client/Paint/PaintVisualizerSystem.cs
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);
}
}
}
19 changes: 8 additions & 11 deletions Content.Server/AutoVote/AutoVoteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,15 @@ public override void Initialize()
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
}

public void OnReturnedToLobby(RoundRestartCleanupEvent ev)
{
CallAutovote();
}
public void OnReturnedToLobby(RoundRestartCleanupEvent ev) => CallAutovote();

public void OnPlayerJoinedLobby(PlayerJoinedLobbyEvent ev)
{
if (_shouldVoteNextJoin)
{
CallAutovote();
_shouldVoteNextJoin = false;
}
if (!_shouldVoteNextJoin)
return;

CallAutovote();
_shouldVoteNextJoin = false;
}

private void CallAutovote()
Expand All @@ -50,8 +47,8 @@ private void CallAutovote()
}

if (_cfg.GetCVar(CCVars.MapAutoVoteEnabled))
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
if (_cfg.GetCVar(CCVars.PresetAutoVoteEnabled))
_voteManager.CreateStandardVote(null, StandardVoteType.Map);
if (_cfg.GetCVar(CCVars.PresetAutoVoteEnabled))
_voteManager.CreateStandardVote(null, StandardVoteType.Preset);
}
}
6 changes: 5 additions & 1 deletion Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -963,14 +963,18 @@ public string WrapMessage(LocId wrapId, InGameICChatType chatType, EntityUid sou
var color = DefaultSpeakColor;
if (language.SpeechOverride.Color is { } colorOverride)
color = Color.InterpolateBetween(color, colorOverride, colorOverride.A);
var languageDisplay = language.IsVisibleLanguage
? $"{language.ChatName} | "
: "";

return Loc.GetString(wrapId,
("color", color),
("entityName", entityName),
("verb", Loc.GetString(verbId)),
("fontType", language.SpeechOverride.FontId ?? speech.FontId),
("fontSize", language.SpeechOverride.FontSize ?? speech.FontSize),
("message", message));
("message", message),
("language", languageDisplay));
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null,
else
{
_xformSystem.AttachToGridOrMap(entity, xform);
var direction = holder.CurrentDirection == Direction.Invalid ? holder.PreviousDirection : holder.CurrentDirection;

if (holder.PreviousDirection != Direction.Invalid && gridUid != null && _xformQuery.TryGetComponent(gridUid, out var parentXform))
if (direction != Direction.Invalid && _xformQuery.TryGetComponent(gridUid, out var gridXform))
{
var direction = holder.CurrentDirection.ToAngle();
direction += _xformSystem.GetWorldRotation(parentXform);
_throwing.TryThrow(entity, direction.ToWorldVec() * 3f, 10f);
var directionAngle = direction.ToAngle();
directionAngle += _xformSystem.GetWorldRotation(gridXform);
_throwing.TryThrow(entity, directionAngle.ToWorldVec() * 3f, 10f);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Content.Server/Dragon/DragonRiftSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public override void Update(float frameTime)
comp.State = DragonRiftState.AlmostFinished;
Dirty(comp);

var location = xform.LocalPosition;
_announcer.SendAnnouncement(_announcer.GetAnnouncementId("CarpRift"), Filter.Broadcast(),
"carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", location));
"carp-rift-warning", colorOverride: Color.Red, localeArgs: ("location", FormattedMessage.RemoveMarkupPermissive(_navMap.GetNearestBeaconString((uid, xform)))));
_navMap.SetBeaconEnabled(uid, true);
}

Expand Down
Loading

0 comments on commit b48a44e

Please sign in to comment.