id = $id; $this->name = $name; $this->dialogue = $dialogue; $this->hasShop = $hasShop; $this->shopInventory = $shopInventory ?? []; } public function getName(): string { return $this->name; } /** * 获取指定对话ID的文本 */ public function getDialogueText(string $key): string { return $this->dialogue[$key] ?? "NPC:对不起,我不知道你在说什么。"; } }