use of de.gurkenlabs.litiengine.entities.Spawnpoint in project litiengine by gurkenlabs.
the class Environment method addEntity.
private void addEntity(final IEntity entity) {
int desiredID = entity.getMapId();
// assign local map id if the entity's mapID is invalid
if (desiredID == 0 || this.allEntities.keySet().contains(desiredID)) {
entity.setMapId(getLocalMapId());
log.fine(() -> String.format("Entity [%s] was assigned a local mapID because #%d was already taken or invalid.", entity, desiredID));
}
if (entity instanceof Emitter) {
Emitter emitter = (Emitter) entity;
this.addEmitter(emitter);
}
if (entity instanceof ICombatEntity) {
this.combatEntities.put(entity.getMapId(), (ICombatEntity) entity);
}
if (entity instanceof IMobileEntity) {
this.mobileEntities.put(entity.getMapId(), (IMobileEntity) entity);
}
if (entity instanceof Prop) {
this.props.add((Prop) entity);
}
if (entity instanceof Creature) {
this.creatures.add((Creature) entity);
}
if (entity instanceof CollisionBox) {
this.colliders.add((CollisionBox) entity);
}
if (entity instanceof LightSource) {
this.lightSources.add((LightSource) entity);
}
if (entity instanceof Trigger) {
this.triggers.add((Trigger) entity);
}
if (entity instanceof Spawnpoint) {
this.spawnPoints.add((Spawnpoint) entity);
}
if (entity instanceof SoundSource) {
this.soundSources.add((SoundSource) entity);
}
if (entity instanceof StaticShadow) {
this.staticShadows.add((StaticShadow) entity);
} else if (entity instanceof MapArea) {
this.mapAreas.add((MapArea) entity);
}
for (String rawTag : entity.getTags()) {
if (rawTag == null) {
continue;
}
final String tag = rawTag.trim().toLowerCase();
if (tag.isEmpty()) {
continue;
}
this.getEntitiesByTag().computeIfAbsent(tag, t -> new CopyOnWriteArrayList<>()).add(entity);
}
// we need to load the new entity manually
if (this.loaded) {
this.load(entity);
}
this.allEntities.put(entity.getMapId(), entity);
}
use of de.gurkenlabs.litiengine.entities.Spawnpoint in project litiengine by gurkenlabs.
the class SpawnpointMapObjectLoader method load.
@Override
public Collection<IEntity> load(Environment environment, IMapObject mapObject) {
Collection<IEntity> entities = new ArrayList<>();
if (!this.isMatchingType(mapObject)) {
return entities;
}
final Direction direction = mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION) != null ? Direction.valueOf(mapObject.getStringValue(MapObjectProperty.SPAWN_DIRECTION)) : Direction.DOWN;
final String spawnType = mapObject.getStringValue(MapObjectProperty.SPAWN_INFO);
final Spawnpoint spawn = this.createSpawnpoint(mapObject, direction, spawnType);
loadDefaultProperties(spawn, mapObject);
entities.add(spawn);
return entities;
}
Aggregations