-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored some handlers and added comments to classes/methods.
- Loading branch information
Showing
24 changed files
with
204 additions
and
194 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
source/Coop.Core/Client/Services/Kingdoms/ClientKingdomHandler.cs
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
source/Coop.Core/Client/Services/Kingdoms/Handlers/ClientKingdomDecisionHandler.cs
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
source/Coop.Core/Client/Services/Kingdoms/Handlers/ClientKingdomHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Common.Messaging; | ||
using Common.Network; | ||
using Coop.Core.Server.Services.Kingdoms.Messages; | ||
using GameInterface.Services.Kingdoms.Messages; | ||
|
||
namespace Coop.Core.Client.Services.Kingdoms.Handlers; | ||
|
||
/// <summary> | ||
/// Client side handler for Kingdom internal and network messages | ||
/// </summary> | ||
public class ClientKingdomHandler : IHandler | ||
{ | ||
|
||
private readonly IMessageBroker messageBroker; | ||
private readonly INetwork network; | ||
|
||
public ClientKingdomHandler(IMessageBroker messageBroker, INetwork network) | ||
{ | ||
this.messageBroker = messageBroker; | ||
this.network = network; | ||
messageBroker.Subscribe<NetworkAddDecision>(HandleNetworkAddDecision); | ||
messageBroker.Subscribe<NetworkRemoveDecision>(HandleNetworkRemoveDecision); | ||
} | ||
|
||
private void HandleNetworkRemoveDecision(MessagePayload<NetworkRemoveDecision> obj) | ||
{ | ||
var payload = obj.What; | ||
var message = new RemoveDecision(payload.KingdomId, payload.Index); | ||
messageBroker.Publish(this, message); | ||
} | ||
|
||
private void HandleNetworkAddDecision(MessagePayload<NetworkAddDecision> obj) | ||
{ | ||
var payload = obj.What; | ||
var message = new AddDecision(payload.KingdomId, payload.Data, payload.IgnoreInfluenceCost); | ||
messageBroker.Publish(this, message); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
messageBroker.Unsubscribe<NetworkAddDecision>(HandleNetworkAddDecision); | ||
messageBroker.Unsubscribe<NetworkRemoveDecision>(HandleNetworkRemoveDecision); | ||
} | ||
} | ||
|
||
|
42 changes: 0 additions & 42 deletions
42
source/Coop.Core/Server/Services/Kingdoms/Handlers/ServerKingdomDecisionHandler.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.