kbdluv-artemis

shortcuts for libgdx/artemis-odb

License

License

Categories

Categories

Net
GroupId

GroupId

net.onedaybeard.kbdluv
ArtifactId

ArtifactId

kbdluv-artemis
Last Version

Last Version

0.2.3
Release Date

Release Date

Type

Type

jar
Description

Description

kbdluv-artemis
shortcuts for libgdx/artemis-odb
Project URL

Project URL

https://github.com/junkdog/kbdluv
Source Code Management

Source Code Management

https://github.com/junkdog/kbdluv/

Download kbdluv-artemis

How to add to project

<!-- https://jarcasting.com/artifacts/net.onedaybeard.kbdluv/kbdluv-artemis/ -->
<dependency>
    <groupId>net.onedaybeard.kbdluv</groupId>
    <artifactId>kbdluv-artemis</artifactId>
    <version>0.2.3</version>
</dependency>
// https://jarcasting.com/artifacts/net.onedaybeard.kbdluv/kbdluv-artemis/
implementation 'net.onedaybeard.kbdluv:kbdluv-artemis:0.2.3'
// https://jarcasting.com/artifacts/net.onedaybeard.kbdluv/kbdluv-artemis/
implementation ("net.onedaybeard.kbdluv:kbdluv-artemis:0.2.3")
'net.onedaybeard.kbdluv:kbdluv-artemis:jar:0.2.3'
<dependency org="net.onedaybeard.kbdluv" name="kbdluv-artemis" rev="0.2.3">
  <artifact name="kbdluv-artemis" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.onedaybeard.kbdluv', module='kbdluv-artemis', version='0.2.3')
)
libraryDependencies += "net.onedaybeard.kbdluv" % "kbdluv-artemis" % "0.2.3"
[net.onedaybeard.kbdluv/kbdluv-artemis "0.2.3"]

Dependencies

provided (2)

Group / Artifact Type Version
com.badlogicgames.gdx : gdx jar 1.9.2
net.onedaybeard.artemis : artemis-odb jar 2.0.0-RC5

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
com.badlogicgames.gdx : gdx-backend-headless jar 1.9.2

Project Modules

There are no modules declared in this project.

kbdluv-artemis

Easy shortcuts for libgdx/artemis.

Usage

  • Extend ShortcutProcessor
  • Implement getEntity()
  • getEntity can return null if no shortcut methods take an Entity or Component parameter
  • Create a method, annotate it with @Shortcut. Method can take 4 forms:
    1. zeroArguments()
    2. withEntity(Entity e) (see getEntity())
    3. withEntityAndComponent(Entity e, Position posiiton)
    4. withComponent(Position posiiton)
  • Register the input processor as you normally would.

Getting Started

Maven

<dependency>
	<groupId>net.onedaybeard.kbdluv</groupId>
	<artifactId>kbdluv-artemis</artifactId>
	<version>0.2.3</version>
</dependency>

Gradle

  dependencies { compile "net.onedaybeard.artemis:kbdluv-artemis:0.2.3" }

Example

Method parameters for shortcuts are guaranteed to never be null. If any parameter can't be inferred, the shortcut method is not invoked.

// makes for shorter @Shorcut:s.
import static com.badlogic.gdx.Input.Keys.*;

public class MyShortcuts extends ShortcutProcessor {

    // shortcut processors are auto-wiring
    private ComonentMapper<Position> positionMapper;
    private TagManager tagManager;

    public MyShortcuts(World world) {
        super(world);
    }

    /**
     * The entity returned by this method is passed to shortcuts which
     * require an {@link Entity} - see below.
     */
    @Override
    protected Entity getEntity() {
        // how entities are resolved is up to you is up to you
        return world.getSystem(FooBarEntityTrackerSystem.class).getHoveredEntity();
    }

    // 'A' - note "import static com.badlogic.gdx.Input.Keys.*;"
    @Shortcut(A)
    private void shortcutWithNoParameters() {
        // ...
    }

	// MOD_ fields live in ShortcutProcessor
    @Shortcut(MOD_SHIFT | B) // left and right modifier keys are treated equally
    private void doSomethingWith(Entity e) {
        // ...
    }

    @Shortcut(MOD_CTRL | MOD_SHIFT | C) // combine multiple modifier keys
    private void entityAndComponent(Entity owner, ComponentA componentOfOwner) {
        // ...
    }

    @Shortcut(MOD_ALT | D) // same as above, but omits the Entity
    private void justTheComponent(ComponentA comp) {
        // ...
    }
}

Versions

Version
0.2.3
0.2.2
0.2.1
0.2.0
0.1.1