codecombat/app/lib/surface/IndieLank.coffee

37 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2014-01-03 13:32:13 -05:00
Thang = require 'lib/world/thang'
Lank = require 'lib/surface/Lank'
2014-01-03 13:32:13 -05:00
module.exports = IndieLank = class IndieLank extends Lank
2014-01-03 13:32:13 -05:00
notOfThisWorld: true
subscriptions:
'script:note-group-started': 'onNoteGroupStarted'
'script:note-group-ended': 'onNoteGroupEnded'
2014-01-03 13:32:13 -05:00
constructor: (thangType, options) ->
2014-08-24 19:09:06 -04:00
options.thang = @makeIndieThang thangType, options
2014-01-03 13:32:13 -05:00
super thangType, options
@shadow = @thang
2014-01-03 13:32:13 -05:00
2014-08-24 19:09:06 -04:00
makeIndieThang: (thangType, options) ->
@thang = thang = new Thang null, thangType.get('name'), options.thangID
2014-01-03 13:32:13 -05:00
# Build needed results of what used to be Exists, Physical, Acts, and Selectable Components
thang.exists = true
thang.width = thang.height = thang.depth = 4
2014-08-24 19:09:06 -04:00
thang.pos = options.pos ? @defaultPos()
2014-02-01 14:02:20 -05:00
thang.pos.z = thang.depth / 2
thang.shape = 'ellipsoid'
2014-01-03 13:32:13 -05:00
thang.rotation = 0
thang.action = 'idle'
thang.setAction = (action) -> thang.action = action
thang.getActionName = -> thang.action
thang.acts = true
thang.isSelectable = true
thang.team = options.team
thang.teamColors = options.teamColors
2014-01-03 13:32:13 -05:00
thang
onNoteGroupStarted: => @scriptRunning = true
onNoteGroupEnded: => @scriptRunning = false
onMouseEvent: (e, ourEventName) -> super e, ourEventName unless @scriptRunning
defaultPos: -> x: -20, y: 20, z: @thang.depth / 2