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

equip sound + sword grunt + sword sound #3674

Closed
wants to merge 11 commits into from
Closed

Conversation

tcm390
Copy link
Contributor

@tcm390 tcm390 commented Aug 30, 2022

  1. Play the equip/drop sound in metaverse_components/wear.js instead of character-sfx.js
    (Should we just only play the equip sound for localPlayer?)
  2. Because some apps like sword do not have the file index.js to play the sword whoosh, can we create a metaverse components use for the app to handle the sound event?
  3. In animation-baker.js, baked the sword velocity to slash animation. And play the sword grunt and emit meleewhoosh event according to the velocity. (instead of using constant)
  4. And for the redo sword animation, we haven't had the new sword animation so I just change sword animation to animationCombo in this PR: change animation to animationCombo sword#2

Sibling:
webaverse/sword#2

related:
#3659

Result:

Webaverse.-.Google.Chrome.2022-08-31.20-40-50.mp4

@tcm390 tcm390 changed the title equip sound + add sword grunt + sword sound equip sound + sword grunt + sword sound Aug 30, 2022
@tcm390 tcm390 marked this pull request as draft August 31, 2022 17:02
@tcm390 tcm390 marked this pull request as ready for review September 1, 2022 00:58
character-sfx.js Outdated
}));
}
const _handleCombo = () => {
if (this.player.hasAction('use') && this.player.getAction('use').behavior === 'sword' && this.player.getAction('use').animationCombo) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why look it up 3 times per if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

character-sfx.js Outdated
if (index > maxDeltaIndex) {
this.alreadyPlayComboSound = true;
this.playGrunt('attack');
const soundIndex = this.player.avatar.useAnimationIndex * 4 + Math.floor(Math.random() * 4);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 4? Don't include random constants in the middle of the code.

Copy link
Contributor Author

@tcm390 tcm390 Sep 3, 2022

Choose a reason for hiding this comment

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

@@ -0,0 +1,45 @@
import * as THREE from 'three';
Copy link
Contributor

@avaer avaer Sep 4, 2022

Choose a reason for hiding this comment

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

Why break out sound only into the component? There is a lot of use behavior we can move to the use component, but this simply makes the code worse for now since it fragments the behavior even more across files.

If we are doing to break out use into a component, we should do it for all use behavior, not just sounds.

}
}
const _unwear = () => {
if (component.behavior === 'sword') {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be an if, but a declarative object.

}));
}
const _handleCombo = () => {
if (this.player.hasAction('use') && this.player.getAction('use').behavior === 'sword') {
Copy link
Contributor

@avaer avaer Sep 4, 2022

Choose a reason for hiding this comment

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

Why is this query tripled/quadrupled? Each one is a lookup so this is really inefficient.

this.player = player;

this.lastJumpState = false;
this.lastStepped = [false, false];
this.lastWalkTime = 0;

Copy link
Contributor

Choose a reason for hiding this comment

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

Bad spacing.




this.lastSwordComboName = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

There are now so many random state keys on this class that it needs to be broken up further.


};

_handleCombo();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is poor quality unstructured code. The rest of the file has the exact same problem of being random unstructured if statements with a huge state vector, but it's gotten to the point where it is difficult for anyone to review this or even understand what is going on here.

IMO this file needs a complete redesign under some sort of structured coding theory before anyone can review it.

@@ -534,6 +534,122 @@ const {CharsetEncoder} = require('three/examples/js/libs/mmdparser.js');
});
// console.log('got animations', animations);

const comboAnimationNames = [
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is completely unabstracted and unreadable.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are no comments or functions here, so it's not clear what this is supposed to do or why it would be correct.

Copy link
Contributor

@avaer avaer left a comment

Choose a reason for hiding this comment

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

The code quality on this PR and associated files is too poor to properly review. There is little function abstraction, with massive code blocks, repeated lookups with little variable reuse, and enormous state vectors on classes that are randomly accessed.

Most of the files this touches need a structured rewrite before this can even be reviewed for correctness.

@tcm390 tcm390 closed this Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants