Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move parts of SpriteComponent to SpriteSystem #5602

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
428173d
Partial sprite component ECS
ElectroJr Jan 12, 2025
1d117ca
release notes
ElectroJr Jan 12, 2025
86dfefa
Merge branch 'master' of https://github.com/space-wizards/RobustToolb…
ElectroJr Jan 13, 2025
47940dc
tests
ElectroJr Jan 13, 2025
1eef1aa
Why
ElectroJr Jan 13, 2025
1b61680
SetSnapCardinals
ElectroJr Jan 13, 2025
62c7f5f
NoRotation
ElectroJr Jan 13, 2025
81b0145
DirectionOverride
ElectroJr Jan 13, 2025
e7f3970
This is why I love distinct overrides that take in object
ElectroJr Jan 13, 2025
8cb2283
LayerSetData
ElectroJr Jan 13, 2025
33d3b7e
ISerializationHooks continue to haunt me
ElectroJr Jan 13, 2025
3b31b49
Relocate SetShader
ElectroJr Jan 13, 2025
d14931c
LayerSetSprite
ElectroJr Jan 13, 2025
1484d43
LayerSetTexture
ElectroJr Jan 13, 2025
7212a20
yipeeeee
ElectroJr Jan 13, 2025
ba54d92
LayerSetRsi
ElectroJr Jan 13, 2025
5111655
Remove GetFallbackState
ElectroJr Jan 13, 2025
2c8a421
LayerSet Scale,Rotation,Color,Visible
ElectroJr Jan 13, 2025
5b39b2d
Fix LayerSetRsi
ElectroJr Jan 13, 2025
e34ae6c
LayerSetOffset
ElectroJr Jan 13, 2025
3209113
LayerSetDirOffset
ElectroJr Jan 13, 2025
4059cfa
Add overrides that take in a Layer
ElectroJr Jan 13, 2025
35d1798
LayerSetAnimationTime
ElectroJr Jan 13, 2025
299ae1c
LayerSetRenderingStrategy
ElectroJr Jan 13, 2025
2eb303c
Reduce Resolves, Add Layer.Index
ElectroJr Jan 13, 2025
5bc336b
Access
ElectroJr Jan 13, 2025
c3ec771
Try fix NREs
ElectroJr Jan 13, 2025
954c3bb
Asserts
ElectroJr Jan 13, 2025
5955933
LayerGetState
ElectroJr Jan 14, 2025
d717172
Cleanup
ElectroJr Jan 14, 2025
4a2b3ee
Merge helper partial classes
ElectroJr Jan 14, 2025
517b262
partial rendering
ElectroJr Jan 14, 2025
9681e08
GetLayerDirectionCount
ElectroJr Jan 14, 2025
09aa985
Cache local bounds
ElectroJr Jan 14, 2025
0a2753f
RenderLayer
ElectroJr Jan 14, 2025
6a2b369
RefreshCachedState
ElectroJr Jan 14, 2025
d268a1c
RoundToCardinalAngle
ElectroJr Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ END TEMPLATE-->

### Other

*None yet*
* Several SpriteComponent methods have been marked as obsolete, and should be replaced with new methods in SpriteSystem.

### Internal

Expand Down
28 changes: 8 additions & 20 deletions Robust.Client/ComponentTrees/SpriteTreeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,15 @@
using Robust.Client.GameObjects;
using Robust.Shared.ComponentTrees;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Physics;

namespace Robust.Client.ComponentTrees;

public sealed class SpriteTreeSystem : ComponentTreeSystem<SpriteTreeComponent, SpriteComponent>
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SpriteComponent, QueueSpriteTreeUpdateEvent>(OnQueueUpdate);
}

private void OnQueueUpdate(EntityUid uid, SpriteComponent component, ref QueueSpriteTreeUpdateEvent args)
=> QueueTreeUpdate(uid, component, args.Xform);

// TODO remove this when finally ECSing sprite components
[ByRefEvent]
internal readonly struct QueueSpriteTreeUpdateEvent
{
public readonly TransformComponent Xform;
public QueueSpriteTreeUpdateEvent(TransformComponent xform)
{
Xform = xform;
}
}
[Dependency] private readonly SpriteSystem _sprite = default!;

#region Component Tree Overrides
protected override bool DoFrameUpdate => true;
Expand All @@ -36,6 +19,11 @@ public QueueSpriteTreeUpdateEvent(TransformComponent xform)
protected override int InitialCapacity => 1024;

protected override Box2 ExtractAabb(in ComponentTreeEntry<SpriteComponent> entry, Vector2 pos, Angle rot)
=> entry.Component.CalculateRotatedBoundingBox(pos, rot, default).CalcBoundingBox();
{
// TODO SPRITE optimize this
// Because the just take the BB of the rotated BB, I'mt pretty sure we do a lot of unnecessary maths.
return _sprite.CalculateBounds((entry.Uid, entry.Component), pos, rot, default).CalcBoundingBox();
}

#endregion
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Robust.Shared.GameObjects;
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;

namespace Robust.Client.GameObjects
{
[Obsolete]
public partial interface IRenderableComponent : IComponent
{
int DrawDepth { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Numerics;
using Robust.Client.Graphics;
using Robust.Shared.Graphics;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Maths;

Expand Down
Loading
Loading