import { InputNumber } from "antd"; import { observer } from "mobx-react"; import React, { ReactNode, Component } from "react"; import { QuestNpc, QuestObject, QuestEntity } from "../../domain"; import "./EntityInfoComponent.css"; export type Props = { entity?: QuestEntity; }; @observer export class EntityInfoComponent extends Component { render(): ReactNode { const entity = this.props.entity; if (entity) { const section_id = entity.section ? entity.section.id : entity.section_id; let name = null; if (entity instanceof QuestObject) { name = ( Object: {entity.type.name} ); } else if (entity instanceof QuestNpc) { name = ( NPC: {entity.type.name} ); } return (
{name}
Section: {section_id}
World position:
Section position:
); } else { return
; } } } @observer class CoordRow extends Component<{ entity: QuestEntity; position_type: "position" | "section_position"; coord: "x" | "y" | "z"; }> { render(): ReactNode { const entity = this.props.entity; const value = entity[this.props.position_type][this.props.coord]; return ( {this.props.coord.toUpperCase()}: ); } private changed = (value?: number) => { if (value != null) { const entity = this.props.entity; const pos_type = this.props.position_type; const pos = entity[pos_type].clone(); pos[this.props.coord] = value; entity[pos_type] = pos; } }; }