Changed: Version; System Registration behaviour

This commit is contained in:
Brychan Dempsey 2021-06-09 12:51:50 +12:00
parent d86c07352a
commit 0571986059
3 changed files with 10 additions and 7 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>nz.ac.massey.javaecs</groupId> <groupId>nz.ac.massey.javaecs</groupId>
<artifactId>javaecs</artifactId> <artifactId>javaecs</artifactId>
<version>1.2-PRERELEASE-v2</version> <version>0.9.2-PRERELEASE</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>

View File

@ -13,10 +13,14 @@ package nz.ac.massey.javaecs;
*/ */
import java.util.Set; import java.util.Set;
import java.util.BitSet;
import java.util.HashSet; import java.util.HashSet;
public abstract class ECSSystem{ public abstract class ECSSystem{
Set<Entity> entities = new HashSet<>(); protected Set<Entity> entities = new HashSet<>();
protected BitSet registrationSet;
public BitSet getRegistrationSet;
/** /**
* Implement additional parameterised init() functions as required. * Implement additional parameterised init() functions as required.

View File

@ -15,7 +15,7 @@ import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
class SystemManager{ class SystemManager{
private Map<Type, BitSet> registrationSignatures = new HashMap<>(); //private Map<Type, BitSet> registrationSignatures = new HashMap<>();
private Map<Type, ECSSystem> systems = new HashMap<>(); private Map<Type, ECSSystem> systems = new HashMap<>();
/** /**
@ -40,8 +40,8 @@ class SystemManager{
// Check if the signature is null // Check if the signature is null
if (!entityRegistrations.equals(null)){ if (!entityRegistrations.equals(null)){
BitSet srcCpy = (BitSet)entityRegistrations.clone(); BitSet srcCpy = (BitSet)entityRegistrations.clone();
srcCpy.and(registrationSignatures.get(key)); srcCpy.and(systems.get(key).registrationSet);
if (srcCpy.equals(registrationSignatures.get(key))){ // Bitwise check if the entity is subscribed to this system if (srcCpy.equals(systems.get(key).registrationSet)){ // Bitwise check if the entity is subscribed to this system
systems.get(key).entities.add(entity); systems.get(key).entities.add(entity);
} }
else{ else{
@ -63,7 +63,6 @@ class SystemManager{
return false; return false;
} }
systems.put(systemType, system); systems.put(systemType, system);
registrationSignatures.put(systemType, new BitSet());
return true; return true;
} }
@ -73,7 +72,7 @@ class SystemManager{
* @param registrations the BitSet containing the required registrations set to true * @param registrations the BitSet containing the required registrations set to true
*/ */
protected void setRegistrationSignature(Type systemType, BitSet registrations){ protected void setRegistrationSignature(Type systemType, BitSet registrations){
registrationSignatures.put(systemType, registrations); systems.get(systemType).registrationSet = registrations;
} }