Added onRemoved fixed attribute action
This commit is contained in:
parent
29df8c3646
commit
6743ad3dcd
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DiIiS_NA.Core.Logging;
|
using DiIiS_NA.Core.Logging;
|
||||||
|
using DiIiS_NA.GameServer.MessageSystem;
|
||||||
|
|
||||||
namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem
|
namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem
|
||||||
{
|
{
|
||||||
@ -17,19 +18,37 @@ namespace DiIiS_NA.GameServer.GSSystem.ObjectsSystem
|
|||||||
{
|
{
|
||||||
private static readonly Logger _logger = LogManager.CreateLogger(nameof(FixedMap));
|
private static readonly Logger _logger = LogManager.CreateLogger(nameof(FixedMap));
|
||||||
private readonly Dictionary<FixedAttribute, Action<GameAttributeMap>> _attributeMap = new();
|
private readonly Dictionary<FixedAttribute, Action<GameAttributeMap>> _attributeMap = new();
|
||||||
|
private readonly Dictionary<FixedAttribute, Action> _removedAttributeMap = new();
|
||||||
|
|
||||||
public void Add(FixedAttribute name, Action<GameAttributeMap> action)
|
public void Add(FixedAttribute name, Action<GameAttributeMap> action,
|
||||||
|
Action removedAction = null)
|
||||||
{
|
{
|
||||||
|
_attributeMap.Add(name, action);
|
||||||
|
if (removedAction != null)
|
||||||
|
{
|
||||||
|
_removedAttributeMap.Add(name, removedAction);
|
||||||
|
}
|
||||||
|
|
||||||
if (Contains(name))
|
if (Contains(name))
|
||||||
{
|
{
|
||||||
_attributeMap[name] += action;
|
_attributeMap[name] += action;
|
||||||
_logger.Warn($"Fixed attribute {name} already exists. Action will be added.");
|
_logger.Warn($"Fixed attribute {name} already exists. Action will be added.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_attributeMap.Add(name, action);
|
_attributeMap.Add(name, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(FixedAttribute name) => _attributeMap.Remove(name);
|
public void Remove(FixedAttribute name)
|
||||||
|
{
|
||||||
|
_attributeMap.Remove(name);
|
||||||
|
if (_removedAttributeMap.ContainsKey(name))
|
||||||
|
{
|
||||||
|
_removedAttributeMap[name]();
|
||||||
|
_removedAttributeMap.Remove(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Clear() => _attributeMap.Clear();
|
public void Clear() => _attributeMap.Clear();
|
||||||
public bool Contains(FixedAttribute name) => _attributeMap.ContainsKey(name);
|
public bool Contains(FixedAttribute name) => _attributeMap.ContainsKey(name);
|
||||||
public void Apply(GameAttributeMap map)
|
public void Apply(GameAttributeMap map)
|
||||||
|
|||||||
@ -2051,7 +2051,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
|||||||
if (!skeleton.Attributes.FixedMap.Contains(FixedAttribute.AttackSpeed))
|
if (!skeleton.Attributes.FixedMap.Contains(FixedAttribute.AttackSpeed))
|
||||||
{
|
{
|
||||||
var originalAttackSpeed = skeleton.Attributes[GameAttribute.Attacks_Per_Second];
|
var originalAttackSpeed = skeleton.Attributes[GameAttribute.Attacks_Per_Second];
|
||||||
skeleton.Attributes.FixedMap.Add(FixedAttribute.AttackSpeed, attr => attr[GameAttribute.Attacks_Per_Second] = originalAttackSpeed * 1.25f);
|
skeleton.Attributes.FixedMap.Add(FixedAttribute.AttackSpeed,
|
||||||
|
attr => attr[GameAttribute.Attacks_Per_Second] = originalAttackSpeed * 1.25f,
|
||||||
|
() => skeleton.Attributes[GameAttribute.Attacks_Per_Second] = originalAttackSpeed);
|
||||||
skeleton.Attributes.BroadcastChangedIfRevealed();
|
skeleton.Attributes.BroadcastChangedIfRevealed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2067,6 +2069,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
|||||||
{
|
{
|
||||||
Target = Target
|
Target = Target
|
||||||
};
|
};
|
||||||
|
|
||||||
attack.AddWeaponDamage(greaterDamage ? 2.15f : 1.0f, damageType);
|
attack.AddWeaponDamage(greaterDamage ? 2.15f : 1.0f, damageType);
|
||||||
attack.OnHit = hit =>
|
attack.OnHit = hit =>
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
user.block.title