Merge pull request #58 from duckietm/Dev

🆕 Effect selection in user dropdown
This commit is contained in:
DuckieTM
2026-04-29 17:08:52 +02:00
committed by GitHub
3 changed files with 17 additions and 13 deletions
@@ -17,6 +17,7 @@ export interface IAvatarImage
processAsImageUrl(setType: string): string; processAsImageUrl(setType: string): string;
processAsContainer(setType: string): Container; processAsContainer(setType: string): Container;
getDirection(): number; getDirection(): number;
getDirectionOffset(): number;
getFigure(): IAvatarFigureContainer; getFigure(): IAvatarFigureContainer;
getPartColor(_arg_1: string): IPartColor; getPartColor(_arg_1: string): IPartColor;
getMainAction(): IActiveActionData; getMainAction(): IActiveActionData;
+5
View File
@@ -399,6 +399,11 @@ export class AvatarImage implements IAvatarImage, IAvatarEffectListener
return this._mainDirection; return this._mainDirection;
} }
public getDirectionOffset(): number
{
return this._directionOffset;
}
public initActionAppends(): void public initActionAppends(): void
{ {
this._actions = []; this._actions = [];
@@ -1104,17 +1104,19 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
if(sprite?.texture) if(sprite?.texture)
{ {
const currentDirection = this._avatarImage?.getDirection(); const displayedDirection = this._avatarImage?.getDirection();
const directionOffset = this._avatarImage?.getDirectionOffset() ?? 0;
let oppositeTexture = sprite.texture; let oppositeTexture = sprite.texture;
if((currentDirection !== undefined) && this._avatarImage) if((displayedDirection !== undefined) && this._avatarImage)
{ {
const oppositeDirection = ((currentDirection + 4) % 8); const rawCurrent = ((displayedDirection - directionOffset) % 8 + 8) % 8;
const rawOpposite = (rawCurrent + 4) % 8;
const displayedOpposite = (displayedDirection + 4) % 8;
if(oppositeDirection !== currentDirection) if(displayedOpposite !== displayedDirection)
{ {
// Reuse the cached opposite texture if direction and base texture haven't changed if(this._reflectionOppositeTexture && (this._reflectionOppositeDirection === displayedDirection) && (this._reflectionOppositeBaseTexture === sprite.texture))
if(this._reflectionOppositeTexture && (this._reflectionOppositeDirection === currentDirection) && (this._reflectionOppositeBaseTexture === sprite.texture))
{ {
oppositeTexture = this._reflectionOppositeTexture; oppositeTexture = this._reflectionOppositeTexture;
} }
@@ -1122,7 +1124,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
{ {
const highlightEnabled = ((this.object.model.getValue<number>(RoomObjectVariable.FIGURE_HIGHLIGHT_ENABLE) === 1) && (this.object.model.getValue<number>(RoomObjectVariable.FIGURE_HIGHLIGHT) === 1)); const highlightEnabled = ((this.object.model.getValue<number>(RoomObjectVariable.FIGURE_HIGHLIGHT_ENABLE) === 1) && (this.object.model.getValue<number>(RoomObjectVariable.FIGURE_HIGHLIGHT) === 1));
this._avatarImage.setDirection(AvatarSetType.FULL, oppositeDirection); this._avatarImage.setDirection(AvatarSetType.FULL, rawOpposite);
const renderedOpposite = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture); const renderedOpposite = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture);
@@ -1133,14 +1135,10 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement
} }
this._reflectionOppositeTexture = this.cloneTexture(renderedOpposite); this._reflectionOppositeTexture = this.cloneTexture(renderedOpposite);
this._reflectionOppositeDirection = currentDirection; this._reflectionOppositeDirection = displayedDirection;
this._reflectionOppositeBaseTexture = sprite.texture; this._reflectionOppositeBaseTexture = sprite.texture;
oppositeTexture = (this._reflectionOppositeTexture || renderedOpposite); oppositeTexture = (this._reflectionOppositeTexture || renderedOpposite);
this._avatarImage.setDirection(AvatarSetType.FULL, rawCurrent);
// Restore the live avatar direction and refresh the current texture so
// movement updates do not keep showing the opposite-facing texture.
this._avatarImage.setDirection(AvatarSetType.FULL, currentDirection);
sprite.texture = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture); sprite.texture = (this._avatarImage.processAsTexture(AvatarSetType.FULL, highlightEnabled) || sprite.texture);
} }