#include <object_factory.hpp>
Public Member Functions | |
ObjectFactory () | |
~ObjectFactory () | |
GameObject * | create (const std::string &name, const Reader &reader) |
GameObject * | create (const std::string &name, const Vector &pos, const Direction dir=AUTO) |
Static Public Member Functions | |
static ObjectFactory & | instance () |
Private Types | |
typedef std::map< std::string, AbstractObjectFactory * > | Factories |
Private Member Functions | |
template<class C> | |
void | add_factory (const char *name) |
void | init_factories () |
Private Attributes | |
Factories | factories |
Definition at line 55 of file object_factory.hpp.
typedef std::map<std::string, AbstractObjectFactory*> ObjectFactory::Factories [private] |
Definition at line 61 of file object_factory.hpp.
ObjectFactory::ObjectFactory | ( | ) |
Definition at line 164 of file object_factory.cpp.
References init_factories().
00164 : 00165 factories() 00166 { 00167 init_factories(); 00168 }
ObjectFactory::~ObjectFactory | ( | ) |
ObjectFactory & ObjectFactory::instance | ( | ) | [static] |
Definition at line 158 of file object_factory.cpp.
Referenced by BonusBlock::BonusBlock(), Owl::initialize(), Dispenser::launch_badguy(), and Sector::parse_object().
00159 { 00160 static ObjectFactory instance_; 00161 return instance_; 00162 }
GameObject * ObjectFactory::create | ( | const std::string & | name, | |
const Reader & | reader | |||
) |
Definition at line 266 of file object_factory.cpp.
References factories.
Referenced by BonusBlock::BonusBlock(), create(), Owl::initialize(), Dispenser::launch_badguy(), and Sector::parse_object().
00267 { 00268 Factories::iterator i = factories.find(name); 00269 00270 if (i == factories.end()) 00271 { 00272 std::stringstream msg; 00273 msg << "No factory for object '" << name << "' found."; 00274 throw std::runtime_error(msg.str()); 00275 } 00276 else 00277 { 00278 return i->second->create(reader); 00279 } 00280 }
GameObject * ObjectFactory::create | ( | const std::string & | name, | |
const Vector & | pos, | |||
const Direction | dir = AUTO | |||
) |
Definition at line 283 of file object_factory.cpp.
References AUTO, create(), lisp::Lisp::get_car(), lisp::Parser::parse(), Vector::x, and Vector::y.
00284 { 00285 std::stringstream lisptext; 00286 lisptext << "((x " << pos.x << ")" 00287 << " (y " << pos.y << ")"; 00288 if(dir != AUTO) 00289 lisptext << " (direction " << dir << "))"; 00290 00291 lisp::Parser parser; 00292 const lisp::Lisp* lisp = parser.parse(lisptext, "create_object"); 00293 00294 GameObject* object = create(name, *(lisp->get_car())); 00295 return object; 00296 }
void ObjectFactory::add_factory | ( | const char * | name | ) | [inline, private] |
Definition at line 73 of file object_factory.hpp.
References factories.
00074 { 00075 assert(factories.find(name) == factories.end()); 00076 factories[name] = new ConcreteObjectFactory<C>(); 00077 }
void ObjectFactory::init_factories | ( | ) | [private] |
Definition at line 175 of file object_factory.cpp.
Referenced by ObjectFactory().
00176 { 00177 // badguys 00178 add_factory<AngryStone>("angrystone"); 00179 add_factory<BouncingSnowball>("bouncingsnowball"); 00180 add_factory<CaptainSnowball>("captainsnowball"); 00181 add_factory<Crystallo>("crystallo"); 00182 add_factory<Dart>("dart"); 00183 add_factory<DartTrap>("darttrap"); 00184 add_factory<Dispenser>("dispenser"); 00185 add_factory<Fish>("fish"); 00186 add_factory<Flame>("flame"); 00187 add_factory<FlyingSnowBall>("flyingsnowball"); 00188 add_factory<GhostTree>("ghosttree"); 00189 add_factory<Haywire>("haywire"); 00190 add_factory<Igel>("igel"); 00191 add_factory<Jumpy>("jumpy"); 00192 add_factory<KamikazeSnowball>("kamikazesnowball"); 00193 add_factory<Kugelblitz>("kugelblitz"); 00194 add_factory<Mole>("mole"); 00195 add_factory<MoleRock>("mole_rock"); 00196 add_factory<MrBomb>("mrbomb"); 00197 add_factory<MrIceBlock>("mriceblock"); 00198 add_factory<MrTree>("mrtree"); 00199 add_factory<Owl>("owl"); 00200 add_factory<Plant>("plant"); 00201 add_factory<PoisonIvy>("poisonivy"); 00202 add_factory<ShortFuse>("short_fuse"); 00203 add_factory<SSpiky>("sspiky"); 00204 add_factory<SkyDive>("skydive"); 00205 add_factory<SkullyHop>("skullyhop"); 00206 add_factory<SmartBall>("smartball"); 00207 add_factory<Snail>("snail"); 00208 add_factory<SnowBall>("snowball"); 00209 add_factory<Snowman>("snowman"); 00210 add_factory<SpiderMite>("spidermite"); 00211 add_factory<Spiky>("spiky"); 00212 add_factory<Stalactite>("stalactite"); 00213 add_factory<Stumpy>("stumpy"); 00214 add_factory<Toad>("toad"); 00215 add_factory<Totem>("totem"); 00216 add_factory<WalkingLeaf>("walkingleaf"); 00217 add_factory<WillOWisp>("willowisp"); 00218 add_factory<Yeti>("yeti"); 00219 add_factory<YetiStalactite>("yeti_stalactite"); 00220 add_factory<Zeekling>("zeekling"); 00221 00222 // other objects 00223 add_factory<AmbientSound>("ambient_sound"); 00224 add_factory<Background>("background"); 00225 add_factory<BicyclePlatform>("bicycle-platform"); 00226 add_factory<BonusBlock>("bonusblock"); 00227 add_factory<Candle>("candle"); 00228 add_factory<Coin>("coin"); 00229 add_factory<Decal>("decal"); 00230 add_factory<Explosion>("explosion"); 00231 add_factory<Firefly>("firefly"); 00232 add_factory<Gradient>("gradient"); 00233 add_factory<HurtingPlatform>("hurting_platform"); 00234 add_factory<IceCrusher>("icecrusher"); 00235 add_factory<InfoBlock>("infoblock"); 00236 add_factory<InvisibleWall>("invisible_wall"); 00237 add_factory<Ispy>("ispy"); 00238 add_factory<Lantern>("lantern"); 00239 add_factory<LevelTime>("leveltime"); 00240 add_factory<MagicBlock>("magicblock"); 00241 add_factory<Platform>("platform"); 00242 add_factory<PneumaticPlatform>("pneumatic-platform"); 00243 add_factory<PowerUp>("powerup"); 00244 add_factory<PushButton>("pushbutton"); 00245 add_factory<Rock>("rock"); 00246 add_factory<ScriptedObject>("scriptedobject"); 00247 add_factory<SkullTile>("skull_tile"); 00248 add_factory<Spotlight>("spotlight"); 00249 add_factory<Thunderstorm>("thunderstorm"); 00250 add_factory<TileMap>("tilemap"); 00251 add_factory<Trampoline>("trampoline"); 00252 add_factory<UnstableTile>("unstable_tile"); 00253 add_factory<WeakBlock>("weak_block"); 00254 add_factory<Wind>("wind"); 00255 00256 // trigger 00257 add_factory<Climbable>("climbable"); 00258 add_factory<Door>("door"); 00259 add_factory<ScriptTrigger>("scripttrigger"); 00260 add_factory<SecretAreaTrigger>("secretarea"); 00261 add_factory<SequenceTrigger>("sequencetrigger"); 00262 add_factory<Switch>("switch"); 00263 }
Factories ObjectFactory::factories [private] |