Files
dl_old/dl/misc/dl_component_use.cpp
T
2025-05-12 16:08:48 +08:00

39 lines
610 B
C++

#include "dl_component_use.h"
#include "io/dl_input.h"
namespace dl
{
namespace Cpt
{
void Drag::Update(Coor* coor, bool is_pickup)
{
_posMove = {};
if (_state == 0)
{
if (g_input->KeyDown(MouseCode::LEFT))
{
if (is_pickup)
{
_state = 1;
_posClick = coor->WorldToThis(toPosition(g_input->GetCursorPosition()));
}
}
}
else
{
if (g_input->KeyUp(MouseCode::LEFT))
{
_state = 0;
}
else
{
Position pos = coor->WorldToThis(toPosition(g_input->GetCursorPosition()));
_posMove = pos - _posClick;
coor->DtPosition(_posMove);
}
}
}
}
}