entityclientfactory.cpp from FreePop at Krugle
Show entityclientfactory.cpp syntax highlighted
/***************************************************************************
entityclientfactory.cpp
-------------------
begin : Tue Jun 1 2004
copyright : (C) 2004 by Brendon Higgins
email : freepop-devel@lists.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <entityclientfactory.h>
#include <treeclient.h>
#include <peepmagnetclient.h>
#include <firecolumnclient.h>
#include <peepclient.h>
#include <townclient.h>
#include <rockclient.h>
#include <cropsclient.h>
#include <swampclient.h>
#include <ClanLib/network.h>
using namespace EntityFactory;
EntityClient* EntityClientFactory::build(WorldClient* w, CL_NetPacket &p,
const Identity& id) {
int t = p.input.read_uint32();
int r = p.input.read_uint32();
if (t == TREE) return new TreeClient(w, id, p, r);
if (t == PEEPMAGNET) return new PeepMagnetClient(w, id, p, r);
if (t == FIRECOLUMN) return new FireColumnClient(w, id, p, r);
if (t == PEEP) return new PeepClient(w, id, p, r);
if (t == TOWN) return new TownClient(w, id, p, r);
if (t == ROCK) return new RockClient(w, id, p, r);
if (t == CROPS) return new CropsClient(w, id, p, r);
if (t == SWAMP) return new SwampClient(id, p, r);
return 0;
}
int EntityClientFactory::getSpriteStages() {
return 7;
}
void EntityClientFactory::loadSprites(CL_Signal_v1<int>& callback, Rules* r) {
callback(0);
TreeClient::loadSprites(r);
callback(1);
PeepMagnetClient::loadSprites();
callback(2);
FireColumnClient::loadSprites();
callback(3);
PeepClient::loadSprites();
callback(4);
RockClient::loadSprites();
callback(5);
SwampClient::loadSprites();
callback(6);
CropsClient::loadSprites(r);
callback(7);
}
void EntityClientFactory::freeSprites() {
TreeClient::freeSprites();
PeepMagnetClient::freeSprites();
FireColumnClient::freeSprites();
PeepClient::freeSprites();
RockClient::freeSprites();
SwampClient::freeSprites();
}
See more files for this project here