bool BTCommon::checkWarDistance()
{
	if(!_eD->_playerSeen) return false; //Si no hemos visto al player, fuera.
	
	if(!_unsheathed) return false; //Si no tenemos la espada en la mano, fuera.
	if(manhattanDist(_eD->_transformC->getPosition(), EntityManager::get().getPlayerPos()) <= _eD->_warDistMh)
	{
		unsigned playerVisibility = EntityManager::get().getComponent<ShadowActionsComponent>(World::instance()->getPlayer())->getVisibility();
		if(playerVisibility == playerVisibility::TELEPORTING) return false;
		else return true;
	}
	return false;
}
Example #2
0
/*
 * Loads small Restaurant Distance structs for the restaurants
 * that meet the minimum rating into a supplied array,
 * and returns the numbers of restaurants loaded
 */
uint16_t loadDistances(uint16_t horiz, uint16_t vert, uint8_t minimumRating, RestDist *distances) {
  uint16_t skippedRestaurants = 0;
  uint16_t distancesIndex = 0;

  for(int i = 0; i < RESTAURANTS_COUNT; i++) {
    Restaurant rest;
    getRestaurant(i, &rest, &card);
    if(rest.rating >= minimumRating) {
      uint16_t rest_horiz = lon_to_x(rest.longitude_scaled);
      uint16_t rest_vert = lat_to_y(rest.latitude_scaled);

      uint16_t distance = manhattanDist(horiz, vert, rest_horiz, rest_vert);

      RestDist restDist = { i, distance };
      distances[distancesIndex] = restDist;
      distancesIndex++;
    } else {
      skippedRestaurants++;
    }
  }
  return RESTAURANTS_COUNT - skippedRestaurants;
}
Example #3
0
// Assign visibility to a dummy vertex representing all the possible pins
// for this pinClassId.
void ConnEnd::assignPinVisibilityTo(VertInf *dummyConnectionVert,
                                    VertInf *targetVert)
{
    unsigned int validPinCount = 0;

    COLA_ASSERT(m_anchor_obj);
    COLA_ASSERT(m_connection_pin_class_id != CONNECTIONPIN_UNSET);

    Router *router = m_anchor_obj->router();
    for (ShapeConnectionPinSet::iterator curr =
                m_anchor_obj->m_connection_pins.begin();
            curr != m_anchor_obj->m_connection_pins.end(); ++curr)
    {
        ShapeConnectionPin *currPin = *curr;
        if ((currPin->m_class_id == m_connection_pin_class_id) &&
                (!currPin->m_exclusive || currPin->m_connend_users.empty()))
        {
            double routingCost = currPin->m_connection_cost;
            Point adjTargetPt = targetVert->point - currPin->m_vertex->point;
            double angle = rotationalAngle(adjTargetPt);
            bool inVisibilityRange = false;

            if (angle <= 45 || angle >= 315)
            {
                if (currPin->directions() & ConnDirRight)
                {
                    inVisibilityRange = true;
                }
            }
            if (angle >= 45 && angle <= 135)
            {
                if (currPin->directions() & ConnDirDown)
                {
                    inVisibilityRange = true;
                }
            }
            if (angle >= 135 && angle <= 225)
            {
                if (currPin->directions() & ConnDirLeft)
                {
                    inVisibilityRange = true;
                }
            }
            if (angle >= 225 && angle <= 315)
            {
                if (currPin->directions() & ConnDirUp)
                {
                    inVisibilityRange = true;
                }
            }
            if (!inVisibilityRange)
            {
                routingCost += router->routingParameter(portDirectionPenalty);
            }

            if (router->m_allows_orthogonal_routing)
            {
                // This has same ID and is either unconnected or not
                // exclusive, so give it visibility.
                EdgeInf *edge = new EdgeInf(dummyConnectionVert,
                                            currPin->m_vertex, true);
                // XXX Can't use a zero cost due to assumptions
                //     elsewhere in code.
                edge->setDist(manhattanDist(dummyConnectionVert->point,
                                            currPin->m_vertex->point) +
                              std::max(0.001, routingCost));
            }

            if (router->m_allows_orthogonal_routing)
            {
                // This has same ID and is either unconnected or not
                // exclusive, so give it visibility.
                EdgeInf *edge = new EdgeInf(dummyConnectionVert,
                                            currPin->m_vertex, false);
                // XXX Can't use a zero cost due to assumptions
                //     elsewhere in code.
                edge->setDist(euclideanDist(dummyConnectionVert->point,
                                            currPin->m_vertex->point) +
                              std::max(0.001, routingCost));
            }

            // Increment the number of valid pins for this ConnEnd connection.
            validPinCount++;
        }
    }

    if (validPinCount == 0)
    {
        // There should be at least one pin, otherwise we will have
        // problems finding connector routes.
        err_printf("Warning: In ConnEnd::assignPinVisibilityTo():\n"
                   "         ConnEnd for connector %d can't connect to shape %d\n"
                   "         since it has no pins with class id of %u.\n",
                   (int) m_conn_ref->id(), (int) m_anchor_obj->id(),
                   m_connection_pin_class_id);
    }
}
bool BTCommon::checkNearCorpse()
{
	if(_targetCorpse == btVector3(0,0,0)) return false;
	return manhattanDist(_eD->_transformC->getPosition(), _targetCorpse) < 4.0f;
}