define([],function(){var e=Class.extend({init:function(e,t){var n=this;this.id=e,this.kind=t,this.sprite=null,this.flipSpriteX=!1,this.flipSpriteY=!1,this.animations=null,this.currentAnimation=null,this.shadowOffsetY=0,this.setGridPosition(0,0),this.isLoaded=!1,this.isHighlighted=!1,this.visible=!0,this.isFading=!1,this.setDirty()},setName:function(e){this.name=e},setPosition:function(e,t){this.x=e,this.y=t},setGridPosition:function(e,t){this.gridX=e,this.gridY=t,this.setPosition(e*16,t*16)},setSprite:function(e){if(!e)throw log.error(this.id+" : sprite is null",!0),"Error";if(this.sprite&&this.sprite.name===e.name)return;this.sprite=e,this.normalSprite=this.sprite;if(Types.isMob(this.kind)||Types.isPlayer(this.kind))this.hurtSprite=e.getHurtSprite();this.animations=e.createAnimations(),this.isLoaded=!0,this.ready_func&&this.ready_func()},getSprite:function(){return this.sprite},getSpriteName:function(){return Types.getKindAsString(this.kind)},getAnimationByName:function(e){var t=null;return e in this.animations?t=this.animations[e]:log.error("No animation called "+e),t},setAnimation:function(e,t,n,r){var i=this;if(this.isLoaded){if(this.currentAnimation&&this.currentAnimation.name===e)return;var s=this.sprite,o=this.getAnimationByName(e);o&&(this.currentAnimation=o,e.substr(0,3)==="atk"&&this.currentAnimation.reset(),this.currentAnimation.setSpeed(t),this.currentAnimation.setCount(n?n:0,r||function(){i.idle()}))}else this.log_error("Not ready for animation")},hasShadow:function(){return!1},ready:function(e){this.ready_func=e},clean:function(){this.stopBlinking()},log_info:function(e){log.info("["+this.id+"] "+e)},log_error:function(e){log.error("["+this.id+"] "+e)},setHighlight:function(e){e===!0?(this.sprite=this.sprite.silhouetteSprite,this.isHighlighted=!0):(this.sprite=this.normalSprite,this.isHighlighted=!1)},setVisible:function(e){this.visible=e},isVisible:function(){return this.visible},toggleVisibility:function(){this.visible?this.setVisible(!1):this.setVisible(!0)},getDistanceToEntity:function(e){var t=Math.abs(e.gridX-this.gridX),n=Math.abs(e.gridY-this.gridY);return t>n?t:n},isCloseTo:function(e){var t,n,r,i=!1;return e&&(t=Math.abs(e.gridX-this.gridX),n=Math.abs(e.gridY-this.gridY),t<30&&n<14&&(i=!0)),i},isAdjacent:function(e){var t=!1;return e&&(t=this.getDistanceToEntity(e)>1?!1:!0),t},isAdjacentNonDiagonal:function(e){var t=!1;return this.isAdjacent(e)&&(this.gridX===e.gridX||this.gridY===e.gridY)&&(t=!0),t},isDiagonallyAdjacent:function(e){return this.isAdjacent(e)&&!this.isAdjacentNonDiagonal(e)},forEachAdjacentNonDiagonalPosition:function(e){e(this.gridX-1,this.gridY,Types.Orientations.LEFT),e(this.gridX,this.gridY-1,Types.Orientations.UP),e(this.gridX+1,this.gridY,Types.Orientations.RIGHT),e(this.gridX,this.gridY+1,Types.Orientations.DOWN)},fadeIn:function(e){this.isFading=!0,this.startFadingTime=e},blink:function(e,t){var n=this;this.blinking=setInterval(function(){n.toggleVisibility()},e)},stopBlinking:function(){this.blinking&&clearInterval(this.blinking),this.setVisible(!0)},setDirty:function(){this.isDirty=!0,this.dirty_callback&&this.dirty_callback(this)},onDirty:function(e){this.dirty_callback=e}});return e});