示例#1
0
void Atmosphere::ProcessTileMove(size_t x, size_t y, size_t z)
{
    auto tile = map_->GetSquares()[x][y][z];
    
    if (tile->GetTurf()->GetAtmosState() == NON_SIMULATED)
    {
        return;
    }
    if (tile->GetTurf()->GetAtmosState() == SPACE)
    {
        return;
    }

    for (size_t d_sh = 0; d_sh < dir_shuffle_.size(); ++d_sh)
    {
        Dir dir = dir_shuffle_[d_sh];

        auto neighbour = tile->GetNeighbourImpl(dir);

        if (!(   (   neighbour->GetTurf()->GetAtmosState() == NON_SIMULATED
                  && PRESSURE_MOVE_BORDER < tile->GetAtmosHolder()->GetPressure())
              || (neighbour->GetAtmosHolder()->GetPressure() + PRESSURE_MOVE_BORDER
                  < tile->GetAtmosHolder()->GetPressure())))
        {
            continue;
        }

        if (!CanPass(tile->GetPassable(dir), Passable::AIR))
        {
            tile->BumpByGas(dir, true);
            continue;
        }

        if (   !CanPass(neighbour->GetPassable(D_ALL), Passable::AIR)
            || !CanPass(neighbour->GetPassable(helpers::revert_dir(dir)), Passable::AIR))
        {
            neighbour->BumpByGas(dir);
            continue;
        }

        if (tile->GetInsideList().size())
        {
            auto i = tile->GetInsideList().rbegin();
            while (   (i != tile->GetInsideList().rend())
                   && ((*i)->passable_level == Passable::EMPTY))
            {
                ++i;
            }
            if (i != tile->GetInsideList().rend())
            {
                (*i)->ApplyForce(DirToVDir[dir]);
            }
        }
    }
}
示例#2
0
void Atmosphere::ProcessTile(size_t x, size_t y, size_t z)
{
    auto tile = map_->GetSquares()[x][y][z];
    
    if (tile->GetTurf()->GetAtmosState() == NON_SIMULATED)
    {
        return;
    }

    //ShuffleDir();

    for (size_t d_sh = 0; d_sh < dir_shuffle_.size(); ++d_sh)
    {
        Dir dir = dir_shuffle_[d_sh];
        auto neighbour = tile->GetNeighbourImpl(dir);
        if (!(   CanPass(tile->GetPassable(dir), Passable::AIR)
              && CanPass(neighbour->GetPassable(helpers::revert_dir(dir)), Passable::AIR)
              && CanPass(neighbour->GetPassable(D_ALL), Passable::AIR))
            )
        {
            continue;
        }

        if (neighbour->GetTurf()->GetAtmosState() == NON_SIMULATED)
        {
            continue;
        }

        int p = MAX_GAS_LEVEL / 2;
        if (!CanPass(tile->GetPassable(D_ALL), Passable::AIR))
        {
            p = 0;
        }

        tile->GetAtmosHolder()->Connect(
            neighbour->GetAtmosHolder(), 
            MAX_GAS_LEVEL, MAX_GAS_LEVEL, p);

        if (tile->GetTurf()->GetAtmosState() == SPACE)
        {
            tile->GetAtmosHolder()->Truncate();
        }
        if (neighbour->GetTurf()->GetAtmosState() == SPACE)
        {
            neighbour->GetAtmosHolder()->Truncate();
        }
    }
}
示例#3
0
void IMovable::ProcessForce()
{
    Dir step = VDirToDir(force_);

    TryMove(step);

    if (!NonZero(force_))
    {
        return;
    }

    VDir vstep = DirToVDir[step];
    force_.x -= (vstep.x * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
    force_.y -= (vstep.y * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
    force_.z -= (vstep.z * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
}
示例#4
0
void IMovable::ProcessForce()
{

    Dir step = VDirToDir(force_);

    checkMove(step);

    if (!NonZero(force_))
        return;

    // qDebug() << "Process force: " << GetId();
    // qDebug() << force_.x;
    // qDebug() << force_.y;

    VDir vstep = DirToVDir[step];
    force_.x -= (vstep.x * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
    force_.y -= (vstep.y * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
    force_.z -= (vstep.z * Friction::CombinedFriction(GetTurf())) / Friction::BASE_FRICTION;
}
示例#5
0
void Lattice::AttackBy(id_ptr_on<Item> item)
{
    if (id_ptr_on<FloorTile> tile = item)
    {
        tile->delThis();

        GetTurf()->delThis();
        SetTurf(GetItemFabric().newItem<ITurf>(Floor::T_ITEM_S()));

        PlaySoundIfVisible("Deconstruct.ogg", owner.ret_id());

        delThis();
    }
}
示例#6
0
void Girder::AttackBy(id_ptr_on<Item> item)
{
    if (id_ptr_on<Metal> metal = item)
    {
        metal->Delete();

        GetTurf()->Delete();
        Create<ITurf>(MetalWall::T_ITEM_S(), GetOwner());

        Delete();
    }
    else if (id_ptr_on<Wrench> wrench = item)
    {
        PlaySoundIfVisible("Ratchet.ogg", owner.ret_id());
        Create<Item>(Metal::T_ITEM_S(), GetOwner());
        Delete();
    }
}