Class entityFactory

java.lang.Object
name.moore.kevin.ze.entities.entityFactory

public class entityFactory extends Object
Creates entity factories which can then in turn create appropriate repository entities.

Before the factory can be used the entityrepository should be injected. Injection is used since it allows more flexibility in testing.

Typical use:
engineEF e = (engineEF) new entityFactory().make(engine.class);
e.toComponents( enginespec ); //build an engine entity based on spec

Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • entityrepository

      @Inject private com.simsilica.es.EntityData entityrepository
    • factory

      private entityFactory.FACTORY factory
  • Constructor Details

  • Method Details

    • make

      public baseEF make(Class c)
      Make a new factory able to provide the specified class.

      Example: engineEF ep = (engineEF) new entityFactory().make(engine.class);

      If we are unable to make the required processor we throw a RuntimeException since there isn't a reasonable way forward.

      Parameters:
      c - required class (without 'Entity' suffix) eg engine.class provides an engineEntity.class
      Returns:
      a factory which can create entities.
      Throws:
      RuntimeException - if an appropriate processor can't be made.
    • writeDOTfile

      public void writeDOTfile(File dotf)
      Output a .dot format diagram of the games entities and components. This becomes part of the site documentation. Failure to create the file is just reported and execution continues - it isnt a show-stopper.
      Parameters:
      dotf -
    • trace

      public StringBuilder trace()
      Used to testing and diagnostics to display the current entity repository.
      Returns: