mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-29 07:24:08 -04:00
Improved the speed of placing down thangs in levels with lots of extant thangs.
This commit is contained in:
parent
3dd143b4e3
commit
514adb2159
2 changed files with 8 additions and 6 deletions
app
|
@ -230,7 +230,7 @@ module.exports = class SpriteBoss extends CocoClass
|
||||||
@selectedSprite = sprite
|
@selectedSprite = sprite
|
||||||
alive = sprite?.thang.health > 0
|
alive = sprite?.thang.health > 0
|
||||||
|
|
||||||
Backbone.Mediator.publish "surface:sprite-selected",
|
Backbone.Mediator.publish 'surface:sprite-selected',
|
||||||
thang: if sprite then sprite.thang else null
|
thang: if sprite then sprite.thang else null
|
||||||
sprite: sprite
|
sprite: sprite
|
||||||
spellName: spellName ? e?.spellName
|
spellName: spellName ? e?.spellName
|
||||||
|
|
|
@ -320,7 +320,7 @@ module.exports = class ThangsTabView extends View
|
||||||
physical.config.pos = x: pos.x, y: pos.y, z: physical.config.pos.z if physical
|
physical.config.pos = x: pos.x, y: pos.y, z: physical.config.pos.z if physical
|
||||||
thang = thangType: thangType.get('original'), id: thangID, components: components
|
thang = thangType: thangType.get('original'), id: thangID, components: components
|
||||||
@thangsTreema.insert '', thang
|
@thangsTreema.insert '', thang
|
||||||
@supermodel.populateModel @level # Make sure we grab any new data for the thang we just added
|
@supermodel.populateModel thangType # Make sure we grab any new data for the thang we just added
|
||||||
|
|
||||||
editThang: (e) ->
|
editThang: (e) ->
|
||||||
if e.target # click event
|
if e.target # click event
|
||||||
|
@ -346,19 +346,21 @@ class ThangsNode extends TreemaNode.nodeMap.array
|
||||||
valueClass: 'treema-array-replacement'
|
valueClass: 'treema-array-replacement'
|
||||||
getChildren: ->
|
getChildren: ->
|
||||||
children = super(arguments...)
|
children = super(arguments...)
|
||||||
# uncomment this if you want to hide all the walls in the the thangs treema
|
# TODO: add some filtering to only work with certain types of units at a time
|
||||||
#children = (c for c in children when not _.string.startsWith(c[1].thangType, 'dungeon_wall'))
|
|
||||||
return children
|
return children
|
||||||
|
|
||||||
class ThangNode extends TreemaObjectNode
|
class ThangNode extends TreemaObjectNode
|
||||||
valueClass: 'treema-thang'
|
valueClass: 'treema-thang'
|
||||||
collection: false
|
collection: false
|
||||||
|
@thangNameMap: {}
|
||||||
buildValueForDisplay: (valEl) ->
|
buildValueForDisplay: (valEl) ->
|
||||||
pos = _.find(@data.components, (c) -> c.config?.pos?)?.config.pos # TODO: hack
|
pos = _.find(@data.components, (c) -> c.config?.pos?)?.config.pos # TODO: hack
|
||||||
s = "#{@data.thangType}"
|
s = "#{@data.thangType}"
|
||||||
if isObjectID s
|
if isObjectID s
|
||||||
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s
|
unless name = ThangNode.thangNameMap[s]
|
||||||
s = thangType.get('name')
|
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s
|
||||||
|
name = ThangNode.thangNameMap[s] = thangType.get 'name'
|
||||||
|
s = name
|
||||||
s += " - " + @data.id if @data.id isnt s
|
s += " - " + @data.id if @data.id isnt s
|
||||||
if pos
|
if pos
|
||||||
s += " (#{Math.round(pos.x)}, #{Math.round(pos.y)})"
|
s += " (#{Math.round(pos.x)}, #{Math.round(pos.y)})"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue