(client) chore:Clean code
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq; // Added for LINQ
|
||||
using Base;
|
||||
using Data;
|
||||
using Entity;
|
||||
using Prefab;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@ -15,11 +14,11 @@ namespace Item
|
||||
public Attributes Attributes { get; private set; }
|
||||
public BulletDef Bullet { get; private set; }
|
||||
public WeaponType Type { get; private set; }
|
||||
|
||||
public DrawNodeDef AttackAnimationDef { get; private set; }
|
||||
public float AttackAnimationTime{get; private set;}
|
||||
|
||||
public float AttackDetectionTime{get;private set;}
|
||||
|
||||
public DrawNodeDef AttackAnimationDef { get; private set; }
|
||||
public float AttackAnimationTime { get; private set; }
|
||||
|
||||
public float AttackDetectionTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数:通过 WeaponDef 对象初始化 WeaponResource。
|
||||
@ -76,12 +75,12 @@ namespace Item
|
||||
Debug.LogError("InstantiateAttackAnimation: 无法加载 Prefab/Animation.");
|
||||
return (null, Array.Empty<ITick>());
|
||||
}
|
||||
|
||||
|
||||
// 逻辑修改说明 2:调用修改后的私有辅助方法来创建 GameObject 层次结构。
|
||||
var animationRoot = _CreateBodyPartGameObject(
|
||||
AttackAnimationDef,
|
||||
parent,
|
||||
imagePrefab,
|
||||
AttackAnimationDef,
|
||||
parent,
|
||||
imagePrefab,
|
||||
animatorPrefab);
|
||||
|
||||
if (animationRoot == null)
|
||||
@ -91,9 +90,9 @@ namespace Item
|
||||
}
|
||||
|
||||
// 逻辑修改说明 3:收集所有实现了 ITick 接口的组件。
|
||||
var tickComponents = animationRoot.GetComponentsInChildren<ITick>(true);
|
||||
var tickComponents = animationRoot.GetComponentsInChildren<ITick>(true);
|
||||
// GetComponentsInChildren(true) 会查找包括自身在内的所有子对象上的组件,即使它们是处于非活动状态。
|
||||
|
||||
|
||||
return (animationRoot, tickComponents);
|
||||
}
|
||||
|
||||
@ -112,7 +111,7 @@ namespace Item
|
||||
|
||||
if (parent == null)
|
||||
{
|
||||
// 逻辑修改说明:这里直接返回 null 更合适,因为没有父节点无法创建实例。
|
||||
// 逻辑修改说明:这里直接返回 null 更合适,因为没有父节点无法创建实例。
|
||||
Debug.LogWarning($"CreateBodyPartGameObject: 父节点为null (节点名: {drawNode.nodeName ?? "Unnamed DrawNode"})");
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user