Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.10.0] - 2024-10-11

- Updated CommandService to allow non struct type commands to be executed for reference type commands
- Added Spawn<T>(T data) method to pool object to allow spawning new objects with defined spawning data

## [0.9.0] - 2024-08-10

- Updated interfaces and classes related to data services, enhancing modularity and improving version handling.
Expand Down
13 changes: 8 additions & 5 deletions Runtime/CommandService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface IGameCommandBase {}
public interface IGameCommand<in TGameLogic> : IGameCommandBase where TGameLogic : class
{
/// <summary>
/// Executes the command logic
/// Executes the command logic defined by the implemention of this interface
/// </summary>
void Execute(TGameLogic gameLogic);

Choose a reason for hiding this comment

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

Image description CodeRabbit

The comment for the Execute method in the IGameCommand interface has a typo. It should be "implementation" instead of "implemention".

- 		/// Executes the command logic defined by the implemention of this interface
+ 		/// Executes the command logic defined by the implementation of this interface

}
Expand All @@ -29,10 +29,13 @@ public interface IGameCommand<in TGameLogic> : IGameCommandBase where TGameLogic
public interface ICommandService<out TGameLogic> where TGameLogic : class
{
/// <summary>
/// Executes the given <paramref name="command"/>.
/// The command execution is done atomically
/// Executes the given <paramref name="command"/>
/// </summary>
void ExecuteCommand<TCommand>(TCommand command) where TCommand : struct, IGameCommand<TGameLogic>;
/// <remarks>
/// IMPORTANT: Defines the <paramref name="command"/> as a class object if logic execution is asynchronous.
/// Define as a struct if togic logic execution is non waitable.
/// </remarks>
Comment on lines +32 to +37

Choose a reason for hiding this comment

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

Image description CodeRabbit

The comment in the ICommandService interface has some incorrect information. It mentions defining the command as a class object if logic execution is asynchronous and as a struct if logic execution is non-waitable. However, the type constraint on TCommand already specifies that it must implement the IGameCommand<TGameLogic> interface, which means it can be either a class or a struct. The comment can be simplified to remove this unnecessary information.

- 		/// Executes the given <paramref name="command"/>
- 		/// <remarks>
- 		/// IMPORTANT: Defines the <paramref name="command"/> as a class object if logic execution is asynchronous.
- 		/// Define as a struct if togic logic execution is non waitable.
- 		/// </remarks>
+ 		/// Executes the given <paramref name="command"/>.

void ExecuteCommand<TCommand>(TCommand command) where TCommand : IGameCommand<TGameLogic>;
}

/// <inheritdoc />
Expand All @@ -46,7 +49,7 @@ public CommandService(TGameLogic gameLogic)
}

/// <inheritdoc />
public void ExecuteCommand<TCommand>(TCommand command) where TCommand : struct, IGameCommand<TGameLogic>
public void ExecuteCommand<TCommand>(TCommand command) where TCommand : IGameCommand<TGameLogic>

Choose a reason for hiding this comment

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

Image description CodeRabbit

The type constraint on the ExecuteCommand method in the ICommandService interface should include the struct constraint for TCommand since the previous version of the code had it. This ensures that only struct types that implement IGameCommand<TGameLogic> can be used as arguments for the method.

- 		public void ExecuteCommand<TCommand>(TCommand command) where TCommand : IGameCommand<TGameLogic>
+ 		public void ExecuteCommand<TCommand>(TCommand command) where TCommand : struct, IGameCommand<TGameLogic>

{
command.Execute(_gameLogic);
}
Expand Down
Loading