-
Notifications
You must be signed in to change notification settings - Fork 54
/
ConditionalSprite.h
75 lines (59 loc) · 1.7 KB
/
ConditionalSprite.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
#include <memory>
#include "TileCondition.h"
// generic superclass
class SpriteNode
{
public:
SpriteNode() = default;
virtual ~SpriteNode() = default;
// this returns true if the sprite matched, and also adds
// sprites to the tile as required
virtual bool copyToTile(Tile* b)=0;
// adds a child if appropriate (vestigial in some cases)
virtual void addChild(std::unique_ptr<SpriteNode> child) {};
};
// root nesting structure
class RootTile : public SpriteNode
{
std::vector<std::unique_ptr<SpriteNode>> children;
public:
RootTile(void);
~RootTile(void);
bool copyToTile(Tile* b);
void addChild(std::unique_ptr<SpriteNode> child);
};
// nesting conditional structure
class SpriteTile : public ConditionalNode, public SpriteNode
{
std::unique_ptr<TileCondition> conditions;
std::vector<std::unique_ptr<SpriteNode>> children;
std::unique_ptr<SpriteNode> elsenode;
public:
SpriteTile(void);
~SpriteTile(void);
bool copyToTile(Tile* b);
bool addCondition(std::unique_ptr<TileCondition> cond);
void addChild(std::unique_ptr<SpriteNode> child);
void addElse(std::unique_ptr<SpriteNode> child);
};
// rotational conditional structure
class RotationTile : public ConditionalNode, public SpriteNode
{
std::vector<std::unique_ptr<SpriteNode>> children;
public:
RotationTile(void);
~RotationTile(void);
bool copyToTile(Tile* b);
bool addCondition(std::unique_ptr<TileCondition> cond);
void addChild(std::unique_ptr<SpriteNode> child);
};
// display element
class SpriteElement : public SpriteNode
{
public:
c_sprite sprite;
SpriteElement(void);
~SpriteElement() = default;
bool copyToTile(Tile* b);
};