package de.gurkenlabs.litiengine.entities;

import java.awt.geom.Point2D;

import de.gurkenlabs.litiengine.Direction;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectProperty;
import de.gurkenlabs.litiengine.environment.tilemap.TmxProperty;

public class Spawnpoint extends Entity {
  @TmxProperty(name = MapObjectProperty.SPAWN_DIRECTION)
  private Direction direction;
  
  @TmxProperty(name = MapObjectProperty.SPAWN_TYPE)
  private String spawnType;

  public Spawnpoint() {
  }

  public Spawnpoint(double x, double y) {
    this(0, x, y);
  }

  public Spawnpoint(int mapId, double x, double y) {
    this(mapId, new Point2D.Double(x, y));
  }

  public Spawnpoint(int mapId, Point2D point) {
    super(mapId);
    this.setLocation(point);
  }

  public Spawnpoint(int mapId, double x, double y, Direction direction) {
    this(mapId, new Point2D.Double(x, y), direction);
  }

  public Spawnpoint(int mapId, Point2D point, Direction direction) {
    this(mapId, point);
    this.setDirection(direction);
  }

  public Spawnpoint(Direction direction) {
    this.setDirection(direction);
  }

  public Spawnpoint(Direction direction, String spawnType) {
    this(direction);
    this.setSpawnType(spawnType);
  }

  public Direction getDirection() {
    return direction;
  }

  public void setDirection(Direction direction) {
    this.direction = direction;
  }

  public String getSpawnType() {
    return spawnType;
  }

  public void setSpawnType(String spawnType) {
    this.spawnType = spawnType;
  }
}
@@ -111,16 +111,112 @@
 ection;%0A
+import de.gurkenlabs.litiengine.Game;%0Aimport de.gurkenlabs.litiengine.environment.IEnvironment;%0A
 import d
@@ -473,18 +473,16 @@
 ection;%0A
-  
 %0A  @TmxP
@@ -1611,10 +1611,371 @@
 ype;%0A  %7D
+%0A%0A  public void spawn(IMobileEntity entity) %7B%0A    entity.setLocation(this.getLocation());%0A    entity.setAngle(Direction.toAngle(this.getDirection()));%0A%0A    IEnvironment env = this.getEnvironment();%0A    if (env == null) %7B%0A      env = Game.world().environment();%0A    %7D%0A%0A    if (env != null && env.get(entity.getMapId()) == null) %7B%0A      env.add(entity);%0A    %7D%0A  %7D
 %0A%7D

Add a spawn method that will take care of actually spawning the specified entity to the environment.