diff --git a/coffee/bot.coffee b/coffee/bot.coffee index fc4a005..1dc2309 100644 --- a/coffee/bot.coffee +++ b/coffee/bot.coffee @@ -419,8 +419,8 @@ class Bot extends Pushable else @dir_sgn = 1 @jump_once = false if action.id != Action.NOOP - log "bot.actionFinished '#{action.name}' position:", @position if action.id in [Action.FORWARD, Action.JUMP_FORWARD, Action.CLIMB_DOWN] - log "bot.actionFinished '#{action.name}' orientation:", @orientation.rounded().name if action.id in [Action.TURN_LEFT, Action.TURN_RIGHT, Action.CLIMB_UP] + # log "bot.actionFinished '#{action.name}' position:", @position if action.id in [Action.FORWARD, Action.JUMP_FORWARD, Action.CLIMB_DOWN] + # log "bot.actionFinished '#{action.name}' orientation:", @orientation.rounded().name if action.id in [Action.TURN_LEFT, Action.TURN_RIGHT, Action.CLIMB_UP] if world.getRealOccupantAtPos(@position.plus @getDown())?.isMutant?() # keep action chain flowinwg in order to detect environment changes diff --git a/coffee/bullet.coffee b/coffee/bullet.coffee index 142ded0..9cfdb51 100644 --- a/coffee/bullet.coffee +++ b/coffee/bullet.coffee @@ -13,7 +13,7 @@ class Bullet extends Item constructor: () -> @size = 0.2 - @src_object = null + @shooter = null super @addAction new Action @, Action.FLY, "fly", 40 @addAction new Action @, Action.EXPLODE, "explode", 200 @@ -21,8 +21,8 @@ class Bullet extends Item del: -> if @mesh? world.scene.remove @mesh - _.pull world.objects, @ Timer.removeActionsOfObject @ + _.pull world.objects, @ @mesh = null createMesh: -> @@ -35,7 +35,7 @@ class Bullet extends Item world.addObject bullet bullet.direction = bot.currentDir() bullet.setPosition bot.position.plus bullet.direction.mul 0.8 - bullet.src_object = bot + bullet.shooter = bot bullet.mesh.material.color.set bot.mesh.material.color world.playSound 'BULLET_SHOT', bot.getPos() @@ -49,7 +49,7 @@ class Bullet extends Item @current_position = @position.plus @direction.mul relTime else if action.id == Action.EXPLODE @size = 0.2 + relTime/2.0 - @mesh.material.opacity = 0.8 * (1.0-relTime) + @mesh?.material.opacity = 0.8 * (1.0-relTime) step: (step) -> @mesh.position.copy @current_position @@ -61,7 +61,7 @@ class Bullet extends Item if world.isInvalidPos(pos) or world.isOccupiedPos pos hitObject = world.getRealOccupantAtPos pos - if hitObject != @src_object + if hitObject != @shooter if hitObject? hitObject.bulletImpact() world.playSound hitObject.bulletHitSound?() ? 'BULLET_HIT_OBJECT' diff --git a/coffee/levels/energy.coffee b/coffee/levels/energy.coffee index c9ea736..f4583fc 100644 --- a/coffee/levels/energy.coffee +++ b/coffee/levels/energy.coffee @@ -79,13 +79,13 @@ module.exports = Switch = require '../switch' switch1 = new Switch - switch1.getEventWithName("switched").addAction world.continuous (sw=switch1) -> switched sw + switch1.getEventWithName("switched").addAction world.continuous -> switched switch1 switch2 = new Switch - switch2.getEventWithName("switched").addAction world.continuous (sw=switch2) -> switched sw + switch2.getEventWithName("switched").addAction world.continuous -> switched switch2 switch3 = new Switch - switch3.getEventWithName("switched").addAction world.continuous (sw=switch3) -> switched sw + switch3.getEventWithName("switched").addAction world.continuous -> switched switch3 switch4 = new Switch - switch4.getEventWithName("switched").addAction world.continuous (sw=switch4) -> switched sw + switch4.getEventWithName("switched").addAction world.continuous -> switched switch4 world.addObjectAtPos switch1, world.decenter -s.x/2+1, 4, 0 world.addObjectAtPos switch2, world.decenter s.x/2, 4, 0 diff --git a/coffee/levels/sandbox.coffee b/coffee/levels/sandbox.coffee index 7ef822b..267ebaa 100644 --- a/coffee/levels/sandbox.coffee +++ b/coffee/levels/sandbox.coffee @@ -30,13 +30,14 @@ module.exports = create: -> switched = -> - unoccupied = false + occupied = true for i in [3...6] for j in [3...6] - if world.isUnoccupiedPos i,j,0 - unoccupied=true - - world.toggle "exit" if not unoccupied + if world.isUnoccupiedPos [i,j,0] + log "isUnoccupiedPos #{i} #{j}" + occupied = false + log "toggle? #{occupied}" + world.toggle "exit" if occupied Switch = require '../switch' swtch = new Switch diff --git a/coffee/world.coffee b/coffee/world.coffee index c49e291..6b21303 100644 --- a/coffee/world.coffee +++ b/coffee/world.coffee @@ -488,8 +488,8 @@ class World extends Actor cell.removeObject object if cell.isEmpty() @cells[@posToIndex(pos)] = null - else - log 'world.unsetObject [WARNING] no cell at pos:', pos + # else + # log 'world.unsetObject [WARNING] no cell at pos:', pos newObject: (object) -> if _.isString object