move construct calls into componentDidUpdate, change shouldCompUpdate
This commit is contained in:
parent
6a4eb1837d
commit
84acb58573
@ -61,42 +61,36 @@ class ConstructAvatar extends Component {
|
|||||||
this.resetAnimations();
|
this.resetAnimations();
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(newProps) {
|
componentDidUpdate(prevProps) {
|
||||||
const { animSource, animTarget, animText, construct } = newProps;
|
const { animSource, animTarget, animText, construct } = this.props;
|
||||||
|
// a different text object and text construct
|
||||||
if (construct !== this.props.construct) {
|
if (animText && animText !== prevProps.animText && animText.constructId === construct.id) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (animText && animText !== this.props.animText && animText.constructId === construct.id) {
|
|
||||||
return wiggle(construct.id, this.idle);
|
return wiggle(construct.id, this.idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animSource === this.props.animSource && animTarget === this.props.animTarget) {
|
// different source object and source construct
|
||||||
// console.warn(construct.name, 'thinks its same props')
|
if (animSource && animSource !== prevProps.animSource && animSource.constructId === construct.id) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// something has changed
|
|
||||||
// what do?
|
|
||||||
|
|
||||||
// this is the source
|
|
||||||
if (animSource && animSource.constructId === construct.id) {
|
|
||||||
// console.warn(construct.name, 'should update')
|
|
||||||
return sourceCast(animSource.constructId, animSource.direction, this.idle);
|
return sourceCast(animSource.constructId, animSource.direction, this.idle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// different target object and target construct
|
||||||
// this is the target
|
if (animTarget && animTarget !== prevProps.animTarget && animTarget.constructId.includes(construct.id)) {
|
||||||
if (animTarget && animTarget.constructId.includes(construct.id)) {
|
|
||||||
// console.warn(construct.name, 'should update')
|
|
||||||
switch (animTarget.skill) {
|
switch (animTarget.skill) {
|
||||||
case 'Banish': return banish(construct.id, this.idle);
|
case 'Banish': return banish(construct.id, this.idle);
|
||||||
case 'Invert': return invert(construct.id, this.idle);
|
case 'Invert': return invert(construct.id, this.idle);
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
shouldComponentUpdate(newProps) {
|
||||||
|
const { animSource, animTarget, animText, construct } = newProps;
|
||||||
|
if (animSource !== this.props.animSource) return true;
|
||||||
|
if (animTarget !== this.props.animTarget) return true;
|
||||||
|
if (animText !== this.props.animText) return true;
|
||||||
|
if (construct !== this.props.construct) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user