DaanVanYperen / artemis-odb-contrib

Drop-in extensions for artemis-odb. Prefab systems, components, networking, events!
MIT License
75 stars 19 forks source link

Lifecycle graftting #130

Closed junkdog closed 5 years ago

junkdog commented 5 years ago

tests

DebugPlugin tests run with graftt agent; maven downloads it and puts the agent under target/ - tests will only work from within the idea if mvn test (or later) has run once, as intellij doesn't care much about maven plugins and their behavior - but it does pick up the agent args from maven.

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <argLine>-javaagent:${graftt.agent}=cp:${graftt.transplants}</argLine>
        <useSystemClassLoader>false</useSystemClassLoader>
    </configuration>
</plugin>

running as a user

As a user, the crux here is that the JVM must start with -javaagent:<graft-agent.jar>. Maybe we should provide a script or something to automatically download the most recent agent?

In the tests, it's solved by relying on maven plugins. I guess something similar could be done for gradle.

other stuff

new module for the transplants: contrib-plugin-lifecycle-transplants. pretty similar-looking to the previous ones. some things are done slightly differently, but I don't think I've changed any behavior.

junkdog commented 5 years ago

Noticed phases aren't emitted, I'll take a look.

public class LifecycleListenerManager extends BaseSystem implements ArtemisPhaseListener {
    private LifecycleListenerMultiplexer listeners = new LifecycleListenerMultiplexer();

    @Override
    public void onPhase(World w, Phase phase) {
        if (phase == Phase.PRE_INITIALIZE) {
            // world on system isn't available at this point in the lifecycle.
            registerEntityLifecycleListeners(w.getSystems());
        }
    }
junkdog commented 5 years ago

Hmm, were was PhaSe.PRE_INITIALIZE sent? I can't find it in either https://github.com/junkdog/artemis-odb/pull/575 or on develop.