File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions
Scripts/Characters/StateMachine/Actions Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ MonoBehaviour:
14
14
m_EditorClassIdentifier :
15
15
_targetTransform : {fileID: 11400000, guid: 35fc4039342b6ba458d0d4429e89ee74, type: 2}
16
16
_chasingSpeed : 2
17
+ _gameState : {fileID: 11400000, guid: 159f9c22d98e249ceb08f2c5de2311a4, type: 2}
Original file line number Diff line number Diff line change @@ -11,11 +11,12 @@ public class ChasingTargetActionSO : StateActionSO
11
11
12
12
[ Tooltip ( "NPC chasing speed" ) ]
13
13
[ SerializeField ] private float _chasingSpeed = default ;
14
+ [ SerializeField ] private GameStateSO _gameState = default ;
14
15
15
16
public Vector3 TargetPosition => _targetTransform . Transform . position ;
16
17
public float ChasingSpeed => _chasingSpeed ;
17
18
18
- protected override StateAction CreateAction ( ) => new ChasingTargetAction ( ) ;
19
+ protected override StateAction CreateAction ( ) => new ChasingTargetAction ( _gameState ) ;
19
20
}
20
21
21
22
public class ChasingTargetAction : StateAction
@@ -24,6 +25,12 @@ public class ChasingTargetAction : StateAction
24
25
private ChasingTargetActionSO _config ;
25
26
private NavMeshAgent _agent ;
26
27
private bool _isActiveAgent ;
28
+ private GameStateSO _gameState = default ;
29
+
30
+ public ChasingTargetAction ( GameStateSO gameState )
31
+ {
32
+ _gameState = gameState ;
33
+ }
27
34
28
35
public override void Awake ( StateMachine stateMachine )
29
36
{
@@ -46,6 +53,12 @@ public override void OnStateEnter()
46
53
if ( _isActiveAgent )
47
54
{
48
55
_agent . speed = _config . ChasingSpeed ;
56
+ _gameState . UpdateGameState ( GameState . Combat ) ;
49
57
}
50
58
}
59
+
60
+ public override void OnStateExit ( )
61
+ {
62
+ _gameState . ResetToPreviousGameState ( ) ;
63
+ }
51
64
}
You can’t perform that action at this time.
0 commit comments