当前位置: 首页>>代码示例>>C++>>正文


C++ MetaType类代码示例

本文整理汇总了C++中MetaType的典型用法代码示例。如果您正苦于以下问题:C++ MetaType类的具体用法?C++ MetaType怎么用?C++ MetaType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MetaType类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: construct

void *KOPtrManager::onClone( Falcon::VMachine *, void *user_data ) 
{
    MetaType *md = (MetaType*) user_data;
    
    // Perform a complete cloning
    return QMetaType::construct( md->typeId(), md->toVoidStar() );
}
开发者ID:KDE,项目名称:kross-interpreters,代码行数:7,代码来源:falconobjman.cpp

示例2: canMakeNow

bool ProductionManager::canMakeNow(BWAPI::UnitInterface* producer, MetaType t)
{
    //UAB_ASSERT(producer != NULL, "Producer was null");

	bool canMake = meetsReservedResources(t);
	if (canMake)
	{
		if (t.isUnit())
		{
			canMake = BWAPI::Broodwar->canMake(t.unitType, producer);
		}
		else if (t.isTech())
		{
			canMake = BWAPI::Broodwar->canResearch(t.techType, producer);
		}
		else if (t.isUpgrade())
		{
			canMake = BWAPI::Broodwar->canUpgrade(t.upgradeType, producer);
		}
		else
		{	
			UAB_ASSERT(false, "Unknown type");
		}
	}

	return canMake;
}
开发者ID:nbarriga,项目名称:ualbertabot,代码行数:27,代码来源:ProductionManager.cpp

示例3: createMetaType

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::createMetaType(BWAPI::UnitInterface* producer, MetaType t) 
{
    if (!producer)
    {
        return;
    }

    // if we're dealing with a building
    if (t.isUnit() && t.unitType.isBuilding() 
        && t.unitType != BWAPI::UnitTypes::Zerg_Lair 
        && t.unitType != BWAPI::UnitTypes::Zerg_Hive
        && t.unitType != BWAPI::UnitTypes::Zerg_Greater_Spire
        && !t.unitType.isAddon())
    {
        // send the building task to the building manager
        BuildingManager::Instance().addBuildingTask(t.unitType, BWAPI::Broodwar->self()->getStartLocation());
    }
    else if (t.unitType.isAddon())
    {
        BWAPI::Broodwar->printf("Building Addon");
        //BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
        producer->buildAddon(t.unitType);
    }
    // if we're dealing with a non-building unit
    else if (t.isUnit()) 
    {
        // if the race is zerg, morph the unit
        if (t.unitType.getRace() == BWAPI::Races::Zerg) 
        {
            producer->morph(t.unitType);
        // if not, train the unit
        } 
        else 
        {
            producer->train(t.unitType);
        }
    }
    // if we're dealing with a tech research
    else if (t.isTech())
    {
        producer->research(t.techType);
    }
    else if (t.isUpgrade())
    {
        //Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
        producer->upgrade(t.upgradeType);
    }
    else
    {	
		
    }
}
开发者ID:nbarriga,项目名称:ualbertabot,代码行数:53,代码来源:ProductionManager.cpp

示例4: canMakeNow

bool ProductionManager::canMakeNow(BWAPI::Unit producer, MetaType t)
{
    //UAB_ASSERT(producer != nullptr, "Producer was null");

	bool canMake = meetsReservedResources(t);
	if (canMake)
	{
		if (t.isUnit())
		{
			canMake = BWAPI::Broodwar->canMake(t.getUnitType(), producer);
		}
		else if (t.isTech())
		{
			canMake = BWAPI::Broodwar->canResearch(t.getTechType(), producer);
		}
		else if (t.isUpgrade())
		{
			if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
			{
				BWAPI::Broodwar->printf("Trying to create carapace with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
			}
			else if ((t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks))
			{
				BWAPI::Broodwar->printf("Trying to create misisle attacks with %d %d EVO CHAMBER\n", producer->getTilePosition().x, producer->getTilePosition().y);
			}
			canMake = BWAPI::Broodwar->canUpgrade(t.getUpgradeType(), producer);
		}
		else
		{	
			UAB_ASSERT(false, "Unknown type");
		}
	}

	return canMake;
}
开发者ID:0x4849,项目名称:c350,代码行数:35,代码来源:ProductionManagerbuggy.cpp

示例5: GetActionType

BOSS::ActionType BOSSManager::GetActionType(const MetaType & t)
{
	// set the appropriate type
	if (t.isUnit())
	{
		return BOSS::ActionType(t.unitType);
	}
	else if (t.isUpgrade())
	{
		return BOSS::ActionType(t.upgradeType);
	} 
	else if (t.isTech())
	{
		return BOSS::ActionType(t.techType);
	}
	else
	{
		UAB_ASSERT(false, "Should have found a valid type here");
	}
	
	return BOSS::ActionType();
}
开发者ID:NextGenIntelligence,项目名称:ualbertabot,代码行数:22,代码来源:BOSSManager.cpp

示例6: getEvolutionChamberProducer

BWAPI::Unit ProductionManager::getEvolutionChamberProducer(BWAPI::Unit producer, MetaType t)
{
	if (upgradingStuff.find(producer) != upgradingStuff.end())
	{
		BWAPI::Broodwar->printf("Entered uprgading stuff loop\n");
		for (auto x : BWAPI::Broodwar->self()->getUnits())
		{
			if (x->getType() == producer->getType() && x != producer)
			{
				if (upgradeMap.find(x) == upgradeMap.end() || (upgradeMap.find(x) != upgradeMap.end() && upgradeMap[x] == 0))
				{
					upgradeMap[x] = BWAPI::Broodwar->getFrameCount() + t.getUpgradeType().upgradeTime();
					return x;
				}
			}
		}
	}
	return producer;
}
开发者ID:0x4849,项目名称:c350,代码行数:19,代码来源:ProductionManagerbuggy.cpp

示例7: meetsReservedResources

// return whether or not we meet resources, including building reserves
bool ProductionManager::meetsReservedResources(MetaType type) 
{
	// return whether or not we meet the resources
	return (type.mineralPrice() <= getFreeMinerals()) && (type.gasPrice() <= getFreeGas());
}
开发者ID:pineal,项目名称:SC_AI_Flash,代码行数:6,代码来源:ProductionManager.cpp

示例8: getProducer

BWAPI::Unit ProductionManager::getProducer(MetaType t, BWAPI::Position closestTo)
{
    // get the type of unit that builds this
    BWAPI::UnitType producerType = t.whatBuilds();

    // make a set of all candidate producers
    BWAPI::Unitset candidateProducers;
    for (auto & unit : BWAPI::Broodwar->self()->getUnits())
    {
        UAB_ASSERT(unit != nullptr, "Unit was null");

        // reasons a unit can not train the desired type
        if (unit->getType() != producerType)                    { continue; }
        if (!unit->isCompleted())                               { continue; }
        if (unit->isTraining())                                 { continue; }
        if (unit->isLifted())                                   { continue; }
        if (!unit->isPowered())                                 { continue; }

        // if the type is an addon, some special cases
        if (t.getUnitType().isAddon())
        {
            // if the unit already has an addon, it can't make one
            if (unit->getAddon() != nullptr)
            {
                continue;
            }

            // if we just told this unit to build an addon, then it will not be building another one
            // this deals with the frame-delay of telling a unit to build an addon and it actually starting to build
            if (unit->getLastCommand().getType() == BWAPI::UnitCommandTypes::Build_Addon 
                && (BWAPI::Broodwar->getFrameCount() - unit->getLastCommandFrame() < 10)) 
            { 
                continue; 
            }

            bool isBlocked = false;

            // if the unit doesn't have space to build an addon, it can't make one
            BWAPI::TilePosition addonPosition(unit->getTilePosition().x + unit->getType().tileWidth(), unit->getTilePosition().y + unit->getType().tileHeight() - t.getUnitType().tileHeight());
            BWAPI::Broodwar->drawBoxMap(addonPosition.x*32, addonPosition.y*32, addonPosition.x*32 + 64, addonPosition.y*32 + 64, BWAPI::Colors::Red);
            
            for (int i=0; i<unit->getType().tileWidth() + t.getUnitType().tileWidth(); ++i)
            {
                for (int j=0; j<unit->getType().tileHeight(); ++j)
                {
                    BWAPI::TilePosition tilePos(unit->getTilePosition().x + i, unit->getTilePosition().y + j);

                    // if the map won't let you build here, we can't build it
                    if (!BWAPI::Broodwar->isBuildable(tilePos))
                    {
                        isBlocked = true;
                        BWAPI::Broodwar->drawBoxMap(tilePos.x*32, tilePos.y*32, tilePos.x*32 + 32, tilePos.y*32 + 32, BWAPI::Colors::Red);
                    }

                    // if there are any units on the addon tile, we can't build it
                    BWAPI::Unitset uot = BWAPI::Broodwar->getUnitsOnTile(tilePos.x, tilePos.y);
                    if (uot.size() > 0 && !(uot.size() == 1 && *(uot.begin()) == unit))
                    {
                        isBlocked = true;;
                        BWAPI::Broodwar->drawBoxMap(tilePos.x*32, tilePos.y*32, tilePos.x*32 + 32, tilePos.y*32 + 32, BWAPI::Colors::Red);
                    }
                }
            }

            if (isBlocked)
            {
                continue;
            }
        }
        
        // if the type requires an addon and the producer doesn't have one
        typedef std::pair<BWAPI::UnitType, int> ReqPair;
        for (const ReqPair & pair : t.getUnitType().requiredUnits())
        {
            BWAPI::UnitType requiredType = pair.first;
            if (requiredType.isAddon())
            {
                if (!unit->getAddon() || (unit->getAddon()->getType() != requiredType))
                {
                    continue;
                }
            }
        }

        // if we haven't cut it, add it to the set of candidates
        candidateProducers.insert(unit);
    }

    return getClosestUnitToPosition(candidateProducers, closestTo);
}
开发者ID:pineal,项目名称:SC_AI_Flash,代码行数:90,代码来源:ProductionManager.cpp

示例9: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item) 
{
    if (!producer)
    {
        return;
    }

    MetaType t = item.metaType;

    // if we're dealing with a building
    if (t.isUnit() && t.getUnitType().isBuilding() 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
        && !t.getUnitType().isAddon())
    {
        // send the building task to the building manager
		if (t.getUnitType() == BWAPI::UnitTypes::Terran_Bunker)
		{
			BWAPI::TilePosition tp = BWAPI::TilePosition(BWTA::getNearestChokepoint(BWAPI::Position(BWAPI::Broodwar->self()->getStartLocation()))->getCenter());
			BuildingManager::Instance().addBuildingTask(t.getUnitType(), tp, item.isGasSteal);
		}
		else {
			BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
		}
    }
    else if (t.getUnitType().isAddon())
    {
        //BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
        producer->buildAddon(t.getUnitType());
    }
    // if we're dealing with a non-building unit
    else if (t.isUnit()) 
    {
        // if the race is zerg, morph the unit
        if (t.getUnitType().getRace() == BWAPI::Races::Zerg) 
        {
            producer->morph(t.getUnitType());
        // if not, train the unit
        } 
        else 
        {
            producer->train(t.getUnitType());
        }
    }
    // if we're dealing with a tech research
    else if (t.isTech())
    {
        producer->research(t.getTechType());
    }
    else if (t.isUpgrade())
    {
        //Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
        producer->upgrade(t.getUpgradeType());
    }
    else
    {	
		
    }
}
开发者ID:smithe0,项目名称:ualbertabot,代码行数:61,代码来源:ProductionManager.cpp

示例10: MetaType

void ProductionManager::buildBunker() {
	BWAPI::Position base = BWAPI::Position(BWAPI::Broodwar->self()->getStartLocation());
	BWTA::Chokepoint *entrance = BWTA::getNearestChokepoint(base); 
	MetaType bunker = MetaType(BWAPI::UnitTypes::Terran_Bunker);
	BWAPI::Unit producer = ProductionManager::Instance().getProducer(bunker, entrance->getCenter());

	int numBarracks = BWAPI::Broodwar->self()->allUnitCount(BWAPI::UnitTypes::Terran_Barracks);
	bool canMake = canMakeNow(producer, bunker);

	Building b(bunker.getUnitType(), BWAPI::TilePosition(entrance->getCenter()));
	b.isGasSteal = false;

	// set the producer as the closest worker, but do not set its job yet
	producer = WorkerManager::Instance().getBuilder(b, false);
	// get a possible building location for the building
	
	if (!_haveLocationForThisBuilding)
	{
		_predictedTilePosition = BuildingManager::Instance().getBuildingLocation(b);
	}

	if (_predictedTilePosition != BWAPI::TilePositions::None)
	{
		_haveLocationForThisBuilding = true;
	}

	if (producer && canMake && (numBarracks > 0))
	{
		// create it
		create(producer, BuildOrderItem(bunker, 1, true));
		_assignedWorkerForThisBuilding = false;
		_haveLocationForThisBuilding = false;

		// draw a box where the building will be placed
		int x1 = _predictedTilePosition.x * 32;
		int x2 = x1 + (b.type.tileWidth()) * 32;
		int y1 = _predictedTilePosition.y * 32;
		int y2 = y1 + (b.type.tileHeight()) * 32;
		if (Config::Debug::DrawWorkerInfo)
		{
			BWAPI::Broodwar->drawBoxMap(x1, y1, x2, y2, BWAPI::Colors::Blue, false);
		}

		// where we want the worker to walk to
		BWAPI::Position walkToPosition = BWAPI::Position(x1 + (b.type.tileWidth() / 2) * 32, y1 + (b.type.tileHeight() / 2) * 32);

		// compute how many resources we need to construct this building
		int mineralsRequired = std::max(0, b.type.mineralPrice() - getFreeMinerals());
		int gasRequired = std::max(0, b.type.gasPrice() - getFreeGas());

		// get a candidate worker to move to this location
		BWAPI::Unit moveWorker = WorkerManager::Instance().getMoveWorker(walkToPosition);

		// Conditions under which to move the worker: 
		//		- there's a valid worker to move
		//		- we haven't yet assigned a worker to move to this location
		//		- the build position is valid
		//		- we will have the required resources by the time the worker gets there
		if (moveWorker && _haveLocationForThisBuilding && !_assignedWorkerForThisBuilding && (_predictedTilePosition != BWAPI::TilePositions::None) &&
			WorkerManager::Instance().willHaveResources(mineralsRequired, gasRequired, moveWorker->getDistance(walkToPosition)))
		{
			// we have assigned a worker
			_assignedWorkerForThisBuilding = true;

			// tell the worker manager to move this worker
			WorkerManager::Instance().setMoveWorker(mineralsRequired, gasRequired, walkToPosition);
		}
	}
}
开发者ID:smithe0,项目名称:ualbertabot,代码行数:69,代码来源:ProductionManager.cpp

示例11: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item)
{
	if (!producer)
	{
		return;
	}

	MetaType t = item.metaType;

	// if we're dealing with a building
	if (t.isUnit() && t.getUnitType().isBuilding()
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
		&& !t.getUnitType().isAddon())
	{
		// send the building task to the building manager
		BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
	}
	else if (t.getUnitType().isAddon())
	{
		//BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
		producer->buildAddon(t.getUnitType());
	}
	// if we're dealing with a non-building unit
	else if (t.isUnit())
	{
		// if the race is zerg, morph the unit
		if (t.getUnitType().getRace() == BWAPI::Races::Zerg)
		{
			producer->morph(t.getUnitType());
			if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
			{
				_overlordTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime() + 35;
			}

			// if not, train the unit
		}
		else
		{
			producer->train(t.getUnitType());
		}
	}
	// if we're dealing with a tech research
	else if (t.isTech())
	{
		producer->research(t.getTechType());
	}
	else if (t.isUpgrade())
	{
		//Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
		
		if (t.getUpgradeType() == BWAPI::UpgradeTypes::Muscular_Augments)
		{
			muscBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUpgradeType().upgradeTime();
			muscBuild = true;
		}
		producer->upgrade(t.getUpgradeType());
	}
	else
	{

	}
}
开发者ID:0x4849,项目名称:c350,代码行数:66,代码来源:ProductionManager.cpp

示例12: create

// this function will check to see if all preconditions are met and then create a unit
void ProductionManager::create(BWAPI::Unit producer, BuildOrderItem & item) 
{
    if (!producer)
    {
        return;
    }

    MetaType t = item.metaType;

    // if we're dealing with a building
    if (t.isUnit() && t.getUnitType().isBuilding() 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Lair 
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Hive
        && t.getUnitType() != BWAPI::UnitTypes::Zerg_Greater_Spire
		&& t.getUnitType() != BWAPI::UnitTypes::Zerg_Sunken_Colony
        && !t.getUnitType().isAddon())
    {
        // send the building task to the building manager
        BuildingManager::Instance().addBuildingTask(t.getUnitType(), BWAPI::Broodwar->self()->getStartLocation(), item.isGasSteal);
    }
    else if (t.getUnitType().isAddon())
    {
        //BWAPI::TilePosition addonPosition(producer->getTilePosition().x + producer->getType().tileWidth(), producer->getTilePosition().y + producer->getType().tileHeight() - t.unitType.tileHeight());
        producer->buildAddon(t.getUnitType());
    }
    // if we're dealing with a non-building unit
    else if (t.isUnit()) 
    {
        // if the race is zerg, morph the unit
        if (t.getUnitType().getRace() == BWAPI::Races::Zerg) 
        {
			if (t.getUnitType() == BWAPI::UnitTypes::Zerg_Overlord)
			{
				overlordBuildTimer = BWAPI::Broodwar->getFrameCount() + t.getUnitType().buildTime();
				canOverlord = true;
			}
            producer->morph(t.getUnitType());
        // if not, train the unit
        } 
        else 
        {
            producer->train(t.getUnitType());
        }
    }
    // if we're dealing with a tech research
    else if (t.isTech())
    {
        producer->research(t.getTechType());
    }
    else if (t.isUpgrade())
    {
		if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Carapace)
		{
			BWAPI::Broodwar->printf("Got a request for carapace upgrade using producer x %d y %d: \n", producer->getTilePosition().x, producer->getTilePosition().y);
		}
		else if (t.getUpgradeType() == BWAPI::UpgradeTypes::Zerg_Missile_Attacks)
		{
			BWAPI::Broodwar->printf("Got a request for missile attacks upgrade using producer x %d y %d : \n", producer->getTilePosition().x, producer->getTilePosition().y);
		}
		producer = getEvolutionChamberProducer(producer, t);
		//BWAPI::Broodwar->printf("Got request for capace or missile attacks with producer type : x : %d  y: %d\n", producer->getTilePosition().x, producer->getTilePosition().y);
		//}
        //Logger::Instance().log("Produce Upgrade: " + t.getName() + "\n");
        producer->upgrade(t.getUpgradeType());
		upgradingStuff.insert(producer);
    }
    else
    {	
		
    }
}
开发者ID:0x4849,项目名称:c350,代码行数:72,代码来源:ProductionManagerbuggy.cpp


注:本文中的MetaType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。