本文整理汇总了C++中EntityList类的典型用法代码示例。如果您正苦于以下问题:C++ EntityList类的具体用法?C++ EntityList怎么用?C++ EntityList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main ( int argc,
char *argv[] )
{
int i;
for ( i=1; i<argc; ++i )
{
Graph *g = new Graph ( );
EntityList *el = new EntityList ( );
el->parseFromFile ( argv[i] );
g->initFromEntityList ( el );
delete el;
g->assignGridCoordinates ( );
delete g;
}
return 0;
}
示例2: ForceRange
void ScrollComponent::SetPosition(CL_Vec2f vDisplacement, bool bForceUpdate)
{
if (vDisplacement == CL_Vec2f(0,0) && !bForceUpdate) return;
/*
//this works, but it still totally feels wrong, really I would need to turn "momentum" off as well, and perfectly tune the
//sensitivity so it feels like you're dragging the scroll bar
if (IsDesktop())
{
vDisplacement.y *= -1; //on desktops where you use a mouse, it makes more sense to drag the scroll bar down, rather than "drag the screen up"
}
*/
m_vecChildPos += vDisplacement;
//force it within our ranges
ForceRange(m_vecChildPos.x, m_pBoundsRect->left, m_pBoundsRect->right);
if (m_pBoundsRect->top > m_pBoundsRect->bottom) m_pBoundsRect->top = m_pBoundsRect->bottom;
ForceRange(m_vecChildPos.y, m_pBoundsRect->top, m_pBoundsRect->bottom);
CL_Vec2f percent2d(0,0);
//avoid divide by 0 errors
if (m_pBoundsRect->get_width() != 0) percent2d.x = m_vecChildPos.x/(-m_pBoundsRect->get_width());
if (m_pBoundsRect->get_height() != 0) percent2d.y = m_vecChildPos.y/ (-m_pBoundsRect->get_height());
m_progressVar->Set(percent2d);
//also run this on all children
EntityList *pChildren = GetParent()->GetChildren();
Variant *pPos;
EntityList::iterator itor = pChildren->begin();
while (itor != pChildren->end())
{
pPos = (*itor)->GetVar("pos2d");
pPos->Set(m_vecChildPos);
itor++;
}
}
示例3: doRun
void EntityShadows::doRun(::Camera& camera, const TileList& tl, const EntityList& el) {
// If shadows are not enabled, return immediatly.
if (!gfx.shadows_enable) {
return;
}
// Get the renderer.
auto& renderer = Renderer::get();
// Do not write into the depth buffer.
renderer.setDepthWriteEnabled(false);
// Enable depth tests.
renderer.setDepthTestEnabled(true);
// Enable blending.
renderer.setBlendingEnabled(true);
renderer.setBlendFunction(BlendFunction::Zero, BlendFunction::OneMinusSourceColour);
// Keep track of the number of rendered shadows.
size_t count = 0;
if (gfx.shadows_highQuality_enable) {
// Render high-quality shadows.
for (size_t i = 0; i < el.getSize(); ++i) {
CHR_REF ichr = el.get(i).ichr;
if (INVALID_CHR_REF == ichr) continue;
if (0 == _currentModule->getObjectHandler().get(ichr)->shadow_size) continue;
doHighQualityShadow(ichr);
count++;
}
} else {
// Render low-quality shadows.
for (size_t i = 0; i < el.getSize(); ++i) {
CHR_REF ichr = el.get(i).ichr;
if (INVALID_CHR_REF == ichr) continue;
if (0 == _currentModule->getObjectHandler().get(ichr)->shadow_size) continue;
doLowQualityShadow(ichr);
count++;
}
}
}
示例4: assert
void Map::ResolveCell(EntityList& entities,
Entities::EntityDispatcherBase& dispatcher)
{
assert(entities.count());
Location loc = entities[0]->NewLocation();
QList<Entity*> new_entities;
for (EntityList::const_iterator it = entities.begin();
it != entities.end(); ++it)
{
Entity* lhs = *it;
for (EntityList::const_iterator jt = it + 1; jt != entities.end(); jt++)
{
if (!lhs->Alive())
{
break;
}
Entity* rhs = *jt;
if (!rhs->Alive())
{
continue;
}
new_entities.append(dispatcher.Dispatch(*lhs, *rhs));
}
}
for (EntityList::const_iterator it = entities.begin();
it != entities.end(); ++it)
{
Entity *entity_p( *it );
if (entity_p->Alive())
{
entity_p->SetLocation(loc);
entity_p->Commit();
}
}
for (QList<Entity*>::const_iterator it = new_entities.begin();
it != new_entities.end(); ++it)
{
Entity *entity_p = *it;
entity_p->SetLocation(loc);
entity_p->Commit();
entities.append(entity_p);
}
}
示例5: projectDebris
void DebrisFountain::projectDebris(EntityList &entityList, Direction direction, Position from, double spread, int amount, RGB &colour, float size)
{
double startAngle = direction.Angle() - spread / 2.0;
double angleStep = spread / (double) amount;
for (int i = 0; i < amount; i++)
{
Direction debrisDirection{direction.Speed(), startAngle+angleStep*i, ((rand() % 10) / 10.f) - 0.5f};
Actor *actor = new Actor(colour, mover, renderer, std::unique_ptr<ElapsedTimeToLive>(new ElapsedTimeToLive(1000)));
actor->position().set(from.X(), from.Y(), from.Rotation());
actor->direction().set(debrisDirection);
actor->shape().Radius(size);
entityList.add(actor);
}
}
示例6:
void Spawn2::LoadGrid() {
if(!npcthis)
return;
if(grid_ < 1)
return;
if(!entity_list.IsMobInZone(npcthis))
return;
//dont set an NPC's grid until its loaded for them.
npcthis->SetGrid(grid_);
npcthis->AssignWaypoints(grid_);
_log(SPAWNS__MAIN, "Spawn2 %d: Loading grid %d for %s", spawn2_id, grid_, npcthis->GetName());
}
示例7: GetNPCType
uint32 SpawnGroup::GetNPCType() {
int npcType = 0;
int totalchance = 0;
if(!entity_list.LimitCheckGroup(id, group_spawn_limit))
return(0);
std::list<SpawnEntry*>::iterator cur,end;
std::list<SpawnEntry*> possible;
cur = list_.begin();
end = list_.end();
for(; cur != end; ++cur) {
SpawnEntry *se = *cur;
if(!entity_list.LimitCheckType(se->NPCType, se->npc_spawn_limit))
continue;
totalchance += se->chance;
possible.push_back(se);
}
if(totalchance == 0)
return 0;
int32 roll = 0;
roll = MakeRandomInt(0, totalchance-1);
cur = possible.begin();
end = possible.end();
for(; cur != end; ++cur) {
SpawnEntry *se = *cur;
if (roll < se->chance) {
npcType = se->NPCType;
break;
} else {
roll -= se->chance;
}
}
return npcType;
}
示例8: Process
bool Beacon::Process()
{
if(remove_me)
{
return false;
}
if
(
spell_timer.Enabled() &&
spell_timer.Check() &&
IsValidSpell(spell_id)
)
{
Mob *caster = entity_list.GetMob(caster_id);
if(caster && spell_iterations-- && max_targets)
{
// NPCs should never be affected by an AE they cast. PB AEs shouldn't affect caster either
// I don't think any other cases that get here matter
bool affect_caster = (!caster->IsNPC() && !caster->IsAIControlled()) && spells[spell_id].targettype != ST_AECaster;
entity_list.AESpell(caster, this, spell_id, affect_caster, resist_adjust, &max_targets);
}
else
{
// spell is done casting, or caster disappeared
spell_id = 0xFFFF;
spell_iterations = 0;
spell_timer.Disable();
caster_id = 0;
}
}
if(remove_timer.Enabled() && remove_timer.Check())
{
return false;
}
return true;
}
示例9: SendRaidMoveAll
void Raid::SendRaidMoveAll(const char* who)
{
Client *c = entity_list.GetClientByName(who);
SendRaidRemoveAll(who);
if(c)
SendRaidCreate(c);
SendMakeLeaderPacket(leadername);
SendRaidAddAll(who);
if(c){
SendBulkRaid(c);
if(IsLocked()) { SendRaidLockTo(c); }
}
}
示例10: _shutdown
void _shutdown()
{
if( mTerrainPaging )
{
OGRE_DELETE mTerrainPaging;
OGRE_DELETE mPageManager;
}
else
OGRE_DELETE mTerrainGroup;
OGRE_DELETE mTerrainGlobals;
mHouseList.clear();
SdkSample::_shutdown();
}
示例11: RandomSpawn
void Object::RandomSpawn(bool send_packet) {
if(!m_ground_spawn)
return;
m_data.x = MakeRandomFloat(m_min_x, m_max_x);
m_data.y = MakeRandomFloat(m_min_y, m_max_y);
respawn_timer.Disable();
if(send_packet) {
EQApplicationPacket app;
CreateSpawnPacket(&app);
entity_list.QueueClients(NULL, &app, true);
}
}
示例12: Process
bool Beacon::Process()
{
if(remove_me)
{
return false;
}
if
(
spell_timer.Enabled() &&
spell_timer.Check() &&
IsValidSpell(spell_id)
)
{
Mob *caster = entity_list.GetMob(caster_id);
if(caster && spell_iterations--)
{
bool affect_caster = (!caster->IsNPC() && !caster->IsAIControlled()); //NPC AE spells do not affect the NPC caster
entity_list.AESpell(caster, this, spell_id, affect_caster, resist_adjust);
}
else
{
// spell is done casting, or caster disappeared
spell_id = 0xFFFF;
spell_iterations = 0;
spell_timer.Disable();
caster_id = 0;
}
}
if(remove_timer.Enabled() && remove_timer.Check())
{
return false;
}
return true;
}
示例13: DisbandGroup
void Group::DisbandGroup() {
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupUpdate_Struct));
GroupUpdate_Struct* gu = (GroupUpdate_Struct*) outapp->pBuffer;
gu->action = groupActDisband;
Client *Leader = nullptr;
uint32 i;
for (i = 0; i < MAX_GROUP_MEMBERS; i++)
{
if (members[i] == nullptr)
{
continue;
}
if (members[i]->IsClient())
{
if(IsLeader(members[i]))
{
Leader = members[i]->CastToClient();
}
strcpy(gu->yourname, members[i]->GetName());
database.SetGroupID(members[i]->GetName(), 0, members[i]->CastToClient()->CharacterID());
members[i]->CastToClient()->QueuePacket(outapp);
}
members[i]->SetGrouped(false);
members[i] = nullptr;
membername[i][0] = '\0';
}
ServerPacket* pack = new ServerPacket(ServerOP_DisbandGroup, sizeof(ServerDisbandGroup_Struct));
ServerDisbandGroup_Struct* dg = (ServerDisbandGroup_Struct*)pack->pBuffer;
dg->zoneid = zone->GetZoneID();
dg->groupid = GetID();
dg->instance_id = zone->GetInstanceID();
worldserver.SendPacket(pack);
safe_delete(pack);
entity_list.RemoveGroup(GetID());
if(GetID() != 0)
{
database.ClearGroup(GetID());
}
safe_delete(outapp);
}
示例14: SetGroupMentor
void Raid::SetGroupMentor(uint32 group_id, int percent, char *name)
{
if (group_id > 11)
return;
group_mentor[group_id].name = name;
group_mentor[group_id].mentor_percent = percent;
Client *client = entity_list.GetClientByName(name);
group_mentor[group_id].mentoree = client ? client : nullptr;
std::string query = StringFormat("UPDATE raid_leaders SET mentoree = '%s', mentor_percent = %i WHERE gid = %i AND rid = %i LIMIT 1",
name, percent, group_id, GetID());
auto results = database.QueryDatabase(query);
if (!results.Success())
LogFile->write(EQEMuLog::Error, "Unable to set raid group mentor: %s\n", results.ErrorMessage().c_str());
}
示例15: CheckSpawnLimit
bool CheckSpawnLimit(int32 in_NPCTypeID)
{
if ( in_NPCTypeID <= 0 )
return false;
// check limit from database
int db_limit = Database::Instance()->CheckNPCTypeSpawnLimit(in_NPCTypeID);
if (db_limit > 0) // Doing this check first because we want to avoid a zone entity_list iteration if we can help it
{
// There should be a limit now, let's check to see how many exist in the zone
if ( entity_list.GetNPCTypeCount(in_NPCTypeID) >= db_limit )
return false; // Hit the cap, don't allow any more to spawn!
}
return true;
}