Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Entity Component System (ECS) architecture #3149

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

rofidakhaled
Copy link

@rofidakhaled rofidakhaled commented Dec 10, 2024

This pull request implements the ECS pattern, improving and enabling : entity management, component interaction, scalability, and reusability.

Close # <485>

@rofidakhaled rofidakhaled force-pushed the feature/485-ecs-pattern-implementation branch from c3ef23c to f92c2a4 Compare January 11, 2025 20:50
Copy link

github-actions bot commented Jan 12, 2025

PR Summary

This pull request implements the Entity Component System (ECS) architecture, improving entity management, component interaction, scalability, and reusability. It includes comprehensive unit tests for all components and systems.

Changes

File Summary
entity-component-system/README.md New file describing the implementation of the Entity Component System (ECS) architecture.
entity-component-system/etc/entity-component-system.urm.puml New file containing a UML diagram illustrating the ECS architecture, showing the relationships between entities, components, and systems.
entity-component-system/pom.xml New file containing the project's dependencies and build configuration for the ECS implementation.
entity-component-system/src/main/java/com/iluwatar/App.java New file containing the main application class that demonstrates the ECS pattern by creating, updating, and interacting with entities and components.
entity-component-system/src/main/java/com/iluwatar/Component.java New file defining the Component abstract class, which represents a component in the ECS system. It includes methods for enabling/disabling components and updating them.
entity-component-system/src/main/java/com/iluwatar/Entity.java New file defining the Entity class, which represents an entity in the ECS system. It manages components, children entities, and provides methods for updating and enabling/disabling entities.
entity-component-system/src/main/java/com/iluwatar/GameSystem.java New file defining the GameSystem class, which manages entities, updates them, and provides methods for rendering and sorting entities by distance.
entity-component-system/src/main/java/com/iluwatar/HealthComponent.java New file defining the HealthComponent class, which represents a health component in the ECS system. It tracks current health, max health, and whether the entity is alive.
entity-component-system/src/main/java/com/iluwatar/TransformComponent.java New file defining the TransformComponent class, which handles the transformation (position, scale, rotation) of an entity in 3D space.
entity-component-system/src/main/java/com/iluwatar/VelocityComponent.java New file defining the VelocityComponent class, which manages the velocity of an entity in 3D space. It includes methods for applying forces and friction.
entity-component-system/src/test/java/com/iluwatar/AppTest.java New file containing unit tests for the main application class, verifying the functionality of entity creation, component addition, and state updates.
entity-component-system/src/test/java/com/iluwatar/ComponentTest.java New file containing unit tests for the Component class, verifying the functionality of setting and getting component names and enabling/disabling components.
entity-component-system/src/test/java/com/iluwatar/EntityTest.java New file containing unit tests for the Entity class, verifying the functionality of adding, removing, and retrieving components, as well as managing child entities and enabling/disabling entities.
entity-component-system/src/test/java/com/iluwatar/GameSystemTest.java New file containing unit tests for the GameSystem class, verifying the functionality of adding, removing, and managing entities within the system, including sorting by distance.
entity-component-system/src/test/java/com/iluwatar/HealthComponentTest.java New file containing unit tests for the HealthComponent class, verifying the functionality of applying damage, healing, and checking the entity's alive status.
entity-component-system/src/test/java/com/iluwatar/TransformComponentTest.java New file containing unit tests for the TransformComponent class, verifying the functionality of setting and getting position, rotation, and scale.
entity-component-system/src/test/java/com/iluwatar/VelocityComponentTest.java New file containing unit tests for the VelocityComponent class, verifying the functionality of applying forces, friction, and resetting velocity.
pom.xml The entity-component-system module was added to the project's modules list.
update-header.sh The header of the script was updated to include the MIT license information.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Review Summary

Commits Considered (10)
  • b6a3848: Merge branch 'master' into feature/485-ecs-pattern-implementation
  • f92c2a4: even more issues fixed
  • cada3be: fixing the last issues
  • b4c6a30: fixing more maintainability and intentionality issues
  • 80e42c3: Update HealthComponentTest.java
  • a9edc07: fixing maintainability, and intentionality issues
  • 38ef4a6: even more test cases
  • cd41e1a: Update EntityTest.java
  • 49cfb6b: adding test cases to all classes
  • 0bb2e90: implementing ECS pattern
Files Processed (19)
  • entity-component-system/README.md (0 hunks)
  • entity-component-system/etc/entity-component-system.urm.puml (1 hunk)
  • entity-component-system/pom.xml (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/App.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/Component.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/Entity.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/GameSystem.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/HealthComponent.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/TransformComponent.java (1 hunk)
  • entity-component-system/src/main/java/com/iluwatar/VelocityComponent.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/AppTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/ComponentTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/EntityTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/GameSystemTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/HealthComponentTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/TransformComponentTest.java (1 hunk)
  • entity-component-system/src/test/java/com/iluwatar/VelocityComponentTest.java (1 hunk)
  • pom.xml (1 hunk)
  • update-header.sh (1 hunk)
Actionable Comments (0)
Skipped Comments (0)

Copy link
Owner

@iluwatar iluwatar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, please update the README.md. It needs to have a very specific format described in https://github.com/iluwatar/java-design-patterns/wiki/01.-How-to-contribute. See the other patterns for examples.

Comment on lines +27 to +30
/**
* The main entry point for the application.
* This class simulates a game loop where entities are created, updated, and their states are modified.
*/
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, above the App class, please explain the pattern briefly and describe how the code example implements it.

Comment on lines +43 to +44
Entity entity1 = new Entity("Entity1");
Entity entity2 = new Entity("Entity2");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments where needed. Remember, this is learning material.

Comment on lines +34 to +35
private String name;
private boolean isEnabled;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Lombok to get rid of boilerplate code such as getters and setters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants