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

Refactor update event and added state move #13

Merged
merged 3 commits into from
Nov 12, 2024
Merged

Refactor update event and added state move #13

merged 3 commits into from
Nov 12, 2024

Conversation

kelindar
Copy link
Owner

This pull request changes the tile update event structure, as it also adds an ability to Move() a state of a tile from one to another via a new Move() method on a Tile[T] itself. This moves the state and notifies observers correctly (and only once) by dispatching an event with both New and Old tiles set, their location, and the state which was added/deleted. To accomplish this I needed to refactor a bunch of stuff as well.

Enhancements to Observer Notification System:

  • Introduced UpdateState struct to encapsulate the state of a tile before and after an update. (view.go)
  • Modified pubsub to include Notify1 and Notify2 methods for handling notifications for single and multiple observers respectively. (view.go) [1] [2]

Improvements to Tile Update Mechanics:

  • Refactored writeTile, mergeTile, addObject, and delObject methods to use UpdateState for more granular update notifications. (grid.go) [1] [2]
  • Added Move method to Tile struct to handle moving objects between tiles and notify observers accordingly. (grid.go)

@kelindar kelindar merged commit 79fd55f into master Nov 12, 2024
2 checks passed
@kelindar kelindar deleted the move branch November 12, 2024 18:24
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.

1 participant