mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -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 = []
|
@actionQueue = []
|
||||||
@marks = {}
|
@marks = {}
|
||||||
@labels = {}
|
@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()
|
@actions = @thangType.getActions()
|
||||||
@buildFromSpriteSheet @buildSpriteSheet()
|
@buildFromSpriteSheet @buildSpriteSheet()
|
||||||
@ticker = 0
|
|
||||||
|
|
||||||
destroy: ->
|
destroy: ->
|
||||||
super()
|
super()
|
||||||
|
@ -87,7 +97,6 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
# temp, until these are re-exported with perspective
|
# temp, until these are re-exported with perspective
|
||||||
if @options.camera and @thangType.get('name') in ['Dungeon Floor', 'Grass', 'Goal Trigger', 'Obstacle']
|
if @options.camera and @thangType.get('name') in ['Dungeon Floor', 'Grass', 'Goal Trigger', 'Obstacle']
|
||||||
sprite.scaleY *= @options.camera.y2x
|
sprite.scaleY *= @options.camera.y2x
|
||||||
@displayObject = new createjs.Container()
|
|
||||||
@imageObject = sprite
|
@imageObject = sprite
|
||||||
@displayObject.addChild(sprite)
|
@displayObject.addChild(sprite)
|
||||||
@addHealthBar()
|
@addHealthBar()
|
||||||
|
@ -135,6 +144,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
|
|
||||||
update: ->
|
update: ->
|
||||||
# Gets the sprite to reflect what the current state of the thangs and surface are
|
# Gets the sprite to reflect what the current state of the thangs and surface are
|
||||||
|
return if @stillLoading
|
||||||
@updatePosition()
|
@updatePosition()
|
||||||
@updateScale()
|
@updateScale()
|
||||||
@updateAlpha()
|
@updateAlpha()
|
||||||
|
|
|
@ -27,7 +27,7 @@ module.exports = class ThangType extends CocoModel
|
||||||
return @actions or @buildActions()
|
return @actions or @buildActions()
|
||||||
|
|
||||||
buildActions: ->
|
buildActions: ->
|
||||||
@actions = _.cloneDeep(@get('actions'))
|
@actions = _.cloneDeep(@get('actions') or {})
|
||||||
for name, action of @actions
|
for name, action of @actions
|
||||||
action.name = name
|
action.name = name
|
||||||
for relatedName, relatedAction of action.relatedActions ? {}
|
for relatedName, relatedAction of action.relatedActions ? {}
|
||||||
|
|
|
@ -19,7 +19,7 @@ componentOriginals =
|
||||||
"physics.Physical" : "524b75ad7fc0f6d519000001"
|
"physics.Physical" : "524b75ad7fc0f6d519000001"
|
||||||
|
|
||||||
class ThangTypeSearchCollection extends CocoCollection
|
class ThangTypeSearchCollection extends CocoCollection
|
||||||
url: '/db/thang_type/search'
|
url: '/db/thang_type/search?project=true'
|
||||||
model: ThangType
|
model: ThangType
|
||||||
|
|
||||||
module.exports = class ThangsTabView extends View
|
module.exports = class ThangsTabView extends View
|
||||||
|
@ -63,7 +63,7 @@ module.exports = class ThangsTabView extends View
|
||||||
|
|
||||||
getRenderData: (context={}) =>
|
getRenderData: (context={}) =>
|
||||||
context = super(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
|
context
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
|
|
|
@ -114,7 +114,7 @@ module.exports = class Handler
|
||||||
@modelClass.textSearch term, filter, callback
|
@modelClass.textSearch term, filter, callback
|
||||||
else
|
else
|
||||||
args = [filter.filter]
|
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
|
@modelClass.find(args...).limit(100).exec callback
|
||||||
|
|
||||||
versions: (req, res, id) ->
|
versions: (req, res, id) ->
|
||||||
|
|
Loading…
Reference in a new issue