Package games.stendhal.server.entity

Examples of games.stendhal.server.entity.Entity


  private Entity getCollidingObject(final Entity entity, final Rectangle2D area) {
    for (final RPObject other : objects.values()) {
      // Ignore same object
      if (entity != other) {
        final Entity otherEntity = (Entity) other;

        // Check if the objects overlap
        if (area.intersects(otherEntity.getX(), otherEntity.getY(), otherEntity.getWidth(), otherEntity.getHeight())) {
          // Check if it's blocking
          if (otherEntity.isObstacle(entity)) {
            return otherEntity;
          }
        }
      }
    }
View Full Code Here


   * @param y coordinate
   * @return the first entity found if there are more than one or null if there are none
   */
  public synchronized Entity getEntityAt(final double x, final double y) {
    for (final RPObject other : objects.values()) {
      final Entity otherEntity = (Entity) other;

      final Rectangle2D rect = otherEntity.getArea();
      if (rect.contains(x, y)) {
        return otherEntity;
      }
    }
    return null;
View Full Code Here

   */
  public synchronized List<Entity> getEntitiesAt(final double x, final double y) {
    List<Entity> entities = new LinkedList<Entity>();

    for (final RPObject other : objects.values()) {
      final Entity entity = (Entity) other;

      final Rectangle2D rect = entity.getArea();
      if (rect.contains(x, y)) {
        entities.add(entity);
      }
    }

View Full Code Here

  public List<Entity> getFilteredEntities(final FilterCriteria<Entity> criteria) {
    final List <Entity> result = new LinkedList<Entity>();

    for (final RPObject obj : objects.values()) {
              if (obj instanceof Entity) {
          final Entity entity = (Entity) obj;
          if (criteria.passes(entity)) {
            result.add(entity);
          }

        }
View Full Code Here

   */
  private void createEntityCollisionMap() {
    Point targetPoint = new Point(goalNode.getX(), goalNode.getY());
    resistanceMap = new ResistanceMap(zone.getWidth(), zone.getHeight());
    for (final RPObject obj : zone) {
      final Entity otherEntity = (Entity) obj;
      if (!entity.getID().equals(otherEntity.getID())
          && (otherEntity.stopped() || otherEntity.nextTo(
              startNode.getX(), startNode.getY(), 0.25))) {
        final Rectangle2D area = otherEntity.getArea();
        // Hack: Allow players to move onto portals as destination
        if ((entity instanceof Player) && (otherEntity instanceof Portal) && area.contains(targetPoint)) {
          continue;
        }
        int resistance = otherEntity.getResistance(entity);
        resistanceMap.addResistance(area, resistance);
      }
    }
  }
View Full Code Here

    if ((target == null) || (player == null)) {
      return null;
    }

    final StendhalRPZone zone = player.getZone();
    Entity entity = null;

    if ((target.length() > 1) && (target.charAt(0) == '#')
        && Character.isDigit(target.charAt(1))) {
      final int objectId = Integer.parseInt(target.substring(1));
View Full Code Here

    if ((target == null) || (player == null)) {
      return null;
    }

    final StendhalRPZone zone = player.getZone();
    Entity entity = null;

    if ((target.length() > 1) && (target.charAt(0) == '#')
        && Character.isDigit(target.charAt(1))) {
      final int objectId = Integer.parseInt(target.substring(1));
View Full Code Here

    if (!(base instanceof Entity)) {
      // Shouldn't really happen because everything is an entity
      return null;
    }

    final Entity baseEntity = (Entity) base;

    if (baseEntity.hasSlot(action.get(ATTR_BASESLOT))) {
      final RPSlot slot = baseEntity.getSlot(action.get(ATTR_BASESLOT));

      if (slot.size() == 0) {
        return null;
      }
View Full Code Here

            if (!(base instanceof Entity)) {
                // Shouldn't really happen because everything is an entity
                return null;
            }

            final Entity baseEntity = (Entity) base;

            if (baseEntity.hasSlot(action.get(ATTR_BASESLOT))) {
                final RPSlot slot = baseEntity.getSlot(action.get(ATTR_BASESLOT));
                if (!(slot instanceof EntitySlot)) {
                    return null;
                }
                return (EntitySlot) slot;
            }

        } else if (action.has(TARGET)) {
           
            String target = action.get(TARGET);

            if ((target.length() > 1) && (target.charAt(0) == '#')
                    && Character.isDigit(target.charAt(1))) {
                final int objectId = Integer.parseInt(target.substring(1));

                Entity entity = entityFromZoneByID(objectId, zone);
                if ((entity != null) && (entity instanceof Item)) {
                    return new GroundSlot(zone, (Item) entity);
                } else {
                    return null;
                }
View Full Code Here

  }

  public void onAction(final Player player, final RPAction action) {

    // evaluate the target parameter
    final Entity entity = EntityHelper.entityFromTargetName(
      action.get(TARGET), player);

    if ((entity == null) || !(entity instanceof HousePortal)) {
      // unlikely to happen since players can only see Knock on HousePortal right click menus, but you never know ...
      player.sendPrivateText("Hmm, that's not something you can knock on effectively.");
View Full Code Here

TOP

Related Classes of games.stendhal.server.entity.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.