Android Open Source - acceptableLosses Movement System






From Project

Back to project page acceptableLosses.

License

The source code is released under:

MIT License

If you think the Android project acceptableLosses listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package acceptableLosses.systems;
//from  w  w w .  j  a v a2s.c  o  m

import acceptableLosses.components.Destination;
import acceptableLosses.components.Path;
import acceptableLosses.components.Position;
import acceptableLosses.map.Region;
import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.annotations.Wire;
import com.artemis.systems.EntityProcessingSystem;
import com.badlogic.gdx.Gdx;

public class MovementSystem extends EntityProcessingSystem {

    @Wire
    ComponentMapper<Position> positionComponentMapper;

    @Wire
    ComponentMapper<Path> pathComponentMapper;

    private Region region;

    public MovementSystem(Region region) {
        super(Aspect.getAspectForAll(Position.class, Path.class));
        this.region = region;
    }

    @Override
    protected void process(Entity e) {
        Position position = positionComponentMapper.get(e);
        Path path = pathComponentMapper.get(e);


        if (path.step < path.fullPath3d.getLength()) {

            // See if we can travel there
            if (region.tiles[path.fullPath3d.getX(path.step)]
                    [path.fullPath3d.getY(path.step)]
                    [path.fullPath3d.getZ(path.step)].blocks) {

                e.edit().create(Destination.class).set(
                        path.fullPath3d.getX(path.fullPath3d.getLength() - 1),
                        path.fullPath3d.getY(path.fullPath3d.getLength() - 1),
                        path.fullPath3d.getZ(path.fullPath3d.getLength() - 1));

                e.edit().remove(Path.class);

                Gdx.app.debug("MovementSystem", "Cannot follow path, signaling a repath");

            } else {
                //move
                position.set(
                        path.fullPath3d.getX(path.step),
                        path.fullPath3d.getY(path.step),
                        path.fullPath3d.getZ(path.step));
                path.step++;
            }

        } else {
            //we are at destination
            e.edit().remove(Path.class);
            //TODO: do we want to do something here?

        }

    }
}




Java Source Code List

acceptableLosses.AcceptableLossesGame.java
acceptableLosses.android.AndroidLauncher.java
acceptableLosses.assets.AssetLoader.java
acceptableLosses.assets.FurnitureType.java
acceptableLosses.assets.TileType.java
acceptableLosses.components.Appearance.java
acceptableLosses.components.Cargo.java
acceptableLosses.components.Citizen.java
acceptableLosses.components.Destination.java
acceptableLosses.components.Health.java
acceptableLosses.components.Path.java
acceptableLosses.components.Position.java
acceptableLosses.components.Resume.java
acceptableLosses.components.Sentience.java
acceptableLosses.components.Task.java
acceptableLosses.controls.GestureDetectorController.java
acceptableLosses.controls.InputManager.java
acceptableLosses.controls.ZoomInputProcessor.java
acceptableLosses.controls.commands.Command.java
acceptableLosses.controls.commands.TapCommand.java
acceptableLosses.desktop.DesktopLauncher.java
acceptableLosses.desktop.ImagePacker.java
acceptableLosses.map.AsteroidGenerator.java
acceptableLosses.map.Chunk.java
acceptableLosses.map.Furniture.java
acceptableLosses.map.MapTools.java
acceptableLosses.map.Region.java
acceptableLosses.map.Spawner.java
acceptableLosses.pathing.FastNonOptimalHeuristic.java
acceptableLosses.screens.GameScreen.java
acceptableLosses.screens.SplashScreen.java
acceptableLosses.systems.AiSystem.java
acceptableLosses.systems.AppearanceRenderSystem.java
acceptableLosses.systems.ElevationSystem.java
acceptableLosses.systems.FurnitureRenderSystem.java
acceptableLosses.systems.JobAssignerSystem.java
acceptableLosses.systems.MapRenderSystem.java
acceptableLosses.systems.MovementSystem.java
acceptableLosses.systems.PathFinderSystem.java
acceptableLosses.work.CivilianMover.java
acceptableLosses.work.jobs.DigJob.java
acceptableLosses.work.jobs.Job.java