コード例 #1
0
ファイル: DynamicObject.cpp プロジェクト: Actionfox/mangos
void DynamicObject::Update(uint32 p_time)
{
    // caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
    Unit* caster = GetCaster();
    if(!caster)
    {
        Delete();
        return;
    }

    bool deleteThis = false;

    if(m_aliveDuration > int32(p_time))
        m_aliveDuration -= p_time;
    else
        deleteThis = true;

    // TODO: make a timer and update this in larger intervals
    CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
    Cell cell(p);
    cell.data.Part.reserved = ALL_DISTRICT;
    cell.SetNoCreate();

    MaNGOS::DynamicObjectUpdater notifier(*this,caster);

    TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
    TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);

    CellLock<GridReadGuard> cell_lock(cell, p);
    cell_lock->Visit(cell_lock, world_object_notifier, *GetMap());
    cell_lock->Visit(cell_lock, grid_object_notifier,  *GetMap());

    if(deleteThis)
    {
        caster->RemoveDynObjectWithGUID(GetGUID());
        Delete();
    }
}
コード例 #2
0
ファイル: Compounding.cpp プロジェクト: qadll52001314/loa
bool CompoundMgr::IsNearSpellFocus(const Player* player, uint32 spellFocus) const
{
    GameObject* focus = NULL;
    Trinity::GameObjectFocusCheck check(player, spellFocus);
    Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck> searcher(player, focus, check);

    float x, y;
    x = player->GetPositionX();
    y = player->GetPositionY();

    CellCoord p(Trinity::ComputeCellCoord(x, y));
    Cell cell(p);
    cell.SetNoCreate();

    Map& map = *(player->GetMap());

    TypeContainerVisitor<Trinity::GameObjectSearcher<Trinity::GameObjectFocusCheck>, GridTypeMapContainer >  grid_object_notifier(searcher);
    cell.Visit(p, grid_object_notifier, map, player->GetVisibilityRange(), x, y);

    if (focus)
        return true;
    return false;
}