Add WeaponFeedback component and AddressableManagerWindow meta file
- Implemented WeaponFeedback class for handling weapon-related feedbacks such as hit effects and attack sounds. - Added meta file for AddressableManagerWindow to manage addressable assets. - Included a new jump.data file for profiler data.
This commit is contained in:
@@ -18,6 +18,8 @@ namespace BaseGames.Combat
|
||||
protected Rigidbody2D _rb;
|
||||
protected HitBox _hitBox;
|
||||
protected float _aliveTimer;
|
||||
// Lifetime 在 Initialize 时缓存,避免 Update 每帧访问 SO 成员并做 null check
|
||||
private float _lifetime = float.MaxValue;
|
||||
|
||||
private PooledObject _pooledObject;
|
||||
|
||||
@@ -32,6 +34,7 @@ namespace BaseGames.Combat
|
||||
public virtual void Initialize(ProjectileConfigSO config, DamageInfo damageInfo, Vector2 direction, int ownerLayer = 0)
|
||||
{
|
||||
_config = config;
|
||||
_lifetime = config.Lifetime;
|
||||
DamageInfo = damageInfo;
|
||||
Direction = direction.normalized;
|
||||
_aliveTimer = 0f;
|
||||
@@ -75,7 +78,7 @@ namespace BaseGames.Combat
|
||||
protected virtual void Update()
|
||||
{
|
||||
_aliveTimer += Time.deltaTime;
|
||||
if (_config != null && _aliveTimer >= _config.Lifetime)
|
||||
if (_aliveTimer >= _lifetime)
|
||||
ReturnToPool();
|
||||
}
|
||||
|
||||
@@ -91,6 +94,7 @@ namespace BaseGames.Combat
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
_aliveTimer = 0f;
|
||||
_lifetime = float.MaxValue; // 归还对象池后重置,防止未初始化时自毁
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user