2014-01-03 13:32:13 -05:00
|
|
|
ScriptModule = require './ScriptModule'
|
|
|
|
|
|
|
|
module.exports = class SurfaceScriptModule extends ScriptModule
|
|
|
|
@neededFor: (noteGroup) ->
|
|
|
|
return noteGroup.surface?
|
|
|
|
|
|
|
|
startNotes: ->
|
|
|
|
notes = []
|
|
|
|
notes.push(@surfaceCameraNote()) if @noteGroup.surface.focus?
|
|
|
|
notes.push(@surfaceHighlightNote()) if @noteGroup.surface.highlight?
|
|
|
|
notes.push(@surfaceLockSelectNote()) if @noteGroup.surface.lockSelect?
|
|
|
|
return notes
|
|
|
|
|
|
|
|
endNotes: ->
|
|
|
|
notes = []
|
2014-08-27 15:24:03 -04:00
|
|
|
notes.push({channel:'sprite:highlight-sprites', event: {thangIDs: []}}) if @noteGroup.surface.highlight?
|
2014-01-03 13:32:13 -05:00
|
|
|
notes.push(@surfaceCameraNote(true)) if @noteGroup.surface.focus?
|
|
|
|
notes.push(@surfaceLockSelectNote()) if @noteGroup.surface.lockSelect?
|
|
|
|
return notes
|
|
|
|
|
|
|
|
skipNotes: ->
|
|
|
|
notes = []
|
|
|
|
notes.push(@surfaceCameraNote(true)) if @noteGroup.surface.focus?
|
|
|
|
notes.push(@surfaceLockSelectNote()) if @noteGroup.surface.lockSelect?
|
|
|
|
return notes
|
|
|
|
|
|
|
|
surfaceCameraNote: (instant=false) ->
|
|
|
|
focus = @noteGroup.surface.focus
|
|
|
|
e = {}
|
|
|
|
e.pos = focus.target if _.isPlainObject focus.target
|
|
|
|
e.thangID = focus.target if _.isString focus.target
|
2014-02-19 15:43:25 -05:00
|
|
|
e.zoom = focus.zoom or 2.0 # TODO: test only doing this if e.pos, e.thangID, or focus.zoom?
|
2014-01-03 13:32:13 -05:00
|
|
|
e.duration = if focus.duration? then focus.duration else 1500
|
|
|
|
e.duration = 0 if instant
|
|
|
|
e.bounds = focus.bounds if focus.bounds?
|
2014-08-27 15:24:03 -04:00
|
|
|
return { channel: 'camera:set-camera', event: e }
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
surfaceHighlightNote: ->
|
|
|
|
highlight = @noteGroup.surface.highlight
|
|
|
|
note =
|
2014-08-27 15:24:03 -04:00
|
|
|
channel: 'sprite:highlight-sprites'
|
2014-01-03 13:32:13 -05:00
|
|
|
event:
|
|
|
|
thangIDs: highlight.targets
|
|
|
|
delay: highlight.delay
|
|
|
|
@maybeApplyDelayToNote note, @noteGroup
|
|
|
|
return note
|
|
|
|
|
|
|
|
surfaceLockSelectNote: ->
|
2014-08-27 15:24:03 -04:00
|
|
|
return { channel: 'level:lock-select', event: {lock: @noteGroup.surface.lockSelect} }
|