(client) chore:Clean code

This commit is contained in:
2025-08-28 16:20:24 +08:00
parent 909e995e15
commit c3bff1cf88
76 changed files with 5689 additions and 445 deletions

View File

@ -1,12 +1,10 @@
using UnityEngine;
namespace Item
{
public class ItemBase
{
public ItemResource resource;
public int count=0;
public int count = 0;
}
}

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Data;
using Managers;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Item

View File

@ -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;
}