#ifndef GOAP_ACTION_HPP
#define GOAP_ACTION_HPP

#include "state.hpp"
#include <godot_cpp/classes/object.hpp>
#include <godot_cpp/classes/ref_counted.hpp>
#include <godot_cpp/classes/resource.hpp>
#include <godot_cpp/templates/hash_map.hpp>
#include <godot_cpp/templates/pair.hpp>
#include <godot_cpp/variant/variant.hpp>

namespace godot { class CharacterActor; }

namespace godot::goap {
typedef HashMap<StringName, Variant> WorldState;
typedef KeyValue<StringName, Variant> WorldProperty;

class Action : public Resource {
    GDCLASS(Action, Resource);
    static void _bind_methods();
public:
    void set_context_prerequisites(Dictionary dict);
    Dictionary get_context_prerequisites() const;
    void set_prerequisites(Dictionary dict);
    Dictionary get_prerequisites() const;
    void set_effects(Dictionary dict);
    Dictionary get_effects() const;
    void set_apply_state(Ref<StateArgs> args);
    Ref<StateArgs> get_apply_state() const;

    bool get_is_completed(CharacterActor *context);

    static Dictionary property_map_to_dict(WorldState const &props);
    static void dict_to_property_map(Dictionary const &dict, WorldState &out);
public:
    WorldState context_prerequisites{};
    WorldState prerequisites{};
    WorldState effects{};
    Ref<StateArgs> apply_state{};
};
}

#endif //!GOAP_ACTION_HPP
