outline color is decided from particular system level

This commit is contained in:
Hanusiak Piotr 2022-02-07 10:39:03 +01:00
parent 862c502bea
commit 72b4438d1e
5 changed files with 28 additions and 22 deletions

View file

@ -455,16 +455,16 @@ export abstract class Character extends Container implements OutlineableInterfac
this.outlineColorStore.removeApiColor(); this.outlineColorStore.removeApiColor();
} }
public pointerOverOutline(): void { public pointerOverOutline(color: number): void {
this.outlineColorStore.pointerOver(); this.outlineColorStore.pointerOver(color);
} }
public pointerOutOutline(): void { public pointerOutOutline(): void {
this.outlineColorStore.pointerOut(); this.outlineColorStore.pointerOut();
} }
public characterCloseByOutline(): void { public characterCloseByOutline(color: number): void {
this.outlineColorStore.characterCloseBy(); this.outlineColorStore.characterCloseBy(color);
} }
public characterFarAwayOutline(): void { public characterFarAwayOutline(): void {

View file

@ -11,6 +11,8 @@ export class ActivatablesManager {
private currentPlayer: Player; private currentPlayer: Player;
private readonly outlineColor = 0xffff00;
constructor(currentPlayer: Player) { constructor(currentPlayer: Player) {
this.currentPlayer = currentPlayer; this.currentPlayer = currentPlayer;
} }
@ -27,7 +29,7 @@ export class ActivatablesManager {
} }
this.selectedActivatableObjectByPointer = object; this.selectedActivatableObjectByPointer = object;
if (isOutlineable(this.selectedActivatableObjectByPointer)) { if (isOutlineable(this.selectedActivatableObjectByPointer)) {
this.selectedActivatableObjectByPointer?.pointerOverOutline(); this.selectedActivatableObjectByPointer?.pointerOverOutline(this.outlineColor);
} }
} }
@ -37,7 +39,7 @@ export class ActivatablesManager {
} }
this.selectedActivatableObjectByPointer = undefined; this.selectedActivatableObjectByPointer = undefined;
if (isOutlineable(this.selectedActivatableObjectByDistance)) { if (isOutlineable(this.selectedActivatableObjectByDistance)) {
this.selectedActivatableObjectByDistance?.characterCloseByOutline(); this.selectedActivatableObjectByDistance?.characterCloseByOutline(this.outlineColor);
} }
} }
@ -60,7 +62,7 @@ export class ActivatablesManager {
} }
this.selectedActivatableObjectByDistance = newNearestObject; this.selectedActivatableObjectByDistance = newNearestObject;
if (isOutlineable(this.selectedActivatableObjectByDistance)) { if (isOutlineable(this.selectedActivatableObjectByDistance)) {
this.selectedActivatableObjectByDistance?.characterCloseByOutline(); this.selectedActivatableObjectByDistance?.characterCloseByOutline(this.outlineColor);
} }
} }

View file

@ -1737,6 +1737,12 @@ ${escapedMessage}
emoteMenuStore.openEmoteMenu(); emoteMenuStore.openEmoteMenu();
} }
}); });
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OVER, (pointer: Phaser.Input.Pointer) => {
this.CurrentPlayer.pointerOverOutline(0x00ffff);
});
this.CurrentPlayer.on(Phaser.Input.Events.POINTER_OUT, (pointer: Phaser.Input.Pointer) => {
this.CurrentPlayer.pointerOutOutline();
});
this.CurrentPlayer.on(requestEmoteEventName, (emoteKey: string) => { this.CurrentPlayer.on(requestEmoteEventName, (emoteKey: string) => {
this.connection?.emitEmoteEvent(emoteKey); this.connection?.emitEmoteEvent(emoteKey);
analyticsClient.launchEmote(emoteKey); analyticsClient.launchEmote(emoteKey);

View file

@ -3,8 +3,8 @@ export interface OutlineableInterface {
removeFollowOutlineColor(): void; removeFollowOutlineColor(): void;
setApiOutlineColor(color: number): void; setApiOutlineColor(color: number): void;
removeApiOutlineColor(): void; removeApiOutlineColor(): void;
pointerOverOutline(): void; pointerOverOutline(color: number): void;
pointerOutOutline(): void; pointerOutOutline(): void;
characterCloseByOutline(): void; characterCloseByOutline(color: number): void;
characterFarAwayOutline(): void; characterFarAwayOutline(): void;
} }

View file

@ -5,38 +5,36 @@ export function createColorStore() {
let followColor: number | undefined = undefined; let followColor: number | undefined = undefined;
let apiColor: number | undefined = undefined; let apiColor: number | undefined = undefined;
let pointedByPointer: number | undefined = undefined;
let pointedByCharacter: number | undefined = undefined;
let pointedByPointer: boolean = false;
let pointedByCharacter: boolean = false;
const updateColor = () => { const updateColor = () => {
if (pointedByPointer || pointedByCharacter) { console.log('update color');
set(0xffff00); console.log(pointedByPointer, pointedByCharacter, followColor, apiColor);
} else { set(pointedByPointer ?? pointedByCharacter ?? followColor ?? apiColor);
set(followColor ?? apiColor);
}
}; };
return { return {
subscribe, subscribe,
pointerOver() { pointerOver(color: number) {
pointedByPointer = true; pointedByPointer = color;
updateColor(); updateColor();
}, },
pointerOut() { pointerOut() {
pointedByPointer = false; pointedByPointer = undefined;
updateColor(); updateColor();
}, },
characterCloseBy() { characterCloseBy(color: number) {
pointedByCharacter = true; pointedByCharacter = color;
updateColor(); updateColor();
}, },
characterFarAway() { characterFarAway() {
pointedByCharacter = false; pointedByCharacter = undefined;
updateColor(); updateColor();
}, },