本文整理汇总了C++中UnitArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitArray::push_back方法的具体用法?C++ UnitArray::push_back怎么用?C++ UnitArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitArray
的用法示例。
在下文中一共展示了UnitArray::push_back方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBestUnitTarget
Unit* AscentScriptCreatureAI::GetBestUnitTarget( TargetFilter pTargetFilter, float pMinRange, float pMaxRange )
{
//Build potential target list
UnitArray TargetArray;
if ( pTargetFilter & TargetFilter_Friendly )
{
for ( unordered_set< Object* >::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
{
if ( IsValidUnitTarget( *ObjectIter, pTargetFilter, pMinRange, pMaxRange ) )
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
};
if ( IsValidUnitTarget( _unit, pTargetFilter ) )
TargetArray.push_back( _unit ); //Also add self as possible friendly target
}
else
{
for ( unordered_set< Object* >::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
{
if ( IsValidUnitTarget( *ObjectIter, pTargetFilter, pMinRange, pMaxRange ) )
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
};
};
return ChooseBestTargetInArray( TargetArray, pTargetFilter );
};
示例2: ChooseBestTargetInArray
Unit *MoonScriptCreatureAI::GetBestUnitTarget( TargetFilters pTargetFilter, float pMinRange, float pMaxRange)
{
//Build potential target list
UnitArray TargetArray;
if ( pTargetFilter & TargetFilter_Friendly )
{
for ( unordered_set< Object *>::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
{
// Trololololo.......
if( IsValidUnitTarget(*ObjectIter, pTargetFilter, pMinRange, pMaxRange) )
{
if(pTargetFilter & TargetFilter_ManaClass)
{
if(TO_UNIT(*ObjectIter)->GetPowerType() == POWER_TYPE_MANA)
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
}
else
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
}
};
if ( IsValidUnitTarget( _unit, pTargetFilter ) )
TargetArray.push_back( _unit ); //Also add self as possible friendly target
}
else
{
for ( unordered_set< Object *>::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
{
// Problem, Dylan?
if( IsValidUnitTarget(*ObjectIter, pTargetFilter, pMinRange, pMaxRange) )
{
if(pTargetFilter & TargetFilter_ManaClass)
{
if(TO_UNIT(*ObjectIter)->GetPowerType() == POWER_TYPE_MANA)
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
}
else
TargetArray.push_back( TO_UNIT( *ObjectIter ) );
}
};
};
return ChooseBestTargetInArray( TargetArray, pTargetFilter );
};
示例3: GetBestPlayerTarget
Unit* ArcScriptCreatureAI::GetBestPlayerTarget(TargetFilter pFilter)
{
//Build potential target list
UnitArray TargetArray;
for( set<Player*>::iterator PlayerIter = _unit->GetInRangePlayerSetBegin(); PlayerIter != _unit->GetInRangePlayerSetEnd(); ++PlayerIter )
{
if( IsValidUnitTarget(*PlayerIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*PlayerIter));
}
return ChooseBestTargetInArray(TargetArray, pFilter);
}
示例4: GetBestUnitTarget
Unit* ArcScriptCreatureAI::GetBestUnitTarget(TargetFilter pFilter)
{
//Build potential target list
UnitArray TargetArray;
if( pFilter & TargetFilter_Friendly )
{
for( std::set<Object*>::iterator ObjectIter = _unit->GetInRangeSetBegin(); ObjectIter != _unit->GetInRangeSetEnd(); ++ObjectIter )
{
if( IsValidUnitTarget(*ObjectIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*ObjectIter));
}
if( IsValidUnitTarget(_unit, pFilter) ) TargetArray.push_back(_unit); //Also add self as possible friendly target
}
else
{
for( std::set<Object*>::iterator ObjectIter = _unit->GetInRangeOppFactsSetBegin(); ObjectIter != _unit->GetInRangeOppFactsSetEnd(); ++ObjectIter )
{
if( IsValidUnitTarget(*ObjectIter, pFilter) ) TargetArray.push_back(static_cast<Unit*>(*ObjectIter));
}
}
return ChooseBestTargetInArray(TargetArray, pFilter);
}
示例5: GetInRangePlayers
UnitArray GetInRangePlayers()
{
UnitArray TargetArray;
for (unordered_set<Player*>::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); itr++)
{
if (IsValidUnitTarget(*itr, TargetFilter_None))
{
TargetArray.push_back(TO_UNIT(*itr));
}
}
return TargetArray;
}
示例6: GetInRangePlayers
UnitArray GetInRangePlayers()
{
UnitArray TargetArray;
for (set< Object* >::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); ++itr)
{
if (IsValidUnitTarget(*itr, TargetFilter_None))
{
TargetArray.push_back(TO< Unit* >(*itr));
}
}
return TargetArray;
}
示例7:
Unit *MoonScriptCreatureAI::ForceCreatureFind( uint32 pCreatureId, float pX, float pY, float pZ )
{
Unit *UnitPtr = NULLUNIT;
MapMgr *Mgr = _unit->GetMapMgr();
if ( Mgr == NULL )
return UnitPtr;
UnitPtr = TO_UNIT(Mgr->GetObjectClosestToCoords(pCreatureId, pX, pY, pZ, 99999.0f, TYPEID_UNIT ));
if ( UnitPtr == NULL )
{
UnitArray Array;
for ( uint32 i = 0; i != Mgr->m_CreatureHighGuid; ++i )
{
UnitPtr = Mgr->m_CreatureStorage[ i ];
if ( UnitPtr != NULL )
{
if ( UnitPtr->GetEntry() == pCreatureId && UnitPtr != _unit )
Array.push_back( UnitPtr );
}
}
if ( Array.size() == 1 )
return Array[ 0 ];
UnitPtr = NULLUNIT;
float Distance, NearestDistance = 99999;
for ( UnitArray::iterator UnitIter = Array.begin(); UnitIter != Array.end(); ++UnitIter )
{
Distance = _unit->CalcDistance( pX, pY, pZ, ( *UnitIter )->GetPositionX(), ( *UnitIter )->GetPositionY(), ( *UnitIter )->GetPositionZ() );
if ( Distance < NearestDistance )
{
NearestDistance = Distance;
UnitPtr = ( *UnitIter );
}
}
}
return UnitPtr;
}
示例8: ForceCreatureFind
Unit* AscentScriptCreatureAI::ForceCreatureFind( uint32 pCreatureId, float pX, float pY, float pZ )
{
Unit* UnitPtr = NULL;
MapMgr* Mgr = _unit->GetMapMgr();
if ( Mgr == NULL )
return UnitPtr;
UnitPtr = Mgr->GetInterface()->GetCreatureNearestCoords( pX, pY, pZ, pCreatureId );
if ( UnitPtr == NULL )
{
UnitArray Array;
for ( uint32 i = 0; i != Mgr->m_CreatureHighGuid; ++i )
{
UnitPtr = Mgr->m_CreatureStorage[ i ];
if ( UnitPtr != NULL )
{
if ( UnitPtr->GetEntry() == pCreatureId && UnitPtr != _unit )
Array.push_back( UnitPtr );
};
};
if ( Array.size() == 1 )
return Array[ 0 ];
UnitPtr = NULL;
float Distance, NearestDistance = 99999;
for ( UnitArray::iterator UnitIter = Array.begin(); UnitIter != Array.end(); ++UnitIter )
{
Distance = _unit->CalcDistance( pX, pY, pZ, ( *UnitIter )->GetPositionX(), ( *UnitIter )->GetPositionY(), ( *UnitIter )->GetPositionZ() );
if ( Distance < NearestDistance )
{
NearestDistance = Distance;
UnitPtr = ( *UnitIter );
};
};
};
return UnitPtr;
};