public/js-roguelike-skeleton/src/object-manager.js
function(x, y, obj) {
            if(typeof obj === 'string'){
                obj = this.makeNewObjectFromType(obj);
            }
            var existing = this.get(x, y);
            if(existing){
                this.remove(existing);
            }
            obj.game = this.game;
            obj.x = x;
            obj.y = y;
            this.objects.push(obj);
            this.map.set(x, y, obj);
            if(obj.onAdd){
                obj.onAdd();
            }
            return obj;
        }
function(x, y, obj) {
            if(typeof obj === 'string'){
                obj = this.makeNewObjectFromType(obj);
            }
            var existing = this.get(x, y);
            if(existing){
                this.remove(existing);
            }
            obj.game = this.game;
            obj.x = x;
            obj.y = y;
            this.objects.push(obj);
            this.map.set(x, y, obj);
            if(obj.onAdd){
                obj.onAdd();
            }
            return obj;
        }
function ( x , y , obj ) { if ( typeof obj === 'string' ) { obj = this . makeNewObjectFromType ( obj ) ; } var existing = this . get ( x , y ) ; if ( existing ) { this . remove ( existing ) ; } obj . game = this . game ; obj . x = x ; obj . y = y ; this . objects . push ( obj ) ; this . map . set ( x , y , obj ) ; if ( obj . onAdd ) { obj . onAdd ( ) ; } return obj ; }
Adds an object to the manager at given map tile coord.
If an object is already at this map tile coord it is removed from the manager completely.
@method add
@param {Number} x - The tile map coord x.
@param {Number} y - The tile map coord y.
@param {Object|String} obj - The Object being set at given coords. If obj is a string a new Object will be created using `this.makeNewObjectFromType(obj)`.
@return {Object} The added object.
Adds an object to the manager at given map tile coord . If an object is already at this map tile coord it is removed from the manager completely .