forked from Mirrors/openclonk
Object movement in editor respects Def->HorizontalFix and attachment procedure.
When moving attached objects, it will now move the attachment target along with the object. This makes moving elevator cases and wind generators a lot easier.issue1247
parent
cf9aca70fe
commit
2cde706611
|
@ -1204,6 +1204,20 @@ C4ControlEMMoveObject::~C4ControlEMMoveObject()
|
|||
delete [] pObjects; pObjects = NULL;
|
||||
}
|
||||
|
||||
void C4ControlEMMoveObject::MoveObject(C4Object *moved_object) const
|
||||
{
|
||||
// move given object by this->tx/ty and do callbacks
|
||||
if (!moved_object || !moved_object->Status) return;
|
||||
int32_t old_x = moved_object->GetX(), old_y = moved_object->GetY();
|
||||
C4Real tx = this->tx;
|
||||
if (moved_object->Def->NoHorizontalMove) tx = Fix0;
|
||||
moved_object->ForcePosition(moved_object->fix_x + tx, moved_object->fix_y + ty);
|
||||
moved_object->xdir = moved_object->ydir = 0;
|
||||
moved_object->Mobile = false;
|
||||
C4AulParSet pars(C4VInt(old_x), C4VInt(old_y));
|
||||
moved_object->Call(PSF_EditCursorMoved, &pars);
|
||||
}
|
||||
|
||||
void C4ControlEMMoveObject::Execute() const
|
||||
{
|
||||
bool fLocalCall = LocalControl();
|
||||
|
@ -1218,12 +1232,16 @@ void C4ControlEMMoveObject::Execute() const
|
|||
if ((pObj = ::Objects.SafeObjectPointer(pObjects[i])))
|
||||
if (pObj->Status)
|
||||
{
|
||||
int32_t old_x = pObj->GetX(), old_y = pObj->GetY();
|
||||
pObj->ForcePosition(pObj->fix_x+tx,pObj->fix_y+ty);
|
||||
pObj->xdir=pObj->ydir=0;
|
||||
pObj->Mobile = false;
|
||||
C4AulParSet pars(C4VInt(old_x), C4VInt(old_y));
|
||||
pObj->Call(PSF_EditCursorMoved, &pars);
|
||||
MoveObject(pObj);
|
||||
// attached objects: Also move attachment target
|
||||
while (pObj->GetProcedure() == DFA_ATTACH)
|
||||
{
|
||||
pObj = pObj->Action.Target;
|
||||
if (!pObj) break; // leftover action cancelled next frame
|
||||
for (int j = 0; j < iObjectNum; ++j) if (pObjects[j] == pObj->Number) { pObj = NULL; break; } // ensure we aren't moving twice
|
||||
if (!pObj) break;
|
||||
MoveObject(pObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -469,6 +469,8 @@ protected:
|
|||
int32_t iObjectNum; // number of objects moved
|
||||
int32_t *pObjects; // pointer on array of objects moved
|
||||
StdStrBuf StringParam; // script to execute, or ID of object to create
|
||||
private:
|
||||
void MoveObject(C4Object *moved_object) const;
|
||||
public:
|
||||
DECLARE_C4CONTROL_VIRTUALS
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue