Ejemplo n.º 1
0
void TiledMapLoader::loadGidFactories(cocos2d::TMXTiledMap& map)
{
    Value* info = nullptr;

    for (auto& child : map.getChildren()) {
        auto mapLayer = dynamic_cast<TMXLayer*>(child);
        if (!mapLayer) {
            continue;
        }

        for (int x = 0; x < map.getMapSize().width; ++x) {
            for (int y = 0; y < map.getMapSize().height; ++y) {

                auto currentGID = mapLayer->getTileGIDAt({static_cast<float>(x), static_cast<float>(y)});
                if (!gidFactories.count(currentGID)) {
                    continue;
                }

                map.getPropertiesForGID(currentGID, &info);
                ValueMap data;

                if (info) {
                    data = info->asValueMap();
                }

                if (!data.count("gid")) data["gid"] = Value(static_cast<int>(currentGID));
                if (!data.count("x")) data["x"] = Value(static_cast<float>(x));
                if (!data.count("y")) data["y"] = Value(static_cast<float>(y));

                Configuration config{data, mapLayer->getLayerName(), map, box2dContainer};
                for (auto& callback : gidFactories.at(currentGID)) {
                    callback(config);
                }
            }
        }
    }
}
Ejemplo n.º 2
0
bool Session::snmpGetNext( Identifier &identifier, Value &value, ErrorInfo *error )
{
    ValueMap vars;
    IdentifierList ids;

    ids << identifier;

    if ( !snmpGetInternal( SNMP_MSG_GETNEXT, ids, vars, error ) )
        return false;

    assert( vars.count() == 1 );

    ValueMap::ConstIterator it = vars.begin();
    identifier = it.key();
    value = it.data();

    return true;

}