Skip to content

Commit

Permalink
Fixed moved cell not showing if no cell to place type was selected (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyyrylainen authored Oct 31, 2024
1 parent 3050b5c commit 947309c
Showing 1 changed file with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,34 +259,48 @@ public override void _Process(double delta)
}

// Show the cell that is about to be placed
if (activeActionName != null && Editor.ShowHover)
if (Editor.ShowHover)
{
GetMouseHex(out int q, out int r);

var effectiveSymmetry = Symmetry;

var cellType = CellTypeFromName(activeActionName);
CellType? cellType = null;

if (MovingPlacedHex == null)
if (MovingPlacedHex == null && activeActionName != null)
{
cellType = CellTypeFromName(activeActionName);

// Can place stuff at all?
// TODO: should placementRotation be used here in some way?
isPlacementProbablyValid = IsValidPlacement(new HexWithData<CellTemplate>(new CellTemplate(cellType))
{
Position = new Hex(q, r),
});
}
else
else if (MovingPlacedHex != null)
{
isPlacementProbablyValid = IsMoveTargetValid(new Hex(q, r), placementRotation, MovingPlacedHex);

if (MovingPlacedHex.Data != null)
{
cellType = MovingPlacedHex.Data.CellType;
}
else
{
GD.PrintErr("Moving placed hex has no cell data");
}

if (!Settings.Instance.MoveOrganellesWithSymmetry)
effectiveSymmetry = HexEditorSymmetry.None;
}

RunWithSymmetry(q, r,
(finalQ, finalR, rotation) => RenderHighlightedCell(finalQ, finalR, rotation, cellType),
effectiveSymmetry);
if (cellType != null)
{
RunWithSymmetry(q, r,
(finalQ, finalR, rotation) => RenderHighlightedCell(finalQ, finalR, rotation, cellType),
effectiveSymmetry);
}
}
else if (forceUpdateCellGraphics)
{
Expand Down

0 comments on commit 947309c

Please sign in to comment.