<commit_before>{ EntityScript } = require('src/lib/LazerScript')

class TurretInActive extends EntityScript

  spawn: (options) ->
    Crafty.e('TurretInactive, BulletCannon, KeepAlive').bulletCannon()

  execute: ->
    @invincible yes

class TurretActive extends EntityScript

  spawn: (options) ->
    entity = Crafty('TurretInactive').get(0)
    if entity
      entity.removeComponent('TurretInactive')
    else
      entity = Crafty.e('BulletCannon, KeepAlive').bulletCannon()

    entity

  execute: ->
    @bindSequence 'Destroyed', @onKilled
    @sequence(
      @invincible no
      @action 'start-shooting'
      @repeat @sequence(
        @wait 100
        @action 'aim'
      )
    )

  onKilled: ->
    @leaveAnimation @sequence(
      @deathDecoy()
      @bigExplosion()
      @wait(400)
      @bigExplosion()
    )

module.exports = {
  TurretInActive,
  TurretActive
}
<commit_msg>Fix destoryed turret still absorbing bullets<commit_after>{ EntityScript } = require('src/lib/LazerScript')

class TurretInActive extends EntityScript

  spawn: (options) ->
    Crafty.e('TurretInactive, BulletCannon, KeepAlive').bulletCannon()

  execute: ->
    @invincible yes

class TurretActive extends EntityScript

  spawn: (options) ->
    entity = Crafty('TurretInactive').get(0)
    if entity
      entity.removeComponent('TurretInactive')
    else
      entity = Crafty.e('BulletCannon, KeepAlive').bulletCannon()

    entity

  execute: ->
    @bindSequence 'Destroyed', @onKilled
    @sequence(
      @invincible no
      @action 'start-shooting'
      @repeat @sequence(
        @wait 100
        @action 'aim'
      )
    )

  onKilled: ->
    @leaveAnimation @sequence(
      @deathDecoy()
      @sendToBackground(1.0)
      @bigExplosion()
      @wait(400)
      @bigExplosion()
    )

module.exports = {
  TurretInActive,
  TurretActive
}

{'fraction_non_alphanumeric': 0.11758360302049622, 'fraction_numerical': 0.008629989212513484, 'mean_word_length': 2.930084745762712, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6597565', 'n_tokens_mistral': 632, 'n_tokens_neox': 595, 'n_words': 118}