42
42
const unsigned SMOLDERING_LENGTH = 3000;
44
44
/// Work steps for the construction of the wood pile and the cover
45
const unsigned short CONSTRUCTION_WORKING_STEPS[2] = {6,6};
45
const unsigned short CONSTRUCTION_WORKING_STEPS[2] = {6, 6};
46
46
/// Work steps for one graphical step during the remove of the cover
47
47
const unsigned short REMOVECOVER_WORK_STEPS = 1;
48
48
/// Work steps for one graphical step during the "harvest"
49
49
const unsigned short HARVEST_WORK_STEPS = 1;
51
noCharburnerPile::noCharburnerPile(const unsigned short x, const unsigned short y) : noCoordBase(NOP_CHARBURNERPILE,x,y),
52
state(STATE_WOOD), step(0), sub_step(1), event(NULL)
51
noCharburnerPile::noCharburnerPile(const unsigned short x, const unsigned short y) : noCoordBase(NOP_CHARBURNERPILE, x, y),
52
state(STATE_WOOD), step(0), sub_step(1), event(NULL)
56
56
noCharburnerPile::~noCharburnerPile()
61
61
void noCharburnerPile::Destroy_noCharburnerPile()
63
em->RemoveEvent(event);
65
// Bauplätze drumrum neu berechnen
66
gwg->RecalcBQAroundPointBig(x,y);
68
Destroy_noCoordBase();
71
void noCharburnerPile::Serialize_noCharburnerPile(SerializedGameData * sgd) const
73
Serialize_noCoordBase(sgd);
75
sgd->PushUnsignedChar(static_cast<unsigned char>(state));
76
sgd->PushUnsignedShort(step);
77
sgd->PushUnsignedShort(sub_step);
78
sgd->PushObject(event,true);
81
noCharburnerPile::noCharburnerPile(SerializedGameData * sgd, const unsigned obj_id) : noCoordBase(sgd,obj_id),
82
state(State(sgd->PopUnsignedChar())),
83
step(sgd->PopUnsignedShort()),
84
sub_step(sgd->PopUnsignedShort()),
85
event(sgd->PopObject<EventManager::Event>(GOT_EVENT))
89
void noCharburnerPile::Draw( int x, int y)
95
// Draw sand on which the wood stack is constructed
96
LOADER.GetImageN("charburner_bobs",25)->Draw(x,y);
98
glArchivItem_Bitmap * image;
100
image = LOADER.GetImageN("charburner_bobs",26);
103
image = LOADER.GetImageN("charburner_bobs",28);
105
// Draw wood pile beneath the cover
106
LOADER.GetImageN("charburner_bobs",26)->Draw(x,y);
109
unsigned short progress = sub_step*image->getHeight() / CONSTRUCTION_WORKING_STEPS[step];
110
unsigned short height = image->getHeight() - progress;
112
image->Draw(x, y+height, 0, 0, 0, height, 0, progress);
114
case STATE_SMOLDERING:
116
LOADER.GetImageN("charburner_bobs",27+GameClient::inst().
117
GetGlobalAnimation(2,10,1,obj_id+this->x*10+this->y*10))->Draw(x,y);
119
// Dann Qualm zeichnen
120
LOADER.GetMapImageN(692+1*8+GAMECLIENT.GetGlobalAnimation(8,5,2,(this->x+this->y)*100))
121
->Draw(x+21,y-11,0,0,0,0,0,0,0x99EEEEEE);
122
LOADER.GetMapImageN(692+2*8+GAMECLIENT.GetGlobalAnimation(8,5,2,(this->x+this->y)*100))
123
->Draw(x-2,y-06,0,0,0,0,0,0,0x99EEEEEE);
124
LOADER.GetMapImageN(692+1*8+GAMECLIENT.GetGlobalAnimation(8,5,2,(this->x+this->y)*100))
125
->Draw(x-25,y-11,0,0,0,0,0,0,0x99EEEEEE);
126
LOADER.GetMapImageN(692+3*8+GAMECLIENT.GetGlobalAnimation(8,5,2,(this->x+this->y)*100))
127
->Draw(x-2,y-35,0,0,0,0,0,0,0x99EEEEEE);
129
case STATE_REMOVECOVER:
131
LOADER.GetImageN("charburner_bobs",28+step)->Draw(x,y);
135
LOADER.GetImageN("charburner_bobs",34+step)->Draw(x,y);
63
em->RemoveEvent(event);
65
// Bauplätze drumrum neu berechnen
66
gwg->RecalcBQAroundPointBig(x, y);
68
Destroy_noCoordBase();
71
void noCharburnerPile::Serialize_noCharburnerPile(SerializedGameData* sgd) const
73
Serialize_noCoordBase(sgd);
75
sgd->PushUnsignedChar(static_cast<unsigned char>(state));
76
sgd->PushUnsignedShort(step);
77
sgd->PushUnsignedShort(sub_step);
78
sgd->PushObject(event, true);
81
noCharburnerPile::noCharburnerPile(SerializedGameData* sgd, const unsigned obj_id) : noCoordBase(sgd, obj_id),
82
state(State(sgd->PopUnsignedChar())),
83
step(sgd->PopUnsignedShort()),
84
sub_step(sgd->PopUnsignedShort()),
85
event(sgd->PopObject<EventManager::Event>(GOT_EVENT))
89
void noCharburnerPile::Draw( int x, int y)
95
// Draw sand on which the wood stack is constructed
96
LOADER.GetImageN("charburner_bobs", 25)->Draw(x, y);
98
glArchivItem_Bitmap* image;
100
image = LOADER.GetImageN("charburner_bobs", 26);
103
image = LOADER.GetImageN("charburner_bobs", 28);
105
// Draw wood pile beneath the cover
106
LOADER.GetImageN("charburner_bobs", 26)->Draw(x, y);
109
unsigned short progress = sub_step * image->getHeight() / CONSTRUCTION_WORKING_STEPS[step];
110
unsigned short height = image->getHeight() - progress;
112
image->Draw(x, y + height, 0, 0, 0, height, 0, progress);
114
case STATE_SMOLDERING:
116
LOADER.GetImageN("charburner_bobs", 27 + GameClient::inst().
117
GetGlobalAnimation(2, 10, 1, obj_id + this->x * 10 + this->y * 10))->Draw(x, y);
119
// Dann Qualm zeichnen
120
LOADER.GetMapImageN(692 + 1 * 8 + GAMECLIENT.GetGlobalAnimation(8, 5, 2, (this->x + this->y) * 100))
121
->Draw(x + 21, y - 11, 0, 0, 0, 0, 0, 0, 0x99EEEEEE);
122
LOADER.GetMapImageN(692 + 2 * 8 + GAMECLIENT.GetGlobalAnimation(8, 5, 2, (this->x + this->y) * 100))
123
->Draw(x - 2, y - 06, 0, 0, 0, 0, 0, 0, 0x99EEEEEE);
124
LOADER.GetMapImageN(692 + 1 * 8 + GAMECLIENT.GetGlobalAnimation(8, 5, 2, (this->x + this->y) * 100))
125
->Draw(x - 25, y - 11, 0, 0, 0, 0, 0, 0, 0x99EEEEEE);
126
LOADER.GetMapImageN(692 + 3 * 8 + GAMECLIENT.GetGlobalAnimation(8, 5, 2, (this->x + this->y) * 100))
127
->Draw(x - 2, y - 35, 0, 0, 0, 0, 0, 0, 0x99EEEEEE);
129
case STATE_REMOVECOVER:
131
LOADER.GetImageN("charburner_bobs", 28 + step)->Draw(x, y);
135
LOADER.GetImageN("charburner_bobs", 34 + step)->Draw(x, y);
142
142
void noCharburnerPile::HandleEvent(const unsigned int id)
144
// Smoldering is over
145
// Pile is ready for the remove of the cover
146
state = STATE_REMOVECOVER;
144
// Smoldering is over
145
// Pile is ready for the remove of the cover
146
state = STATE_REMOVECOVER;
151
151
/// Charburner has worked on it --> Goto next step
152
152
void noCharburnerPile::NextStep()
160
if(sub_step == CONSTRUCTION_WORKING_STEPS[step])
165
// Reached new state?
169
state = STATE_SMOLDERING;
170
event = em->AddEvent(this,SMOLDERING_LENGTH,0);
175
case STATE_REMOVECOVER:
178
if(sub_step == REMOVECOVER_WORK_STEPS)
183
// Reached new state?
186
state = STATE_HARVEST;
195
if(sub_step == HARVEST_WORK_STEPS)
200
// Reached new state?
203
// Add an empty pile as environmental object
204
gwg->SetNO(new noEnvObject(x,y,40,6),x,y);
205
em->AddToKillList(this);
207
// BQ drumrum neu berechnen
208
gwg->RecalcBQAroundPoint(x,y);
160
if(sub_step == CONSTRUCTION_WORKING_STEPS[step])
165
// Reached new state?
169
state = STATE_SMOLDERING;
170
event = em->AddEvent(this, SMOLDERING_LENGTH, 0);
175
case STATE_REMOVECOVER:
178
if(sub_step == REMOVECOVER_WORK_STEPS)
183
// Reached new state?
186
state = STATE_HARVEST;
195
if(sub_step == HARVEST_WORK_STEPS)
200
// Reached new state?
203
// Add an empty pile as environmental object
204
gwg->SetNO(new noEnvObject(x, y, 40, 6), x, y);
205
em->AddToKillList(this);
207
// BQ drumrum neu berechnen
208
gwg->RecalcBQAroundPoint(x, y);
217
217
noCharburnerPile::WareType noCharburnerPile::GetNeededWareType() const
219
if(sub_step % 2 == 0)
219
if(sub_step % 2 == 0)