Class ServiceLocator

java.lang.Object
com.csse3200.game.services.ServiceLocator

public class ServiceLocator extends Object
A simplified implementation of the Service Locator pattern: https://martinfowler.com/articles/injection.html#UsingAServiceLocator

Allows global access to a few core game services. Warning: global access is a trap and should be used extremely sparingly. Read the wiki for details (https://github.com/UQcsse3200/game-engine/wiki/Service-Locator).

  • Method Details

    • getPlayer

      public static Entity getPlayer()
    • getEntityService

      public static EntityService getEntityService()
    • getRenderService

      public static RenderService getRenderService()
    • getPhysicsService

      public static PhysicsService getPhysicsService()
    • getTimeSource

      public static GameTime getTimeSource()
    • getInputService

      public static InputService getInputService()
    • getResourceService

      public static ResourceService getResourceService()
    • getGameArea

      public static GameArea getGameArea()
    • isTransitioning

      public static boolean isTransitioning()
    • setTransitioning

      public static void setTransitioning(boolean value)
    • getSaveLoadService

      public static SaveLoadService getSaveLoadService()
    • getMusicService

      public static MusicService getMusicService()
    • getDifficulty

      public static Difficulty getDifficulty()
    • getButtonSoundService

      public static ButtonSoundService getButtonSoundService()
    • registerGameArea

      public static void registerGameArea(GameArea theArea)
    • registerPlayer

      public static void registerPlayer(Entity person)
    • getCachedPlayerStamina

      public static Float getCachedPlayerStamina()
      Returns cached player stamina to restore after area transitions.
    • setCachedPlayerStamina

      public static void setCachedPlayerStamina(Float value)
      Caches player stamina to be restored when the next player entity is created.
    • getCachedPlayerHealth

      public static Integer getCachedPlayerHealth()
      Returns cached player health to restore after area transitions.
    • setCachedPlayerHealth

      public static void setCachedPlayerHealth(Integer value)
      Caches player health to be restored when the next player entity is created.
    • registerEntityService

      public static void registerEntityService(EntityService service)
    • registerRenderService

      public static void registerRenderService(RenderService service)
    • registerPhysicsService

      public static void registerPhysicsService(PhysicsService service)
    • registerTimeSource

      public static void registerTimeSource(GameTime source)
    • registerInputService

      public static void registerInputService(InputService source)
    • registerResourceService

      public static void registerResourceService(ResourceService source)
    • registerSaveLoadService

      public static void registerSaveLoadService(SaveLoadService source)
    • registerMusicService

      public static void registerMusicService(MusicService source)
    • registerDifficulty

      public static void registerDifficulty(Difficulty source)
    • registerButtonSoundService

      public static void registerButtonSoundService(ButtonSoundService source)
    • clear

      public static void clear()
    • getGlobalEvents

      public static EventHandler getGlobalEvents()