更新地图选取范围格子的逻辑

This commit is contained in:
milimoe 2025-09-07 22:42:11 +08:00
parent 030ef179e8
commit 09eea71cb6
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0
4 changed files with 25 additions and 9 deletions

View File

@ -813,6 +813,7 @@ namespace Milimoe.FunGame.Core.Entity
{
result = damageType == DamageType.Physical ? GamingQueue.CalculatePhysicalDamage(actor, enemy, false, expectedDamage, out damage, ref changeCount) : GamingQueue.CalculateMagicalDamage(actor, enemy, false, MagicType, expectedDamage, out damage, ref changeCount);
}
// 注意此方法在后台线程运行
GamingQueue.DamageToEnemyAsync(actor, enemy, damage, false, damageType, magicType, result);
return result;
}

View File

@ -205,12 +205,13 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
}
/// <summary>
/// 获取以某个格子为中心,一定范围内的格子(曼哈顿距离),只考虑同一平面的格子,不包含中心格子
/// 获取以某个格子为中心,一定范围内的格子(曼哈顿距离),只考虑同一平面的格子
/// </summary>
/// <param name="grid"></param>
/// <param name="range"></param>
/// <param name="includeCharacter"></param>
/// <returns></returns>
public virtual List<Grid> GetGridsByRange(Grid grid, int range)
public virtual List<Grid> GetGridsByRange(Grid grid, int range, bool includeCharacter = false)
{
List<Grid> grids = [];
@ -227,23 +228,26 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
int z = grid.Z;
if (GridsByCoordinate.TryGetValue((x, y, z), out Grid? select) && select != null)
{
grids.Add(select);
if (includeCharacter || select.Characters.Count == 0)
{
grids.Add(select);
}
}
}
}
}
grids.RemoveAll(g => g.Id == grid.Id);
return grids;
}
/// <summary>
/// 获取以某个格子为中心,一定半径内的格子(圆形范围,欧几里得距离),只考虑同一平面的格子,不包含中心格子
/// 获取以某个格子为中心,一定半径内的格子(圆形范围,欧几里得距离),只考虑同一平面的格子
/// </summary>
/// <param name="grid"></param>
/// <param name="range"></param>
/// <param name="includeCharacter"></param>
/// <returns></returns>
public virtual List<Grid> GetGridsByCircleRange(Grid grid, int range)
public virtual List<Grid> GetGridsByCircleRange(Grid grid, int range, bool includeCharacter = false)
{
List<Grid> grids = [];
@ -265,12 +269,14 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
if (GridsByCoordinate.TryGetValue((x, y, z), out Grid? select) && select != null)
{
grids.Add(select);
if (includeCharacter || select.Characters.Count == 0)
{
grids.Add(select);
}
}
}
}
}
grids.RemoveAll(g => g.Id == grid.Id);
return grids;
}

View File

@ -44,5 +44,14 @@ namespace Milimoe.FunGame.Core.Library.Common.Addon
/// 此格子呈现的颜色(默认为 <see cref="Color.Gray"/>
/// </summary>
public Color Color { get; set; } = Color.Gray;
/// <summary>
/// 默认的字符串表示形式
/// </summary>
/// <returns></returns>
public override string ToString()
{
return $"Grid: {Id} ({X}, {Y}, {Z})";
}
}
}

View File

@ -2342,7 +2342,7 @@ namespace Milimoe.FunGame.Core.Model
{
return target;
}
if (map.Characters.TryGetValue(character, out Grid? current) && current != null)
else if (target.Id == -2 && map.Characters.TryGetValue(character, out Grid? current) && current != null)
{
List<Grid> grids = map.GetGridsByRange(current, character.MOV);
if (grids.Count > 0)