<commit_before>package net.mostlyoriginal.api.system.core;


import com.artemis.Aspect;
import com.artemis.Entity;
import com.artemis.EntitySystem;
import com.artemis.World;
import com.artemis.utils.IntBag;


/**
 * Spread entity processing.
 * <p/>
 *
 * The system spreads out invocations while maintaining
 * a fixed processing interval per entity.
 *
 * Use to spread out work over multiple frames.
 *
 * The more entities are added, the smaller the interval
 * between {@see #process(Entity)} invocations.
 *
 * @author <NAME>
 * @author <NAME>
 */
public abstract class SpreadProcessingSystem extends EntitySystem {


	protected int index;
	protected float roundTripTime;
	protected float entitiesToProcess=0;
	protected int lastProcessedEntityId =-1;
	protected Entity flyweight;

	/**
	 * Creates a new SpreadProcessingSystem.
	 *
	 * @param aspect        the aspect to match entites
	 * @param roundTripTime time required to cycle through all entities.
	 */
	public SpreadProcessingSystem(Aspect.Builder aspect, float roundTripTime) {
		super(aspect);
		setRoundTripTime(roundTripTime);
	}

	@Override
	protected void setWorld(World world) {
		super.setWorld(world);
		flyweight = createFlyweightEntity();
	}

	/**
	 * Process a entity this system is interested in.
	 *
	 * @param e the entity to process
	 */
	protected abstract void process(Entity e);

	@Override
	protected void processSystem() {

		final IntBag entities = subscription.getEntities();

		final int processedPerSecond = (int) (( entities.size() / getRoundTripTime()));

		// Depending on subscription size invocation could potentially require less than
		// one invocation. Keep track of 'partial' invocations until we can invoke.
		entitiesToProcess += processedPerSecond * world.delta;
		if ( entitiesToProcess >= 1f ) {
			processEntities((int) entitiesToProcess, entities.getData(), entities.size());

			// keep remainder.
			entitiesToProcess-=(int)entitiesToProcess;
		}
	}

	protected void processEntities(int entitiesToProcess, int[] entities, int size) {

		flyweight.id=-1;

		// process up to array size.<commit_msg>Make world delta configurable for @Namek.<commit_after>package net.mostlyoriginal.api.system.core;


import com.artemis.Aspect;
import com.artemis.Entity;
import com.artemis.EntitySystem;
import com.artemis.World;
import com.artemis.utils.IntBag;


/**
 * Spread entity processing.
 * <p/>
 *
 * The system spreads out invocations while maintaining
 * a fixed processing interval per entity.
 *
 * Use to spread out work over multiple frames.
 *
 * The more entities are added, the smaller the interval
 * between {@see #process(Entity)} invocations.
 *
 * @author <NAME>
 * @author <NAME>
 */
public abstract class SpreadProcessingSystem extends EntitySystem {


	protected int index;
	protected float roundTripTime;
	protected float entitiesToProcess=0;
	protected int lastProcessedEntityId =-1;
	protected Entity flyweight;

	/**
	 * Creates a new SpreadProcessingSystem.
	 *
	 * @param aspect        the aspect to match entites
	 * @param roundTripTime time required to cycle through all entities.
	 */
	public SpreadProcessingSystem(Aspect.Builder aspect, float roundTripTime) {
		super(aspect);
		setRoundTripTime(roundTripTime);
	}

	@Override
	protected void setWorld(World world) {
		super.setWorld(world);
		flyweight = createFlyweightEntity();
	}

	/**
	 * Process a entity this system is interested in.
	 *
	 * @param e the entity to process
	 */
	protected abstract void process(Entity e);

	@Override
	protected void processSystem() {

		final IntBag entities = subscription.getEntities();

		final int processedPerSecond = (int) (( entities.size() / getRoundTripTime()));

		// Depending on subscription size invocation could potentially require less than
		// one invocation. Keep track of 'partial' invocations until we can invoke.
		entitiesToProcess += processedPerSecond * getWorldDelta();
		if ( entitiesToProcess >= 1f ) {
			processEntities((int) entitiesToProcess, entities.getData(), entities.size());

			// keep remainder.
			entitiesToProcess-=(int)entitiesToProcess;
		}
	}

	protected float getWorldDelta() {
		return world.delta;
	}

	protected void processEntities(int entitiesToProcess, int[] entities, int size) {

		flyweight.id=-1;

		// process up to array size.
{'fraction_non_alphanumeric': 0.09500580720092915, 'fraction_numerical': 0.0018583042973286876, 'mean_word_length': 4.232077764277035, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4828200', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1176, 'n_words': 393}