Changed descriptions for most files
Brought in-line to the docstrings
This commit is contained in:
parent
4cbfb97225
commit
227d7fd874
@ -5,6 +5,8 @@
|
||||
body {
|
||||
margin: 0px;
|
||||
background-color: #383c4a;
|
||||
padding-top: 20px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
0
docs/ECS.md
Normal file
0
docs/ECS.md
Normal file
85
docs/component/ComponentArray.md
Normal file
85
docs/component/ComponentArray.md
Normal 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
docs/component/ComponentManager.md
Normal file
125
docs/component/ComponentManager.md
Normal 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.
|
@ -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)
|
@ -11,7 +11,7 @@
|
||||
| [Notes](#notes)|
|
||||
|
||||
## About
|
||||
Controls adding and removing entities, and registration and deregistration of components to specific entities.
|
||||
Controls adding and removing entities, and registration and unregistration of components to specific entities.
|
||||
|
||||
## Implementation
|
||||
Before attempting to use a system, it must be registered.
|
||||
@ -22,14 +22,14 @@ See [EntityManager.java](/BrychanD/JaveECS/src/branch/master/javaecs/src/main/ja
|
||||
|
||||
## Constructors
|
||||
``` java
|
||||
public EntityManager(){}
|
||||
protected EntityManager(){}
|
||||
```
|
||||
The default constructor initialises [unusedEntities](#unusedEntities) to a new queue containing `1024` unique integers.
|
||||
The default constructor initialises [unusedEntities](#unusedEntities) to a new queue containing [maxSize](#maxSize) (`1024`) unique integers.
|
||||
|
||||
<br>
|
||||
|
||||
``` java
|
||||
public EntityManager(int maxEntities){}
|
||||
protected EntityManager(int maxEntities){}
|
||||
```
|
||||
Initialises [unusedEntities](#unusedEntities) to a new queue containing `maxEntities` unique integers.
|
||||
|
||||
@ -38,7 +38,7 @@ Initialises [unusedEntities](#unusedEntities) to a new queue containing `maxEnti
|
||||
## Methods
|
||||
### addEntity
|
||||
``` java
|
||||
public Integer addEntity();
|
||||
protected Integer addEntity();
|
||||
```
|
||||
Pops the next available entity index off the queue, and returns its value.
|
||||
|
||||
@ -46,17 +46,27 @@ Returns `-1` if there is no remaining unused entities.
|
||||
|
||||
<br>
|
||||
|
||||
### getMaxSize
|
||||
``` java
|
||||
protected Integer getMaxSize();
|
||||
```
|
||||
Gets the current maximum entity count.
|
||||
|
||||
<br>
|
||||
|
||||
### getRegistrations
|
||||
``` java
|
||||
public BitSet getRegistrations(int entity);
|
||||
protected BitSet getRegistrations(int entity);
|
||||
```
|
||||
Returns the `BitSet` of registrations the `entity` has
|
||||
Returns the `BitSet` of registrations the `entity` has.
|
||||
|
||||
If the call results in an `IndexOutOfBoundsError`, then returns a new BitSet();
|
||||
|
||||
<br>
|
||||
|
||||
### registerComponent
|
||||
``` java
|
||||
public void registerComponent(int component, int entity);
|
||||
protected void registerComponent(int component, int entity);
|
||||
```
|
||||
Sets the bit `component` in [entityRegistrations](#entityRegistrations) for `entity` to `true`.
|
||||
|
||||
@ -64,7 +74,7 @@ Sets the bit `component` in [entityRegistrations](#entityRegistrations) for `ent
|
||||
|
||||
### removeEntity
|
||||
``` java
|
||||
public void removeEntity(int entity);
|
||||
protected void removeEntity(int entity);
|
||||
```
|
||||
Adds the entity's index back to the unused queue, and clears the assigned registration bits
|
||||
#### Note
|
||||
@ -72,12 +82,32 @@ Adds the entity's index back to the unused queue, and clears the assigned regist
|
||||
|
||||
<br>
|
||||
|
||||
### resize
|
||||
``` java
|
||||
protected boolean resize(int newSize, SystemManager systemManager, ComponentManager componentManager);
|
||||
```
|
||||
Resizes the currentSize of the entity manager. Moves elements above `newSize` if space is available.
|
||||
|
||||
If the current defined elements won't fit, the operation returns `false` and the previous state is maintained.
|
||||
|
||||
<br>
|
||||
|
||||
### setRegistrations
|
||||
``` java
|
||||
protected void setRegistrations(int entity, BitSet registrations);
|
||||
```
|
||||
Sets the entity's registrations to the provided BitSet
|
||||
|
||||
<br>
|
||||
|
||||
### unregisterComponent
|
||||
``` java
|
||||
public void unregisterComponent(int component, int entity);
|
||||
protected void unregisterComponent(int component, int entity);
|
||||
```
|
||||
Sets the bit `component` in [entityRegistrations](#entityRegistrations) for `entity` to `false`.
|
||||
|
||||
Returns `true` if successful.
|
||||
|
||||
<br>
|
||||
|
||||
## Fields
|
||||
@ -85,14 +115,22 @@ Sets the bit `component` in [entityRegistrations](#entityRegistrations) for `ent
|
||||
``` java
|
||||
List<BitSet> entityRegistrations;
|
||||
```
|
||||
The BitSet of registrations for each entity
|
||||
|
||||
<br>
|
||||
|
||||
### maxSize
|
||||
``` java
|
||||
private int maxSize = 1024;
|
||||
```
|
||||
The current maximum entity count.
|
||||
|
||||
Default `1024`
|
||||
|
||||
|
||||
### unusedEntities
|
||||
``` java
|
||||
Queue<Integer> unusedEntities;
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
The queue of unused entity values
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
*| [JavaECS](../README.md) | [docs](../overview.md) | entity*
|
||||
# Overview
|
||||
### In this folder
|
||||
*[Entity.md](./Entity.md)
|
||||
*[EntityManager.md](./EntityManager.md)
|
||||
* [Entity.md](./Entity.md)
|
||||
* [EntityManager.md](./EntityManager.md)
|
||||
|
||||
### See source file:
|
||||
* [EntityManager.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/EntityManager.java)
|
@ -30,19 +30,20 @@ public ECSSystem(){}
|
||||
<br>
|
||||
|
||||
## Methods
|
||||
> These two functions are labelled as abstract (must be implemented) to indicate the type of implementation required.
|
||||
> It is not required to add functionality to them. Parametrised versions can also be added.
|
||||
### init
|
||||
``` java
|
||||
public void init(){}
|
||||
abstract void init();
|
||||
```
|
||||
Functionality that needs to occur at the initialisation of the system should be performed here
|
||||
* `init()` should be called only once, before the system is utilised
|
||||
* An example of the type of call that could be made here is opening a file
|
||||
|
||||
<br>
|
||||
|
||||
### update
|
||||
``` java
|
||||
public void update(){}
|
||||
abstract void update();
|
||||
```
|
||||
Functionality that needs to be called regularly should be defined here
|
||||
* `update()` is intended to be called regularly
|
||||
|
@ -18,63 +18,68 @@ Before attempting to use a system, it must be registered.
|
||||
|
||||
Registration requires a call to `registerSystem(String systemName, ECSSystem system)`, with params of the `String name` and a object reference of the [ECSSystem](./ECSSystem.md). Using the object reference, a system can be invoked at any time.
|
||||
|
||||
See [SystemManager.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/SystemManager.java) for the full implementation.
|
||||
|
||||
## Constructors
|
||||
Default constructor
|
||||
``` java
|
||||
public SystemManager(){}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
## Methods
|
||||
|
||||
### entityDestroyed
|
||||
``` java
|
||||
public void entityDestroyed(int entity);
|
||||
protected void entityDestroyed(int entity);
|
||||
```
|
||||
Removes the specified entity from every system, if it was associated
|
||||
Signals the SystemManager that an entity was destroyed. Removes the entity from each system's tracked entities
|
||||
|
||||
<br>
|
||||
|
||||
### entitySignatureChanged
|
||||
``` java
|
||||
public void entitySignatureChanged(int entity, BitSet entitySignature);
|
||||
protected void entityRegistrationsChanged(int entity, BitSet entityRegistrations);
|
||||
```
|
||||
Checks the entity's new signature against the current registrations. Registers the entity if it wasn't previously registered, or removes it if it is no longer registered.
|
||||
Signals the SystemManager that an entity had its registrations changed; iterates through each system validating the entities list
|
||||
|
||||
<br>
|
||||
|
||||
### registerSystem
|
||||
``` java
|
||||
public boolean registerSystem(String systemName, ECSSystem system);
|
||||
protected boolean registerSystem(Type systemType, ECSSystem system);
|
||||
```
|
||||
Registers the specified system name and system reference to this manager.
|
||||
|
||||
*adds a `systemName:system` pair to [systems](#systems)*
|
||||
*adds a `systemType:system` pair to [systems](#systems)*
|
||||
|
||||
*and a `systemName:new BitSet()` pair to [signatures](#signatures)*
|
||||
*adds a `systemType:new BitSet()` pair to [registrationSignatures](#registrationSignatures)*
|
||||
|
||||
<br>
|
||||
|
||||
### setSignature
|
||||
``` java
|
||||
public void setSignature(String system, BitSet registrations);
|
||||
protected void setRegistrationSignature(Type systemType, BitSet registrations);
|
||||
```
|
||||
Sets the required signature of the `system`
|
||||
Sets the registrations the system requires
|
||||
|
||||
<br>
|
||||
|
||||
## Fields
|
||||
### signatures
|
||||
### registrationSignatures
|
||||
``` java
|
||||
Map<String, BitSet> signatures = new HashMap<>();
|
||||
private Map<Type, BitSet> registrationSignatures = new HashMap<>()
|
||||
```
|
||||
The mapped list of required registrations
|
||||
|
||||
<br>
|
||||
|
||||
### systems
|
||||
``` java
|
||||
Map<String, ECSSystem> systems = new HashMap<>();
|
||||
private Map<Type, ECSSystem> systems = new HashMap<>();
|
||||
```
|
||||
The mapped list of system instances
|
||||
|
||||
<br>
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
*| [JavaECS](../README.md) | [docs](../overview.md) | system*
|
||||
# Overview
|
||||
| **In this folder** |
|
||||
|-|
|
||||
| [ECSSystem.md](./ECSSystem.md) |
|
||||
| [System.md](./System.md) |
|
||||
| [SystemManager.md](./SystemManager.md) |
|
||||
### In this folder
|
||||
* [ECSSystem.md](./ECSSystem.md)
|
||||
* [System.md](./System.md)
|
||||
* [SystemManager.md](./SystemManager.md)
|
||||
|
||||
### See source files:
|
||||
* [ECSSystem.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/ECSSystem.java)
|
||||
* [SystemManager.java](/BrychanD/JavaECS/src/branch/master/javaecs/src/main/java/nz/ac/massey/javaecs/SystemManager.java)
|
Loading…
x
Reference in New Issue
Block a user