mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Set up the level editor to lazily load thang types.
This commit is contained in:
parent
5a78d92173
commit
222fa6100b
4 changed files with 16 additions and 6 deletions
|
@ -61,9 +61,19 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@actionQueue = []
|
||||
@marks = {}
|
||||
@labels = {}
|
||||
@ticker = 0
|
||||
@displayObject = new createjs.Container()
|
||||
if @thangType.get('actions')
|
||||
@onThangTypeLoaded()
|
||||
else
|
||||
@stillLoading = true
|
||||
@thangType.fetch()
|
||||
@thangType.once 'sync', @onThangTypeLoaded, @
|
||||
|
||||
onThangTypeLoaded: ->
|
||||
@stillLoading = false
|
||||
@actions = @thangType.getActions()
|
||||
@buildFromSpriteSheet @buildSpriteSheet()
|
||||
@ticker = 0
|
||||
|
||||
destroy: ->
|
||||
super()
|
||||
|
@ -87,7 +97,6 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
# temp, until these are re-exported with perspective
|
||||
if @options.camera and @thangType.get('name') in ['Dungeon Floor', 'Grass', 'Goal Trigger', 'Obstacle']
|
||||
sprite.scaleY *= @options.camera.y2x
|
||||
@displayObject = new createjs.Container()
|
||||
@imageObject = sprite
|
||||
@displayObject.addChild(sprite)
|
||||
@addHealthBar()
|
||||
|
@ -135,6 +144,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
|
||||
update: ->
|
||||
# Gets the sprite to reflect what the current state of the thangs and surface are
|
||||
return if @stillLoading
|
||||
@updatePosition()
|
||||
@updateScale()
|
||||
@updateAlpha()
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = class ThangType extends CocoModel
|
|||
return @actions or @buildActions()
|
||||
|
||||
buildActions: ->
|
||||
@actions = _.cloneDeep(@get('actions'))
|
||||
@actions = _.cloneDeep(@get('actions') or {})
|
||||
for name, action of @actions
|
||||
action.name = name
|
||||
for relatedName, relatedAction of action.relatedActions ? {}
|
||||
|
|
|
@ -19,7 +19,7 @@ componentOriginals =
|
|||
"physics.Physical" : "524b75ad7fc0f6d519000001"
|
||||
|
||||
class ThangTypeSearchCollection extends CocoCollection
|
||||
url: '/db/thang_type/search'
|
||||
url: '/db/thang_type/search?project=true'
|
||||
model: ThangType
|
||||
|
||||
module.exports = class ThangsTabView extends View
|
||||
|
@ -63,7 +63,7 @@ module.exports = class ThangsTabView extends View
|
|||
|
||||
getRenderData: (context={}) =>
|
||||
context = super(context)
|
||||
context.thangTypes = (thangType.attributes for thangType in @supermodel.getModels(ThangType) when not _.isEmpty thangType.get('actions'))
|
||||
context.thangTypes = (thangType.attributes for thangType in @supermodel.getModels(ThangType))
|
||||
context
|
||||
|
||||
afterRender: ->
|
||||
|
|
|
@ -114,7 +114,7 @@ module.exports = class Handler
|
|||
@modelClass.textSearch term, filter, callback
|
||||
else
|
||||
args = [filter.filter]
|
||||
args.push filter.project if req.query.project
|
||||
args.push project if req.query.project
|
||||
@modelClass.find(args...).limit(100).exec callback
|
||||
|
||||
versions: (req, res, id) ->
|
||||
|
|
Loading…
Reference in a new issue