fix: dialogues and entities on ECS change
This commit is contained in:
parent
ad18da3b93
commit
dd456743f8
|
@ -16,6 +16,11 @@ export default class Interlocutor extends Component {
|
||||||
return class InterlocutorInstance extends super.instanceFromSchema() {
|
return class InterlocutorInstance extends super.instanceFromSchema() {
|
||||||
dialogues = {};
|
dialogues = {};
|
||||||
id = 0;
|
id = 0;
|
||||||
|
destroy() {
|
||||||
|
for (const key in this.dialogues) {
|
||||||
|
this.dialogues[key].onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
dialogue(specification) {
|
dialogue(specification) {
|
||||||
Component.markChange(this.entity, 'dialogue', {[this.id++]: specification});
|
Component.markChange(this.entity, 'dialogue', {[this.id++]: specification});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {useState} from 'react';
|
import {useState} from 'react';
|
||||||
|
|
||||||
|
import {usePacket} from '@/context/client.js';
|
||||||
import {useEcs, useEcsTick} from '@/context/ecs.js';
|
import {useEcs, useEcsTick} from '@/context/ecs.js';
|
||||||
import {parseLetters} from '@/dialogue.js';
|
import {parseLetters} from '@/dialogue.js';
|
||||||
|
|
||||||
|
@ -8,6 +9,9 @@ import Entity from './entity.jsx';
|
||||||
export default function Entities({camera, scale, setMonopolizers}) {
|
export default function Entities({camera, scale, setMonopolizers}) {
|
||||||
const [ecs] = useEcs();
|
const [ecs] = useEcs();
|
||||||
const [entities, setEntities] = useState({});
|
const [entities, setEntities] = useState({});
|
||||||
|
usePacket('EcsChange', async () => {
|
||||||
|
setEntities({});
|
||||||
|
}, [setEntities]);
|
||||||
useEcsTick((payload) => {
|
useEcsTick((payload) => {
|
||||||
if (!ecs) {
|
if (!ecs) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user