summaryrefslogtreecommitdiffhomepage
path: root/src/critter-script-empty.cpp
blob: 7c269aa4845aa08ed90040d2ae796d04656082d6 (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
#include "critter-script.inl"
#include "entity/name-of.hpp"

namespace floormat {

namespace {

struct empty_critter_script final : critter_script
{
    StringView name() const override;
    const void* id() const override;

    void on_init(const bptr<critter>& c) override;
    void on_update(const bptr<critter>& c, size_t& i, const Ns& dt) override;
    void on_destroy(const bptr<critter>& c, script_destroy_reason reason) override;
    void delete_self() noexcept override;
};

constexpr StringView script_name = name_of<empty_critter_script>;

StringView empty_critter_script::name() const
{
    return "empty"_s;
}

const void* empty_critter_script::id() const
{
    return &script_name;
}

void empty_critter_script::on_init(const bptr<critter>&) {}
void empty_critter_script::on_update(const bptr<critter>&, size_t&, const Ns&) {}
void empty_critter_script::on_destroy(const bptr<critter>&, script_destroy_reason) {}
void empty_critter_script::delete_self() noexcept { }

constinit empty_critter_script empty_script_ = {};

} // namespace

template <>
critter_script* Script<critter_script, critter>::make_empty()
{
    return &empty_script_;
}

template class Script<critter_script, critter>;

critter_script::~critter_script() noexcept = default;

} // namespace floormat