/*
 * Copyright 2023 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
 */

#include "commands.hpp"
#include "rmobject.hpp"

namespace jasper::world {

RmObject::RmObject(WorldObjectSet &doc, size_t const rmIdx) noexcept:
		m_doc(doc),
		m_rmIdx(rmIdx) {
}

ox::Error RmObject::redo() noexcept {
	m_obj = std::move(m_doc.objects[m_rmIdx]);
	return m_doc.objects.erase(m_rmIdx).error;
}

ox::Error RmObject::undo() noexcept {
	m_doc.objects.emplace(m_rmIdx, std::move(m_obj));
	return {};
}

int RmObject::commandId() const noexcept {
	return static_cast<int>(WorldObjCommand::RmObject);
}

}
