1
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Net.Project.B.Health
|
||||
/// </summary>
|
||||
public interface IKnockedService
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
/// <summary>
|
||||
/// 击倒列表
|
||||
/// </summary>
|
||||
@@ -56,6 +57,8 @@ namespace Net.Project.B.Health
|
||||
|
||||
private int OnHealthPlus(int id, int oldHp, int plus, object sendor)
|
||||
{
|
||||
if (Enabled is false) return plus;
|
||||
|
||||
if (_entitiesService.TryGetEntity(id, out var entity) is false) return plus;
|
||||
|
||||
if (entity.ServiceProvider.GetService<IKnockedComponent>() is null) return plus;
|
||||
@@ -82,7 +85,8 @@ namespace Net.Project.B.Health
|
||||
_knocked.Add(id);
|
||||
_onKnocked?.Invoke(id, true);
|
||||
// _logger.LogInformation($"Entity {id} 被击倒了");
|
||||
return oldHp-1;
|
||||
//return 0;
|
||||
return -Math.Abs(oldHp-1);
|
||||
}
|
||||
|
||||
private void OnHealthChanged(int arg1, int arg2, int arg3, object arg4)
|
||||
@@ -101,6 +105,7 @@ namespace Net.Project.B.Health
|
||||
private static readonly ConcurrentDictionary<int,int> _knockedHealth = new();
|
||||
private static event Action<int, bool> _onKnocked;
|
||||
private static event Action<int, int, int> _onKnockedHealthChanged;
|
||||
public bool Enabled { get; set; } = true;
|
||||
public HashSet<int> Knocked=> _knocked;
|
||||
public IReadOnlyDictionary<int, int> KnockedHealth => _knockedHealth;
|
||||
public event Action<int, bool> OnKnocked
|
||||
|
Reference in New Issue
Block a user