Skip to content

Commit

Permalink
Script API: added Object.DestinationX/Y, complement Character's props
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Nov 3, 2024
1 parent 3971f6b commit 8ab7534
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Editor/AGS.Editor/Resources/agsdefns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,12 @@ builtin managed struct Object {
/// Gets the script name of this object.
import readonly attribute String ScriptName;
#endif // SCRIPT_API_v361
#ifdef SCRIPT_API_v362
/// Gets the X coordinate of the object's final moving destination; or current position if object is not moving.
readonly import attribute int DestinationX;
/// Gets the Y coordinate of the object's final moving destination; or current position if object is not moving.
readonly import attribute int DestinationY;
#endif
int reserved[2]; // $AUTOCOMPLETEIGNORE$
};
Expand Down Expand Up @@ -2871,9 +2877,9 @@ builtin managed struct Character {
import bool IsInteractionAvailable(CursorMode);
/// Sets the individual light level for this character.
import function SetLightLevel(int light_level);
/// Gets the X position this character is currently moving towards.
/// Gets the X coordinate of the character's final moving destination; or current position if character is not moving.
readonly import attribute int DestinationX;
/// Gets the Y position this character is currently moving towards.
/// Gets the Y coordinate of the character's final moving destination; or current position if character is not moving.
readonly import attribute int DestinationY;
#endif // SCRIPT_API_v340
#ifdef SCRIPT_API_v341
Expand Down
38 changes: 38 additions & 0 deletions Engine/ac/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,32 @@ int Object_GetClickable(ScriptObject *objj) {
return 1;
}

int Object_GetDestinationX(ScriptObject *objj)
{
if (!is_valid_object(objj->id))
quit("!Object.DestionationX: Invalid object specified");

if (objs[objj->id].moving)
{
MoveList *cmls = &mls[objs[objj->id].moving];
return cmls->pos.back().X;
}
return objs[objj->id].x;
}

int Object_GetDestinationY(ScriptObject *objj)
{
if (!is_valid_object(objj->id))
quit("!Object.DestionationX: Invalid object specified");

if (objs[objj->id].moving)
{
MoveList *cmls = &mls[objs[objj->id].moving];
return cmls->pos.back().Y;
}
return objs[objj->id].y;
}

void Object_SetManualScaling(ScriptObject *objj, bool on)
{
if (on) objs[objj->id].flags &= ~OBJF_USEROOMSCALING;
Expand Down Expand Up @@ -1031,6 +1057,16 @@ RuntimeScriptValue Sc_Object_SetClickable(void *self, const RuntimeScriptValue *
API_OBJCALL_VOID_PINT(ScriptObject, Object_SetClickable);
}

RuntimeScriptValue Sc_Object_GetDestinationX(void *self, const RuntimeScriptValue *params, int32_t param_count)
{
API_OBJCALL_INT(ScriptObject, Object_GetDestinationX);
}

RuntimeScriptValue Sc_Object_GetDestinationY(void *self, const RuntimeScriptValue *params, int32_t param_count)
{
API_OBJCALL_INT(ScriptObject, Object_GetDestinationY);
}

// int (ScriptObject *objj)
RuntimeScriptValue Sc_Object_GetFrame(void *self, const RuntimeScriptValue *params, int32_t param_count)
{
Expand Down Expand Up @@ -1230,6 +1266,8 @@ void RegisterObjectAPI()
{ "Object::set_BlockingWidth", API_FN_PAIR(Object_SetBlockingWidth) },
{ "Object::get_Clickable", API_FN_PAIR(Object_GetClickable) },
{ "Object::set_Clickable", API_FN_PAIR(Object_SetClickable) },
{ "Object::get_DestinationX", API_FN_PAIR(Object_GetDestinationX) },
{ "Object::get_DestinationY", API_FN_PAIR(Object_GetDestinationY) },
{ "Object::get_Frame", API_FN_PAIR(Object_GetFrame) },
{ "Object::get_Graphic", API_FN_PAIR(Object_GetGraphic) },
{ "Object::set_Graphic", API_FN_PAIR(Object_SetGraphic) },
Expand Down

0 comments on commit 8ab7534

Please sign in to comment.