Class distribution

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

public class distribution extends Object implements com.simsilica.es.EntityComponent
A component that specifies the power distribution eg from an engine to multiple ship components such as the hull and weapons.

It is a component for entities that need to route power from an engine onto other equipment such as hulls (for movement) and weapons. Even if there is only an engine and a hull, there will still be a distribution component (it will specify all power routes to the hull)

The distribution is held as a map of EntityId -> fraction - these fractions should sum to 1. Each installed piece of equipment will have a value in the distribution - it may be NaN if the equipment isn't 'chargeable' ie doesn't accept energy. Using NaN allows for chargeable equipment to have a distribution of zero ie capable of generating but not accepting energy.

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

    • distribution

      private Map<com.simsilica.es.EntityId,​Double> distribution
  • Constructor Details

    • distribution

      public distribution()
      Default to a distribution with nothing set, implicating zero parts.
    • distribution

      public distribution(Map<com.simsilica.es.EntityId,​Double> dist)
      Parameters:
      dist -
  • Method Details

    • getDistribution

      public Map<com.simsilica.es.EntityId,​Double> getDistribution()
      Return the normalised (ie values sum to 100%) distribution eg [0.5,0.4,0.1].
      Returns:
      immutable collection.
    • setDistribution

      public void setDistribution(Map<com.simsilica.es.EntityId,​Double> dist)
      Prefer not to directly change the data, we should just create a new distribution component. But we don't have access to the entity to remove/add the new component.
      Parameters:
      dist -
    • toString

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