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

Mass Engine Update #1220

Merged
merged 145 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
a502d18
Fix silver crate name.
sleepyyapril Nov 14, 2024
6e1533e
Engine update!
sleepyyapril Nov 14, 2024
37ec395
Update submodule to 228.0.0 (#29947)
metalgearsloth Jul 13, 2024
a655da9
FabricateActionEvent use EntProtoId
sleepyyapril Nov 14, 2024
f9b85b3
Wait, few too many versions ahead lmao.
sleepyyapril Nov 14, 2024
a399409
Merge branch 'Simple-Station:master' into engine-update
sleepyyapril Nov 14, 2024
9712601
229.0.0
sleepyyapril Nov 14, 2024
6fc2f07
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 14, 2024
10c9179
Wake better
sleepyyapril Nov 14, 2024
2861960
v230.0.0
sleepyyapril Nov 14, 2024
c80b52d
Use EntProtoId
sleepyyapril Nov 14, 2024
80b0d2d
More EntProtoId
sleepyyapril Nov 14, 2024
276d248
v230.2.0
sleepyyapril Nov 14, 2024
1741356
Partial buckling refactor (#29031)
ElectroJr Jun 19, 2024
c89af12
Revert "Partial buckling refactor (#29031)"
sleepyyapril Nov 14, 2024
1b1fb43
Merge branch 'master' into engine-update
sleepyyapril Nov 14, 2024
0133da8
Code cleanup: Dirty(Comp) (#26238)
Tayrtahn Mar 20, 2024
5fd6b68
aaaaaaaaa
VMSolidus Nov 15, 2024
1e0b373
Add StorageInteractionTest (#28541)
ElectroJr Jun 3, 2024
38b8b3f
Fix storage UI interactions (#28291)
ElectroJr May 26, 2024
736538e
Update SharedSingerSystem.cs
ElectroJr Jun 19, 2024
9150547
Alerts Refactor
EmoGarbage404 May 24, 2024
d6d2aeb
Partial buckling refactor (#29031)
ElectroJr Jun 19, 2024
a556466
Fix silliness, need more errors to fix...
sleepyyapril Nov 15, 2024
bee97d1
Fix usage of BuckleChangeEvent
sleepyyapril Nov 15, 2024
68b9755
Use Unbuckled
sleepyyapril Nov 15, 2024
3edbaac
AlertType usage...
sleepyyapril Nov 15, 2024
d2ebd0f
BuckledChangeEvent murder!
sleepyyapril Nov 15, 2024
cc0ce1e
Mood system updates
sleepyyapril Nov 15, 2024
cae442f
Fix yaml
sleepyyapril Nov 15, 2024
238d176
Prevent ghosts from spawning on terminating maps/grids (#28099)
Tayrtahn May 20, 2024
2230a2c
Fix unbuckling others when clicking on the strap entity (#29998)
ShadowCommander Sep 18, 2024
42c62ce
Fix unbuckling others when clicking on the strap entity (#29998)
ShadowCommander Aug 25, 2024
fe67113
Test!
sleepyyapril Nov 15, 2024
bd43299
...buckled?
sleepyyapril Nov 15, 2024
5e682c0
sigh.
sleepyyapril Nov 15, 2024
5a8b36a
What.
sleepyyapril Nov 15, 2024
85ce424
Fix unbuckling others when clicking on the strap entity (#29998)
metalgearsloth Sep 22, 2024
3323706
Buckling an entity requires a do-after (#29621)
Plykiya Aug 9, 2024
df5dbf2
Yeah
sleepyyapril Nov 15, 2024
3b0d51d
Replace IClickAlert with events (#30728)
EmoGarbage404 Aug 7, 2024
be8a62e
Hm
sleepyyapril Nov 15, 2024
10e0674
Revert "Test!"
sleepyyapril Nov 15, 2024
f173767
Revert "Hm"
sleepyyapril Nov 15, 2024
a578a26
Revert "Replace IClickAlert with events (#30728)"
sleepyyapril Nov 15, 2024
e83bab2
Revert "Yeah"
sleepyyapril Nov 15, 2024
647a333
Revert "Buckling an entity requires a do-after (#29621)"
sleepyyapril Nov 15, 2024
0592827
Revert "Fix unbuckling others when clicking on the strap entity (#299…
sleepyyapril Nov 15, 2024
94edf6e
Revert "What."
sleepyyapril Nov 15, 2024
4eb581c
Revert "sigh."
sleepyyapril Nov 15, 2024
d1080ec
Revert "...buckled?"
sleepyyapril Nov 15, 2024
3495278
Revert "Test!"
sleepyyapril Nov 15, 2024
236e78b
Merge branch 'master' into engine-update
sleepyyapril Nov 15, 2024
2f90f1f
Test!
sleepyyapril Nov 15, 2024
9e7147b
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 15, 2024
9472963
Test
sleepyyapril Nov 15, 2024
28bd70a
Sigh
sleepyyapril Nov 15, 2024
ed5385e
PrettyString
sleepyyapril Nov 15, 2024
d6b52f3
Decouple interactions from hands, cleanup old events, add new fears (…
EmoGarbage404 May 31, 2024
4d1a91b
Remove IActivate (#9705)
ElectroJr Jul 14, 2022
300645c
Test!
sleepyyapril Nov 15, 2024
3117286
Revert "Remove IActivate (#9705)"
sleepyyapril Nov 15, 2024
2e7d99c
Revert "Test!"
sleepyyapril Nov 15, 2024
f36c8eb
Revert "Decouple interactions from hands, cleanup old events, add new…
sleepyyapril Nov 15, 2024
f3d8fe4
Improve buckling's interactions with standing state (#29741)
Tayrtahn Jul 7, 2024
2ed1eeb
Please work
sleepyyapril Nov 15, 2024
7389c94
Solidus input!
sleepyyapril Nov 15, 2024
fdf18eb
Delete setDrawDepth
sleepyyapril Nov 16, 2024
d7817c0
Fix standingState being attempted to use as bool
sleepyyapril Nov 16, 2024
3acdb19
No unbuckle
sleepyyapril Nov 16, 2024
ed505c8
Switch back to old
sleepyyapril Nov 16, 2024
72dcf2c
Onto 231.0.0...
sleepyyapril Nov 16, 2024
93b2242
v232.0.0
sleepyyapril Nov 16, 2024
e2f3a84
Use SharedAppearanceSystem
sleepyyapril Nov 16, 2024
e171cb3
Try using EntityManager instead
sleepyyapril Nov 16, 2024
4f59956
Like this
VMSolidus Nov 16, 2024
0f627a0
v233.0.0
sleepyyapril Nov 16, 2024
e47827f
Fix broken tests directly mutating entities from wrong thread. (#31647)
PJB3005 Aug 31, 2024
b713374
Fix DockTest
PJB3005 Aug 31, 2024
fb4f01d
Fix test threading (#31669)
metalgearsloth Aug 31, 2024
4dabff3
Code Cleanup: Integration Tests (#29584)
Tayrtahn Jul 3, 2024
4de91ae
Fix thing!
sleepyyapril Nov 16, 2024
d0d082c
Add Job preference tests (#28625)
ElectroJr Jun 5, 2024
a7e0b97
Merge branch 'master' into engine-update
sleepyyapril Nov 16, 2024
e6b9a74
Hm
sleepyyapril Nov 16, 2024
d3dbe05
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 16, 2024
8f1269c
Revert "Add Job preference tests (#28625)"
sleepyyapril Nov 16, 2024
d755809
Remove unnecessary
sleepyyapril Nov 16, 2024
800b2ab
Attempt to fix test
sleepyyapril Nov 16, 2024
6f0bf86
Use HashSet
sleepyyapril Nov 16, 2024
d55807b
Threads suck
sleepyyapril Nov 16, 2024
e2c8751
Hm?
sleepyyapril Nov 16, 2024
7a8135e
v233.1.0?
sleepyyapril Nov 16, 2024
8b56726
v234.1.0
sleepyyapril Nov 16, 2024
e2838fd
Add FTL arrival visuals (#29402)
metalgearsloth Jul 1, 2024
6e79e54
Clean up
sleepyyapril Nov 16, 2024
eb3e124
More clean up
sleepyyapril Nov 16, 2024
5f6b4a5
More clean up v2
sleepyyapril Nov 16, 2024
319a2fb
Fix error?
sleepyyapril Nov 16, 2024
1f3e92b
"shootedCount"
sleepyyapril Nov 16, 2024
11fc763
squiggly murder
sleepyyapril Nov 16, 2024
56eb86b
Make clickable 1% nicer (#29706)
metalgearsloth Aug 9, 2024
33b30fb
Merge branch 'master' into engine-update
sleepyyapril Nov 16, 2024
6e9d053
v235 start
sleepyyapril Nov 16, 2024
98947e6
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 16, 2024
801ae49
Update submodule to 235.0.0 (#32265)
metalgearsloth Sep 18, 2024
c8d8981
Replace EntityPrototype.NoSpawn with EntityPrototype.HideSpawnMenu (#…
Plykiya Jul 16, 2024
6ca4311
Remove noSpawn: true
sleepyyapril Nov 16, 2024
7dda7f5
Remove noSpawn
sleepyyapril Nov 16, 2024
e3d7730
Use HideSpawnMenu
sleepyyapril Nov 16, 2024
1bbe344
Silence at last
sleepyyapril Nov 16, 2024
d61c5c9
I'm so good at this "fixing nullables" thing
sleepyyapril Nov 16, 2024
370ff49
audio nullables
sleepyyapril Nov 16, 2024
7c638af
Anotha
sleepyyapril Nov 16, 2024
745bd49
Revert to EE silicon.yml
sleepyyapril Nov 16, 2024
c82d6cc
v236.1.0
sleepyyapril Nov 16, 2024
f125250
v237.1.0
sleepyyapril Nov 16, 2024
65288e8
Convert rules to use guidebook parsing (#28647)
EmoGarbage404 Jun 6, 2024
5e204fe
Add Flash using
sleepyyapril Nov 17, 2024
bdd5ac4
Update rules (#28452)
Chief-Engineer Jun 5, 2024
8fb9bf5
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
sleepyyapril Nov 17, 2024
579d867
Entity Tables (EntitySpawnEntry replacement) (#30579)
EmoGarbage404 Aug 10, 2024
3b17c73
hm
sleepyyapril Nov 17, 2024
d0c5645
move gamerule components to shared (#28572)
deltanedas Jun 4, 2024
3814ae3
Yippee
sleepyyapril Nov 17, 2024
5b0fec2
hm
sleepyyapril Nov 17, 2024
ca621c8
Usings
sleepyyapril Nov 17, 2024
9ad3858
Remove unadded items
sleepyyapril Nov 17, 2024
b80967b
hm yes
sleepyyapril Nov 17, 2024
022d694
hm
sleepyyapril Nov 17, 2024
774a4aa
hm
sleepyyapril Nov 17, 2024
fb75168
oh
sleepyyapril Nov 17, 2024
9633217
Hm
sleepyyapril Nov 17, 2024
3d6789b
hm
sleepyyapril Nov 17, 2024
6c51961
s
sleepyyapril Nov 17, 2024
68b0702
ConstantNumberSelectorrr!
sleepyyapril Nov 17, 2024
fd825a5
Remove crimes
sleepyyapril Nov 17, 2024
810fd39
Update default.toml
sleepyyapril Nov 17, 2024
985669b
Fix lying down
sleepyyapril Nov 17, 2024
7bc03d9
Now fixed
sleepyyapril Nov 17, 2024
194a17d
Merge branch 'engine-update' of https://github.com/sleepyyapril/Einst…
sleepyyapril Nov 17, 2024
840561e
Fix buckling
sleepyyapril Nov 17, 2024
8d91604
Already buckled
sleepyyapril Nov 17, 2024
9eb63d9
Try 2
sleepyyapril Nov 17, 2024
3b3511f
Fix formatting in HumanoidCharacterProfile
sleepyyapril Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Content.Client/Alerts/ClientAlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void OnPlayerDetached(EntityUid uid, AlertsComponent component, LocalPla
ClearAlerts?.Invoke(this, EventArgs.Empty);
}

public void AlertClicked(AlertType alertType)
public void AlertClicked(ProtoId<AlertPrototype> alertType)
{
RaiseNetworkEvent(new ClickAlertEvent(alertType));
}
Expand Down
6 changes: 5 additions & 1 deletion Content.Client/Audio/AmbientSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ private void ProcessNearbyAmbience(TransformComponent playerXform)
.WithMaxDistance(comp.Range);

var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams);
_playingSounds[comp] = (stream.Value.Entity, comp.Sound, key);

if (stream == null)
continue;

_playingSounds[comp] = (stream!.Value.Entity, comp.Sound, key);
playingCount++;

if (_playingSounds.Count >= _maxAmbientCount)
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Audio/ClientGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void PlayAdminSound(AdminSoundEvent soundEvent)
if(!_adminAudioEnabled) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_adminAudio.Add(stream.Value.Entity);
_adminAudio.Add(stream!.Value.Entity);
}

private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
Expand All @@ -76,7 +76,7 @@ private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream.Value.Entity);
_eventAudio.Add(soundEvent.Type, stream!.Value.Entity);
}

private void PlayGameSound(GameGlobalSoundEvent soundEvent)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void UpdateAmbientMusic()
track.ToString(),
Filter.Local(),
false,
AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider));
AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider))!;

_ambientMusicStream = strim.Value.Entity;

Expand Down
6 changes: 5 additions & 1 deletion Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ private void PlaySoundtrack(string soundtrackFilename)
false,
_lobbySoundtrackParams.WithVolume(_lobbySoundtrackParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
);
if (playResult.Value.Entity == default)

if (playResult == null)
return;

if (playResult!.Value.Entity == default)
{
_sawmill.Warning(
$"Tried to play lobby soundtrack '{{Filename}}' using {nameof(SharedAudioSystem)}.{nameof(SharedAudioSystem.PlayGlobal)} but it returned default value of EntityUid!",
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
152 changes: 12 additions & 140 deletions Content.Client/Clickable/ClickableComponent.cs
Original file line number Diff line number Diff line change
@@ -1,145 +1,17 @@
using System.Numerics;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Utility;
using Robust.Shared.Graphics;
using static Robust.Client.GameObjects.SpriteComponent;
using Direction = Robust.Shared.Maths.Direction;
namespace Content.Client.Clickable;

namespace Content.Client.Clickable
[RegisterComponent]
public sealed partial class ClickableComponent : Component
{
[RegisterComponent]
public sealed partial class ClickableComponent : Component
{
[Dependency] private readonly IClickMapManager _clickMapManager = default!;

[DataField("bounds")] public DirBoundData? Bounds;

/// <summary>
/// Used to check whether a click worked. Will first check if the click falls inside of some explicit bounding
/// boxes (see <see cref="Bounds"/>). If that fails, attempts to use automatically generated click maps.
/// </summary>
/// <param name="worldPos">The world position that was clicked.</param>
/// <param name="drawDepth">
/// The draw depth for the sprite that captured the click.
/// </param>
/// <returns>True if the click worked, false otherwise.</returns>
public bool CheckClick(SpriteComponent sprite, TransformComponent transform, EntityQuery<TransformComponent> xformQuery, Vector2 worldPos, IEye eye, out int drawDepth, out uint renderOrder, out float bottom)
{
if (!sprite.Visible)
{
drawDepth = default;
renderOrder = default;
bottom = default;
return false;
}

drawDepth = sprite.DrawDepth;
renderOrder = sprite.RenderOrder;
var (spritePos, spriteRot) = transform.GetWorldPositionRotation(xformQuery);
var spriteBB = sprite.CalculateRotatedBoundingBox(spritePos, spriteRot, eye.Rotation);
bottom = Matrix3Helpers.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;

Matrix3x2.Invert(sprite.GetLocalMatrix(), out var invSpriteMatrix);

// This should have been the rotation of the sprite relative to the screen, but this is not the case with no-rot or directional sprites.
var relativeRotation = (spriteRot + eye.Rotation).Reduced().FlipPositive();

Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero;

// First we get `localPos`, the clicked location in the sprite-coordinate frame.
var entityXform = Matrix3Helpers.CreateInverseTransform(transform.WorldPosition, sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
var localPos = Vector2.Transform(Vector2.Transform(worldPos, entityXform), invSpriteMatrix);

// Check explicitly defined click-able bounds
if (CheckDirBound(sprite, relativeRotation, localPos))
return true;

// Next check each individual sprite layer using automatically computed click maps.
foreach (var spriteLayer in sprite.AllLayers)
{
if (!spriteLayer.Visible || spriteLayer is not Layer layer)
continue;

// Check the layer's texture, if it has one
if (layer.Texture != null)
{
// Convert to image coordinates
var imagePos = (Vector2i) (localPos * EyeManager.PixelsPerMeter * new Vector2(1, -1) + layer.Texture.Size / 2f);

if (_clickMapManager.IsOccluding(layer.Texture, imagePos))
return true;
}

// Either we weren't clicking on the texture, or there wasn't one. In which case: check the RSI next
if (layer.ActualRsi is not { } rsi || !rsi.TryGetState(layer.State, out var rsiState))
continue;

var dir = Layer.GetDirection(rsiState.RsiDirections, relativeRotation);
[DataField] public DirBoundData? Bounds;

// convert to layer-local coordinates
layer.GetLayerDrawMatrix(dir, out var matrix);
Matrix3x2.Invert(matrix, out var inverseMatrix);
var layerLocal = Vector2.Transform(localPos, inverseMatrix);

// Convert to image coordinates
var layerImagePos = (Vector2i) (layerLocal * EyeManager.PixelsPerMeter * new Vector2(1, -1) + rsiState.Size / 2f);

// Next, to get the right click map we need the "direction" of this layer that is actually being used to draw the sprite on the screen.
// This **can** differ from the dir defined before, but can also just be the same.
if (sprite.EnableDirectionOverride)
dir = sprite.DirectionOverride.Convert(rsiState.RsiDirections);
dir = dir.OffsetRsiDir(layer.DirOffset);

if (_clickMapManager.IsOccluding(layer.ActualRsi!, layer.State, dir, layer.AnimationFrame, layerImagePos))
return true;
}

drawDepth = default;
renderOrder = default;
bottom = default;
return false;
}

public bool CheckDirBound(SpriteComponent sprite, Angle relativeRotation, Vector2 localPos)
{
if (Bounds == null)
return false;

// These explicit bounds only work for either 1 or 4 directional sprites.

// This would be the orientation of a 4-directional sprite.
var direction = relativeRotation.GetCardinalDir();

var modLocalPos = sprite.NoRotation
? localPos
: direction.ToAngle().RotateVec(localPos);

// First, check the bounding box that is valid for all orientations
if (Bounds.All.Contains(modLocalPos))
return true;

// Next, get and check the appropriate bounding box for the current sprite orientation
var boundsForDir = (sprite.EnableDirectionOverride ? sprite.DirectionOverride : direction) switch
{
Direction.East => Bounds.East,
Direction.North => Bounds.North,
Direction.South => Bounds.South,
Direction.West => Bounds.West,
_ => throw new InvalidOperationException()
};

return boundsForDir.Contains(modLocalPos);
}

[DataDefinition]
public sealed partial class DirBoundData
{
[DataField("all")] public Box2 All;
[DataField("north")] public Box2 North;
[DataField("south")] public Box2 South;
[DataField("east")] public Box2 East;
[DataField("west")] public Box2 West;
}
[DataDefinition]
public sealed partial class DirBoundData
{
[DataField] public Box2 All;
[DataField] public Box2 North;
[DataField] public Box2 South;
[DataField] public Box2 East;
[DataField] public Box2 West;
}
}
Loading
Loading