-
Notifications
You must be signed in to change notification settings - Fork 158
world/viewer.go: Allow for more complex entity animations to be played #940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| package world | ||
|
|
||
| // EntityAnimation represents an animation that may be played on an entity from an active resource pack on | ||
| // the client. | ||
| type EntityAnimation struct { | ||
| name string | ||
| nextState string | ||
| controller string | ||
| stopCondition string | ||
| } | ||
|
|
||
| // NewEntityAnimation returns a new animation that can be played on an entity. If no controller or stop | ||
| // condition is set, the animation will play for its full duration, including looping. Controllers can be set | ||
| // to manage multiple states of animations. It is also possible to use vanilla animations/controllers if they | ||
| // work for your entity, i.e. "animation.pig.baby_transform". | ||
| func NewEntityAnimation(name string) EntityAnimation { | ||
| return EntityAnimation{name: name} | ||
| } | ||
|
|
||
| // Name returns the name of the animation to be played. | ||
| func (a EntityAnimation) Name() string { | ||
| return a.name | ||
| } | ||
|
|
||
| // Controller returns the name of the controller to be used for the animation. | ||
| func (a EntityAnimation) Controller() string { | ||
| return a.controller | ||
| } | ||
|
|
||
| // WithController returns a copy of the EntityAnimation with the provided animation controller. An animation | ||
| // controller with the same name must be defined in a resource pack for it to work. | ||
| func (a EntityAnimation) WithController(controller string) EntityAnimation { | ||
| a.controller = controller | ||
| return a | ||
| } | ||
|
|
||
| // NextState returns the state to transition to after the animation has finished playing within the | ||
DaPigGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // animation controller. | ||
| func (a EntityAnimation) NextState() string { | ||
| return a.nextState | ||
| } | ||
|
|
||
| // WithNextState returns a copy of the EntityAnimation with the provided state to transition to after the | ||
| // animation has finished playing within the animation controller. | ||
| func (a EntityAnimation) WithNextState(state string) EntityAnimation { | ||
| a.nextState = state | ||
| return a | ||
| } | ||
|
|
||
| // StopCondition returns the condition that must be met for the animation to stop playing. This is often | ||
| // a Molang expression that can be used to query various entity properties to determine when the animation | ||
| // should stop playing. | ||
| func (a EntityAnimation) StopCondition() string { | ||
| return a.stopCondition | ||
| } | ||
|
|
||
| // WithStopCondition returns a copy of the EntityAnimation with the provided stop condition. The stop condition | ||
| // is a Molang expression that can be used to query various entity properties to determine when the animation | ||
| // should stop playing. | ||
| func (a EntityAnimation) WithStopCondition(condition string) EntityAnimation { | ||
| a.stopCondition = condition | ||
| return a | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.