High-Level Entity Methods (WIP) - #397
Draft
caelunshun wants to merge 1 commit into
Draft
caelunshun wants to merge 1 commit into
caelunshun wants to merge 1 commit into
Conversation
caelunshun
marked this pull request as draft
March 9, 2021 04:02
Defman
reviewed
Mar 9, 2021
Defman
left a comment
Member
There was a problem hiding this comment.
Hmm I feel like this hides which components you are querying, could we maybe create the QueryFrom struct via a query! macro.
let query = query! {
_: &PlayerMarker,
health: &mut Health,
position: &mut Position,
gamemode: &Gamemode,
_: MessageReciver,
}| impl crate::entity::FromQuery for $wrapper_struct { | ||
| type Item = Self; | ||
|
|
||
| fn add_component_types(components: &mut impl Extend<crate::HostComponent>) { |
Member
There was a problem hiding this comment.
Hmm, $wrapper_struct can only contain a single component or are $marker going to become $($marker:ident),*?
| Q: FromQuery, | ||
| { | ||
| pub(crate) fn new() -> Self { | ||
| let mut component_types = Vec::new(); |
Member
There was a problem hiding this comment.
Should this maybe not be a set, since FromQuery can have overlapping components?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR aims to create a framework for high-level entity methods like "get item in main hand," "deal damage," "send message," etc. These methods require access to multiple components, so they cannot be implemented as methods on a single component struct. The approach taken by this PR is to provide entity wrapper structs for each entity. These wrapper structs implement traits providing the high-level methods.
For example, the
Playerstruct implements theSendMessagetrait providing thesend_message()method.Entity wrappers can be used in queries in the same way components are used right now. For example, to send a message to all players using Quill:
All marker components have been suffixed with
Marker(e.g.PlayerMarker) to make them distinct from the new wrapper structs, and to indicate their purpose is secondary to that of wrapper structs.I also intend to add wrappers for abstract entities like
LivingEntity, which would implement theDamageable,HasInventory, etc. traits.This PR is incomplete. I still need to figure out how we can provide entity wrappers in Feather internally as well as Quill without duplicating code. Also, I haven't actually implemented the traits yet.
This might act as an alternative to #388.