@@ -14,7 +14,7 @@ public class Ability : IAbility
14
14
public bool IsActive => _IsActive ;
15
15
[ SerializeField ]
16
16
private bool _Enabled = true ;
17
- public bool Enabled => _Enabled ;
17
+ public bool IsEnabled => _Enabled ;
18
18
19
19
20
20
public event System . Action < IAbility > OnDidActivate ;
@@ -24,7 +24,7 @@ public class Ability : IAbility
24
24
25
25
public void Disable ( )
26
26
{
27
- if ( ! Enabled )
27
+ if ( ! IsEnabled )
28
28
return ;
29
29
_Enabled = false ;
30
30
if ( Agent == null )
@@ -37,7 +37,7 @@ public void Disable()
37
37
38
38
public void Enable ( )
39
39
{
40
- if ( Enabled )
40
+ if ( IsEnabled )
41
41
return ;
42
42
_Enabled = true ;
43
43
@@ -59,24 +59,24 @@ protected virtual void OnStop(StopReason reason) {}
59
59
60
60
public virtual bool ShouldStopMyselfDueToActivatingAbility ( IAbility abilityThatBlocks ) => false ;
61
61
62
- public bool TryToAdd ( IAgent agent )
62
+ protected virtual bool ShouldBeAddedToAgent ( IAgent agent ) => true ;
63
+ protected virtual bool ShouldBeActivated ( ) => true ;
64
+
65
+ bool IAbility . TryToAdd ( IAgent agent )
63
66
{
64
67
if ( Agent != null )
65
68
return false ;
66
69
if ( agent == null )
67
70
return false ;
68
- if ( ! ValidateAgent ( agent ) )
71
+ if ( ! ShouldBeAddedToAgent ( agent ) )
69
72
return false ;
70
73
_Agent = agent ;
71
74
return true ;
72
75
}
73
76
74
- protected virtual bool ValidateAgent ( IAgent agent ) => true ;
75
- protected virtual bool ShouldBeActivated ( ) => true ;
76
-
77
- public bool TryToActivate ( )
77
+ bool IAbility . TryToActivate ( )
78
78
{
79
- if ( ! IsActive && Enabled && Agent != null && ShouldBeActivated ( ) )
79
+ if ( ! IsActive && IsEnabled && Agent != null && ShouldBeActivated ( ) )
80
80
{
81
81
_IsActive = true ;
82
82
OnDidActivate ? . Invoke ( this ) ;
@@ -92,7 +92,7 @@ public void Stop()
92
92
93
93
public virtual void Dispose ( ) { }
94
94
95
- public void DetachFromAgent ( )
95
+ void IAbility . DetachFromAgent ( )
96
96
{
97
97
Stop ( ) ;
98
98
_Agent = null ;
0 commit comments