feat: create creature interface
This commit is contained in:
parent
b8b92b7cf8
commit
31febdd341
61
Client/Application/ViewModels/CreatureListViewModel.cs
Normal file
61
Client/Application/ViewModels/CreatureListViewModel.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public class CreatureListViewModel : NotifyPropertyChanged
|
||||
{
|
||||
public uint Id => creature.Id;
|
||||
|
||||
public string Name => creature.Name;
|
||||
|
||||
public string BriefInfo => creature.BriefInfo;
|
||||
|
||||
public float Distance => creature.Transform.Position.HorizontalDistance(hero.Transform.Position) / 100;
|
||||
|
||||
public float DeltaZ => (creature.Transform.Position.Z - hero.Transform.Position.Z) / 100;
|
||||
|
||||
public CreatureListViewModel(CreatureInterface creature, Hero hero)
|
||||
{
|
||||
creature.PropertyChanged += Creature_PropertyChanged;
|
||||
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||
|
||||
this.creature = creature;
|
||||
this.hero = hero;
|
||||
}
|
||||
|
||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void Position_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void Creature_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Name")
|
||||
{
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
if (e.PropertyName == "BriefInfo")
|
||||
{
|
||||
OnPropertyChanged("BriefInfo");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly CreatureInterface creature;
|
||||
private readonly Hero hero;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public interface CreatureListViewModelInterface
|
||||
{
|
||||
uint Id { get; }
|
||||
string Title { get; }
|
||||
string Info { get; }
|
||||
float Distance { get; }
|
||||
float DeltaZ { get; }
|
||||
}
|
||||
}
|
@ -23,8 +23,8 @@ namespace Client.Application.ViewModels
|
||||
MainViewModelInterface,
|
||||
EventHandlerInterface<HeroCreatedEvent>,
|
||||
EventHandlerInterface<HeroDeletedEvent>,
|
||||
EventHandlerInterface<NpcCreatedEvent>,
|
||||
EventHandlerInterface<NpcDeletedEvent>
|
||||
EventHandlerInterface<CreatureCreatedEvent>,
|
||||
EventHandlerInterface<CreatureDeletedEvent>
|
||||
{
|
||||
|
||||
public void AddChatMessage(ChatMessage chatMessage)
|
||||
@ -32,19 +32,6 @@ namespace Client.Application.ViewModels
|
||||
ChatMessages.Add(new ChatMessageViewModel(chatMessage));
|
||||
}
|
||||
|
||||
public void AddPlayer(Player player)
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Creatures.Add(new PlayerListViewModel(player, hero));
|
||||
}
|
||||
}
|
||||
|
||||
public void RemovePlayer(Player player)
|
||||
{
|
||||
Creatures.RemoveAll(x => x.Id == player.Id);
|
||||
}
|
||||
|
||||
public void AddDrop(Drop drop)
|
||||
{
|
||||
if (hero != null)
|
||||
@ -72,21 +59,21 @@ namespace Client.Application.ViewModels
|
||||
OnPropertyChanged("Hero");
|
||||
}
|
||||
|
||||
public void Handle(NpcCreatedEvent @event)
|
||||
public void Handle(CreatureCreatedEvent @event)
|
||||
{
|
||||
if (hero != null)
|
||||
{
|
||||
Creatures.Add(new NpcListViewModel(@event.NPC, hero));
|
||||
Creatures.Add(new CreatureListViewModel(@event.Creature, hero));
|
||||
}
|
||||
}
|
||||
|
||||
public void Handle(NpcDeletedEvent @event)
|
||||
public void Handle(CreatureDeletedEvent @event)
|
||||
{
|
||||
Creatures.RemoveAll(x => x.Id == @event.Id);
|
||||
}
|
||||
|
||||
public ObservableCollection<ChatMessageViewModel> ChatMessages { get; } = new ObservableCollection<ChatMessageViewModel>();
|
||||
public ObservableCollection<CreatureListViewModelInterface> Creatures { get; } = new ObservableCollection<CreatureListViewModelInterface>();
|
||||
public ObservableCollection<CreatureListViewModel> Creatures { get; } = new ObservableCollection<CreatureListViewModel>();
|
||||
public ObservableCollection<DropListViewModel> Drops { get; } = new ObservableCollection<DropListViewModel>();
|
||||
public HeroSummaryInfoViewModel? Hero { get; private set; }
|
||||
public Hero? hero;
|
||||
|
@ -1,110 +0,0 @@
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public class NpcListViewModel : NotifyPropertyChanged, CreatureListViewModelInterface
|
||||
{
|
||||
public uint Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return npc.Id;
|
||||
}
|
||||
}
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = "";
|
||||
|
||||
if (npc.IsDead())
|
||||
{
|
||||
result += "Dead ";
|
||||
}
|
||||
result += npc.FullName.Nickname + "[" + npc.NpcId + "]";
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = "Npc";
|
||||
|
||||
if (npc.IsHostile)
|
||||
{
|
||||
result = "Monster";
|
||||
if (npc.AggroRadius > 0)
|
||||
{
|
||||
result += "*";
|
||||
}
|
||||
}
|
||||
result += " " + npc.Level + "lvl";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public float Distance
|
||||
{
|
||||
get
|
||||
{
|
||||
return npc.Transform.Position.HorizontalDistance(hero.Transform.Position) / 100;
|
||||
}
|
||||
}
|
||||
public float DeltaZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return (npc.Transform.Position.Z - hero.Transform.Position.Z) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
public NpcListViewModel(NPC npc, Hero hero)
|
||||
{
|
||||
this.npc = npc;
|
||||
this.hero = hero;
|
||||
|
||||
npc.VitalStats.PropertyChanged += VitalStats_PropertyChanged;
|
||||
npc.FullName.PropertyChanged += FullName_PropertyChanged;
|
||||
npc.Transform.Position.PropertyChanged += NpcPosition_PropertyChanged;
|
||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||
}
|
||||
|
||||
private void NpcPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void FullName_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Nickname")
|
||||
{
|
||||
OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Hp" || e.PropertyName == "MaxHp")
|
||||
{
|
||||
OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly NPC npc;
|
||||
private readonly Hero hero;
|
||||
}
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public class PlayerListViewModel : NotifyPropertyChanged, CreatureListViewModelInterface
|
||||
{
|
||||
public uint Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return player.Id;
|
||||
}
|
||||
}
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return player.FullName.Nickname;
|
||||
}
|
||||
}
|
||||
public string Info
|
||||
{
|
||||
get
|
||||
{
|
||||
//todo race and class strings
|
||||
return player.Phenotype.Race.ToString() + ", " + player.Phenotype.Class.ToString();
|
||||
}
|
||||
}
|
||||
public float Distance
|
||||
{
|
||||
get
|
||||
{
|
||||
return player.Transform.Position.HorizontalDistance(hero.Transform.Position) / 100;
|
||||
}
|
||||
}
|
||||
public float DeltaZ
|
||||
{
|
||||
get
|
||||
{
|
||||
return (player.Transform.Position.Z - hero.Transform.Position.Z) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
public PlayerListViewModel(Player player, Hero hero)
|
||||
{
|
||||
this.player = player;
|
||||
this.hero = hero;
|
||||
|
||||
player.Phenotype.PropertyChanged += Phenotype_PropertyChanged;
|
||||
player.FullName.PropertyChanged += FullName_PropertyChanged;
|
||||
player.Transform.Position.PropertyChanged += PlayerPosition_PropertyChanged;
|
||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||
}
|
||||
|
||||
private void Phenotype_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Race" || e.PropertyName == "Class")
|
||||
{
|
||||
OnPropertyChanged("Info");
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayerPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged("Distance");
|
||||
OnPropertyChanged("DeltaZ");
|
||||
}
|
||||
|
||||
private void FullName_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Nickname")
|
||||
{
|
||||
OnPropertyChanged("Title");
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Player player;
|
||||
private readonly Hero hero;
|
||||
}
|
||||
}
|
@ -51,11 +51,11 @@
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Margin="5">
|
||||
<TextBlock FontSize="16" Text="{Binding Path=Title,Mode=OneWay}" />
|
||||
<TextBlock FontSize="16" Text="{Binding Path=Name,Mode=OneWay}" />
|
||||
<TextBlock FontSize="11">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding StringFormat="{}{0}; distance: {1:F2}m; delta z: {2:F2}m">
|
||||
<Binding Path="Info" Mode="OneWay"/>
|
||||
<Binding Path="BriefInfo" Mode="OneWay"/>
|
||||
<Binding Path="Distance" Mode="OneWay"/>
|
||||
<Binding Path="DeltaZ" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
|
@ -67,8 +67,8 @@ namespace Client
|
||||
var viewModel = serviceProvider.GetRequiredService<MainViewModelInterface>();
|
||||
eventBus.Subscrbe((EventHandlerInterface<HeroCreatedEvent>)viewModel);
|
||||
eventBus.Subscrbe((EventHandlerInterface<HeroDeletedEvent>)viewModel);
|
||||
eventBus.Subscrbe((EventHandlerInterface<NpcCreatedEvent>)viewModel);
|
||||
eventBus.Subscrbe((EventHandlerInterface<NpcDeletedEvent>)viewModel);
|
||||
eventBus.Subscrbe((EventHandlerInterface<CreatureCreatedEvent>)viewModel);
|
||||
eventBus.Subscrbe((EventHandlerInterface<CreatureDeletedEvent>)viewModel);
|
||||
}
|
||||
|
||||
private void OnMessage(string args)
|
||||
|
19
Client/Domain/Entities/CreatureInterface.cs
Normal file
19
Client/Domain/Entities/CreatureInterface.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Client.Domain.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public interface CreatureInterface : INotifyPropertyChanged
|
||||
{
|
||||
uint Id { get; set; }
|
||||
Transform Transform { get; set; }
|
||||
string Name { get; }
|
||||
string BriefInfo { get; }
|
||||
|
||||
}
|
||||
}
|
@ -10,17 +10,97 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public class NPC : NotifyPropertyChanged, EntityInterface
|
||||
public class NPC : NotifyPropertyChanged, EntityInterface, CreatureInterface
|
||||
{
|
||||
public uint Id { get; set; }
|
||||
public Transform Transform { get; set; }
|
||||
public bool IsHostile { get; set; }
|
||||
public uint NpcId { get; set; }
|
||||
public SpoilStateEnum SpoilState { get; set; }
|
||||
public FullName FullName { get; set; }
|
||||
public VitalStats VitalStats { get; set; }
|
||||
public uint Level { get => level; set { if (value != level) { level = value; OnPropertyChanged("Level"); } } }
|
||||
public uint AggroRadius { get => aggroRadius; set { if (value != aggroRadius) { aggroRadius = value; OnPropertyChanged("AggroRadius"); } } }
|
||||
public FullName FullName
|
||||
{
|
||||
get => fullName;
|
||||
set
|
||||
{
|
||||
fullName = value;
|
||||
if (fullName != null)
|
||||
{
|
||||
FullName.PropertyChanged += FullName_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
public VitalStats VitalStats
|
||||
{
|
||||
get => vitalStats;
|
||||
set
|
||||
{
|
||||
vitalStats = value;
|
||||
if (vitalStats != null)
|
||||
{
|
||||
VitalStats.PropertyChanged += VitalStats_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
public uint Level
|
||||
{
|
||||
get => level;
|
||||
set
|
||||
{
|
||||
if (value != level)
|
||||
{
|
||||
level = value;
|
||||
OnPropertyChanged("Level");
|
||||
OnPropertyChanged("BriefInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
public uint AggroRadius
|
||||
{
|
||||
get => aggroRadius;
|
||||
set
|
||||
{
|
||||
if (value != aggroRadius)
|
||||
{
|
||||
aggroRadius = value;
|
||||
OnPropertyChanged("AggroRadius");
|
||||
OnPropertyChanged("BriefInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = "";
|
||||
|
||||
if (IsDead())
|
||||
{
|
||||
result += "Dead ";
|
||||
}
|
||||
result += FullName.Nickname + "[" + NpcId + "]";
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public string BriefInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
string result = "Npc";
|
||||
|
||||
if (IsHostile)
|
||||
{
|
||||
result = "Monster";
|
||||
if (AggroRadius > 0)
|
||||
{
|
||||
result += "*";
|
||||
}
|
||||
}
|
||||
result += " " + Level + "lvl";
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public NPC(uint id, Transform transform, bool isHostile, uint npcId, SpoilStateEnum spoilState, FullName fullName, VitalStats vitalStats)
|
||||
{
|
||||
@ -33,6 +113,22 @@ namespace Client.Domain.Entities
|
||||
VitalStats = vitalStats;
|
||||
}
|
||||
|
||||
private void FullName_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Nickname")
|
||||
{
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Hp" || e.PropertyName == "MaxHp")
|
||||
{
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDead()
|
||||
{
|
||||
return VitalStats.MaxHp > 0 && VitalStats.Hp <= 0;
|
||||
@ -40,5 +136,7 @@ namespace Client.Domain.Entities
|
||||
|
||||
private uint level;
|
||||
private uint aggroRadius;
|
||||
private VitalStats vitalStats;
|
||||
private FullName fullName;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,62 @@
|
||||
using Client.Domain.Enums;
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Enums;
|
||||
using Client.Domain.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public class Player : EntityInterface
|
||||
public class Player : NotifyPropertyChanged, EntityInterface, CreatureInterface
|
||||
{
|
||||
private FullName fullName;
|
||||
private Phenotype phenotype;
|
||||
|
||||
public uint Id { get; set; }
|
||||
public Transform Transform { get; set; }
|
||||
public FullName FullName { get; set; }
|
||||
public Phenotype Phenotype { get; set; }
|
||||
public FullName FullName
|
||||
{
|
||||
get => fullName;
|
||||
set
|
||||
{
|
||||
fullName = value;
|
||||
if (fullName != null)
|
||||
{
|
||||
FullName.PropertyChanged += FullName_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Phenotype Phenotype
|
||||
{
|
||||
get => phenotype;
|
||||
set
|
||||
{
|
||||
phenotype = value;
|
||||
if (phenotype != null)
|
||||
{
|
||||
Phenotype.PropertyChanged += Phenotype_PropertyChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return FullName.Nickname;
|
||||
}
|
||||
}
|
||||
public string BriefInfo
|
||||
{
|
||||
get
|
||||
{
|
||||
//todo race and class strings
|
||||
return Phenotype.Race.ToString() + ", " + Phenotype.Class.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public Player(uint id, Transform transform, FullName fullName, Phenotype phenotype)
|
||||
{
|
||||
@ -22,5 +65,21 @@ namespace Client.Domain.Entities
|
||||
FullName = fullName;
|
||||
Phenotype = phenotype;
|
||||
}
|
||||
|
||||
private void Phenotype_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Race" || e.PropertyName == "Class")
|
||||
{
|
||||
OnPropertyChanged("BriefInfo");
|
||||
}
|
||||
}
|
||||
|
||||
private void FullName_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Nickname")
|
||||
{
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class NpcCreatedEvent : EventInterface
|
||||
public class CreatureCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly NPC NPC;
|
||||
public readonly CreatureInterface Creature;
|
||||
|
||||
public NpcCreatedEvent(NPC npc)
|
||||
public CreatureCreatedEvent(CreatureInterface creature)
|
||||
{
|
||||
NPC = npc;
|
||||
Creature = creature;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Events
|
||||
{
|
||||
public class NpcDeletedEvent : EventInterface
|
||||
public class CreatureDeletedEvent : EventInterface
|
||||
{
|
||||
public readonly uint Id;
|
||||
|
||||
public NpcDeletedEvent(uint id)
|
||||
public CreatureDeletedEvent(uint id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
@ -9,18 +9,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Service
|
||||
{
|
||||
public class PlayerHandler : EntityHandler<Player>
|
||||
public class DropHandler : EntityHandler<Drop>
|
||||
{
|
||||
public override void OnCreate(Player entity)
|
||||
public override void OnCreate(Drop entity)
|
||||
{
|
||||
mainViewModel.AddPlayer(entity);
|
||||
mainViewModel.AddDrop(entity);
|
||||
}
|
||||
public override void OnDelete(Player entity)
|
||||
public override void OnDelete(Drop entity)
|
||||
{
|
||||
mainViewModel.RemovePlayer(entity);
|
||||
mainViewModel.RemoveDrop(entity);
|
||||
}
|
||||
|
||||
public PlayerHandler(EntityFactoryInterface<Player> factory, MainViewModelInterface mainViewModel) : base(factory)
|
||||
public DropHandler(EntityFactoryInterface<Drop> factory, MainViewModelInterface mainViewModel) : base(factory)
|
||||
{
|
||||
this.mainViewModel = mainViewModel;
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ namespace Client.Domain.Service
|
||||
{
|
||||
entity.Level = npcInfoHelper.GetLevel(entity.NpcId);
|
||||
entity.AggroRadius = npcInfoHelper.GetAggroRadius(entity.NpcId);
|
||||
eventBus.Publish(new NpcCreatedEvent(entity));
|
||||
eventBus.Publish(new CreatureCreatedEvent(entity));
|
||||
}
|
||||
public override void OnDelete(NPC entity)
|
||||
{
|
||||
eventBus.Publish(new NpcDeletedEvent(entity.Id));
|
||||
eventBus.Publish(new CreatureDeletedEvent(entity.Id));
|
||||
}
|
||||
|
||||
public NpcHandler(EntityFactoryInterface<NPC> factory, EventBusInterface eventBus, NpcInfoHelperInterface npcInfoHelper) : base(factory)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using Client.Domain.ViewModels;
|
||||
using System;
|
||||
@ -9,22 +10,22 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Service
|
||||
{
|
||||
public class DropHandler : EntityHandler<Drop>
|
||||
public class PlayerHandler : EntityHandler<Player>
|
||||
{
|
||||
public override void OnCreate(Drop entity)
|
||||
public override void OnCreate(Player entity)
|
||||
{
|
||||
mainViewModel.AddDrop(entity);
|
||||
eventBus.Publish(new CreatureCreatedEvent(entity));
|
||||
}
|
||||
public override void OnDelete(Drop entity)
|
||||
public override void OnDelete(Player entity)
|
||||
{
|
||||
mainViewModel.RemoveDrop(entity);
|
||||
eventBus.Publish(new CreatureDeletedEvent(entity.Id));
|
||||
}
|
||||
|
||||
public DropHandler(EntityFactoryInterface<Drop> factory, MainViewModelInterface mainViewModel) : base(factory)
|
||||
public PlayerHandler(EntityFactoryInterface<Player> factory, EventBusInterface eventBus) : base(factory)
|
||||
{
|
||||
this.mainViewModel = mainViewModel;
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
private readonly MainViewModelInterface mainViewModel;
|
||||
private readonly EventBusInterface eventBus;
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ namespace Client.Domain.ViewModels
|
||||
public interface MainViewModelInterface
|
||||
{
|
||||
void AddChatMessage(ChatMessage chatMessage);
|
||||
void AddPlayer(Player player);
|
||||
void RemovePlayer(Player player);
|
||||
void AddDrop(Drop drop);
|
||||
void RemoveDrop(Drop drop);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user