<commit_before>import { Unit } from 'Unit';
var _ = require('lodash');

export class EntityManager {
  constructor({game}) {
    this.game = game;

    this._entities = {};
  }

  // getters / setter for EntityManager.entities
  get entities() {
    let array = _.keys(this._entities).map( (key) => this._entities[key]);
    return array;
  }

  // not allowed to set it
  set entities(value) {
    return;
  }

  addUnit(unitProperties, unitId = this.generateUIDForUnit()) {
    this._entities[unitId] = new Unit(unitProperties);
    return unitId;
  }

  generateUIDForUnit() {
    return _.uniqueId('unit_');
  }

  update() {
    this.entities.forEach( (entity) => entity.update() );
  }

  render() {
    this.entities.forEach( (entity) => entity.render() );
  }

  filterEntities(predicate) {
    return this.entities.filter( predicate );
  }

  setCameraToFollowEntity(entityId) {
    this.game.camera.follow(this._entities[entityId].sprite);
  }
}<commit_msg>added a createcamera method to entityManager<commit_after>import { Unit } from 'Unit';
import { Camera } from 'Camera';
var _ = require('lodash');

export class EntityManager {
  constructor({game}) {
    this.game = game;

    this._entities = {};
  }

  // getters / setter for EntityManager.entities
  get entities() {
    let array = _.keys(this._entities).map( (key) => this._entities[key] );
    return array;
  }

  // not allowed to set it
  set entities(value) {
    return;
  }

  addUnit(unitProperties, unitId = this.generateUIDForUnit()) {
    this._entities[unitId] = new Unit(unitProperties);
    return unitId;
  }

  createCamera(cameraProperties) {
    this._entities['camera'] = new Camera(cameraProperties);
    this.game.camera.follow(this._entities['camera'].sprite);
    return this._entities['camera'];
  }

  getUnit(unitId) {
    return this._entities[unitId];
  }

  generateUIDForUnit() {
    return _.uniqueId('unit_');
  }

  update() {
    this.entities.forEach( (entity) => entity.update() );
  }

  render() {
    this.entities.forEach( (entity) => entity.render() );
  }

  filterEntities(predicate) {
    return this.entities.filter( predicate );
  }
}
{'fraction_non_alphanumeric': 0.14763231197771587, 'fraction_numerical': 0.0, 'mean_word_length': 3.3979591836734695, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2947762', 'n_tokens_mistral': 695, 'n_tokens_neox': 693, 'n_words': 135}