AGS 4: implement MotionPath script API #2687
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #2685
This exposes MoveList functionality into the script.
Initially thought to call this MovePath, but MovePath name is taken by a function name in Character and Object, so I came with MotionPath. This object replicates internal MoveList struct, which defines a state of moving along the path following certain rules, such as direction and repeat style.
Here's the MotionPath declaration, as you may notice it's pretty expansive:
MotionPath is constructed from a path of points, movement speeds and few optional parameters.
For each pair of points there's a speed vector built.
Stage means a state of traversion from point A to point B. Here in this API StageX/Y mean the stage's start position.
Progress is a fraction of current stage passed, a float in the range of [0, 1). When the progress reaches 1.0, the Stage counter updates.
When the last Stage is reached, MotionPath either marks itself as "Completed" or, if told to Repeat, resets to the beginning of the path.
Here in this API I added 3 functions that control the state of movement: StepForward increments progress by +1.0, StepBack decrements it by -1.0, Reset allows to set any stage and in-stage progress (but these values are clamped to existing limits).
I.e. calling Reset(2, 0.5) would reset it to the middle of the third stage.
Following is an example of using MotionPath in order to move Overlay:
TODO:
This is a draft for now, because following planned parts have not been implemented yet: