Skip to content

Instantly share code, notes, and snippets.

@mackthehobbit
Created August 4, 2015 12:39
Show Gist options
  • Save mackthehobbit/9fc13b0a935f996b7778 to your computer and use it in GitHub Desktop.
Save mackthehobbit/9fc13b0a935f996b7778 to your computer and use it in GitHub Desktop.
#pragma once
#include <string>
class Level;
class Mob;
class TileSource;
class Vec3;
class Vec2;
class MobFactory {
public:
MobFactory(Level &);
Mob *CreateMob(int entityType, TileSource &ts, const Vec3 &position, Vec2 *rotation);
};
...
// could be any class, this is just an example
// anywhere you can get a Level instance, you could spawn a mob by the same method
class SomeItem : public Item {
public:
...
virtual void use(ItemInstance&, Player &player) {
// 32 = zombie
player.level->mobFactory->CreateMob(32, player.region, player.getPos(), player.getRotation());
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment