Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-08-06 14:30:59 -07:00
commit 5cf6a2fae7
10 changed files with 42 additions and 27 deletions

View file

@ -391,7 +391,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
rotationType = @thangType.get('rotationType')
return if rotationType is 'fixed'
rotation = @getRotation()
if @thangType.get('name') in ['Arrow', 'Spear']
if @thangType.get('name') in ['Arrow', 'Spear'] and @thang.velocity
# Rotates the arrow to see it arc based on velocity.z.
# Notice that rotation here does not affect thang's state - it is just the effect.
# Thang's rotation is always pointing where it is heading.

View file

@ -180,7 +180,11 @@ module.exports = class SpriteBoss extends CocoClass
adjustSpriteExistence: ->
# Add anything new, remove anything old, update everything current
updateCache = false
itemsJustEquipped = []
for thang in @world.thangs when thang.exists
if thang.equip and not thang.equipped
thang.equip() # Pretty hacky, since initialize may not be called
itemsJustEquipped.push thang
if sprite = @sprites[thang.id]
sprite.setThang thang # make sure Sprite has latest Thang
else
@ -188,6 +192,7 @@ module.exports = class SpriteBoss extends CocoClass
Backbone.Mediator.publish 'surface:new-thang-added', thang:thang, sprite:sprite
updateCache = updateCache or sprite.imageObject.parent is @spriteLayers['Obstacle']
sprite.playSounds()
item.modifyStats() for item in itemsJustEquipped
for thangID, sprite of @sprites
missing = not (sprite.notOfThisWorld or @world.thangMap[thangID]?.exists)
isObstacle = sprite.imageObject.parent is @spriteLayers['Obstacle']

View file

@ -240,7 +240,7 @@ module.exports = class World
calculateBounds: ->
bounds = {left: 0, top: 0, right: 0, bottom: 0}
hasLand = _.some @thangs, 'isLand'
for thang in @thangs when thang.isLand or not hasLand # Look at Lands only
for thang in @thangs when thang.isLand or (not hasLand and thang.rectangle) # Look at Lands only
rect = thang.rectangle().axisAlignedBoundingBox()
bounds.left = Math.min(bounds.left, rect.x - rect.width / 2)
bounds.right = Math.max(bounds.right, rect.x + rect.width / 2)

View file

@ -105,7 +105,7 @@ _.extend ThangTypeSchema.properties,
shapes: c.object {title: 'Shapes', additionalProperties: ShapeObjectSchema}
containers: c.object {title: 'Containers', additionalProperties: ContainerObjectSchema}
animations: c.object {title: 'Animations', additionalProperties: RawAnimationObjectSchema}
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark'], default: 'Misc', title: 'Kind'}
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark', 'Item'], default: 'Misc', title: 'Kind'}
actions: c.object {title: 'Actions', additionalProperties: {$ref: '#/definitions/action'}}
soundTriggers: c.object {title: 'Sound Triggers', additionalProperties: c.array({}, {$ref: '#/definitions/sound'})},

View file

@ -110,6 +110,12 @@ $mobile: 1050px
.treema-node.treema-Wall
display: block
&.hide-except-Item
.treema-node
display: none
.treema-node.treema-Item
display: block
&.hide-except-Misc
.treema-node
display: none

View file

@ -15,6 +15,8 @@ button.navbar-toggle.toggle.btn-primary#thangs-palette-toggle(type="button", dat
i.icon-globe
button.btn.btn-primary(value="Doodad", title="Doodad")
i.icon-leaf
button.btn.btn-primary(value="Item", title="Item")
i.icon-gift
button.btn.btn-primary(value="Misc", title="Misc")
i.icon-question-sign
.editor-nano-container.nano

View file

@ -47,7 +47,7 @@ module.exports = class SaveLevelModal extends SaveVersionModal
shouldSaveEntity: (m) ->
return false unless m.hasWriteAccess()
return false unless m.hasLocalChanges()
return true if m.hasLocalChanges()
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

@ -49,7 +49,7 @@ clusters = {
}
'dungeon_wall': {
'thangs': ['Dungeon Wall']
'margin': -1
'margin': 2
}
'dungeon_floor': {
'thangs': ['Dungeon Floor']
@ -264,6 +264,9 @@ module.exports = class TerrainRandomizeModal extends ModalView
roomThickness = _.random(room.thickness[0], room.thickness[1])
rect.x = _.random(rect.width/2 + preset.borderSize * (roomThickness+1), presetSize.x - rect.width/2 - preset.borderSize * (roomThickness+1))
rect.y = _.random(rect.height/2 + preset.borderSize * (roomThickness+1), presetSize.y - rect.height/2 - preset.borderSize * (roomThickness+1))
# Snap room walls to the wall grid.
rect.x = Math.round((rect.x - preset.borderSize / 2) / preset.borderSize) * preset.borderSize + preset.borderSize / 2
rect.y = Math.round((rect.y - preset.borderSize / 2) / preset.borderSize) * preset.borderSize + preset.borderSize / 2
break if @addRect {
'x': rect.x
'y': rect.y
@ -333,7 +336,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
for existingThang in @thangs
if existingThang.margin is -1 or thang.margin is -1
continue
if Math.abs(existingThang.pos.x - thang.pos.x) <= thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) <= thang.margin + existingThang.margin
if Math.abs(existingThang.pos.x - thang.pos.x) < thang.margin + existingThang.margin and Math.abs(existingThang.pos.y - thang.pos.y) < thang.margin + existingThang.margin
@falseCount++
return false
@thangs.push thang
@ -345,7 +348,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
@falseCount = 0
return true
for existingRect in @rects
if Math.abs(existingRect.x - rect.x) <= rect.width/2 + existingRect.width/2 and Math.abs(existingRect.y - rect.y) <= rect.height/2 + existingRect.height/2
if Math.abs(existingRect.x - rect.x) < rect.width/2 + existingRect.width/2 and Math.abs(existingRect.y - rect.y) < rect.height/2 + existingRect.height/2
@falseCount++
return false
@rects.push rect

View file

@ -500,7 +500,7 @@ class ThangNode extends TreemaObjectNode
s = "#{@data.thangType}"
if isObjectID s
unless name = ThangNode.thangNameMap[s]
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s
thangType = _.find @settings.supermodel.getModels(ThangType), (m) -> m.get('original') is s and m.get('kind')
name = ThangNode.thangNameMap[s] = thangType.get 'name'
ThangNode.thangKindMap[s] = thangType.get 'kind'
kind = ThangNode.thangKindMap[s]

View file

@ -166,7 +166,7 @@ module.exports = class Handler
ids = ids.split(',') if _.isString ids
ids = _.uniq ids
project = {name:1, original:1}
project = {name:1, original:1, kind:1}
sort = {'version.major':-1, 'version.minor':-1}
makeFunc = (id) =>
@ -450,4 +450,3 @@ module.exports = class Handler
projection = {}
projection[field] = 0 for field in model.privateProperties
projection