本文整理汇总了C++中ObjectManager::createNewObject方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectManager::createNewObject方法的具体用法?C++ ObjectManager::createNewObject怎么用?C++ ObjectManager::createNewObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::createNewObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createGame
void taeRuleset::createGame() {
Game* game = Game::getGame();
ObjectManager* obm = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
//Create ship design category
Category* cat = new Category();
cat->setName("Ships");
cat->setDescription("Ship components");
game->getDesignStore()->addCategory(cat);
//Create properties
createProperties();
//Create components
createComponents();
//Create resources
setupResources();
uint32_t obT_Universe = obtm->getObjectTypeByName("Universe");
uint32_t obT_Galaxy = obtm->getObjectTypeByName("Galaxy");
//Create the universe
IGObject* universe = obm->createNewObject();
obtm->setupObject(universe, obT_Universe);
Universe* theUniverse = (Universe*)(universe->getObjectBehaviour());
theUniverse->setSize(1000000000000ll);
universe->setName("The Universe");
theUniverse->setPosition(Vector3d(0ll,0ll,0ll));
obm->addObject(universe);
//Create the galaxy
IGObject* gal = obm->createNewObject();
obtm->setupObject(gal, obT_Galaxy);
EmptyObject* galob = (EmptyObject*)(gal->getObjectBehaviour());
galob->setSize(100000000000ll);
gal->setName("The Fertile Galaxy");
galob->setPosition(Vector3d(0ll, -6000ll, 0ll));
gal->addToParent(universe->getID());
obm->addObject(gal);
string path = string(Settings::getSettings()->get("board_path"));
Logger::getLogger()->debug(path.c_str());
createBoard(path, gal->getID());
Logger::getLogger()->info("TaE created");
}
示例2: createBoard
void taeRuleset::createBoard(string path, uint32_t galaxy) {
Game* game = Game::getGame();
ObjectManager* obm = game->getObjectManager();
ObjectTypeManager* obtm = game->getObjectTypeManager();
stack<string> lines;
string line;
int row = 0;
ifstream file (path.c_str());
//Attempt to read in a custom map
if (file.is_open())
{
while(!file.eof()) {
getline (file,line);
lines.push(line);
}
if(lines.top().compare("") == 0) {
lines.pop();
}
file.close();
} else {
//Build default map
lines.push(string("....MMMMM.A.M..."));
lines.push(string(".A..M.......M..A"));
lines.push(string("...MMA......MM.."));
lines.push(string("MMMM.........MMM"));
lines.push(string(".............AMM"));
lines.push(string("..............M."));
lines.push(string("MMMM....A...MMM."));
lines.push(string(".A.MMMM.....M..."));
lines.push(string("......MMMMMMM.A."));
lines.push(string(".....A.........."));
lines.push(string("..........A....."));
}
while(!lines.empty()) {
line = lines.top();
lines.pop();
for(int i = 0; i < line.length(); i++) {
//Create a star system
IGObject* sys1 = obm->createNewObject();
obtm->setupObject(sys1, obtm->getObjectTypeByName("Star System"));
StarSystem* sys1ob = (StarSystem*)(sys1->getObjectBehaviour());
sys1ob->setSize(60000ll);
char* name = new char[8];
sprintf(name, "%d, %d", i, row);
sys1->setName(name);
sys1ob->setPosition(Vector3d(1ll + 80000ll*i, 1ll+80000ll*(row+1), 0ll));
sys1ob->setDestroyed(false);
sys1->addToParent(galaxy);
obm->addObject(sys1);
//Create a planet
IGObject *p = obm->createNewObject();
obtm->setupObject(p, obtm->getObjectTypeByName("Planet"));
Planet * pob = (Planet*)(p->getObjectBehaviour());
pob->setSize(2);
char* planetName = new char[20];
sprintf(planetName, "Planet %d, %d", i, row);
p->setName(planetName);
pob->setPosition(sys1ob->getPosition());
OrderQueue *planetoq = new OrderQueue();
planetoq->setObjectId(p->getID());
planetoq->addOwner(0);
game->getOrderManager()->addOrderQueue(planetoq);
OrderQueueObjectParam* oqop = static_cast<OrderQueueObjectParam*>(p->getParameterByType(obpT_Order_Queue));
oqop->setQueueId(planetoq->getQueueId());
pob->setDefaultOrderTypes();
p->addToParent(sys1->getID());
obm->addObject(p);
if(line[i] == '.') {
sys1ob->setInhabitable(true);
} else if (line[i] == 'M') {
sys1ob->setInhabitable(false);
pob->addResource(1,1);
} else if (line[i] == 'A') {
sys1ob->setInhabitable(true);
sys1ob->setRegion(sys1->getID());
pob->addResource(3,1);
pob->addResource(5,1);
}
}
row++;
}
}