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:
ShadowCommander
2022-01-17 18:02:20 -08:00
committed by GitHub
parent 76b4455053
commit 7d30bff5ea
2 changed files with 35 additions and 25 deletions

View File

@@ -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;
/// <summary>
/// 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)