Adding the ability to set the player's color outline via the scripting API

(currently not shared with the other players yet)
This commit is contained in:
David Négrier 2021-12-21 17:02:18 +01:00
parent e086f6dac0
commit 90f7287860
11 changed files with 282 additions and 9 deletions

View file

@ -0,0 +1,40 @@
import { writable } from "svelte/store";
export function createColorStore() {
const { subscribe, set } = writable<number | undefined>(undefined);
let color: number | undefined = undefined;
let focused: boolean = false;
const updateColor = () => {
if (focused) {
set(0xffff00);
} else {
set(color);
}
};
return {
subscribe,
pointerOver() {
focused = true;
updateColor();
},
pointerOut() {
focused = false;
updateColor();
},
setColor(newColor: number) {
color = newColor;
updateColor();
},
removeColor() {
color = undefined;
updateColor();
},
};
}