(client)feat:视野范围检测,
This commit is contained in:
@ -29,7 +29,7 @@ namespace Entity
|
||||
|
||||
public ProgressBarPrefab healthBarPrefab;
|
||||
|
||||
|
||||
public VisionRangeDetector visionRangeDetector;
|
||||
/// <summary>
|
||||
/// 人工智能行为树,定义实体的行为逻辑。
|
||||
/// </summary>
|
||||
@ -154,7 +154,7 @@ namespace Entity
|
||||
|
||||
[SerializeField] private float _hitBarUIShowTime = 5;
|
||||
private float _hitBarUIShowTimer = 0;
|
||||
private int _walkingTimer = 1;
|
||||
private int _walkingTimer = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -219,16 +219,17 @@ namespace Entity
|
||||
{
|
||||
targetObj = InitBodyPart(nodeDef, body); // 创建新对象
|
||||
}
|
||||
|
||||
|
||||
stateBodyNodes[orientation] = targetObj;
|
||||
|
||||
// 提取动画组件(安全处理空组件情况)
|
||||
// 逻辑修改:确保 stateAnimNodes[orientation] 总是被初始化为一个列表
|
||||
var animatorsForOrientation = new List<ITick>(); // 总是创建一个新的列表
|
||||
var animators = targetObj.GetComponentsInChildren<SpriteAnimator>();
|
||||
if (animators.Length > 0)
|
||||
{
|
||||
stateAnimNodes[orientation] = animators.Cast<ITick>().ToList();
|
||||
animatorsForOrientation.AddRange(animators.Cast<ITick>());
|
||||
}
|
||||
// 无动画组件时保持 stateAnimNodes[orientation] 为 null(符合原始逻辑)
|
||||
stateAnimNodes[orientation] = animatorsForOrientation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,13 +464,15 @@ namespace Entity
|
||||
|
||||
_currentState = state;
|
||||
_currentOrientation = orientation;
|
||||
|
||||
if (bodyAnimationNode.TryGetValue(_currentState, out var animationNode))
|
||||
|
||||
if (bodyAnimationNode.TryGetValue(_currentState, out var animationNode) &&
|
||||
animationNode.TryGetValue(_currentOrientation, out var value))
|
||||
{
|
||||
if (animationNode.TryGetValue(_currentOrientation, out var value))
|
||||
{
|
||||
_currentAnimatorCache=value;
|
||||
}
|
||||
_currentAnimatorCache = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentAnimatorCache = new List<ITick>(); // 如果没有找到动画,则使用空列表
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user