Using aiSource now for enemy AIs in multiplayer, separate from sample code source.

This commit is contained in:
Nick Winter 2014-10-19 12:44:58 -07:00
parent 754f7128bd
commit 440e1700b1
3 changed files with 14 additions and 10 deletions

View file

@ -52,6 +52,7 @@ module.exports = class SaveLevelModal extends SaveVersionModal
console.log "Should we save", m.get('system'), m.get('name'), m, "? localChanges:", m.hasLocalChanges(), "version:", m.get('version'), 'isPublished:', m.isPublished(), 'collection:', m.collection
return false
return true if m.hasLocalChanges()
console.error "Trying to check major version of #{m.type()} #{m.get('name')}, but it doesn't have a version:", m unless m.get('version')
return true if (m.get('version').major is 0 and m.get('version').minor is 0) or not m.isPublished() and not m.collection
# Sometimes we have two versions: one in a search collection and one with a URL. We only save changes to the latter.
false

View file

@ -77,7 +77,7 @@ module.exports = class ThangTypeEditView extends RootView
context
getAnimationNames: -> _.keys(@thangType.get('actions') or {})
afterRender: ->
super()
return unless @supermodel.finished()
@ -119,7 +119,7 @@ module.exports = class ThangTypeEditView extends RootView
@stage = new createjs.Stage(canvas[0])
@layerAdapter = new LayerAdapter({name:'Default', webGL: true})
@topLayer = new createjs.Container()
@layerAdapter.container.x = @topLayer.x = CENTER.x
@layerAdapter.container.y = @topLayer.y = CENTER.y
@stage.addChild(@layerAdapter.container, @topLayer)
@ -135,7 +135,7 @@ module.exports = class ThangTypeEditView extends RootView
@updateGrid()
_.defer @refreshAnimation
@toggleDots(false)
createjs.Ticker.setFPS(30)
createjs.Ticker.addEventListener('tick', @stage)
@ -244,7 +244,7 @@ module.exports = class ThangTypeEditView extends RootView
lank = new Lank(@thangType, @getLankOptions())
@showLank(lank)
@updateScale()
onNewSpriteSheet: ->
$('#spritesheets').empty()
for image in @layerAdapter.spriteSheet._images
@ -260,7 +260,7 @@ module.exports = class ThangTypeEditView extends RootView
@showAction(animationName)
@updateRotation()
@updateScale() # must happen after update rotation, because updateRotation calls the sprite update() method.
showMovieClip: (animationName) ->
vectorParser = new SpriteBuilder(@thangType)
movieClip = vectorParser.buildMovieClip(animationName)
@ -289,7 +289,7 @@ module.exports = class ThangTypeEditView extends RootView
portrait?.attr('id', 'portrait').addClass('img-thumbnail')
portrait.addClass 'img-thumbnail'
$('#portrait').replaceWith(portrait)
showLank: (lank) ->
@clearDisplayObject()
@clearLank()
@ -306,7 +306,7 @@ module.exports = class ThangTypeEditView extends RootView
clearDisplayObject: ->
@topLayer.removeChild(@currentObject) if @currentObject?
clearLank: ->
@layerAdapter.removeLank(@currentLank) if @currentLank
@currentLank?.destroy()
@ -365,7 +365,8 @@ module.exports = class ThangTypeEditView extends RootView
url = "/editor/thang/#{newThangType.get('slug') or newThangType.id}"
portraitSource = null
if @thangType.get('raster')
image = @currentLank.sprite.image
#image = @currentLank.sprite.image # Doesn't work?
image = @currentLank.sprite.spriteSheet._images[0]
portraitSource = imageToPortrait image
# bit of a hacky way to get that portrait
success = =>
@ -429,7 +430,7 @@ module.exports = class ThangTypeEditView extends RootView
obj = vectorParser.buildMovieClip(key) if type is 'animations'
obj = vectorParser.buildContainerFromStore(key) if type is 'containers'
obj = vectorParser.buildShapeFromStore(key) if type is 'shapes'
bounds = obj?.bounds or obj?.nominalBounds
if bounds
@boundsBox = new createjs.Shape()
@ -437,7 +438,7 @@ module.exports = class ThangTypeEditView extends RootView
@topLayer.addChild(@boundsBox)
obj.regX = @boundsBox.regX = bounds.x + bounds.width / 2
obj.regY = @boundsBox.regY = bounds.y + bounds.height / 2
@showSprite(obj) if obj
@showingSelectedNode = true
@currentLank?.destroy()

View file

@ -40,6 +40,8 @@ module.exports = class Spell
if @permissions.readwrite.length and sessionSource = @session.getSourceFor(@spellKey)
if sessionSource isnt '// Should fill in some default source\n' # TODO: figure out why session is getting this default source in there and stop it
@source = sessionSource
if p.aiSource and not @otherSession and not @canWrite()
@source = @originalSource = p.aiSource
@thangs = {}
if @canRead() # We can avoid creating these views if we'll never use them.
@view = new SpellView {spell: @, level: options.level, session: @session, worker: @worker}