summaryrefslogtreecommitdiffhomepage
path: root/src/critter-script-walk.cpp
blob: 9c92798c758339773bbd11a6932ba9f06d5ce11c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "critter-script.hpp"
//#include "raycast.hpp"
#include "point.hpp"
#include "critter.hpp"
#include "search-result.hpp"
#include "search-astar.hpp"
#include "entity/name-of.hpp"

namespace floormat {

namespace {

enum class walk_mode : uint8_t
{
    none, line, path,
};

struct walk_script final : critter_script
{
    const void* type_id() const override;
    void on_init(const std::shared_ptr<critter>& c) override;
    void on_update(const std::shared_ptr<critter>& c, size_t& i, const Ns& dt) override;
    void on_destroy(const std::shared_ptr<critter>& c, script_destroy_reason reason) override;
    void delete_self() noexcept override;

    point to;
    path_search_result path;
    walk_mode mode = walk_mode::none;
};

constexpr StringView script_name = name_of<walk_script>;

const void* walk_script::type_id() const
{
    return &script_name;
}

void walk_script::on_init(const std::shared_ptr<critter>& c)
{
}

void walk_script::on_update(const std::shared_ptr<critter>& c, size_t& i, const Ns& dt)
{
}

void walk_script::on_destroy(const std::shared_ptr<critter>& c, script_destroy_reason reason)
{
}

void walk_script::delete_self() noexcept
{
    delete this;
}

} // namespace

critter_script* critter_script::make_walk_script(point to, path_search_result path)
{
    return new walk_script{};
}

} // namespace floormat