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

Add items picking logic #126

Merged
merged 8 commits into from
Jul 26, 2022
Merged

Conversation

64kramsystem
Copy link
Member

@64kramsystem 64kramsystem commented Jul 24, 2022

Add items picking logic:

  • items picked are associated to the player
  • bottles are thrown/shot only after being grabbed
  • after throwin/shooting a bottle, the item is not carried anymore

A minor but subtle bug is also fixes see 7e22c45.

Also note the side effect described in d7cdbbf.

Closes #83.

@64kramsystem 64kramsystem added this to the v0.0.3 milestone Jul 24, 2022
@64kramsystem 64kramsystem self-assigned this Jul 24, 2022
@64kramsystem 64kramsystem changed the title Items picking: Base items carrying logic; bottle attacks now require bottle item Add items picking logic Jul 24, 2022
@64kramsystem
Copy link
Member Author

Rebased.

src/item.rs Outdated
Comment on lines 19 to 27
#[derive(Component)]
pub struct Item;

#[derive(Component)]
pub struct CarriedBy(pub Entity);

/// Represents an item, that is either on the map (waiting to be picked up), or carried.
/// If an item is on the map, it has a TransformBundle; if it's carried, it instead has a
/// CarriedBy.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im wondering if instead of ridding the item of its TransformBundle we might consider pushing it as a child of the Fighter who picks it up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be awkward at first before we figure out how to integrate it with animations/what offset/rotation and whatnot it should have, but for now we could always toggle the visibility of the item off when its picked up as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you go! Done. It actually made the code a little bit simpler 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. There have been several conflicts, that I had to fix. I've verified the rebase, hopefully, there have been no subtle breakages 😅.

Copy link
Member

@zicklag zicklag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm lacking bandwidth to do a total review right now, but looks fine after a quick sanity check and it seemed to work after testing it out real quick.

@64kramsystem 64kramsystem force-pushed the add_items_picking_2 branch 2 times, most recently from 78e2c6c to 43c2f3f Compare July 25, 2022 21:21
Comment on lines +72 to +73
if player_item_distance <= PICK_ITEM_RADIUS {
commands.entity(item_id).remove_bundle::<TransformBundle>();
Copy link
Collaborator

@odecay odecay Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant just to keep the transform bundle when both picked and not picked and toggle visibility, but we can always change it later if we need to use the transform for animations in the future. Probably unnecessary for now 👍

Copy link
Member Author

@64kramsystem 64kramsystem Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. if we put it in the animations or something, then it will certainly go back 😄 it is unnecessary now, since if we put it in the HUD (there is a tracking issue), the HUD uses different semnantics/types anyway.

Base version: Multiple items can be picked; items are never released.
WATCH OUT! This may allow throwing and shooting a bottle in the same frame. See [related discussion](fishfolk#83 (comment)).
@64kramsystem
Copy link
Member Author

Ok. Ready for review and hopefully merge. Implemented the change requested in one comment, and resolved the other comment without change.

Copy link
Collaborator

@odecay odecay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@odecay
Copy link
Collaborator

odecay commented Jul 26, 2022

bors merge

@bors
Copy link
Contributor

bors bot commented Jul 26, 2022

Build succeeded:

@bors bors bot merged commit a5955c5 into fishfolk:master Jul 26, 2022
@64kramsystem 64kramsystem deleted the add_items_picking_2 branch July 26, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bottle throwable item
3 participants