Changed descriptions for most files

Brought in-line to the docstrings
This commit is contained in:
2021-06-08 21:13:34 +12:00
parent 4cbfb97225
commit 227d7fd874
10 changed files with 304 additions and 36 deletions
+85
View File
@@ -0,0 +1,85 @@
*| [JavaECS](../../README.md) | [docs](../overview.md) | [component](./dir.md) | ComponentArray[]().md*
# Component Array
| **In this Section** |
|-|
| [About](#about) |
| [Implementation](#implementation) |
| [Constructors](#constructors) |
| [Methods](#methods) |
| [Fields](#fields) |
| [Examples](#examples)|
| [Notes](#notes)|
## About
The `ComponentArray` class defines the a common structure that all component data is stored in.
## Implementation
Associatively maps an entity to the index position of its component data.
See [ComponentArray.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/ComponentArray.java) for the full implementation.
## Constructors
Default constructor
``` java
public ComponentArray(){}
```
<br>
## Methods
### getData
``` java
protected Object getData(int entity);
```
Gets the data Object associated with the entity. Returns `null` if the object was not found.
<br>
### insertData
``` java
protected boolean insertData(int entity, Object component);
```
Inserts the specified `component` and associates it with the entity. If the entity alread has data associated to it, then returns `false`, without adding data.
<br>
### moveData
``` java
protected int moveData(int sourceEntity, int destinationEntity);
```
'Moves' data from the `sourceEntity` to the `destinationEntity`. Actual implementation copies the data Object associated with the key, and inserts it associated with the new entity.
Returns `0` if the operation succeeded, `-1` if the object data was null, `-2` if a `NullPointerException` occurred, and `-3` if inserting the new data failed.
<br>
### removeData
``` java
protected boolean removeData(int entity);
```
Returns `true` if it removed the specified entity's data. If the entity does not exist (data isn't mapped to that entity), then returns `false`.
<br>
## Fields
### componentArray
``` java
private List<Object> componentArray = new ArrayList<>();
```
The `List<>` containing the component Object data
<br>
### componentDataEntityMap
``` java
private Map<Integer, Integer> componentDataEntityMap = new HashMap<>();
```
The mapped list of component data indicies to entities.
<br>
### entityComponentDataMap
``` java
private Map<Integer, Integer> entityComponentDataMap = new HashMap<>();
```
The mapped list of entities to component data indicies.
+125
View File
@@ -0,0 +1,125 @@
*| [JavaECS](../../README.md) | [docs](../overview.md) | [component](./dir.md) | ComponentManager[]().md*
# Component Array
| **In this Section** |
|-|
| [About](#about) |
| [Implementation](#implementation) |
| [Constructors](#constructors) |
| [Methods](#methods) |
| [Fields](#fields) |
| [Examples](#examples)|
| [Notes](#notes)|
## About
The `ComponentArray` class defines the a common structure that all component data is stored in.
## Implementation
Associatively maps an entity to the index position of its component data.
See [ComponentManager.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/ComponentManager.java) for the full implementation.
## Constructors
Default constructor
``` java
public ComponentManager(){}
```
<br>
## Methods
### addComponentToEntity
``` java
protected void addComponentToEntity(Type componentType, Object componentData, int entity);
```
Adds the specified component to the provided entity. Returns `true` if successful, `false` if the component is already associated to the entity.
<br>
### entityDestroyed
``` java
public void entityDestroyed(int entity);
```
Signals to the `ComponentManager` the entity was destroyed. All component data references should be removed.
<br>
### getComponent
``` java
public Object getComponent(Type componentType, int entity);
```
Gets the component data associated with the entity, or `null` if it was not found.
* The result of this operation should be cast back to the specified `Type`
<br>
### getComponentIndex
``` java
protected Integer getComponentIndex(Type type);
```
Gets the registration index of the provided component type. Returns the index, or `-1` if the component isn't registered.
<br>
### getComponentType
``` java
protected Type getComponentType(Integer index);
```
Gets the registration type of the provided component index. Returns the index, or `null` if the component isn't registered.
<br>
### moveComponentData
``` java
protected void moveComponentData(int sourceEntity, int destinationEntity, Type component);
```
Moves a single component data from one entity to another. Returns `true` if the component was moved successfully, else `false`.
<br>
### moveAllComponentData
``` java
protected void moveAllComponentData(int sourceEntity, int destinationEntity, BitSet sourceRegistrations);
```
Moves all component data from one entity to another.
<br>
### registerComponent
``` java
protected boolean registerComponent(Type type);
```
Registers the component type. Returns `true` if successful, else `false`.
<br>
### removeComponentFromEntity
``` java
public boolean removeComponentFromEntity(Type componentType, int entity);
```
Removes the specified component from the entity. Returns `true` if successful, else `false`.
<br>
## Fields
### componentArrays
``` java
private Map<Type, ComponentArray> componentArrays = new HashMap<>();
```
Maps the component `Type` to its [ComponentArray](./ComponentArray.md)
<br>
### componentPosIndex
``` java
private Map<Type, Integer> componentPosIndex = new HashMap<>();
```
The mapped list of component types to the registration indices.
<br>
### indexComponentType
``` java
private Map<Integer, Type> indexComponentType = new HashMap<>();
```
The mapped list of registration indices to component types.
+7 -1
View File
@@ -1,4 +1,10 @@
*| [JavaECS](../README.md) | [docs](../overview.md) | component*
# Overview
### In this folder
[component.md](./component.md)
* [Component.md](./Component.md)
* [componentArray.md](./ComponentArray.md)
* [componentManager.md](./ComponentManager.md)
### See source files:
* [componentArray.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/ComponentArray.java)
* [componentManager.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/ComponentManager.java)