-
Notifications
You must be signed in to change notification settings - Fork 210
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
Conversation
character-sfx.js
Outdated
})); | ||
} | ||
const _handleCombo = () => { | ||
if (this.player.hasAction('use') && this.player.getAction('use').behavior === 'sword' && this.player.getAction('use').animationCombo) { |
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.
Why look it up 3 times per if
?
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.
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); |
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.
Why 4
? Don't include random constants in the middle of the code.
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.
@@ -0,0 +1,45 @@ | |||
import * as THREE from 'three'; |
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.
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') { |
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.
This should not be an if
, but a declarative object.
})); | ||
} | ||
const _handleCombo = () => { | ||
if (this.player.hasAction('use') && this.player.getAction('use').behavior === 'sword') { |
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.
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; | ||
|
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.
Bad spacing.
|
||
|
||
|
||
this.lastSwordComboName = null; |
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.
There are now so many random state keys on this class that it needs to be broken up further.
|
||
}; | ||
|
||
_handleCombo(); |
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.
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 = [ |
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.
This code is completely unabstracted and unreadable.
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.
There are no comments or functions here, so it's not clear what this is supposed to do or why it would be correct.
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.
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.
metaverse_components/wear.js
instead ofcharacter-sfx.js
(Should we just only play the equip sound for localPlayer?)
index.js
to play the sword whoosh, can we create a metaverse componentsuse
for the app to handle the sound event?Sibling:
webaverse/sword#2
related:
#3659
Result:
Webaverse.-.Google.Chrome.2022-08-31.20-40-50.mp4