#ifndef WORLD_COMPONENT_HPP_
#define WORLD_COMPONENT_HPP_

#include <string>
#include <cstddef>

#include <WorldGridNode/WorldGridNode.hpp>

/**
 * @brief Base class for world components.
 */
class WorldComponent
{
public:
    /**
     * @brief Path to the data file.
     * 
     * This gets assigned during node creation.
     */
    std::string dataFilePath;

    /**
     * @brief The node component index which this component came from.
     */
    int nodeComponentIndex;

    virtual ~WorldComponent() = default;

    /**
     * @brief Update this component.
     * 
     * This is called when the `node` was passed to `LocalWorld::markForUpdate()`. This
     * method is allowed to mark parent nodes for update, but not child or sibling nodes.
     * 
     * By default simply returns `false`, indicating nothing was changed.
     * 
     * @param world The world in which the update is occuring.
     * @param node The node that this component is attached to.
     * @return `true` if the state was changed and needs to be saved.
     */
    virtual bool update(LocalWorld &world, std::shared_ptr<WorldGridNode> node);

    /**
     * @brief Serialize this node's state into the specified vector.
     * 
     * By default does not push anything to the vector.
     */
    virtual void serializeState(std::vector<uint8_t> &outBytes);

    /**
     * @brief Dump information about this component in this node.
     */
    virtual void dump(std::shared_ptr<WorldGridNode> node);
};

#endif