本文整理汇总了C++中ActorSet类的典型用法代码示例。如果您正苦于以下问题:C++ ActorSet类的具体用法?C++ ActorSet怎么用?C++ ActorSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActorSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAll
void ActorSet::addAll(ActorSet &s)
{
for(ActorSet::iterator iter = s.begin(); iter != s.end(); ++iter)
{
insert(*iter);
}
}
示例2: 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;
}
示例3: ASSERT
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;
}
示例4: SplitString
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;
}
}
}
示例5: moveObject
void ActorSet::moveObject(ActorSet &dest, OBJECT_ID id)
{
ASSERT(isMember(id), "The object is not a member of this set");
ASSERT(!dest.isMember(id), "The object is already a member of the other set");
// Add it to the other set
dest.insert( make_pair(id, toActor(*find(id))) );
// Remove it from this set
erase(find(id));
}
示例6: bounds
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
}
示例7: exclude
ActorSet ActorSet::exclude(OBJECT_ID id) const
{
ActorSet s = *this;
ActorSet::iterator iter = s.find(id);
if(iter != s.end()) // if present
{
s.erase(iter);
}
return s;
}
示例8: haveMoved
ActorSet ActorSet::haveMoved(void) const
{
ActorSet s;
for(const_iterator i=begin(); i!=end(); ++i)
{
const Actor *p = i->second;
if(!p->zombie && (p->hasAnimated || p->hasMoved))
{
s.insert(*i);
}
}
return s;
}
示例9: isNotWithin
ActorSet ActorSet::isNotWithin(const Frustum &frustum) const
{
ActorSet s;
for(const_iterator i=begin(); i!=end(); ++i)
{
const Actor *p = i->second;
if(!p->zombie && !frustum.SphereInFrustum2(p->getPos(), p->getSphereRadius()*2))
{
s.insert(*i);
}
}
return s;
}
示例10: TextActor
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
}
示例11: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
glutInit(&argc, argv);
MainWindow mainWin;
mainWin.show();
ActorSet* aset = new ActorSet();;
for(int i = 1; i < argc; i++){
aset->addActorFromPath(argv[i]);
}
mainWin.setActorSet(aset);
return app.exec();
}
示例12: calculateReceivers
ActorSet Shadow::calculateReceivers(const ActorSet &zoneActors, const mat4& lightProjectionMatrix, const mat4& lightViewMatrix)
{
Frustum f;
f.CalculateFrustum(lightViewMatrix, lightProjectionMatrix);
const ActorSet s = zoneActors.isWithin(f);
return s;
}
示例13: 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();
}
示例14: getZone
void Bullet::onTrigger(void)
{
OBJECT_ID id = INVALID_ID;
// Only consider Creature from our World that are not the Bullet owner
ActorSet s = getZone().getObjects().typeFilter<Creature>().exclude(owner);
if(isAnythingInProximity(s, id))
{
Creature& creature = dynamic_cast<Creature&>(s.get(id));
creature.damage(damageValue, owner);
creature.applyKnockBack(creature.getPos()-getPos());
if(causesFreeze)
creature.freeze();
kill();
}
}
示例15: update
void Shadow::update(const ActorSet &zoneActors, float deltaTime)
{
if(light!=0 && zoneActors.isMember(actorID))
{
const Actor &actor = zoneActors.get(actorID);
// Update the shadow when something has changed
needsUpdate |= (actor.hasAnimated || actor.hasMoved);
// Update when necessary or requested
if(needsUpdate)
{
float lx=0, ly=0;
calculateAngularSpread(actor, lightViewMatrix, lx, ly);
calculateMatrices(*light, actor, shadowMapSize, lightProjectionMatrix, lightViewMatrix, textureMatrix, lx, ly);
frustum = calculateFrustum(lightProjectionMatrix, lightViewMatrix);
if(g_Application.displayDebugData)
{
calculateFrustumVertices(*light, actor, lx, ly, ntl, ntr, nbl, nbr, ftl, ftr, fbl, fbr);
}
renderToShadow(shadowMapTexture, shadowMapSize, actor, lightProjectionMatrix, lightViewMatrix);
needsUpdate=false;
}
// Periodically take some time to determine the actors that be receiving this shadow
periodicTimer-=deltaTime;
if(periodicTimer<0)
{
periodicTimer = 250.0f + FRAND_RANGE(100.0f, 250.0f); // stagger
receivers = calculateReceivers(zoneActors, lightProjectionMatrix, lightViewMatrix);
}
}
}