fix: dialogues and entities on ECS change

This commit is contained in:
cha0s 2024-07-14 02:38:59 -05:00
parent ad18da3b93
commit dd456743f8
2 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,11 @@ export default class Interlocutor extends Component {
return class InterlocutorInstance extends super.instanceFromSchema() {
dialogues = {};
id = 0;
destroy() {
for (const key in this.dialogues) {
this.dialogues[key].onClose();
}
}
dialogue(specification) {
Component.markChange(this.entity, 'dialogue', {[this.id++]: specification});
}

View File

@ -1,5 +1,6 @@
import {useState} from 'react';
import {usePacket} from '@/context/client.js';
import {useEcs, useEcsTick} from '@/context/ecs.js';
import {parseLetters} from '@/dialogue.js';
@ -8,6 +9,9 @@ import Entity from './entity.jsx';
export default function Entities({camera, scale, setMonopolizers}) {
const [ecs] = useEcs();
const [entities, setEntities] = useState({});
usePacket('EcsChange', async () => {
setEntities({});
}, [setEntities]);
useEcsTick((payload) => {
if (!ecs) {
return;