Fix thangTypes filtering in serialize

This commit is contained in:
Daniel Fiore 2016-01-07 12:26:40 -08:00
parent 7864d3708b
commit ed17d967d2

View file

@ -28,7 +28,13 @@ module.exports = class Level extends CocoModel
# Figure out ThangTypes' Components
tmap = {}
tmap[t.thangType] = true for t in o.thangs ? []
o.thangTypes = (original: tt.get('original'), name: tt.get('name'), components: $.extend(true, [], tt.get('components')) for tt in supermodel.getModels ThangType when tmap[tt.get('original')] or (tt.get('components') and not tt.notInLevel))
heroSelected = session.get('heroConfig').thangType
o.thangTypes = []
for tt in supermodel.getModels ThangType
if tmap[tt.get('original')] or
(tt.get('kind') isnt 'Hero' and tt.get('kind')? and tt.get('components') and not tt.notInLevel) or
(tt.get('kind') is 'Hero' and tt.get('original') is heroSelected)
o.thangTypes.push (original: tt.get('original'), name: tt.get('name'), components: $.extend(true, [], tt.get('components')))
@sortThangComponents o.thangTypes, o.levelComponents, 'ThangType'
@fillInDefaultComponentConfiguration o.thangTypes, o.levelComponents