重构清理敌人类
This commit is contained in:
@@ -18,9 +18,7 @@ namespace SepCore.Entity
|
||||
[SerializeField] protected bool _isEnabled = false;
|
||||
|
||||
public WeaponData WeaponData { get; protected set; }
|
||||
|
||||
public float AttackCooldown => WeaponData.Cooldown;
|
||||
|
||||
|
||||
public bool IsAttacking => _isAttacking;
|
||||
|
||||
protected ITargetSelector TargetSelector { get; private set; }
|
||||
@@ -29,7 +27,7 @@ namespace SepCore.Entity
|
||||
|
||||
protected EntityBase _target;
|
||||
|
||||
protected float _sqrRange;
|
||||
private float _sqrRange;
|
||||
|
||||
public EntityBase Target => _target;
|
||||
|
||||
@@ -40,8 +38,9 @@ namespace SepCore.Entity
|
||||
private StatComponent _attackStatComponent;
|
||||
private System.Action<modifier, bool> _attackStatCallback;
|
||||
|
||||
[SerializeField] protected float _rotateSpeed = 5f;
|
||||
[SerializeField] protected LayerMask _hitMask = ~0;
|
||||
private static float _rotateSpeed => GameEntry.Luban.Global.WeaponRotateSpeed;
|
||||
|
||||
protected LayerMask _hitMask;
|
||||
protected Quaternion _cachedRotation;
|
||||
|
||||
#region Lifecycle
|
||||
@@ -57,8 +56,12 @@ namespace SepCore.Entity
|
||||
{
|
||||
base.OnShow(userData);
|
||||
|
||||
WeaponData = RequireWeaponData<WeaponData>(userData);
|
||||
if (WeaponData == null) return;
|
||||
WeaponData = (WeaponData)userData;
|
||||
if (WeaponData == null)
|
||||
{
|
||||
Log.Error("WeaponData is Invalid!");
|
||||
return;
|
||||
}
|
||||
|
||||
StartAttackCooldown(WeaponData.Cooldown);
|
||||
_sqrRange = WeaponData.AttackRange * WeaponData.AttackRange;
|
||||
@@ -229,18 +232,7 @@ namespace SepCore.Entity
|
||||
protected virtual void OnEnabledChanged(bool enabled)
|
||||
{
|
||||
}
|
||||
|
||||
protected T RequireWeaponData<T>(object userData) where T : WeaponData
|
||||
{
|
||||
var data = userData as T;
|
||||
if (data == null)
|
||||
{
|
||||
Log.Error("{0} data is invalid.", typeof(T).Name);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
protected IEnumerable<EntityBase> GetCandidates()
|
||||
{
|
||||
return GameEntry.EnemyManager.Enemies;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace SepCore.Entity
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
_weapon.ResetAttackCooldown(_weapon.AttackCooldown);
|
||||
_weapon.ResetAttackCooldown(_weapon.WeaponData.Cooldown);
|
||||
_weapon.Attack();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace SepCore.Entity
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
_weapon.ResetAttackCooldown(_weapon.AttackCooldown);
|
||||
_weapon.ResetAttackCooldown(_weapon.WeaponData.Cooldown);
|
||||
_weapon.Attack();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace SepCore.Entity
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
_weapon.ResetAttackCooldown(_weapon.AttackCooldown);
|
||||
_weapon.ResetAttackCooldown(_weapon.WeaponData.Cooldown);
|
||||
_weapon.Attack();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace SepCore.Entity
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
_weapon.ResetAttackCooldown(_weapon.AttackCooldown);
|
||||
_weapon.ResetAttackCooldown(_weapon.WeaponData.Cooldown);
|
||||
_weapon.Attack();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ namespace SepCore.Entity
|
||||
|
||||
public override void OnEnter()
|
||||
{
|
||||
_weapon.ResetAttackCooldown(_weapon.AttackCooldown);
|
||||
_weapon.ResetAttackCooldown(_weapon.WeaponData.Cooldown);
|
||||
_weapon.Attack();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user