Class accumulator

java.lang.Object
name.moore.kevin.ze.components.accumulator
All Implemented Interfaces:
com.simsilica.es.EntityComponent

public class accumulator extends Object implements com.simsilica.es.EntityComponent
A component that can stores up energy upto a predefined limit.

Once at the pre-determined limit, the accumulator will not accept any more energy and will return offered amounts. A discharge (which can only happen once the accumulator is at its limit) releases the stored energy and the store is back to zero. This is used for things like weapons which only fire once fully charged.

The accumulator can also be set (via the constructor) to collect only the first amount of energy offered, but still only to the limit. This is used in hulls.

Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
     
    private boolean
    True to indicate no more energy will be accepted and ready to call discharge().
    private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
     
    private boolean
    Mode to accept only one charge, and consider the accumulator fully charged.
  • Constructor Summary

    Constructors
    Constructor
    Description
    accumulator​(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> limit)
     
    accumulator​(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> limit, boolean once)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
    charge​(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> offered)
    Store energy and return any unused energy; this happens when the accumulator is at its limit ie full.
    org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
    Release all the accumulated energy, but only if fully charged.
    org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
    discharge​(boolean force)
    Discharge the accumulated energy even if not fully charged.
    org.jscience.physics.amount.Amount<javax.measure.quantity.Energy>
     
     

    Methods inherited from class java.lang.Object

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

    • limit

      private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> limit
    • accumulated

      private org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> accumulated
    • charged

      private boolean charged
      True to indicate no more energy will be accepted and ready to call discharge().
    • once

      private boolean once
      Mode to accept only one charge, and consider the accumulator fully charged.
  • Constructor Details

    • accumulator

      public accumulator(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> limit)
      Parameters:
      limit - maximum storage amount
    • accumulator

      public accumulator(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> limit, boolean once)
      Parameters:
      limit - maximum storage amount
      once - can only be charged once before being discharged.
  • Method Details

    • getLimit

      public org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> getLimit()
      Returns:
      maximum storage amount
    • charge

      public org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> charge(org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> offered)
      Store energy and return any unused energy; this happens when the accumulator is at its limit ie full.

      Offer a negative energy to remove or use energy from the accumulator

      Parameters:
      offered - energy to add to the accumulator
      Returns:
      any unused energy
    • discharge

      public org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> discharge()
      Release all the accumulated energy, but only if fully charged.
      Returns:
      all the current stored energy
    • discharge

      public org.jscience.physics.amount.Amount<javax.measure.quantity.Energy> discharge(boolean force)
      Discharge the accumulated energy even if not fully charged.
      Parameters:
      force - true
      Returns:
      all the current stored energy
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns: