Class Prefab

java.lang.Object
dev.prozilla.pine.core.entity.prefab.Prefab
Direct Known Subclasses:
CameraPrefab, CanvasElementPrefab, CanvasPrefab, GridPrefab, ParticleBurstEmitterPrefab, SpritePrefab

@Components(Transform.class) public abstract class Prefab extends Object
Abstract class representing a prefab for creating entities with predefined components and values.
  • Field Details

    • name

      protected String name
    • tag

      protected String tag
    • isActive

      protected boolean isActive
  • Constructor Details

    • Prefab

      public Prefab()
  • Method Details

    • setName

      public void setName(String name)
    • setTag

      public void setTag(String tag)
    • setActive

      public void setActive(boolean active)
    • instantiate

      public Entity instantiate(World world)
      Creates a new entity instance with the prefab's default components at position (0, 0).
      Parameters:
      world - The world where the entity will be added.
      Returns:
      A new entity instance.
    • instantiate

      public Entity instantiate(World world, float x, float y)
      Creates a new entity instance with the prefab's default components.
      Parameters:
      world - The world where the entity will be added.
      x - X position
      y - Y position
      Returns:
      A new entity instance.
    • apply

      protected abstract void apply(Entity entity)
      Adds this prefab's predefined components to a given entity and copies values from this prefab.