2021-11-30 19:10:35 +01:00
|
|
|
<script lang="typescript">
|
2021-12-07 14:01:30 +01:00
|
|
|
import { onDestroy } from "svelte";
|
2021-11-30 19:10:35 +01:00
|
|
|
|
2021-12-07 14:01:30 +01:00
|
|
|
import { gameManager } from "../../Phaser/Game/GameManager";
|
2021-11-30 19:10:35 +01:00
|
|
|
|
|
|
|
export let userId: number;
|
2021-12-01 11:14:54 +01:00
|
|
|
export let placeholderSrc: string;
|
2021-12-07 14:56:42 +01:00
|
|
|
export let width: string = "62px";
|
|
|
|
export let height: string = "62px";
|
2021-11-30 19:10:35 +01:00
|
|
|
|
|
|
|
const gameScene = gameManager.getCurrentGameScene();
|
2021-12-14 14:46:24 +01:00
|
|
|
let playerWokaPictureStore;
|
|
|
|
if (userId === -1) {
|
|
|
|
playerWokaPictureStore = gameScene.CurrentPlayer.pictureStore;
|
|
|
|
} else {
|
|
|
|
playerWokaPictureStore = gameScene.MapPlayersByKey.getNestedStore(userId, (item) => item.pictureStore);
|
|
|
|
}
|
2021-11-30 19:10:35 +01:00
|
|
|
|
2021-12-01 11:14:54 +01:00
|
|
|
let src = placeholderSrc;
|
2021-12-14 14:46:24 +01:00
|
|
|
|
|
|
|
const unsubscribe = playerWokaPictureStore.subscribe((source) => {
|
2021-12-04 16:29:28 +01:00
|
|
|
src = source ?? placeholderSrc;
|
2021-11-30 19:10:35 +01:00
|
|
|
});
|
|
|
|
|
2022-01-05 10:27:40 +01:00
|
|
|
function noDrag() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-11-30 19:10:35 +01:00
|
|
|
onDestroy(unsubscribe);
|
|
|
|
</script>
|
|
|
|
|
2022-01-05 10:27:40 +01:00
|
|
|
<img
|
|
|
|
{src}
|
|
|
|
alt=""
|
|
|
|
class="nes-pointer noselect"
|
|
|
|
style="--theme-width: {width}; --theme-height: {height}"
|
|
|
|
draggable="false"
|
|
|
|
on:dragstart|preventDefault={noDrag}
|
|
|
|
/>
|
2021-11-30 19:10:35 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
img {
|
2021-12-07 14:56:42 +01:00
|
|
|
display: inline-block;
|
2021-11-30 19:10:35 +01:00
|
|
|
pointer-events: auto;
|
2021-12-07 14:56:42 +01:00
|
|
|
width: var(--theme-width);
|
|
|
|
height: var(--theme-height);
|
2021-12-01 10:26:09 +01:00
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
2021-12-07 15:21:54 +01:00
|
|
|
position: static;
|
|
|
|
left: 0;
|
|
|
|
bottom: 0;
|
|
|
|
right: 0;
|
|
|
|
top: 0;
|
2021-11-30 19:10:35 +01:00
|
|
|
image-rendering: pixelated;
|
|
|
|
}
|
2021-12-07 14:01:30 +01:00
|
|
|
</style>
|