Implement stop, threadmove and moveoffset
Some checks failed
Build branch / build-all (push) Failing after 24s
CodeQL / Analyze (push) Has been cancelled

This commit is contained in:
smallmodel 2025-02-15 14:39:54 +01:00
parent 68181acec7
commit 22b593215f
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 57 additions and 2 deletions

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2023 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.
@ -69,6 +69,22 @@ Event EV_ScriptSlave_WaitMove
"Move the script slave and wait until finished.", "Move the script slave and wait until finished.",
EV_NORMAL EV_NORMAL
); );
Event EV_ScriptSlave_Stop
(
"stop",
EV_DEFAULT,
NULL,
NULL,
"Stop the script slave."
);
Event EV_ScriptSlave_ThreadMove
(
"threadmove",
EV_DEFAULT,
"s",
"label",
"Move the script slave and create thread which waits until finished."
);
Event EV_ScriptSlave_Angles Event EV_ScriptSlave_Angles
( (
"angles", "angles",
@ -222,6 +238,15 @@ Event EV_ScriptSlave_MoveRight
"Move the position right.", "Move the position right.",
EV_NORMAL EV_NORMAL
); );
Event EV_ScriptSlave_MoveOffset
(
"moveOffset",
EV_DEFAULT,
"v",
"dist",
"Move the position by the offset vector.",
EV_NORMAL
);
Event EV_ScriptSlave_RotateXDownTo Event EV_ScriptSlave_RotateXDownTo
( (
"rotateXdownto", "rotateXdownto",
@ -609,6 +634,8 @@ CLASS_DECLARATION(Mover, ScriptSlave, "script_object") {
{&EV_Unbind, &ScriptSlave::EventUnbind }, {&EV_Unbind, &ScriptSlave::EventUnbind },
{&EV_ScriptSlave_DoMove, &ScriptSlave::DoMove }, {&EV_ScriptSlave_DoMove, &ScriptSlave::DoMove },
{&EV_ScriptSlave_WaitMove, &ScriptSlave::WaitMove }, {&EV_ScriptSlave_WaitMove, &ScriptSlave::WaitMove },
{&EV_ScriptSlave_Stop, &ScriptSlave::Stop },
{&EV_ScriptSlave_ThreadMove, &ScriptSlave::ThreadMove },
{&EV_ScriptSlave_Angles, &ScriptSlave::SetAnglesEvent }, {&EV_ScriptSlave_Angles, &ScriptSlave::SetAnglesEvent },
{&EV_SetAngle, &ScriptSlave::SetAngleEvent }, {&EV_SetAngle, &ScriptSlave::SetAngleEvent },
{&EV_Model, &ScriptSlave::SetModelEvent }, {&EV_Model, &ScriptSlave::SetModelEvent },
@ -628,6 +655,7 @@ CLASS_DECLARATION(Mover, ScriptSlave, "script_object") {
{&EV_ScriptSlave_MoveBackward, &ScriptSlave::MoveBackward }, {&EV_ScriptSlave_MoveBackward, &ScriptSlave::MoveBackward },
{&EV_ScriptSlave_MoveLeft, &ScriptSlave::MoveLeft }, {&EV_ScriptSlave_MoveLeft, &ScriptSlave::MoveLeft },
{&EV_ScriptSlave_MoveRight, &ScriptSlave::MoveRight }, {&EV_ScriptSlave_MoveRight, &ScriptSlave::MoveRight },
{&EV_ScriptSlave_MoveOffset, &ScriptSlave::MoveOffset },
{&EV_ScriptSlave_RotateXDownTo, &ScriptSlave::RotateXdownto }, {&EV_ScriptSlave_RotateXDownTo, &ScriptSlave::RotateXdownto },
{&EV_ScriptSlave_RotateYDownTo, &ScriptSlave::RotateYdownto }, {&EV_ScriptSlave_RotateYDownTo, &ScriptSlave::RotateYdownto },
{&EV_ScriptSlave_RotateZDownTo, &ScriptSlave::RotateZdownto }, {&EV_ScriptSlave_RotateZDownTo, &ScriptSlave::RotateZdownto },
@ -818,6 +846,24 @@ void ScriptSlave::WaitMove(Event *ev)
Register(0, Director.CurrentScriptThread()); Register(0, Director.CurrentScriptThread());
} }
void ScriptSlave::Stop(Event *ev)
{
commandswaiting = false;
if (RegisterSize(0)) {
Event newev(EV_DelayThrow);
newev.AddConstString(STRING_FAIL);
BroadcastEvent(0, newev);
}
Mover::Stop();
}
void ScriptSlave::ThreadMove(Event *ev)
{
NewMove();
Register(0, CreateThreadInternal(ev->GetValue(1)));
}
void ScriptSlave::MoveEnd(Event *ev) void ScriptSlave::MoveEnd(Event *ev)
{ {
Unregister(0); Unregister(0);
@ -1082,6 +1128,12 @@ void ScriptSlave::MoveRight(Event *ev)
NewPos -= v * ev->GetFloat(1); NewPos -= v * ev->GetFloat(1);
} }
void ScriptSlave::MoveOffset(Event *ev)
{
CheckNewOrders();
NewPos += ev->GetVector(1);
}
// exact rotate commands // exact rotate commands
void ScriptSlave::RotateXdownto(Event *ev) void ScriptSlave::RotateXdownto(Event *ev)

View file

@ -1,6 +1,6 @@
/* /*
=========================================================================== ===========================================================================
Copyright (C) 2023 the OpenMoHAA team Copyright (C) 2025 the OpenMoHAA team
This file is part of OpenMoHAA source code. This file is part of OpenMoHAA source code.
@ -93,6 +93,8 @@ protected:
void EventUnbind(Event *ev); void EventUnbind(Event *ev);
void DoMove(Event *ev); void DoMove(Event *ev);
void WaitMove(Event *ev); void WaitMove(Event *ev);
void Stop(Event *ev);
void ThreadMove(Event *ev);
void MoveEnd(Event *ev); void MoveEnd(Event *ev);
void SetAnglesEvent(Event *ev); void SetAnglesEvent(Event *ev);
void SetAngleEvent(Event *ev); void SetAngleEvent(Event *ev);
@ -113,6 +115,7 @@ protected:
void MoveBackward(Event *ev); void MoveBackward(Event *ev);
void MoveLeft(Event *ev); void MoveLeft(Event *ev);
void MoveRight(Event *ev); void MoveRight(Event *ev);
void MoveOffset(Event *ev);
void RotateXdownto(Event *ev); void RotateXdownto(Event *ev);
void RotateYdownto(Event *ev); void RotateYdownto(Event *ev);
void RotateZdownto(Event *ev); void RotateZdownto(Event *ev);