Skip to content

Commit

Permalink
Merge pull request #2317 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Jun 21, 2024
2 parents fd7c530 + c3221e3 commit a1a46cf
Show file tree
Hide file tree
Showing 444 changed files with 4,674 additions and 2,597 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/rsi-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ jobs:

- name: Get changed files
id: files
uses: Ana06/get-changed-files@v1.2
uses: Ana06/get-changed-files@v2.3.0
with:
format: 'space-delimited'
filter: |
**.rsi
**.png
- name: Diff changed RSIs
id: diff
Expand Down
66 changes: 45 additions & 21 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Buckle.Components;
using Content.Shared.Rotation;
using Robust.Client.GameObjects;
using Robust.Shared.GameStates;

namespace Content.Client.Buckle;

Expand All @@ -14,40 +15,63 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BuckleComponent, AfterAutoHandleStateEvent>(OnBuckleAfterAutoHandleState);
SubscribeLocalEvent<BuckleComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<BuckleComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
}

private void OnBuckleAfterAutoHandleState(EntityUid uid, BuckleComponent component, ref AfterAutoHandleStateEvent args)
private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveEvent args)
{
ActionBlocker.UpdateCanMove(uid);
// I'm moving this to the client-side system, but for the sake of posterity let's keep this comment:
// > This is mega cursed. Please somebody save me from Mr Buckle's wild ride

if (!TryComp<SpriteComponent>(uid, out var ownerSprite))
// The nice thing is its still true, this is quite cursed, though maybe not omega cursed anymore.
// This code is garbage, it doesn't work with rotated viewports. I need to finally get around to reworking
// sprite rendering for entity layers & direction dependent sorting.

if (args.NewRotation == args.OldRotation)
return;

// Adjust draw depth when the chair faces north so that the seat back is drawn over the player.
// Reset the draw depth when rotated in any other direction.
// TODO when ECSing, make this a visualizer
// This code was written before rotatable viewports were introduced, so hard-coding Direction.North
// and comparing it against LocalRotation now breaks this in other rotations. This is a FIXME, but
// better to get it working for most people before we look at a more permanent solution.
if (component is { Buckled: true, LastEntityBuckledTo: { } } &&
Transform(component.LastEntityBuckledTo.Value).LocalRotation.GetCardinalDir() == Direction.North &&
TryComp<SpriteComponent>(component.LastEntityBuckledTo, out var buckledSprite))
{
component.OriginalDrawDepth ??= ownerSprite.DrawDepth;
ownerSprite.DrawDepth = buckledSprite.DrawDepth - 1;
if (!TryComp<SpriteComponent>(uid, out var strapSprite))
return;
}

// If here, we're not turning north and should restore the saved draw depth.
if (component.OriginalDrawDepth.HasValue)
var isNorth = Transform(uid).LocalRotation.GetCardinalDir() == Direction.North;
foreach (var buckledEntity in component.BuckledEntities)
{
ownerSprite.DrawDepth = component.OriginalDrawDepth.Value;
component.OriginalDrawDepth = null;
if (!TryComp<BuckleComponent>(buckledEntity, out var buckle))
continue;

if (!TryComp<SpriteComponent>(buckledEntity, out var buckledSprite))
continue;

if (isNorth)
{
buckle.OriginalDrawDepth ??= buckledSprite.DrawDepth;
buckledSprite.DrawDepth = strapSprite.DrawDepth - 1;
}
else if (buckle.OriginalDrawDepth.HasValue)
{
buckledSprite.DrawDepth = buckle.OriginalDrawDepth.Value;
buckle.OriginalDrawDepth = null;
}
}
}

private void OnHandleState(Entity<BuckleComponent> ent, ref ComponentHandleState args)
{
if (args.Current is not BuckleState state)
return;

ent.Comp.DontCollide = state.DontCollide;
ent.Comp.BuckleTime = state.BuckleTime;
var strapUid = EnsureEntity<BuckleComponent>(state.BuckledTo, ent);

SetBuckledTo(ent, strapUid == null ? null : new (strapUid.Value, null));

var (uid, component) = ent;

}

private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref AppearanceChangeEvent args)
{
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals))
Expand Down
19 changes: 19 additions & 0 deletions Content.Client/Clothing/Systems/PilotedByClothingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Content.Shared.Clothing.Components;
using Robust.Client.Physics;

namespace Content.Client.Clothing.Systems;

public sealed partial class PilotedByClothingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<PilotedByClothingComponent, UpdateIsPredictedEvent>(OnUpdatePredicted);
}

private void OnUpdatePredicted(Entity<PilotedByClothingComponent> entity, ref UpdateIsPredictedEvent args)
{
args.BlockPrediction = true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Content.Shared.DeviceNetwork.Systems;

namespace Content.Client.DeviceNetwork.Systems;

/// <inheritdoc/>
public sealed class DeviceNetworkJammerSystem : SharedDeviceNetworkJammerSystem;
68 changes: 35 additions & 33 deletions Content.Client/Effects/ColorFlashEffectSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
using Robust.Shared.Collections;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.Effects;

public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
[Dependency] private readonly IComponentFactory _factory = default!;

/// <summary>
/// It's a little on the long side but given we use multiple colours denoting what happened it makes it easier to register.
/// </summary>
private const float AnimationLength = 0.30f;
private const string AnimationKey = "color-flash-effect";
private ValueList<EntityUid> _toRemove = new();

public override void Initialize()
{
Expand All @@ -44,8 +46,28 @@ private void OnEffectAnimationCompleted(EntityUid uid, ColorFlashEffectComponent
{
sprite.Color = component.Color;
}
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = AllEntityQuery<ColorFlashEffectComponent>();
_toRemove.Clear();

// Can't use deferred removal on animation completion or it will cause issues.
while (query.MoveNext(out var uid, out _))
{
if (_animation.HasRunningAnimation(uid, AnimationKey))
continue;

RemCompDeferred<ColorFlashEffectComponent>(uid);
_toRemove.Add(uid);
}

foreach (var ent in _toRemove)
{
RemComp<ColorFlashEffectComponent>(ent);
}
}

private Animation? GetDamageAnimation(EntityUid uid, Color color, SpriteComponent? sprite = null)
Expand Down Expand Up @@ -82,51 +104,31 @@ private void OnColorFlashEffect(ColorFlashEffectEvent ev)
{
var ent = GetEntity(nent);

if (Deleted(ent))
if (Deleted(ent) || !TryComp(ent, out SpriteComponent? sprite))
{
continue;
}

if (!TryComp(ent, out AnimationPlayerComponent? player))
{
player = (AnimationPlayerComponent) _factory.GetComponent(typeof(AnimationPlayerComponent));
player.Owner = ent;
player.NetSyncEnabled = false;
AddComp(ent, player);
}

// Need to stop the existing animation first to ensure the sprite color is fixed.
// Otherwise we might lerp to a red colour instead.
if (_animation.HasRunningAnimation(ent, player, AnimationKey))
{
_animation.Stop(ent, player, AnimationKey);
}

if (!TryComp<SpriteComponent>(ent, out var sprite))
{
continue;
}

if (TryComp<ColorFlashEffectComponent>(ent, out var effect))
if (!TryComp(ent, out ColorFlashEffectComponent? comp))
{
sprite.Color = effect.Color;
#if DEBUG
DebugTools.Assert(!_animation.HasRunningAnimation(ent, AnimationKey));
#endif
}

_animation.Stop(ent, AnimationKey);
var animation = GetDamageAnimation(ent, color, sprite);

if (animation == null)
continue;

if (!TryComp(ent, out ColorFlashEffectComponent? comp))
{
comp = (ColorFlashEffectComponent) _factory.GetComponent(typeof(ColorFlashEffectComponent));
comp.Owner = ent;
comp.NetSyncEnabled = false;
AddComp(ent, comp);
continue;
}

EnsureComp<ColorFlashEffectComponent>(ent, out comp);
comp.NetSyncEnabled = false;
comp.Color = sprite.Color;
_animation.Play((ent, player), animation, AnimationKey);

_animation.Play(ent, animation, AnimationKey);
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Gravity/FloatingVisualizerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ private void OnAnimationCompleted(EntityUid uid, FloatingVisualsComponent compon
if (args.Key != component.AnimationKey)
return;

FloatAnimation(uid, component.Offset, component.AnimationKey, component.AnimationTime, !component.CanFloat);
FloatAnimation(uid, component.Offset, component.AnimationKey, component.AnimationTime, stop: !component.CanFloat);
}
}
2 changes: 1 addition & 1 deletion Content.Client/Interaction/DragDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ private void RemoveHighlights()
// CanInteract() doesn't support checking a second "target" entity.
// Doing so manually:
var ev = new GettingInteractedWithAttemptEvent(user, dragged);
RaiseLocalEvent(dragged, ev, true);
RaiseLocalEvent(dragged, ref ev);

if (ev.Cancelled)
return false;
Expand Down
26 changes: 14 additions & 12 deletions Content.Client/Lathe/UI/LatheMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@
Margin="5 0 0 0"
Text="{Loc 'lathe-menu-fabricating-message'}">
</Label>
<TextureRect
Name="Icon"
HorizontalExpand="True"
SizeFlagsStretchRatio="2"
Margin="100 0 0 0">
</TextureRect>
<EntityPrototypeView
Name="FabricatingEntityProto"
HorizontalAlignment="Left"
Margin="100 0 0 0"
/>
<Label
Name="NameLabel"
RectClipContent="True"
Expand All @@ -114,12 +113,15 @@
</Label>
</PanelContainer>
</BoxContainer>
<ItemList
Name="QueueList"
VerticalExpand="True"
SizeFlagsStretchRatio="3"
SelectMode="None">
</ItemList>
<ScrollContainer VerticalExpand="True" HScrollEnabled="False">
<BoxContainer
Name="QueueList"
Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
RectClipContent="True">
</BoxContainer>
</ScrollContainer>
</BoxContainer>
<BoxContainer
VerticalExpand="True"
Expand Down
43 changes: 21 additions & 22 deletions Content.Client/Lathe/UI/LatheMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ public LatheMenu(LatheBoundUserInterface owner)
/// </summary>
public void PopulateRecipes()
{
if (!_entityManager.TryGetComponent<LatheComponent>(_owner, out var component))
return;

var recipesToShow = new List<LatheRecipePrototype>();
foreach (var recipe in Recipes)
{
Expand Down Expand Up @@ -108,21 +105,13 @@ public void PopulateRecipes()
RecipeList.Children.Clear();
foreach (var prototype in sortedRecipesToShow)
{
List<Texture> textures;
EntityPrototype? recipeProto = null;
if (_prototypeManager.TryIndex(prototype.Result, out EntityPrototype? entityProto) && entityProto != null)
{
textures = SpriteComponent.GetPrototypeTextures(entityProto, _resources).Select(o => o.Default).ToList();
}
else
{
textures = prototype.Icon == null
? new List<Texture> { _spriteSystem.GetPrototypeIcon(prototype.Result).Default }
: new List<Texture> { _spriteSystem.Frame0(prototype.Icon) };
}
recipeProto = entityProto;

var canProduce = _lathe.CanProduce(_owner, prototype, quantity);

var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, textures);
var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, recipeProto);
control.OnButtonPressed += s =>
{
if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount <= 0)
Expand Down Expand Up @@ -219,14 +208,23 @@ public void UpdateCategories()
/// <param name="queue"></param>
public void PopulateQueueList(List<LatheRecipePrototype> queue)
{
QueueList.Clear();
QueueList.DisposeAllChildren();

var idx = 1;
foreach (var recipe in queue)
{
var icon = recipe.Icon == null
? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
: _spriteSystem.Frame0(recipe.Icon);
QueueList.AddItem($"{idx}. {recipe.Name}", icon);
var queuedRecipeBox = new BoxContainer();
queuedRecipeBox.Orientation = BoxContainer.LayoutOrientation.Horizontal;

var queuedRecipeProto = new EntityPrototypeView();
if (_prototypeManager.TryIndex(recipe.Result, out EntityPrototype? entityProto) && entityProto != null)
queuedRecipeProto.SetPrototype(entityProto);

var queuedRecipeLabel = new Label();
queuedRecipeLabel.Text = $"{idx}. {recipe.Name}";
queuedRecipeBox.AddChild(queuedRecipeProto);
queuedRecipeBox.AddChild(queuedRecipeLabel);
QueueList.AddChild(queuedRecipeBox);
idx++;
}
}
Expand All @@ -236,9 +234,10 @@ public void SetQueueInfo(LatheRecipePrototype? recipe)
FabricatingContainer.Visible = recipe != null;
if (recipe == null)
return;
Icon.Texture = recipe.Icon == null
? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
: _spriteSystem.Frame0(recipe.Icon);

if (_prototypeManager.TryIndex(recipe.Result, out EntityPrototype? entityProto) && entityProto != null)
FabricatingEntityProto.SetPrototype(entityProto);

NameLabel.Text = $"{recipe.Name}";
}

Expand Down
Loading

0 comments on commit a1a46cf

Please sign in to comment.