本文整理汇总了C++中PatchMap::setInfluence方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchMap::setInfluence方法的具体用法?C++ PatchMap::setInfluence怎么用?C++ PatchMap::setInfluence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchMap
的用法示例。
在下文中一共展示了PatchMap::setInfluence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixupResourceMaps
void Cartographer::fixupResourceMaps(const ResourceType *rt, const Vec2i &pos) {
PF_TRACE();
const Map &map = *world->getMap();
Vec2i junk;
for (set<ResourceMapKey>::iterator it = resourceMapKeys.begin(); it != resourceMapKeys.end(); ++it) {
if (it->resourceType == rt) {
PatchMap<1> *pMap = resourceMaps[*it];
const int &size = it->workerSize;
const Field &field = it->workerField;
Vec2i tl = pos + OrdinalOffsets[odNorthWest] * size;
Vec2i br(tl.x + size + 2, tl.y + size + 2);
Util::RectIterator iter(tl, br);
while (iter.more()) {
Vec2i cur = iter.next();
if (map.isInside(cur) && masterMap->canOccupy(cur, size, field)
&& map.isResourceNear(cur, size, rt, junk)) {
pMap->setInfluence(cur, 1);
} else {
pMap->setInfluence(cur, 0);
}
}
}
}
}
示例2: rect
PatchMap<1>* Cartographer::buildAdjacencyMap(const UnitType *uType, const Vec2i &pos,
CardinalDir facing, Field f, int size) {
PF_TRACE();
const Vec2i mapPos = pos + (OrdinalOffsets[odNorthWest] * size);
const int sx = pos.x;
const int sy = pos.y;
Rectangle rect(mapPos.x, mapPos.y, uType->getSize() + 2 + size, uType->getSize() + 2 + size);
PatchMap<1> *pMap = new PatchMap<1>(rect, 0);
pMap->zeroMap();
PatchMap<1> tmpMap(rect, 0);
tmpMap.zeroMap();
// mark cells occupied by unitType at pos (on tmpMap)
Util::RectIterator rIter(pos, pos + Vec2i(uType->getSize() - 1));
while (rIter.more()) {
Vec2i gpos = rIter.next();
if (!uType->hasCellMap() || uType->getCellMapCell(gpos.x - sx, gpos.y - sy, facing)) {
tmpMap.setInfluence(gpos, 1);
}
}
// mark goal cells on result map
rIter = Util::RectIterator(mapPos, pos + Vec2i(uType->getSize()));
while (rIter.more()) {
Vec2i gpos = rIter.next();
if (tmpMap.getInfluence(gpos) || !masterMap->canOccupy(gpos, size, f)) {
continue; // building or obstacle
}
Util::PerimeterIterator pIter(gpos - Vec2i(1), gpos + Vec2i(size));
while (pIter.more()) {
if (tmpMap.getInfluence(pIter.next())) {
pMap->setInfluence(gpos, 1);
break;
}
}
}
return pMap;
}