From 7d30bff5ea7e08866ba01eed6582ee395051edee Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Mon, 17 Jan 2022 18:02:20 -0800 Subject: [PATCH] Temp fix table clickable bounds (#6206) * Temp fix table clickable bounds * Fix single instance clickable data * Consolidate table clickable bounds --- .../Clickable/ClickableComponent.cs | 57 +++++++++++-------- .../Furniture/Tables/base_structuretables.yml | 3 + 2 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Content.Client/Clickable/ClickableComponent.cs b/Content.Client/Clickable/ClickableComponent.cs index aebb464c3f..6744a819ba 100644 --- a/Content.Client/Clickable/ClickableComponent.cs +++ b/Content.Client/Clickable/ClickableComponent.cs @@ -18,7 +18,7 @@ namespace Content.Client.Clickable [Dependency] private readonly IClickMapManager _clickMapManager = default!; - [ViewVariables] [DataField("bounds")] private DirBoundData _data = DirBoundData.Default; + [ViewVariables] [DataField("bounds")] private DirBoundData? _data; /// /// Used to check whether a click worked. @@ -47,34 +47,41 @@ namespace Content.Client.Clickable var found = false; var worldRotation = transform.WorldRotation; - if (_data.All.Contains(localPos)) + if (_data != null) { - found = true; - } - else - { - // TODO: diagonal support? - - var modAngle = sprite.NoRotation ? SpriteComponent.CalcRectWorldAngle(worldRotation, 4) : Angle.Zero; - var dir = sprite.EnableDirectionOverride ? sprite.DirectionOverride : worldRotation.GetCardinalDir(); - - modAngle += dir.ToAngle(); - - var layerPos = modAngle.RotateVec(localPos); - - var boundsForDir = dir switch - { - Direction.East => _data.East, - Direction.North => _data.North, - Direction.South => _data.South, - Direction.West => _data.West, - _ => throw new InvalidOperationException() - }; - - if (boundsForDir.Contains(layerPos)) + if (_data.All.Contains(localPos)) { found = true; } + else + { + // TODO: diagonal support? + + var modAngle = sprite.NoRotation + ? SpriteComponent.CalcRectWorldAngle(worldRotation, 4) + : Angle.Zero; + var dir = sprite.EnableDirectionOverride + ? sprite.DirectionOverride + : worldRotation.GetCardinalDir(); + + modAngle += dir.ToAngle(); + + var layerPos = modAngle.RotateVec(localPos); + + var boundsForDir = dir switch + { + Direction.East => _data.East, + Direction.North => _data.North, + Direction.South => _data.South, + Direction.West => _data.West, + _ => throw new InvalidOperationException() + }; + + if (boundsForDir.Contains(layerPos)) + { + found = true; + } + } } if (!found) diff --git a/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml b/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml index 3c0f3b9b47..2d4ad9fa4d 100644 --- a/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml +++ b/Resources/Prototypes/Entities/Structures/Furniture/Tables/base_structuretables.yml @@ -17,3 +17,6 @@ key: state base: state_ - type: Climbable + - type: Clickable + bounds: + all: "-0.5,-0.5,0.5,0.5"