summaryrefslogtreecommitdiffhomepage
path: root/src/critter.hpp
blob: 00e01cd1cbab58619c3f4934a9c1f452ee7dfa16 (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
#pragma once
#include "src/global-coords.hpp"
#include "src/rotation.hpp"
#include "src/object.hpp"
#include <Corrade/Containers/String.h>

namespace floormat {

class anim_atlas;
class world;

struct critter_proto : object_proto
{
    String name;
    bool playable : 1 = false;

    critter_proto();
    critter_proto(const critter_proto&);
    ~critter_proto() noexcept override;
    critter_proto& operator=(const critter_proto&);
    bool operator==(const object_proto& proto) const override;
};

struct critter final : object
{
    object_type type() const noexcept override;
    explicit operator critter_proto() const;

    void update(size_t i, float dt) override;
    void set_keys(bool L, bool R, bool U, bool D);
    Vector2 ordinal_offset(Vector2b offset) const override;
    float depth_offset() const override;

    String name;
    Vector2us offset_frac;
    bool b_L : 1 = false, b_R : 1 = false, b_U : 1 = false, b_D : 1 = false;
    bool playable : 1 = false;

private:
    int allocate_frame_time(float dt);

    friend class world;
    critter(object_id id, class chunk& c, const critter_proto& proto);
};

template<> struct object_type_<struct critter> : std::integral_constant<object_type, object_type::critter> {};
template<> struct object_type_<struct critter_proto> : std::integral_constant<object_type, object_type::critter> {};

} // namespace floormat