Skip to content
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

Refactor abilities for characters #165

Open
cdsupina opened this issue Jun 26, 2021 · 0 comments
Open

Refactor abilities for characters #165

cdsupina opened this issue Jun 26, 2021 · 0 comments
Labels
refactoring Improvements to code/infrastructure quality

Comments

@cdsupina
Copy link
Collaborator

Refactor abilities into "trait objects" https://doc.rust-lang.org/book/ch17-02-trait-objects.html#defining-a-trait-for-common-behavior

Character components can each have an ability property containing a struct that implements the ability trait. It would resemble the following.

pub struct CharacterComponent {
    pub ability: Box<dyn Ability> ,
    ...
}

Structs implementing the ability trait could share common functions related to cooldowns and execution.

@cdsupina cdsupina added the refactoring Improvements to code/infrastructure quality label Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improvements to code/infrastructure quality
Projects
None yet
Development

No branches or pull requests

1 participant