Temp fix table clickable bounds (#6206)
* Temp fix table clickable bounds * Fix single instance clickable data * Consolidate table clickable bounds
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Content.Client.Clickable
|
|||||||
|
|
||||||
[Dependency] private readonly IClickMapManager _clickMapManager = default!;
|
[Dependency] private readonly IClickMapManager _clickMapManager = default!;
|
||||||
|
|
||||||
[ViewVariables] [DataField("bounds")] private DirBoundData _data = DirBoundData.Default;
|
[ViewVariables] [DataField("bounds")] private DirBoundData? _data;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to check whether a click worked.
|
/// Used to check whether a click worked.
|
||||||
@@ -47,34 +47,41 @@ namespace Content.Client.Clickable
|
|||||||
var found = false;
|
var found = false;
|
||||||
var worldRotation = transform.WorldRotation;
|
var worldRotation = transform.WorldRotation;
|
||||||
|
|
||||||
if (_data.All.Contains(localPos))
|
if (_data != null)
|
||||||
{
|
{
|
||||||
found = true;
|
if (_data.All.Contains(localPos))
|
||||||
}
|
|
||||||
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;
|
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)
|
if (!found)
|
||||||
|
|||||||
@@ -17,3 +17,6 @@
|
|||||||
key: state
|
key: state
|
||||||
base: state_
|
base: state_
|
||||||
- type: Climbable
|
- type: Climbable
|
||||||
|
- type: Clickable
|
||||||
|
bounds:
|
||||||
|
all: "-0.5,-0.5,0.5,0.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user