Exemple #1
0
void Level::updateVisibility(Vec2 changedSquare) {
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionInfo::NORMAL))
    addLightSource(pos, squares[pos]->getLightEmission(), -1);
  for (auto& elem : fieldOfView)
    elem.squareChanged(changedSquare);
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionInfo::NORMAL))
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
}
Exemple #2
0
void Level::updateVisibility(Vec2 changedSquare) {
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionId::NORMAL)) {
    addLightSource(pos, squares[pos]->getLightEmission(), -1);
    if (Creature* c = squares[pos]->getCreature())
      if (c->isDarknessSource())
        addDarknessSource(pos, darknessRadius, -1);
  }
  for (VisionId vision : ENUM_ALL(VisionId))
    fieldOfView[vision].squareChanged(changedSquare);
  for (Vec2 pos : getVisibleTilesNoDarkness(changedSquare, VisionId::NORMAL)) {
    addLightSource(pos, squares[pos]->getLightEmission(), 1);
    if (Creature* c = squares[pos]->getCreature())
      if (c->isDarknessSource())
        addDarknessSource(pos, darknessRadius, 1);
  }
}
Exemple #3
0
void Level::addLightSource(Vec2 pos, double radius, int numLight) {
  if (radius > 0) {
    for (Vec2 v : getVisibleTilesNoDarkness(pos, VisionId::NORMAL)) {
      double dist = (v - pos).lengthD();
      if (dist <= radius)
        lightAmount[v] += min(1.0, 1 - (dist) / radius) * numLight;
    }
  }
}
Exemple #4
0
void Level::addLightSource(Vec2 pos, double radius, int numLight) {
  if (radius > 0) {
    for (Vec2 v : getVisibleTilesNoDarkness(pos, VisionInfo::NORMAL)) {
      double dist = (v - pos).lengthD();
      if (dist <= radius)
        squares[v]->addLight(min(1.0, 1 - (dist) / radius) * numLight);
    }
  }
}
Exemple #5
0
void Level::addDarknessSource(Vec2 pos, double radius, int numDarkness) {
  if (radius > 0) {
    for (Vec2 v : getVisibleTilesNoDarkness(pos, VisionId::NORMAL)) {
      double dist = (v - pos).lengthD();
      if (dist <= radius)
        lightCapAmount[v] -= min(1.0, 1 - (dist) / radius) * numDarkness;
      squares[v]->updateSunlightMovement(isInSunlight(v));
      updateConnectivity(v);
    }
  }
}