feat: add npc info (level and aggro radius)

This commit is contained in:
k0t9i
2023-01-31 00:32:26 +04:00
parent a8734a4ca0
commit 89cec4f40f
11 changed files with 26504 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
using Client.Domain.Enums;
using Client.Domain.Common;
using Client.Domain.Enums;
using Client.Domain.ValueObjects;
using System;
using System.Collections.Generic;
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace Client.Domain.Entities
{
public class NPC : EntityInterface
public class NPC : NotifyPropertyChanged, EntityInterface
{
public uint Id { get; set; }
public Transform Transform { get; set; }
@@ -18,6 +19,8 @@ namespace Client.Domain.Entities
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 NPC(uint id, Transform transform, bool isHostile, uint npcId, SpoilStateEnum spoilState, FullName fullName, VitalStats vitalStats)
{
@@ -34,5 +37,8 @@ namespace Client.Domain.Entities
{
return VitalStats.MaxHp > 0 && VitalStats.Hp <= 0;
}
private uint level;
private uint aggroRadius;
}
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Domain.Helpers
{
public interface NpcInfoHelperInterface
{
uint GetLevel(uint id);
uint GetAggroRadius(uint id);
}
}

View File

@@ -1,5 +1,6 @@
using Client.Domain.Entities;
using Client.Domain.Factories;
using Client.Domain.Helpers;
using Client.Domain.ViewModels;
using System;
using System.Collections.Generic;
@@ -14,17 +15,21 @@ namespace Client.Domain.Service
public override void OnCreate(NPC entity)
{
mainViewModel.AddNpc(entity);
entity.Level = npcInfoHelper.GetLevel(entity.NpcId);
entity.AggroRadius = npcInfoHelper.GetAggroRadius(entity.NpcId);
}
public override void OnDelete(NPC entity)
{
mainViewModel.RemoveNpc(entity);
}
public NpcHandler(EntityFactoryInterface<NPC> factory, MainViewModelInterface mainViewModel) : base(factory)
public NpcHandler(EntityFactoryInterface<NPC> factory, MainViewModelInterface mainViewModel, NpcInfoHelperInterface npcInfoHelper) : base(factory)
{
this.mainViewModel = mainViewModel;
this.npcInfoHelper = npcInfoHelper;
}
private readonly MainViewModelInterface mainViewModel;
private readonly NpcInfoHelperInterface npcInfoHelper;
}
}