ccdevnet / openc2e

openc2e

This URL has Read+Write access

openc2e / CompoundAgent.h
100644 117 lines (99 sloc) 4.002 kb
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* CompoundAgent.h
* openc2e
*
* Created by Alyssa Milburn on Tue May 25 2004.
* Copyright (c) 2004 Alyssa Milburn. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
 
#include "SimpleAgent.h"
#include "creaturesImage.h"
#include <map>
#include <string>
 
class CompoundPart {
protected:
creaturesImage *sprite;
unsigned int firstimg, pose, frameno;
 
public:
std::vector<unsigned int> animation;
creaturesImage *getSprite() { return sprite; }
unsigned int x, y, zorder, id;
virtual void render(SDLBackend *renderer, int xoffset, int yoffset);
virtual void tick();
unsigned int getWidth() { return sprite->width(firstimg); }
unsigned int getHeight() { return sprite->height(firstimg); }
unsigned int getPose() { return pose; }
unsigned int getCurrentSprite() { return firstimg + pose; }
unsigned int getFrameNo() { return frameno; }
void setFrameNo(unsigned int f) { frameno = f; pose = animation[f]; } // todo: assert it's in the range
void setPose(unsigned int p) { pose = p; }
void setFramerate(unsigned int f) { /* TODO */ }
 
bool operator < (const CompoundPart *b) const {
return zorder < b->zorder;
}
 
CompoundPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z);
virtual ~CompoundPart() { }
};
 
class ButtonPart : public CompoundPart {
protected:
bool hittransparentpixelsonly;
 
public:
ButtonPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z, const bytestring &animhover, int msgid, int option);
};
 
class CameraPart : public CompoundPart {
public:
CameraPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z, unsigned int viewwidth, unsigned int viewheight,
unsigned int camerawidth, unsigned int cameraheight);
};
 
class DullPart : public CompoundPart {
public:
DullPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y, unsigned int _z);
};
 
class FixedTextPart : public CompoundPart {
public:
FixedTextPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z, std::string fontsprite);
};
 
class GraphPart : public CompoundPart {
public:
GraphPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z, unsigned int novalues);
};
 
class TextEntryPart : public CompoundPart {
public:
TextEntryPart(unsigned int _id, std::string spritefile, unsigned int fimg, unsigned int _x, unsigned int _y,
unsigned int _z, unsigned int msgid, std::string fontsprite);
};
 
class CompoundAgent : public Agent {
protected:
std::vector<CompoundPart *> parts;
 
unsigned int width, height;
 
public:
CompoundAgent(unsigned char family, unsigned char genus, unsigned short species, unsigned int plane,
std::string spritefile, unsigned int firstimage, unsigned int imagecount);
virtual ~CompoundAgent();
 
unsigned int partCount() { return parts.size(); }
CompoundPart *part(unsigned int id);
void addPart(CompoundPart *);
void delPart(unsigned int);
virtual void setAttributes(unsigned int attr);
virtual unsigned int getAttributes();
virtual void tick();
virtual unsigned int getWidth() { return width; }
virtual unsigned int getHeight() { return height; }
 
virtual void render(SDLBackend *renderer, int xoffset, int yoffset);
};
/* vim: set noet: */