Skip to content

Commit c43bac0

Browse files
Merge pull request #100 from PaulNonatomic/develop
Develop
2 parents bdfdcc0 + d69c7ff commit c43bac0

4 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## [0.7.2-beta] - Aug 24, 2024
4+
- Exposed the JumpTo method on the StateMachineController
5+
- This allows users to manually trigger a JumpIn node externally broadening the use-cases for the VSM
6+
- Exposed the State member of the StateMachine through a public State member of the StateMachineController
7+
- This allows users to determine the current state and to directly call methods upon externally.
8+
- I experimented with implementing a StatePattern with all States implementing a common interface.
9+
310
## [0.7.1-beta] - Aug 21, 2024
411
- Amended the exception forwarding of StateMachine to throw the original exception rather than wrapping it. This improves debugging errors in states.
512

Runtime/StateGraph/StateMachine.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class StateMachine
1515
{
1616
public event Action<State, StateMachineModel> OnComplete;
1717

18+
public State State => _currentNode?.State;
1819
public StateMachineModel Model { get; private set; }
1920
public bool IsComplete { get; private set; }
2021

Runtime/StateGraph/StateMachineController.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Nonatomic.VSM2.StateGraph.States;
23
using UnityEngine;
34

45
namespace Nonatomic.VSM2.StateGraph
@@ -12,6 +13,8 @@ public class StateMachineController : MonoBehaviour
1213
/// Gets the unique identifier for this controller.
1314
/// </summary>
1415
public string Id => _id;
16+
17+
public State State => _stateMachine?.State;
1518

1619
/// <summary>
1720
/// Gets the current StateMachineModel, either from the active state machine or the serialized field.
@@ -27,6 +30,15 @@ public class StateMachineController : MonoBehaviour
2730
private bool _activated;
2831
private bool _started;
2932

33+
/// <summary>
34+
/// Jumps to a state via a JumpIn state using the JumpId to identify the JumpIn node.
35+
/// </summary>
36+
/// <param name="id">The JumpIn id of the destination JumpIn node</param>
37+
public void JumpTo(JumpId id)
38+
{
39+
_stateMachine?.JumpTo(id);
40+
}
41+
3042
/// <summary>
3143
/// Changes the StateMachineModel and reinitializes the state machine.
3244
/// If the GameObject is active and has already started, it will also call Start and Enter on the new state machine.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.nonatomic.visualstatemachinev2",
3-
"version": "0.7.1-beta",
3+
"version": "0.7.2-beta",
44
"displayName": "Visual State Machine V2",
55
"description": "Visual State Machine V2",
66
"unity": "2022.3",

0 commit comments

Comments
 (0)