feat: add skills
This commit is contained in:
@@ -7,11 +7,6 @@ namespace Client.Domain.Entities
|
||||
{
|
||||
public class Hero : ObservableObject, EntityInterface, CreatureInterface
|
||||
{
|
||||
private FullName fullName;
|
||||
private Phenotype phenotype;
|
||||
private CreatureInterface? target;
|
||||
private uint targetId;
|
||||
|
||||
public uint Id { get; set; }
|
||||
public Transform Transform { get; set; }
|
||||
public VitalStats VitalStats { get; set; }
|
||||
@@ -96,5 +91,10 @@ namespace Client.Domain.Entities
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private FullName fullName;
|
||||
private Phenotype phenotype;
|
||||
private CreatureInterface? target;
|
||||
private uint targetId;
|
||||
}
|
||||
}
|
||||
|
52
Client/Domain/Entities/Skill.cs
Normal file
52
Client/Domain/Entities/Skill.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Client.Domain.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Entities
|
||||
{
|
||||
public class Skill : ObservableObject, EntityInterface
|
||||
{
|
||||
public uint Id { get; set; }
|
||||
public uint Level { get => level; set { if (value != level) { level = value; OnPropertyChanged(); } } }
|
||||
public bool IsActive { get; set; }
|
||||
public uint Cost { get => cost; set { if (value != cost) { cost = value; OnPropertyChanged(); } } }
|
||||
public int Range { get => range; set { if (value != range) { range = value; OnPropertyChanged(); } } }
|
||||
public string Name { get => name; set { if (value != name) { name = value; OnPropertyChanged(); } } }
|
||||
public string Description { get => description; set { if (value != description) { description = value; OnPropertyChanged(); } } }
|
||||
public string IconName { get => iconName; set { if (value != iconName) { iconName = value; OnPropertyChanged(); } } }
|
||||
public bool IsToggled { get => isToggled; set { if (value != isToggled) { isToggled = value; OnPropertyChanged(); } } }
|
||||
public bool IsCasting { get => isCasting; set { if (value != isCasting) { isCasting = value; OnPropertyChanged(); } } }
|
||||
public bool IsReloading { get => isReloading; set { if (value != isReloading) { isReloading = value; OnPropertyChanged(); } } }
|
||||
public bool IsReadyToUse { get => isReadyToUse; set { if (value != isReadyToUse) { isReadyToUse = value; OnPropertyChanged(); } } }
|
||||
|
||||
public Skill(uint id, uint level, bool isActive, uint cost, int range, string name, string description, string iconName, bool isToggled, bool isCasting, bool isReloading, bool isReadyToUse)
|
||||
{
|
||||
Id = id;
|
||||
this.level = level;
|
||||
IsActive = isActive;
|
||||
this.cost = cost;
|
||||
this.range = range;
|
||||
Name = name;
|
||||
this.description = description;
|
||||
IconName = iconName;
|
||||
this.isToggled = isToggled;
|
||||
this.isCasting = isCasting;
|
||||
this.isReloading = isReloading;
|
||||
this.isReadyToUse = isReadyToUse;
|
||||
}
|
||||
|
||||
private string description;
|
||||
private uint cost;
|
||||
private int range;
|
||||
private bool isToggled;
|
||||
private bool isCasting;
|
||||
private bool isReloading;
|
||||
private bool isReadyToUse;
|
||||
private uint level;
|
||||
private string name;
|
||||
private string iconName;
|
||||
}
|
||||
}
|
20
Client/Domain/Events/SkillCreatedEvent.cs
Normal file
20
Client/Domain/Events/SkillCreatedEvent.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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 SkillCreatedEvent : EventInterface
|
||||
{
|
||||
public readonly Skill Skill;
|
||||
|
||||
public SkillCreatedEvent(Skill skill)
|
||||
{
|
||||
Skill = skill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
Client/Domain/Events/SkillDeletedEvent.cs
Normal file
19
Client/Domain/Events/SkillDeletedEvent.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 SkillDeletedEvent : EventInterface
|
||||
{
|
||||
public readonly uint Id;
|
||||
|
||||
public SkillDeletedEvent(uint id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
}
|
@@ -45,8 +45,7 @@ namespace Client.Domain.Service
|
||||
|
||||
public T? GetEntity(uint id)
|
||||
{
|
||||
T? result = null;
|
||||
|
||||
T? result;
|
||||
entities.TryGetValue(id, out result);
|
||||
|
||||
return result;
|
||||
|
30
Client/Domain/Service/SkillHandler.cs
Normal file
30
Client/Domain/Service/SkillHandler.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.Events;
|
||||
using Client.Domain.Factories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Domain.Service
|
||||
{
|
||||
public class SkillHandler : EntityHandler<Skill>
|
||||
{
|
||||
public override void OnCreate(Skill entity)
|
||||
{
|
||||
eventBus.Publish(new SkillCreatedEvent(entity));
|
||||
}
|
||||
public override void OnDelete(Skill entity)
|
||||
{
|
||||
eventBus.Publish(new SkillDeletedEvent(entity.Id));
|
||||
}
|
||||
|
||||
public SkillHandler(EntityFactoryInterface<Skill> factory, EventBusInterface eventBus) : base(factory)
|
||||
{
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
private readonly EventBusInterface eventBus;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user