Skip to content

Commit 73496f6

Browse files
Merge pull request #21 from CoderGamester/develop
Release 0.13.0
2 parents f43d4ab + 900638f commit 73496f6

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [0.13.0] - 2024-11-04
8+
9+
**Changed**:
10+
- Changed *CommandService* to now receive the *MessageBrokerService* in the command and help communication with the game architecture
11+
712
## [0.12.2] - 2024-11-02
813

914
**Fixed**:

Runtime/CommandService.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,22 @@ namespace GameLovers.Services
66
/// Tags the interface as a <see cref="IGameCommand{TGameLogic}"/>
77
/// </summary>
88
public interface IGameCommandBase {}
9-
9+
10+
/// <summary>
11+
/// Contract for the command to be executed in the <see cref="ICommandService{TGameLogic}"/>.
12+
/// Implement this interface if you want logic to be executed ont he server
13+
/// </summary>
14+
/// <remarks>
15+
/// Follows the Command pattern <see cref="https://en.wikipedia.org/wiki/Command_pattern"/>
16+
/// </remarks>
17+
public interface IGameServerCommand<in TGameLogic> : IGameCommandBase where TGameLogic : class
18+
{
19+
/// <summary>
20+
/// Executes the command logic defined by the implemention of this interface
21+
/// </summary>
22+
void ExecuteLogic(TGameLogic gameLogic);
23+
}
24+
1025
/// <summary>
1126
/// Interface representing the command to be executed in the <see cref="ICommandService{TGameLogic}"/>.
1227
/// Implement this interface with the proper command logic
@@ -19,7 +34,7 @@ public interface IGameCommand<in TGameLogic> : IGameCommandBase where TGameLogic
1934
/// <summary>
2035
/// Executes the command logic defined by the implemention of this interface
2136
/// </summary>
22-
void Execute(TGameLogic gameLogic);
37+
void Execute(TGameLogic gameLogic, IMessageBrokerService messageBroker);
2338
}
2439

2540
/// <summary>
@@ -42,16 +57,18 @@ public interface ICommandService<out TGameLogic> where TGameLogic : class
4257
public class CommandService<TGameLogic> : ICommandService<TGameLogic> where TGameLogic : class
4358
{
4459
private readonly TGameLogic _gameLogic;
45-
46-
public CommandService(TGameLogic gameLogic)
60+
private readonly IMessageBrokerService _messageBroker;
61+
62+
public CommandService(TGameLogic gameLogic, IMessageBrokerService messageBroker)
4763
{
4864
_gameLogic = gameLogic;
65+
_messageBroker = messageBroker;
4966
}
50-
67+
5168
/// <inheritdoc />
5269
public void ExecuteCommand<TCommand>(TCommand command) where TCommand : IGameCommand<TGameLogic>
5370
{
54-
command.Execute(_gameLogic);
71+
command.Execute(_gameLogic, _messageBroker);
5572
}
5673
}
5774
}

Tests/Editor/EditMode/CommandServiceTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private struct CommandMockup : IGameCommand<IGameLogicMockup>
2222
{
2323
public int Payload;
2424

25-
public void Execute(IGameLogicMockup gameLogic)
25+
public void Execute(IGameLogicMockup gameLogic, IMessageBrokerService messageBroker)
2626
{
2727
gameLogic.CallMockup(Payload);
2828
}
@@ -32,7 +32,7 @@ public void Execute(IGameLogicMockup gameLogic)
3232
public void Init()
3333
{
3434
_gameLogicMockup = Substitute.For<IGameLogicMockup>();
35-
_commandService = new CommandService<IGameLogicMockup>(_gameLogicMockup);
35+
_commandService = new CommandService<IGameLogicMockup>(_gameLogicMockup, Substitute.For<IMessageBrokerService>());
3636
}
3737

3838
[Test]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.gamelovers.services",
33
"displayName": "Services",
44
"author": "Miguel Tomas",
5-
"version": "0.12.2",
5+
"version": "0.13.0",
66
"unity": "2022.3",
77
"license": "MIT",
88
"description": "The purpose of this package is to provide a set of services to ease the development of a basic game architecture",

0 commit comments

Comments
 (0)