Package name.moore.kevin.ze.components
Class distribution
java.lang.Object
name.moore.kevin.ze.components.distribution
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault to a distribution with nothing set, implicating zero parts.distribution(Map<com.simsilica.es.EntityId,Double> dist) -
Method Summary
Modifier and TypeMethodDescriptionReturn the normalised (ie values sum to 100%) distribution eg [0.5,0.4,0.1].voidsetDistribution(Map<com.simsilica.es.EntityId,Double> dist)Prefer not to directly change the data, we should just create a new distribution component.toString()
-
Field Details
-
distribution
-
-
Constructor Details
-
distribution
public distribution()Default to a distribution with nothing set, implicating zero parts. -
distribution
- Parameters:
dist-
-
-
Method Details
-
getDistribution
Return the normalised (ie values sum to 100%) distribution eg [0.5,0.4,0.1].- Returns:
- immutable collection.
-
setDistribution
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
-