本文整理汇总了C++中ActorSet::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ActorSet::begin方法的具体用法?C++ ActorSet::begin怎么用?C++ ActorSet::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActorSet
的用法示例。
在下文中一共展示了ActorSet::begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetObjectsTagged
ActorSet TagCollection::GetObjectsTagged(String findTag)
{
StringList tags = SplitString(findTag, ", ");
if (tags.size() == 0)
{
return ActorSet();
}
else if (tags.size() == 1)
{
findTag = ToLower(findTag);
std::map<String, ActorSet>::iterator it = _tagMappings.find(findTag);
if (it != _tagMappings.end())
{
return it->second;
}
else
{
return ActorSet();
}
}
else
{
ActorSet t1;
ActorSet t2;
String searchTag = ToLower(tags[0]);
bool t1_active = true;
t1 = GetObjectsTagged(searchTag);
for(unsigned int i=1; i < tags.size(); i++)
{
searchTag = ToLower(tags[i]);
ActorSet compare = GetObjectsTagged(searchTag);
if (t1_active)
{
std::set_intersection(t1.begin(), t1.end(), compare.begin(), compare.end(), std::inserter(t2, t2.begin()));
t1.clear();
t1_active = false;
}
else
{
std::set_intersection(t2.begin(), t2.end(), compare.begin(), compare.end(), std::inserter(t1, t1.begin()));
t2.clear();
t1_active = true;
}
}
if (t1_active)
{
return t1;
}
else
{
return t2;
}
}
}
示例2: getApplicableTargets
ActorSet MonsterFSM::getApplicableTargets(void) const
{
ASSERT(m_Owner!=0, "Owner was NULL");
ActorSet s = m_Owner->getZone().getObjects().exclude(m_Owner->m_ID).typeFilter<Player>();
// remove actors that are dead or ghosts
ActorSet::iterator i = s.begin();
while(i != s.end())
{
ActorSet::iterator nextIterator = i;
++nextIterator;
const Player &player = dynamic_cast<const Player&>(*i->second);
if(!player.isAlive())
{
s.erase(i);
}
i = nextIterator;
}
return s;
}
示例3: addAll
void ActorSet::addAll(ActorSet &s)
{
for(ActorSet::iterator iter = s.begin(); iter != s.end(); ++iter)
{
insert(*iter);
}
}
示例4: Create
Actor* Actor::Create(String archetype)
{
//TODO: this is kind of a fragile way to get the Actor the script created.
// Let's figure out a smarter way to get the object directly from Python,
// hopefully without introducing a bunch of Python API code into Angel proper.
String markerTag = "last-spawned-actor-from-code";
String toExec = "Actor._lastSpawnedActor = Actor.Create('" + archetype + "')\n";
toExec += "Actor._lastSpawnedActor.Tag('" + markerTag + "')\n";
theWorld.ScriptExec(toExec);
ActorSet tagged = theTagList.GetObjectsTagged(markerTag);
if (tagged.size() > 1)
{
sysLog.Log("WARNING: more than one Actor tagged with '" + markerTag + "'. (" + archetype + ")");
}
if (tagged.size() < 1)
{
sysLog.Log("ERROR: Script failed to create Actor with archetype " + archetype + ". ");
return NULL;
}
ActorSet::iterator it = tagged.begin();
Actor* forReturn = *it;
toExec = "Actor._lastSpawnedActor.__disown__()\n";
toExec += "Actor._lastSpawnedActor = None\n";
theWorld.ScriptExec(toExec);
if (forReturn != NULL)
{
forReturn->Untag(markerTag);
}
return forReturn;
}
示例5: Start
void DemoScreenPathfinding::Start()
{
//Set up our obstacle course
theWorld.LoadLevel("maze");
//Create the bounding box that will limit the pathfinding search area
BoundingBox bounds(Vector2(-20, -20), Vector2(20, 20));
//Create our pathfinding graph. In our 2D worlds, this is a relatively fast
// operation -- you shouldn't be doing it every frame, but recalculating every
// so often if your world has changed is not inappropriate.
theSpatialGraph.CreateGraph(
0.75f, //The size of the entity you want to pathfind (so the generator
// can know how small a space can be and still have it fit.)
bounds //The search area
);
//Create a MazeFinder (class definition below), and put him in the bottom
// left corner of the maze
MazeFinder *mf = new MazeFinder();
mf->SetPosition(-11.5, -8);
theWorld.Add(mf);
//Send him to the upper right, watch him scurry
mf->GoTo(Vector2(11.5, 8));
//Demo housekeeping below this point.
#pragma region Demo housekeeping
String description = "This little dude is pathfinding through the area.";
description += "\n\nClick the mouse to give him a new target.";
description += "\n\nPress [B] to see the pathfinding graph.";
TextActor *t = new TextActor("Console", description);
t->SetAlignment(TXT_Center);
t->SetPosition(0.0f, -5.0f);
theWorld.Add(t);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenPathfinding.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(mf);
ActorSet walls = theTagList.GetObjectsTagged("maze_wall");
ActorSet::iterator it = walls.begin();
while (it != walls.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}
示例6: Start
void DemoScreenLayeredCollisionLevelFile::Start()
{
//Give names to some layers so we can reference them more easily
theWorld.NameLayer("background", 0);
theWorld.NameLayer("foreground", 1);
theWorld.NameLayer("hud", 2);
//Loads the file from Config\ActorDef\layeredcollisionlevel_demo.lua
theWorld.LoadLevel("layeredcollisionlevel_demo");
//All the magic happens in the level file!
//Demo housekeeping below this point.
#pragma region Demo housekeeping
t2 = new TextActor("Console", "These new Actors were assigned layers in their level file.");
t2->SetPosition(0, 5.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2, 10);
t3 = new TextActor("Console", "Layers can be given string names as well as numbers");
t3->SetPosition(0, 4.5);
t3->SetAlignment(TXT_Center);
theWorld.Add(t3, 10);
t4 = new TextActor("Console", "and assigned to Actors in their definition file or at runtime.");
t4->SetPosition(0, 3.5);
t4->SetAlignment(TXT_Center);
theWorld.Add(t4, 10);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLayeredCollisionLevelFile.cpp, layeredcollisionlevel_demo.lua");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc, 10);
_objects.push_back(fileLoc);
_objects.push_back(t2);
_objects.push_back(t3);
_objects.push_back(t4);
ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
ActorSet::iterator it = spawnedActors.begin();
while (it != spawnedActors.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}
示例7: Update
void GotoTargetAIEvent::Update(float dt)
{
ActorSet taggedActors = theTagList.GetObjectsTagged(_targetTag);
for( ActorSet::iterator itr = taggedActors.begin(); itr != taggedActors.end(); itr++ )
{
Actor* pTargetActor = (*itr);
if( theSpatialGraph.IsInPathableSpace( pTargetActor->GetPosition() ) )
{
_destination = pTargetActor->GetPosition();
GotoAIEvent::Update( dt );
return;
}
}
//otherwise, we failed
_moveFailed = true;
IssueCallback();
}
示例8: Start
void DemoScreenLevelFile::Start()
{
//Loads the file from Config\ActorDef\level_demo.lua
// Level files automatically add their actors to the world.
theWorld.LoadLevel("level_demo");
//Since the Actors were just added directly to the world,
// we don't have handles to them. The level definition
// gave them the tag "spawned," so we can get them that way.
ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
ActorSet::iterator it = spawnedActors.begin();
while (it != spawnedActors.end())
{
//Can check Individual actors for tags as well.
if ((*it)->IsTagged("left-tilted"))
{
(*it)->SetRotation(25.0f);
}
else if ((*it)->IsTagged("right-tilted"))
{
(*it)->SetRotation(-25.0f);
}
//Applying tags
(*it)->Tag("rotated");
//Removing tags
(*it)->Untag("spawned");
it++;
}
//Demo housekeeping below this point.
#pragma region Demo housekeeping
t = new TextActor("Console", "These Actors were placed and tagged (\"left-tilted\"");
t->SetPosition(0, 5.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
t2 = new TextActor("Console", "and \"right-tilted\") using a level definition file.");
t2->SetPosition(0, 4.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2);
t3 = new TextActor("Console", "Then their rotations were set based on those tags.");
t3->SetPosition(0, -4.5);
t3->SetAlignment(TXT_Center);
theWorld.Add(t3);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLevelFile.cpp, level_demo.lua");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(t3);
it = spawnedActors.begin();
while (it != spawnedActors.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}