void World::NoCheckMove(const ushort x, const ushort y, const ushort z, const ushort newx, const ushort newy, const ushort newz, const quint8 dir) { Block * const block = GetBlock(x, y, z); Block * const block_to = GetBlock(newx, newy, newz); PutBlock(block_to, x, y, z); PutBlock(block, newx, newy, newz); if ( block_to->Transparent() != block->Transparent() ) { ReEnlighten(newx, newy, newz); ReEnlighten(x, y, z); } block_to->Move( Anti(dir) ); block->Move(dir); Shred * shred = GetShred(x, y); shred->AddFalling(Shred::CoordInShred(x), Shred::CoordInShred(y), z+1); shred->AddFalling(Shred::CoordInShred(x), Shred::CoordInShred(y), z); shred = GetShred(newx, newy); shred->AddFalling(Shred::CoordInShred(newx), Shred::CoordInShred(newy), newz+1); shred->AddFalling(Shred::CoordInShred(newx), Shred::CoordInShred(newy), newz); }
void RainMachine::DoRareAction() { if ( not isOn ) return; if ( AIR == GetInvSub(0) ) { if ( RandomManager::getRandBit2() ) { GetShred()->Rain(LIQUID, SUB_CLOUD); } } else if ( RandomManager::rand() % (20 - Count(0)*2) ) { GetShred()->Rain(LIQUID, GetInvSub(0)); } }
void Active::UpdateLightRadius(const int old_radius) { if ( IsInside() ) return; const int radius = LightRadius(); if ( radius != old_radius ) { const XyzInt xyz = GetXyz(); World* const world = World::GetWorld(); world->Shine(xyz, -old_radius); world->Shine(xyz, radius); emit world->UpdatedAround(XYZ(xyz)); } if ( radius && old_radius == 0 ) { GetShred()->AddShining(this); } else if ( old_radius && radius == 0 ) { GetShred()->RemShining(this); } }
void RainMachine::Damage(const int dmg, const int dmg_kind) { if ( dmg_kind >= DAMAGE_PUSH_UP ) { GetShred()->SetWeather( (isOn = not isOn) ? WEATHER_RAIN : WEATHER_CLEAR ); } else { Block::Damage(dmg, dmg_kind); } }
//private. use Enlightened instead, which is smart wrapper of this. uchar World::LightMap( const ushort x, const ushort y, const ushort z) const { return GetShred(x, y)-> LightMap(x%shred_width, y%shred_width, z); }
//private bool World::SetLightMap( const uchar level, const ushort x, const ushort y, const ushort z) { return GetShred(x, y)-> SetLightMap(level, x%shred_width, y%shred_width, z); }
void World::DestroyAndReplace(const ushort x, const ushort y, const ushort z) { Block * const temp = GetBlock(x, y, z); if ( temp->Durability() > 0 ) { return; } Block * const dropped = temp->DropAfterDamage(); Shred * const shred = GetShred(x, y); const ushort x_in_shred = Shred::CoordInShred(x); const ushort y_in_shred = Shred::CoordInShred(y); if ( PILE!=temp->Kind() && (temp->HasInventory() || dropped) ) { Block * const new_pile=( ( dropped && PILE==dropped->Kind() ) ? dropped : NewBlock(PILE, DIFFERENT) ); shred->SetBlock(new_pile, x_in_shred, y_in_shred, z); Inventory * const inv = temp->HasInventory(); Inventory * const new_pile_inv = new_pile->HasInventory(); if ( inv ) { new_pile_inv->GetAll(inv); } if ( dropped && PILE!=dropped->Kind() && !new_pile_inv->Get(dropped) ) { DeleteBlock(dropped); } shred->AddFalling(x_in_shred, y_in_shred, z); } else { PutBlock(Normal(AIR), x, y, z); } const int old_transparency = temp->Transparent(); const uchar old_light = temp->LightRadius(); DeleteBlock(temp); shred->AddFalling(x_in_shred, y_in_shred, z+1); if ( old_transparency != INVISIBLE ) { ReEnlightenBlockRemove(x, y, z); } if ( old_light ) { RemoveFireLight(x, y, z); } } // void World::DestroyAndReplace(ushort x, y, z)
int Active::Y() const { return GetShred()->ShredY() << SHRED_WIDTH_BITSHIFT | Xyz::Y(); }
Falling::~Falling() { if ( not IsInside() && falling ) { GetShred()->RemFalling(this); } }
int World::Sub(const ushort x, const ushort y, const ushort z) const { return GetShred(x, y)-> Sub(Shred::CoordInShred(x), Shred::CoordInShred(y), z); }
int World::Transparent(const ushort x, const ushort y, const ushort z) const { return GetShred(x, y)-> GetBlock(Shred::CoordInShred(x), Shred::CoordInShred(y), z)-> Transparent(); }
void World::PutBlock(Block * const block, const ushort x, const ushort y, const ushort z) { GetShred(x, y)->PutBlock(block, Shred::CoordInShred(x), Shred::CoordInShred(y), z); }
Block * World::GetBlock(const ushort x, const ushort y, const ushort z) const { return GetShred(x, y)-> GetBlock(Shred::CoordInShred(x), Shred::CoordInShred(y), z); }