<commit_before>import Phaser from 'phaser'
import { Facade } from 'pure-mvc'
import ParticleProxy from '../../../model/ParticleProxy'
import ParticleEditorFacade from '../../../ParticleEditorFacade'
import { ParticleEditorPlugin } from '@koreez/phaser-particle-editor-plugin'

export default class SandboxState extends Phaser.State {
  static NAME = 'SandboxState'
  static STATE_READY = SandboxState.NAME + 'Ready'

  init (...args) {
    this.facade = Facade.getInstance(ParticleEditorFacade.KEY)
    this.game.add.plugin(ParticleEditorPlugin)
  }

  create () {
    this.stage.backgroundColor = '#000000'
    // setBodyColor('#999999')
    this.game.renderer.renderSession.roundPixels = true
    this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL
    this.scale.pageAlignHorizontally = true
    this.scale.pageAlignVertically = true

    this.followCursorStatus = false
    this.bgImage = this.game.add.sprite()
    this.game.input.onDown.add(this.enableFollowCursor, this)
    this.game.input.onUp.add(this.disableFollowCursor, this)
    this.particleProxy = this.facade.retrieveProxy(ParticleProxy.NAME)
    const particleVO = this.particleProxy.getData()
    this.particle = this.game.add.particleEffect(this.world.centerX, this.world.centerY, particleVO)
    this.game.input.addMoveCallback(this.followCursor, this)
    this.facade.sendNotification(SandboxState.STATE_READY)
  }

  enableFollowCursor () {
    this.followCursorStatus = true
  }

  disableFollowCursor () {
    this.followCursorStatus = false
  }

  followCursor () {
    if (!this.followCursorStatus) {
      return
    }
    this.particle.emitX = this.game.input.x - this.particle.x
    this.particle.emitY = this.game.input.y - this.particle.y
  }

  updateParticleProperty (emitterName) {
    const particleVO = this.particleProxy.getData()
    this.particle.updateEmitterProperties(emitterName, particleVO.emitters[emitterName])
  }

  updateParticleOption (emitterName) {
    const particleVO = this.particleProxy.getData()
    this.particle.updateEmitterOption(emitterName, particleVO.emitters[emitterName])
  }<commit_msg>if cursor is out of sandbox particle position setting to center of sandbox<commit_after>import Phaser from 'phaser'
import { Facade } from 'pure-mvc'
import ParticleProxy from '../../../model/ParticleProxy'
import ParticleEditorFacade from '../../../ParticleEditorFacade'
import { ParticleEditorPlugin } from '@koreez/phaser-particle-editor-plugin'

export default class SandboxState extends Phaser.State {
  static NAME = 'SandboxState'
  static STATE_READY = SandboxState.NAME + 'Ready'

  init (...args) {
    this.facade = Facade.getInstance(ParticleEditorFacade.KEY)
    this.game.add.plugin(ParticleEditorPlugin)
  }

  create () {
    this.stage.backgroundColor = '#000000'
    this.game.renderer.renderSession.roundPixels = true
    this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL
    this.scale.pageAlignHorizontally = true
    this.scale.pageAlignVertically = true

    this.followCursorStatus = false
    this.bgImage = this.game.add.sprite()
    this.particleProxy = this.facade.retrieveProxy(ParticleProxy.NAME)
    const particleVO = this.particleProxy.getData()
    this.particle = this.game.add.particleEffect(this.world.centerX, this.world.centerY, particleVO)
    this.game.input.onDown.add(this.enableFollowCursor, this)
    this.game.input.onUp.add(this.disableFollowCursor, this)
    this.game.input.mouse.mouseOutCallback = this.centerParticle.bind(this)
    this.game.input.addMoveCallback(this.followCursor, this)
    this.facade.sendNotification(SandboxState.STATE_READY)
  }

  enableFollowCursor () {
    this.followCursorStatus = true
  }

  disableFollowCursor () {
    this.followCursorStatus = false
  }

  centerParticle () {
    this.particle.emitX = 0
    this.particle.emitY = 0
  }

  followCursor () {
    if (!this.followCursorStatus) {
      return
    }
    this.particle.emitX = this.game.input.x - this.particle.x
    this.particle.emitY = this.game.input.y - this.particle.y
  }

  updateParticleProperty (emitterName) {
    const particleVO = this.particleProxy.getData()
    this.particle.updateEmitterProperties(emitterName, particleVO.emitters[emitterName])
  }

  updateParticleOption (emitterName) {
    const particleVO = this.particleProxy.getData()
    this.particle.updateEmitterOption(emitterName, particleVO.emitters[emitterName])
  }
{'fraction_non_alphanumeric': 0.11143961792130998, 'fraction_numerical': 0.004548555833522857, 'mean_word_length': 3.99205448354143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2275951', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1347, 'n_words': 218}