<commit_before>define([
	'goo/entities/systems/System',
	'goo/entities/SystemBus',
	'goo/scripts/Scripts'
], function (
	System,
	SystemBus,
	Scripts
) {
	'use strict';

	/**
	 * Processes all entities with script components, running the scripts where applicable
	 * @extends System
	 */
	function ScriptSystem(world) {
		System.call(this, 'ScriptSystem', ['ScriptComponent']);

		//! AT: why this?
		this._world = world;

		var renderer = this._world.gooRunner.renderer;
		// General world environment
		this.context = {
			domElement: renderer.domElement,
			viewportWidth: renderer.viewportWidth,
			viewportHeight: renderer.viewportHeight,
			world: world,
			activeCameraEntity: null,
			worldData: {},
			playTime: 0
		};

		this._playing = true;

		SystemBus.addListener('goo.setCurrentCamera', function (data) {
			this.context.activeCameraEntity = data.entity;
		}.bind(this));

		SystemBus.addListener('goo.viewportResize', function (data) {
			this.context.viewportWidth = data.width;
			this.context.viewportHeight = data.height;
		}.bind(this));

		this.manualSetup = false;

		this.priority = 500;
	}

	ScriptSystem.prototype = Object.create(System.prototype);
	ScriptSystem.prototype.constructor = ScriptSystem;

	/*
	ScriptSystem.prototype.inserted = function (entity) {
		if (!this.manualSetup) {
			entity.scriptComponent.setup(entity);
		}
	};*/

	ScriptSystem.prototype.play = function () {
		this.context.playTime = 0;
		this._playing = true;
	};

	ScriptSystem.prototype.resume = function () {
		this._playing = true;
	};

	ScriptSystem.prototype.pause = function () {
		this._playing = false;
	};

	ScriptSystem.prototype.stop = ScriptSystem.prototype.pause;

	ScriptSystem.prototype.process = function (entities, tpf) {
		// Update scripts
		for (var i = 0; i < entities.length; i++) {
			var scriptComponent = entities[i].scriptComponent;
			scriptComponent.run(entities[i], tpf);
		}

		// update play time
		if (this._playing) {
			this.context.playTime += tpf;
		}
	};

	ScriptSystem.prototype.addedComponent = function (entity, component) {
		if (component.type === 'ScriptComponent' && !this.manualSetup) {
			component.setup(entity);
		}
	};

	ScriptSystem.prototype.removedComponent = function (entity, component) {
		if (component.type === 'ScriptComponent' && !this.manualSetup) {
			component.cleanup();
		}
	};

	/*
	ScriptSystem.prototype.deleted = function (entity) {
		if (entity.scriptComponent && !this.manualSetup) {
			entity.scriptComponent.cleanup();
		}
	};*/

	ScriptSystem.prototype.clear = function () {
		for (var i = 0; i < this._activeEntities.length; i++) {
			var entity = this._activeEntities[i];
			entity.scriptComponent.cleanup();
		}

		this._world = null;
		this.context = null;

		System.prototype.clear.call(this);
	};

	Scripts.addClass('ScriptSystem', ScriptSystem);

	return ScriptSystem;
});<commit_msg>Removed a use of Scripts.addClass<commit_after>define([
	'goo/entities/systems/System',
	'goo/entities/SystemBus'
], function (
	System,
	SystemBus
) {
	'use strict';

	/**
	 * Processes all entities with script components, running the scripts where applicable
	 * @extends System
	 */
	function ScriptSystem(world) {
		System.call(this, 'ScriptSystem', ['ScriptComponent']);

		//! AT: why this?
		this._world = world;

		var renderer = this._world.gooRunner.renderer;
		// General world environment
		this.context = {
			domElement: renderer.domElement,
			viewportWidth: renderer.viewportWidth,
			viewportHeight: renderer.viewportHeight,
			world: world,
			activeCameraEntity: null,
			worldData: {},
			playTime: 0
		};

		this._playing = true;

		SystemBus.addListener('goo.setCurrentCamera', function (data) {
			this.context.activeCameraEntity = data.entity;
		}.bind(this));

		SystemBus.addListener('goo.viewportResize', function (data) {
			this.context.viewportWidth = data.width;
			this.context.viewportHeight = data.height;
		}.bind(this));

		this.manualSetup = false;

		this.priority = 500;
	}

	ScriptSystem.prototype = Object.create(System.prototype);
	ScriptSystem.prototype.constructor = ScriptSystem;

	/*
	ScriptSystem.prototype.inserted = function (entity) {
		if (!this.manualSetup) {
			entity.scriptComponent.setup(entity);
		}
	};*/

	ScriptSystem.prototype.play = function () {
		this.context.playTime = 0;
		this._playing = true;
	};

	ScriptSystem.prototype.resume = function () {
		this._playing = true;
	};

	ScriptSystem.prototype.pause = function () {
		this._playing = false;
	};

	ScriptSystem.prototype.stop = ScriptSystem.prototype.pause;

	ScriptSystem.prototype.process = function (entities, tpf) {
		// Update scripts
		for (var i = 0; i < entities.length; i++) {
			var scriptComponent = entities[i].scriptComponent;
			scriptComponent.run(entities[i], tpf);
		}

		// update play time
		if (this._playing) {
			this.context.playTime += tpf;
		}
	};

	ScriptSystem.prototype.addedComponent = function (entity, component) {
		if (component.type === 'ScriptComponent' && !this.manualSetup) {
			component.setup(entity);
		}
	};

	ScriptSystem.prototype.removedComponent = function (entity, component) {
		if (component.type === 'ScriptComponent' && !this.manualSetup) {
			component.cleanup();
		}
	};

	/*
	ScriptSystem.prototype.deleted = function (entity) {
		if (entity.scriptComponent && !this.manualSetup) {
			entity.scriptComponent.cleanup();
		}
	};*/

	ScriptSystem.prototype.clear = function () {
		for (var i = 0; i < this._activeEntities.length; i++) {
			var entity = this._activeEntities[i];
			entity.scriptComponent.cleanup();
		}

		this._world = null;
		this.context = null;

		System.prototype.clear.call(this);
	};

	return ScriptSystem;
});
{'fraction_non_alphanumeric': 0.1399365526965104, 'fraction_numerical': 0.0024673951357067326, 'mean_word_length': 3.973707274320771, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4216173', 'n_tokens_mistral': 1993, 'n_tokens_neox': 1773, 'n_words': 342}