Class EntityFactory

java.lang.Object
com.devcharles.piazzapanic.utility.EntityFactory

public class EntityFactory extends Object
Factory pattern class that creates entities used in the game.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private com.badlogic.gdx.physics.box2d.CircleShape
     
    private final com.badlogic.ashley.core.PooledEngine
     
    private static final Map<FoodComponent.FoodType,com.badlogic.gdx.graphics.g2d.TextureRegion>
     
    private com.badlogic.gdx.physics.box2d.BodyDef
     
    private com.badlogic.gdx.physics.box2d.FixtureDef
     
    private final com.badlogic.gdx.physics.box2d.World
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EntityFactory(com.badlogic.ashley.core.PooledEngine engine, com.badlogic.gdx.physics.box2d.World world)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.badlogic.ashley.core.Entity
    createCook(int x, int y)
    Creates cook entity, and adds it to the engine.
    com.badlogic.ashley.core.Entity
    createCustomer(com.badlogic.gdx.math.Vector2 position)
    Create an AI customer entity.
    private void
    Create reusable definitions for bodies and fixtures.
    com.badlogic.ashley.core.Entity
    Create the food entity at 0,0.
    com.badlogic.ashley.core.Entity
    createStation(Station.StationType type, com.badlogic.gdx.math.Vector2 position, FoodComponent.FoodType ingredientType)
    Create a station entity with interactable features enabled.
    static void
    Cut the food textures, run at game initialisation.
    static com.badlogic.gdx.graphics.g2d.TextureRegion
    Get the texture associated with a certain food.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • engine

      private final com.badlogic.ashley.core.PooledEngine engine
    • world

      private final com.badlogic.gdx.physics.box2d.World world
    • movingFixtureDef

      private com.badlogic.gdx.physics.box2d.FixtureDef movingFixtureDef
    • movingBodyDef

      private com.badlogic.gdx.physics.box2d.BodyDef movingBodyDef
    • circleShape

      private com.badlogic.gdx.physics.box2d.CircleShape circleShape
    • foodTextures

      private static final Map<FoodComponent.FoodType,com.badlogic.gdx.graphics.g2d.TextureRegion> foodTextures
  • Constructor Details

    • EntityFactory

      public EntityFactory(com.badlogic.ashley.core.PooledEngine engine, com.badlogic.gdx.physics.box2d.World world)
  • Method Details

    • createDefinitions

      private void createDefinitions()
      Create reusable definitions for bodies and fixtures. These can be then be used while creating the bodies for entities.
    • createCook

      public com.badlogic.ashley.core.Entity createCook(int x, int y)
      Creates cook entity, and adds it to the engine.
      Returns:
      Reference to the entity.
    • createFood

      public com.badlogic.ashley.core.Entity createFood(FoodComponent.FoodType foodType)
      Create the food entity at 0,0.
      Parameters:
      foodType - The type of food to create.
      Returns:
      reference to the Entity
    • createStation

      public com.badlogic.ashley.core.Entity createStation(Station.StationType type, com.badlogic.gdx.math.Vector2 position, FoodComponent.FoodType ingredientType)
      Create a station entity with interactable features enabled. This does not render the station as it is rendered in the tilemap.
      Parameters:
      type - Type of station to create. See Station.StationType.
      position - position vector (z is set to 0).
      ingredientType - (optional) if this is an Ingredient station, which ingredient should it spawn.
    • cutFood

      public static void cutFood(String path)
      Cut the food textures, run at game initialisation.
      Parameters:
      path - (optional) custom path for food textures.
    • getFoodTexture

      public static com.badlogic.gdx.graphics.g2d.TextureRegion getFoodTexture(FoodComponent.FoodType type)
      Get the texture associated with a certain food.
      Returns:
      TextureRegion of the food.
    • createCustomer

      public com.badlogic.ashley.core.Entity createCustomer(com.badlogic.gdx.math.Vector2 position)
      Create an AI customer entity. The entity will not walk until it receives a SteeringBehavior.
      Parameters:
      position - of the customer at spawn point.
      Returns:
      reference to the entity.