Class GravitySystem

java.lang.Object
technology.sola.ecs.EcsSystem
technology.sola.engine.physics.system.GravitySystem

@NullMarked public class GravitySystem extends technology.sola.ecs.EcsSystem
GravitySystem is an EcsSystem that applies a gravity constant of force to all Entity that have a DynamicBodyComponent, are not kinematic and not grounded.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The order for this system which is one before the PhysicsSystem.ORDER.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a GravitySystem instance and registers event listeners to CollisionEvent to handle updating the grounding of dynamic bodies.
    GravitySystem(EventHub eventHub, float gravityConstant)
    Creates a GravitySystem instance with desired gravity constant and registers event listeners to CollisionEvent to handle updating the grounding of dynamic bodies.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
     
    int
     
    void
    setGravityConstant(float gravityConstant)
    Updates the gravity constant
    void
    update(technology.sola.ecs.World world, float deltaTime)
     

    Methods inherited from class technology.sola.ecs.EcsSystem

    isActive, setActive

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • GravitySystem

      public GravitySystem(EventHub eventHub)
      Creates a GravitySystem instance and registers event listeners to CollisionEvent to handle updating the grounding of dynamic bodies.
      Parameters:
      eventHub - the EventHub instance
    • GravitySystem

      public GravitySystem(EventHub eventHub, float gravityConstant)
      Creates a GravitySystem instance with desired gravity constant and registers event listeners to CollisionEvent to handle updating the grounding of dynamic bodies.
      Parameters:
      eventHub - the EventHub instance
      gravityConstant - the gravity constant to use
  • Method Details

    • update

      public void update(technology.sola.ecs.World world, float deltaTime)
      Specified by:
      update in class technology.sola.ecs.EcsSystem
    • getOrder

      public int getOrder()
      Overrides:
      getOrder in class technology.sola.ecs.EcsSystem
    • getGravityConstant

      public float getGravityConstant()
      Returns:
      the gravity constant
    • setGravityConstant

      public void setGravityConstant(float gravityConstant)
      Updates the gravity constant
      Parameters:
      gravityConstant - the new gravity constant