diff --git a/logic/GameClass/GameObj/Character/Character.BuffManager.cs b/logic/GameClass/GameObj/Character/Character.BuffManager.cs
index 1677eaa..4979e42 100644
--- a/logic/GameClass/GameObj/Character/Character.BuffManager.cs
+++ b/logic/GameClass/GameObj/Character/Character.BuffManager.cs
@@ -15,35 +15,15 @@ namespace GameClass.GameObj
///
private class BuffManager
{
- [StructLayout(LayoutKind.Explicit, Size = 8)]
- private struct BuffValue // buff参数联合体类型,可能是int或double
- {
- [FieldOffset(0)]
- public int iValue;
- [FieldOffset(0)]
- public double lfValue;
-
- public BuffValue(int intValue)
- {
- this.lfValue = 0.0;
- this.iValue = intValue;
- }
- public BuffValue(double longFloatValue)
- {
- this.iValue = 0;
- this.lfValue = longFloatValue;
- }
- }
-
///
/// buff列表
///
- private readonly LinkedList[] buffList;
+ private readonly LinkedList[] buffList;
private readonly object[] buffListLock;
- private void AddBuff(BuffValue bf, int buffTime, BuffType buffType, Action ReCalculateFunc)
+ private void AddBuff(double bf, int buffTime, BuffType buffType, Action ReCalculateFunc)
{
- LinkedListNode buffNode;
+ LinkedListNode buffNode;
lock (buffListLock[(int)buffType])
{
buffNode = buffList[(int)buffType].AddLast(bf);
@@ -80,13 +60,13 @@ namespace GameClass.GameObj
{
foreach (var add in buffList[(int)buffType])
{
- times *= add.lfValue;
+ times *= add;
}
}
return Math.Max(Math.Min((int)Math.Round(orgVal * times), maxVal), minVal);
}
- public void AddMoveSpeed(double add, int buffTime, Action SetNewMoveSpeed, int orgMoveSpeed) => AddBuff(new BuffValue(add), buffTime, BuffType.AddSpeed, () => SetNewMoveSpeed(ReCalculateFloatBuff(BuffType.AddSpeed, orgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed)));
+ public void AddMoveSpeed(double add, int buffTime, Action SetNewMoveSpeed, int orgMoveSpeed) => AddBuff(add, buffTime, BuffType.AddSpeed, () => SetNewMoveSpeed(ReCalculateFloatBuff(BuffType.AddSpeed, orgMoveSpeed, GameData.MaxSpeed, GameData.MinSpeed)));
public bool HasFasterSpeed
{
get
@@ -98,7 +78,7 @@ namespace GameClass.GameObj
}
}
- public void AddShield(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Shield, () =>
+ public void AddShield(int shieldTime) => AddBuff(0, shieldTime, BuffType.Shield, () =>
{ });
public bool HasShield
{
@@ -123,7 +103,7 @@ namespace GameClass.GameObj
return false;
}
- public void AddAp(int time) => AddBuff(new BuffValue(), time, BuffType.AddAp, () => { });
+ public void AddAp(int time) => AddBuff(0, time, BuffType.AddAp, () => { });
public bool HasAp
{
get
@@ -147,7 +127,7 @@ namespace GameClass.GameObj
return false;
}
- public void AddLife(int totelTime) => AddBuff(new BuffValue(), totelTime, BuffType.AddLife, () =>
+ public void AddLife(int totelTime) => AddBuff(0, totelTime, BuffType.AddLife, () =>
{ });
public bool HasLIFE
{
@@ -172,7 +152,7 @@ namespace GameClass.GameObj
return false;
}
- public void AddSpear(int spearTime) => AddBuff(new BuffValue(), spearTime, BuffType.Spear, () =>
+ public void AddSpear(int spearTime) => AddBuff(0, spearTime, BuffType.Spear, () =>
{ });
public bool HasSpear
{
@@ -210,7 +190,7 @@ namespace GameClass.GameObj
return false;
}
- public void AddClairaudience(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Clairaudience, () =>
+ public void AddClairaudience(int shieldTime) => AddBuff(0, shieldTime, BuffType.Clairaudience, () =>
{ });
public bool HasClairaudience
{
@@ -223,7 +203,7 @@ namespace GameClass.GameObj
}
}
- public void AddInvisible(int shieldTime) => AddBuff(new BuffValue(), shieldTime, BuffType.Invisible, () =>
+ public void AddInvisible(int shieldTime) => AddBuff(0, shieldTime, BuffType.Invisible, () =>
{ });
public bool HasInvisible
{
@@ -253,12 +233,12 @@ namespace GameClass.GameObj
public BuffManager()
{
var buffTypeArray = Enum.GetValues(typeof(BuffType));
- buffList = new LinkedList[buffTypeArray.Length];
+ buffList = new LinkedList[buffTypeArray.Length];
buffListLock = new object[buffList.Length];
int i = 0;
foreach (BuffType type in buffTypeArray)
{
- buffList[i] = new LinkedList();
+ buffList[i] = new LinkedList();
buffListLock[i++] = new object();
}
}
diff --git a/logic/Preparation/Utility/SafeValue.cs b/logic/Preparation/Utility/SafeValue.cs
index 286b721..df8f626 100644
--- a/logic/Preparation/Utility/SafeValue.cs
+++ b/logic/Preparation/Utility/SafeValue.cs
@@ -301,9 +301,7 @@ namespace Preparation.Utility
return v = (value > maxV) ? maxV : value;
}
}
- ///
- /// 返回实际改变量
- ///
+ /// 返回实际改变量
public int AddV(int addV)
{
lock (vLock)
@@ -316,8 +314,9 @@ namespace Preparation.Utility
}
}
///
- /// 应当保证该增加值大于0,返回实际改变量
+ /// 应当保证增加值大于0
///
+ /// 返回实际改变量
public int AddPositiveV(int addPositiveV)
{
lock (vLock)