Class EntityFactory
java.lang.Object
com.devcharles.piazzapanic.utility.EntityFactory
Factory pattern class that creates entities used in the game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.badlogic.gdx.physics.box2d.CircleShapeprivate final com.badlogic.ashley.core.PooledEngineprivate static final Map<FoodComponent.FoodType,com.badlogic.gdx.graphics.g2d.TextureRegion> private com.badlogic.gdx.physics.box2d.BodyDefprivate com.badlogic.gdx.physics.box2d.FixtureDefprivate final com.badlogic.gdx.physics.box2d.World -
Constructor Summary
ConstructorsConstructorDescriptionEntityFactory(com.badlogic.ashley.core.PooledEngine engine, com.badlogic.gdx.physics.box2d.World world) -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.ashley.core.EntitycreateCook(int x, int y) Creates cook entity, and adds it to the engine.com.badlogic.ashley.core.EntitycreateCustomer(com.badlogic.gdx.math.Vector2 position) Create an AI customer entity.private voidCreate reusable definitions for bodies and fixtures.com.badlogic.ashley.core.EntitycreateFood(FoodComponent.FoodType foodType) Create the food entity at 0,0.com.badlogic.ashley.core.EntitycreateStation(Station.StationType type, com.badlogic.gdx.math.Vector2 position, FoodComponent.FoodType ingredientType) Create a station entity with interactable features enabled.static voidCut the food textures, run at game initialisation.static com.badlogic.gdx.graphics.g2d.TextureRegionGet the texture associated with a certain food.
-
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
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. SeeStation.StationType.position- position vector (z is set to 0).ingredientType- (optional) if this is an Ingredient station, which ingredient should it spawn.
-
cutFood
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:
TextureRegionof 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 aSteeringBehavior.- Parameters:
position- of the customer at spawn point.- Returns:
- reference to the entity.
-