Beispiel #1
0
def location_from_json(location: Dict[str, float]) -> NodeLocation:
    return NodeLocation(location["x"], location["y"], location["z"])
Beispiel #2
0
    def create_new_node(self) -> Node:
        node_type = self.node_type_combo.currentData()
        name = self.name_edit.text()
        heal = self.heals_check.isChecked()
        location = None
        if self.location_group.isChecked():
            location = NodeLocation(self.location_x_spin.value(),
                                    self.location_y_spin.value(),
                                    self.location_z_spin.value())
        index = self.node.index

        if node_type == GenericNode:
            return GenericNode(name, heal, location, index)

        elif node_type == DockNode:
            return DockNode(
                name,
                heal,
                location,
                index,
                self.dock_index_spin.value(),
                DockConnection(
                    self.dock_connection_area_combo.currentData(
                    ).area_asset_id,
                    self.dock_connection_node_combo.currentData()),
                self.dock_weakness_combo.currentData(),
            )

        elif node_type == PickupNode:
            return PickupNode(
                name,
                heal,
                location,
                index,
                PickupIndex(self.pickup_index_spin.value()),
                self.major_location_check.isChecked(),
            )

        elif node_type == TeleporterNode:
            instance_id = self.teleporter_instance_id_edit.text()
            scan_asset_id = self.teleporter_scan_asset_id_edit.text()

            return TeleporterNode(
                name,
                heal,
                location,
                index,
                int(instance_id, 0) if instance_id != "" else None,
                AreaLocation(
                    self.teleporter_destination_world_combo.currentData(
                    ).world_asset_id,
                    self.teleporter_destination_area_combo.currentData().
                    area_asset_id),
                int(scan_asset_id, 0) if scan_asset_id != "" else None,
                self.teleporter_vanilla_name_edit.isChecked(),
                self.teleporter_editable_check.isChecked(),
            )

        elif node_type == EventNode:
            event = self.event_resource_combo.currentData()
            if event is None:
                raise ValueError(
                    "There are no events in the database, unable to create EventNode."
                )
            return EventNode(
                name,
                heal,
                location,
                index,
                event,
            )

        elif node_type == TranslatorGateNode:
            return TranslatorGateNode(
                name, heal, location, index,
                TranslatorGate(self.translator_gate_spin.value()),
                self._get_scan_visor())

        elif node_type == LogbookNode:
            lore_type: LoreType = self.lore_type_combo.currentData()
            if lore_type == LoreType.LUMINOTH_LORE:
                required_translator = self.logbook_extra_combo.currentData()
                if required_translator is None:
                    raise ValueError("Missing required translator.")
            else:
                required_translator = None

            if lore_type == LoreType.LUMINOTH_WARRIOR:
                hint_index = self.logbook_extra_combo.currentData()
            else:
                hint_index = None

            return LogbookNode(
                name, heal, location, index,
                int(self.logbook_string_asset_id_edit.text(), 0),
                self._get_scan_visor(), lore_type, required_translator,
                hint_index)

        elif node_type == PlayerShipNode:
            return PlayerShipNode(name, heal, location, index,
                                  self._unlocked_by_requirement,
                                  self._get_command_visor())

        else:
            raise RuntimeError(f"Unknown node type: {node_type}")