<commit_before>package net.mostlyoriginal.game.manager;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Wire;
import com.artemis.managers.GroupManager;
import com.artemis.managers.TagManager;
import com.artemis.systems.EntityProcessingSystem;
import com.badlogic.gdx.math.MathUtils;
import net.mostlyoriginal.api.component.basic.Pos;
import net.mostlyoriginal.api.component.graphics.Anim;
import net.mostlyoriginal.game.G;
import net.mostlyoriginal.game.component.environment.RouteNode;

/**
 * Plot system.
 *
 * @author <NAME>
 */
@Wire
public class RouteSystem extends EntityProcessingSystem {

    public static final int CHANCE_OF_ROUTE_BEING_NODE = 50;
    public static final int DEFAULT_ROUTE_LENGTH = 10;

    protected GroupManager groupManager;
    protected EntityFactorySystem efs;

    protected ComponentMapper<RouteNode> mRouteNode;
    protected ComponentMapper<Anim> mAnim;
    protected ComponentMapper<Pos> mPos;
    private TagManager tagManager;

    public RouteSystem() {
        super(Aspect.getAspectForAll(RouteNode.class));
    }

    @Override
    protected void initialize() {
        super.initialize();

        efs.createRouteIndicator();
        createRoute(DEFAULT_ROUTE_LENGTH);
    }


    private void createRoute( int length ) {

        deleteRoute();

        for ( int i=0; i<length; i++ )
        {
            RouteNode.Action action = ( (i==0) || (i==length-1) || (MathUtils.random(0, 99) < CHANCE_OF_ROUTE_BEING_NODE) ) ? RouteNode.Action.EVENT : RouteNode.Action.SKIP;

            efs.createRouteNode( 8 + i * 8, G.SCREEN_TOP - 16, action, i);
         }

        markVisitedUpTo(0);
    }

    /** Signal everything visited up to given step. */
    public void markVisitedUpTo(int upToStep)
    {

        for ( Entity node : groupManager.getEntities("route")) {
            if( mRouteNode.has(node) )
            {
                RouteNode routeNode = (RouteNode) mRouteNode.get(node);
                routeNode.visited = ( routeNode.order <= upToStep );

                // move indicator to active step.
                if ( routeNode.order == upToStep )
                {
                    placeIndicatorAboveNode(node);
                }
            }
        }
    }

    private void placeIndicatorAboveNode(Entity node) {
        Entity routeIndicator = tagManager.getEntity("routeindicator");
        if ( routeIndicator != null && mPos.has(routeIndicator)) {
            Pos indicatorPos = mPos.get(routeIndicator);
            Pos nodePos = mPos.get(node);
            indicatorPos.x = nodePos.x;
            indicatorPos.y = nodePos.y + 6;
        }
    }

    private void deleteRoute() {

        for ( Entity e : groupManager.getEntities("route")) {
            e.deleteFromWorld();
        }
    }
<commit_msg>Tweak route location.<commit_after>package net.mostlyoriginal.game.manager;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Wire;
import com.artemis.managers.GroupManager;
import com.artemis.managers.TagManager;
import com.artemis.systems.EntityProcessingSystem;
import com.badlogic.gdx.math.MathUtils;
import net.mostlyoriginal.api.component.basic.Pos;
import net.mostlyoriginal.api.component.graphics.Anim;
import net.mostlyoriginal.game.G;
import net.mostlyoriginal.game.component.environment.RouteNode;

/**
 * Plot system.
 *
 * @author <NAME>
 */
@Wire
public class RouteSystem extends EntityProcessingSystem {

    public static final int CHANCE_OF_ROUTE_BEING_NODE = 50;
    public static final int DEFAULT_ROUTE_LENGTH = 16;

    protected GroupManager groupManager;
    protected EntityFactorySystem efs;

    protected ComponentMapper<RouteNode> mRouteNode;
    protected ComponentMapper<Anim> mAnim;
    protected ComponentMapper<Pos> mPos;
    private TagManager tagManager;

    public RouteSystem() {
        super(Aspect.getAspectForAll(RouteNode.class));
    }

    @Override
    protected void initialize() {
        super.initialize();

        efs.createRouteIndicator();
        createRoute(DEFAULT_ROUTE_LENGTH);
    }


    private void createRoute( int length ) {

        deleteRoute();

        // center our route.
        int startX = (G.SCREEN_WIDTH / 2) - (length * 4);

        for ( int i=0; i<length; i++ )
        {
            RouteNode.Action action = ( (i==0) || (i==length-1) || (MathUtils.random(0, 99) < CHANCE_OF_ROUTE_BEING_NODE) ) ? RouteNode.Action.EVENT : RouteNode.Action.SKIP;

            efs.createRouteNode( startX + i * 8, G.SCREEN_HEIGHT - 16, action, i);
         }

        markVisitedUpTo(0);
    }

    /** Signal everything visited up to given step. */
    public void markVisitedUpTo(int upToStep)
    {

        for ( Entity node : groupManager.getEntities("route")) {
            if( mRouteNode.has(node) )
            {
                RouteNode routeNode = (RouteNode) mRouteNode.get(node);
                routeNode.visited = ( routeNode.order <= upToStep );

                // move indicator to active step.
                if ( routeNode.order == upToStep )
                {
                    placeIndicatorAboveNode(node);
                }
            }
        }
    }

    private void placeIndicatorAboveNode(Entity node) {
        Entity routeIndicator = tagManager.getEntity("routeindicator");
        if ( routeIndicator != null && mPos.has(routeIndicator)) {
            Pos indicatorPos = mPos.get(routeIndicator);
            Pos nodePos = mPos.get(node);
            indicatorPos.x = nodePos.x;
            indicatorPos.y = nodePos.y + 5;
        }
    }

    private void deleteRoute() {

        for ( Entity e : groupManager.getEntities("route")) {
            e.deleteFromWorld();
        }
    }

{'fraction_non_alphanumeric': 0.10296143250688705, 'fraction_numerical': 0.005681818181818182, 'mean_word_length': 2.531306990881459, 'pattern_counts': {'":': 0, '<': 17, '<?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': '5709701', 'n_tokens_mistral': 1747, 'n_tokens_neox': 1663, 'n_words': 347}