feat: add events for drop and chat message
This commit is contained in:
@@ -109,8 +109,8 @@ namespace Client.Domain.Entities
|
||||
IsHostile = isHostile;
|
||||
NpcId = npcId;
|
||||
SpoilState = spoilState;
|
||||
FullName = fullName;
|
||||
VitalStats = vitalStats;
|
||||
this.fullName = FullName = fullName;
|
||||
this.vitalStats = VitalStats = vitalStats;
|
||||
}
|
||||
|
||||
private void FullName_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
|
@@ -62,8 +62,8 @@ namespace Client.Domain.Entities
|
||||
{
|
||||
Id = id;
|
||||
Transform = transform;
|
||||
FullName = fullName;
|
||||
Phenotype = phenotype;
|
||||
this.fullName = FullName = fullName;
|
||||
this.phenotype = Phenotype = phenotype;
|
||||
}
|
||||
|
||||
private void Phenotype_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
|
20
Client/Domain/Events/ChatMessageCreatedEvent.cs
Normal file
20
Client/Domain/Events/ChatMessageCreatedEvent.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class ChatMessageCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly ChatMessage Message;
|
||||
|
||||
public ChatMessageCreatedEvent(ChatMessage message)
|
||||
{
|
||||
Message = message;
|
||||
}
|
||||
}
|
||||
}
|
19
Client/Domain/Events/DropCreatedEvent.cs
Normal file
19
Client/Domain/Events/DropCreatedEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class DropCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly Drop Drop;
|
||||
|
||||
public DropCreatedEvent(Drop drop)
|
||||
{
|
||||
Drop = drop;
|
||||
}
|
||||
}
|
||||
}
|
19
Client/Domain/Events/DropDeletedEvent.cs
Normal file
19
Client/Domain/Events/DropDeletedEvent.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class DropDeletedEvent : EventInterface
|
||||
{
|
||||
public readonly uint Id;
|
||||
|
||||
public DropDeletedEvent(uint id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,9 +6,9 @@ using System.Threading.Tasks;
|
||||
using Client.Domain.DTO;
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Enums;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.ValueObjects;
|
||||
using Client.Domain.ViewModels;
|
||||
|
||||
namespace Client.Domain.Service
|
||||
{
|
||||
@@ -23,19 +23,17 @@ namespace Client.Domain.Service
|
||||
{
|
||||
throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
messages.Add(message);
|
||||
mainViewModel.AddChatMessage(message);
|
||||
eventBus.Publish(new ChatMessageCreatedEvent(message));
|
||||
}
|
||||
}
|
||||
|
||||
public ChatMessageHandler(EntityFactoryInterface<ChatMessage> factory, MainViewModelInterface mainViewModel)
|
||||
public ChatMessageHandler(EntityFactoryInterface<ChatMessage> factory, EventBusInterface eventBus)
|
||||
{
|
||||
this.factory = factory;
|
||||
this.mainViewModel = mainViewModel;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
private readonly EntityFactoryInterface<ChatMessage> factory;
|
||||
private readonly MainViewModelInterface mainViewModel;
|
||||
private List<ChatMessage> messages = new List<ChatMessage>();
|
||||
private readonly EventBusInterface eventBus;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -13,18 +13,18 @@ namespace Client.Domain.Service
|
||||
{
|
||||
public override void OnCreate(Drop entity)
|
||||
{
|
||||
mainViewModel.AddDrop(entity);
|
||||
eventBus.Publish(new DropCreatedEvent(entity));
|
||||
}
|
||||
public override void OnDelete(Drop entity)
|
||||
{
|
||||
mainViewModel.RemoveDrop(entity);
|
||||
eventBus.Publish(new DropDeletedEvent(entity.Id));
|
||||
}
|
||||
|
||||
public DropHandler(EntityFactoryInterface<Drop> factory, MainViewModelInterface mainViewModel) : base(factory)
|
||||
public DropHandler(EntityFactoryInterface<Drop> factory, EventBusInterface eventBus) : base(factory)
|
||||
{
|
||||
this.mainViewModel = mainViewModel;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
private readonly MainViewModelInterface mainViewModel;
|
||||
private readonly EventBusInterface eventBus;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.Helpers;
|
||||
using Client.Domain.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@@ -2,7 +2,6 @@
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.Helpers;
|
||||
using Client.Domain.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@@ -1,18 +0,0 @@
|
||||
using Client.Application.ViewModels;
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.ViewModels
|
||||
{
|
||||
public interface MainViewModelInterface
|
||||
{
|
||||
void AddChatMessage(ChatMessage chatMessage);
|
||||
void AddDrop(Drop drop);
|
||||
void RemoveDrop(Drop drop);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user