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

Minor Refactoring and Add EntityFactory #38

Merged
merged 7 commits into from Mar 28, 2024
Merged

Conversation

HoJunHao2000
Copy link
Contributor

@HoJunHao2000 HoJunHao2000 commented Mar 27, 2024

Resolves #32

Changes made

  1. Minor refactoring throughout
  2. Remove unnecessary functions in EventModifiable
  3. Created EntityFactory and EntityBuilder to create and add components into game instead of manual creation and insertion

@HoJunHao2000 HoJunHao2000 requested review from ruihan00, Junyi00 and jasonqiu212 and removed request for ruihan00 and Junyi00 March 27, 2024 14:51

import Foundation

struct EntityFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs some discussion, but I was thinking if we should use a Builder Pattern here to create the entities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Builder pattern sounds good. Incorporated it.

But i think we should still have the factory pattern. The whole idea is that we don't want users to forget to add components into the game. Builder pattern still requires player to manually add the components.

Now when you call the factory, it will instantiate an EntityBuilder to create the components of the entity.

Copy link
Contributor

@jasonqiu212 jasonqiu212 left a comment

Choose a reason for hiding this comment

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

LGTM :)

@HoJunHao2000 HoJunHao2000 merged commit 4d838ad into main Mar 28, 2024
1 check passed
@HoJunHao2000 HoJunHao2000 deleted the entity-component-factory branch March 28, 2024 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Factory method for entity and components during initialisation
2 participants