Skip to content

Conversation

@DzmitryKharko
Copy link
Collaborator

WHAT Create sample for ControllersTree package

{
await UniTask.Yield();
if (cancellationToken.IsCancellationRequested)
{

Choose a reason for hiding this comment

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

Consider throwing an operation cancelled exception simply passing CT into yield

/// RootLifetimeScope sets up the DI container for the game application, configuring essential components such as
/// the entry point (Bootstrap), controllers, and services. This setup ensures efficient dependency management and lifecycle handling during gameplay.
/// </summary>
public class RootLifetimeScope : LifetimeScope

Choose a reason for hiding this comment

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

Consider not to use LifetimeScope cause it's tied to unity engine lifecycle. Try to keep control code centric.

Choose a reason for hiding this comment

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

protected override async UniTask OnFlowAsync(CancellationToken cancellationToken)
{
_view = await _factory.CreateAsync(_data.ResourceId, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();

Choose a reason for hiding this comment

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

you can safely remove all cancellationToken.ThrowIfCancellationRequested(), cause asynchronous operations you're using will throw an exception anyway

/// Upon creation, each board is positioned randomly within a specified range and visually represented using asset
/// data obtained from FruitVisualisationProvider.
/// </summary>
public class FruitBoardFactory

Choose a reason for hiding this comment

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

Seems we need IFruitBoardFactory interface to follow Dependency inversion principle

{
private const string ShowAnimationName = "AfterLevelScreen_Show";

public Button RestartButton => _restartButton;

Choose a reason for hiding this comment

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

Controllers will be cleaner if we won't expose buttons and other ui components. We can expose button clicked event instead of button

/// <summary>
/// AfterLevelScreenView is a MonoBehaviour, manages the view component displayed after completing a game level.
/// </summary>
public class AfterLevelScreenView : MonoBehaviour

Choose a reason for hiding this comment

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

Do we need interfaces for views? If we need to test controllers, then yes


protected override async UniTask OnFlowAsync(CancellationToken cancellationToken)
{
var prefab = await _resourcesProvider.LoadAsync<AfterLevelScreenView>("AfterLevelScreen", cancellationToken);

Choose a reason for hiding this comment

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

Should we move the view creation flow to some factory?


private async UniTask FlowAsync()
{
while (!CancellationToken.IsCancellationRequested)

Choose a reason for hiding this comment

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

Better to pass a cancellation token as a parameter


public async UniTask InitializeAsync(CancellationToken cancellationToken)
{
GameConfiguration = await _resourcesProvider.LoadAsync<GameConfiguration>("GameConfiguration", cancellationToken);

Choose a reason for hiding this comment

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

Is the model a domain model? Seems it should not access _resourcesProvider. It is better to load the game configuration outside of the model (Controller) and pass it as a parameter

private readonly ResourcesProvider _resourcesProvider;
private readonly IGameEventsRequestsModel _eventRequestsModel;

private FruitData[] _fruitsCollected;

Choose a reason for hiding this comment

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

Minor. _fruitsCollected is a good name for event. For field _collectedFruits will be better

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.

4 participants