-
Notifications
You must be signed in to change notification settings - Fork 139
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
Introduce entity animations #806
Open
RoyalMCPE
wants to merge
7
commits into
df-mc:master
Choose a base branch
from
MCApocalypse:feature/animations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
115bf76
Base animation footprint
RoyalMCPE 097e867
Add support for stop conditions
RoyalMCPE 08df7d8
Document stop condition methods
RoyalMCPE afe4f9f
viewer.go: Cleanup ViewEntityAnimation signature
RoyalMCPE fb518b1
session\world.go: Leave StopConditionVersion as it's default
RoyalMCPE 6c8fe33
animation.go: Rename variable to be more descriptive
RoyalMCPE 06bedd9
world.go: Rename PlayAnimation -> AnimateEntity
RoyalMCPE 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 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,61 @@ | ||
package animation | ||
|
||
// Animation represents an animation & controller that may be attached to an entity. | ||
// Animations and controllers must be defined in a resource pack | ||
type Animation struct { | ||
name, state, controller string | ||
stopCondition string | ||
} | ||
|
||
// New returns a new animation that can be attached to an entity. By default no controller or state is sent to the viewer. | ||
// To add a state and controller use WithController and WithState respectively. | ||
func New(animationName string) Animation { | ||
return Animation{ | ||
name: animationName, | ||
state: "", | ||
controller: "", | ||
stopCondition: "", | ||
} | ||
} | ||
|
||
// Name returns the name of the animation to be played | ||
func (a Animation) Name() string { | ||
return a.name | ||
} | ||
|
||
// WithController sets the controller with the specified state. | ||
// The controller must be added in a resource pack | ||
func (a Animation) WithController(controller string) Animation { | ||
a.controller = controller | ||
return a | ||
} | ||
|
||
// Controller returns the name of the controller being used. Controller returns an empty string if | ||
// no controller was previously set | ||
func (a Animation) Controller() string { | ||
return a.controller | ||
} | ||
|
||
// WithState sets the state to transition to as defined in the controller. | ||
func (a Animation) WithState(state string) Animation { | ||
a.state = state | ||
return a | ||
} | ||
|
||
// State returns the current state being played. State returns an empty string if | ||
// no controller was previously set | ||
func (a Animation) State() string { | ||
return a.state | ||
} | ||
|
||
// WithStopCondition takes the molang expression and stops the animation if the query passes. | ||
func (a Animation) WithStopCondition(condition string) Animation { | ||
a.stopCondition = condition | ||
return a | ||
} | ||
|
||
// StopCondition returns the stop condition. StopCondition returns an empty string if | ||
// no molang expression was set | ||
func (a Animation) StopCondition() string { | ||
return a.stopCondition | ||
} |
This file contains 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.