Made the level editor not break when using units that are incomplete.

This commit is contained in:
Scott Erickson 2014-04-22 10:39:15 -07:00
parent 684c76194d
commit e8da248302

View file

@ -323,7 +323,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
if not action and @thang?.actionActivated and not @stopLogging if not action and @thang?.actionActivated and not @stopLogging
console.error "action is", action, "for", @thang?.id, "from", @currentRootAction, @thang.action, @thang.getActionName?() console.error "action is", action, "for", @thang?.id, "from", @currentRootAction, @thang.action, @thang.getActionName?()
@stopLogging = true @stopLogging = true
@queueAction(action) if isDifferent or (@thang?.actionActivated and action.name isnt 'move') @queueAction(action) if action and (isDifferent or (@thang?.actionActivated and action.name isnt 'move'))
@updateActionDirection() @updateActionDirection()
determineAction: -> determineAction: ->
@ -332,8 +332,11 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
action = thang.action if thang?.acts action = thang.action if thang?.acts
action ?= @currentRootAction.name if @currentRootAction? action ?= @currentRootAction.name if @currentRootAction?
action ?= 'idle' action ?= 'idle'
action = null unless @actions[action]? unless @actions[action]?
return null unless action @warnedFor ?= {}
console.warn 'Cannot show action', action, 'for', @thangType.get('name'), 'because it DNE' unless @warnedFor[action]
@warnedFor[action] = true
return null
action = 'break' if @actions.break? and @thang?.erroredOut action = 'break' if @actions.break? and @thang?.erroredOut
action = 'die' if @actions.die? and thang?.health? and thang.health <= 0 action = 'die' if @actions.die? and thang?.health? and thang.health <= 0
@actions[action] @actions[action]