Skip to content

Commit

Permalink
[Continous Drawing] Move Tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kaczy93 committed Nov 30, 2023
1 parent c4cfa60 commit e7f33a5
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions CentrED/Tools/MoveTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class MoveTool : Tool
private int _yDelta;

private bool _pressed;
private StaticObject _focusObject;

internal override void DrawWindow()
{
Expand Down Expand Up @@ -42,6 +41,8 @@ public override void OnMouseEnter(TileObject? o)

public override void OnMouseLeave(TileObject? o)
{
if(_pressed)
Apply(o);
if (o is StaticObject so)
{
so.Alpha = 1f;
Expand All @@ -51,20 +52,24 @@ public override void OnMouseLeave(TileObject? o)

public override void OnMousePressed(TileObject? o)
{
if (!_pressed && o is StaticObject so)
_pressed = true;
}

public override void OnMouseReleased(TileObject? o)
{
if (_pressed)
{
_pressed = true;
_focusObject = so;
Apply(o);
}
_pressed = false;
}

public override void OnMouseReleased(TileObject? o)
private void Apply(TileObject? o)
{
if (_pressed && o is StaticObject so && so == _focusObject)
if (o is StaticObject so)
{
so.StaticTile.UpdatePos
((ushort)(so.StaticTile.X + _xDelta), (ushort)(so.StaticTile.Y + _yDelta), so.StaticTile.Z);
}
_pressed = false;
}
}

0 comments on commit e7f33a5

Please sign in to comment.