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

feat(grid): Refactor grid to use GridComponent + AActor instead of AGridItem #1

Merged
merged 8 commits into from
Jan 17, 2025

Conversation

finger563
Copy link
Member

@finger563 finger563 commented Jan 16, 2025

Description

  • Add GridComponent class which is the required functionality from AGridItem refactored into an ActorComponent instead of an Actor
  • Replace grid item storage with AActor* instead of AGridItem - allowing any arbitrary actor class to be stored in the grid
  • Update implementation of how item management is handled in the grid

Motivation and Context

As we're expanding the systems in the game, we need to be able to customize our classes and actors better to interface to our various Grid, Growth, Interaction, Inventory, and other subsystems well.

Previously anything that could be placed into the grid must be a subclass of AGridItem, which meant that if we wanted to ensure some consistency between item types (some which can be in the grid and some which can't) we'd have to duplicate some actor level code for no real reason.

This PR makes it so that any actor class can be placed into the grid, as long as it has a GridComponent within it, which defines how the actor will interface to the grid (providing the functions and grid related data storage).

This means for instance that a mushroom or a moss can be blueprint actor type which simply contains

  • GridComponent
  • GrowthComponent
  • InteractionComponent

And may implement any arbitrary interfaces without needing to have a parent hierarchy that includes GridManager classes.

This has a few benefits, the least of which is that the actor classes can now more easily and more generically have code which pulls in their various attributes from the various datatables in a nice and data-driven manner.

Finally, this means that we can more easily separate types of items and the code required for them while keeping the inheritance tree / class hierarchy fairly simple.

I will add some documentation to the docs folder as this is finished which will provide documentation around the new way to create items and define their attributes.

How has this been tested?

  • Compiling the code
  • Updating the blueprints and running in editor

Screenshots (if appropriate):

image
Growth shown after some time:
image

Multi-cell items:
image
Which also grow after some time:
image

And which also work on a slope:
image

Rotation works:

grid-rotation-test.mp4

And on a slope:

grid-rotation-slope-test.mp4

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • New Art / Asset
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Art / Asset Update
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

…ridItem

* Add GridComponent class which is the required functionality from AGridItem refactored into an ActorComponent instead of an Actor
* Replace grid item storage with AActor* instead of AGridItem - allowing any arbitrary actor class to be stored in the grid
* Update implementation of how item management is handled in the grid
@finger563 finger563 merged commit b508602 into main Jan 17, 2025
@finger563 finger563 deleted the feat/grid-component-refactor branch January 24, 2025 05:55
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.

1 participant