Skip to content

Commit 51f54e8

Browse files
authored
Merge pull request #112 from bazyleu/feature/readme-minor-updates
Readme and tutorial minor updates
2 parents 2c0fa51 + 62b9f5d commit 51f54e8

3 files changed

Lines changed: 22 additions & 23 deletions

File tree

Assets/Examples/States/LostState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class LostState : StateBase
1010
{
1111
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
1212
{
13-
Debug.Log("You lost. You will have a another chance in...");
13+
Debug.Log("You lost. You will have another chance in...");
1414

1515
Debug.Log("3 seconds");
1616
await UniTask.Delay(TimeSpan.FromSeconds(1), cancellationToken: token);

Assets/Examples/States/RollDiceState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public override async UniTask<StateTransitionInfo> Execute(CancellationToken tok
1515

1616
await UniTask.Delay(TimeSpan.FromSeconds(2), cancellationToken: token);
1717

18-
var dice = Random.Range(0, 7);
18+
var dice = Random.Range(1, 7);
1919

2020
Debug.Log($"Dice is {dice}");
2121

README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pattern or be used to address specific tasks.
2121
* **Flexibility**: everything in framework core is an abstraction. Can be replaced with your own implementation,
2222
see [state creating](#state-creating) and [creating a state machine](#creating-a-state-machine) sections for details.
2323
* **Testability**: UniState is designed to be testable. All abstractions use interfaces that can be easily mocked with
24-
[NSubstitutes](https://nsubstitute.github.io/) or any other framework. States can be run separately for testing
24+
[NSubstitute](https://nsubstitute.github.io/) or any other framework. States can be run separately for testing
2525
purposes.
2626
* **DI friendly**: has [integration](#integrations) with most popular DI containers
2727
* **Continuous Testing**: fully covered by tests. All tests run [automatically](https://github.com/bazyleu/UniState/actions) to verify each change.
@@ -138,14 +138,14 @@ Additional information on DI configuration is available [here](#integrations).
138138

139139
public void Start()
140140
{
141-
_stateMachine.Execute<StartGameState>(CancellationToken.None).Forget();
141+
_stateMachine.Execute<MainMenuState>(CancellationToken.None).Forget();
142142
}
143143
}
144144
```
145145
More details on running the state machine can be found [here](#running-a-state-machine).
146146

147-
That is it! Your first project with UniState is set up. In [tutorials](#tutorials) section more detailed tutorial can be
148-
found.
147+
That's it! Your first UniState project is set up. You can find a more detailed walkthrough in the
148+
[tutorials](#tutorials) section.
149149

150150
## Installation
151151

@@ -160,7 +160,7 @@ found.
160160
You can add `https://github.com/bazyleu/UniState.git?path=Assets/UniState` to Package Manager.
161161

162162
It is a good practice to specify target version, UniState uses the `*.*.*` release tag so you can specify a version
163-
like `#1.8.0`. For example `https://github.com/bazyleu/UniState.git?path=Assets/UniState#1.8.0`.
163+
like `#1.9.0`. For example `https://github.com/bazyleu/UniState.git?path=Assets/UniState#1.9.0`.
164164
You can find latest version number [here](https://github.com/bazyleu/UniState/releases).
165165

166166
![image](https://github.com/user-attachments/assets/120e6750-1f33-44f7-99c8-a3e7fa166d21)
@@ -169,7 +169,7 @@ You can find latest version number [here](https://github.com/bazyleu/UniState/re
169169
### Option 2: Add via manifest.json
170170

171171
You can add `"com.bazyleu.unistate": "https://github.com/bazyleu/UniState.git?path=Assets/UniState"` (or with version
172-
tag `https://github.com/bazyleu/UniState.git?path=Assets/UniState#1.8.0`) to `Packages/manifest.json`.
172+
tag `https://github.com/bazyleu/UniState.git?path=Assets/UniState#1.9.0`) to `Packages/manifest.json`.
173173

174174
## Performance
175175

@@ -179,7 +179,7 @@ and up to a 10x reduction in allocations.
179179

180180
For typical scenarios involving small to medium state chains - the most common use case - UniState can reduce memory
181181
allocations by a factor ranging between 2x and 10x. In cases where state chains exceed 200 states, the benefits in
182-
memory allocation become less pronounced but execution speed remain consistent with 5000x+ boost.
182+
memory allocation become less pronounced, but execution speed remains consistent with a 5000x+ boost.
183183

184184
Measurements for Windows PC (with IL2CPP scripting backend):
185185
```
@@ -228,8 +228,8 @@ which were mentioned above support this, and you can choose any based on your pr
228228
outside the scope of UniState.
229229

230230
```csharp
231-
//Popup prefab (Monobehaviour, view)
232-
public class SimplePopupView : ISimplePopupView, Monobehaviour
231+
// Popup prefab (MonoBehaviour, view)
232+
public class SimplePopupView : ISimplePopupView, MonoBehaviour
233233
{
234234
//...
235235
}
@@ -242,7 +242,7 @@ outside the scope of UniState.
242242
public override async UniTask Initialize(CancellationToken token)
243243
{
244244
_view = LoadPopupView(token);
245-
Disposables.Add(UnloadShopView);
245+
Disposables.Add(UnloadPopupView);
246246
}
247247

248248
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
@@ -259,12 +259,12 @@ outside the scope of UniState.
259259
}
260260

261261
// The implementation of this method depends on other frameworks/patterns used in the project.
262-
private ISimplePopupView LoadShopView(CancellationToken token)
262+
private ISimplePopupView LoadPopupView(CancellationToken token)
263263
{
264264
// Loading logic
265265
}
266266

267-
private void UnloadShopView()
267+
private void UnloadPopupView()
268268
{
269269
// Unloading logic
270270
}
@@ -295,7 +295,7 @@ state machine, ensuring they are properly cleaned up after the state machine exi
295295

296296
// Run the internal state machine for ShopPopup.
297297
// In all states inside this state machine, all resources allocated in this state will be available.
298-
await stateMachine.Execute<ShopPopupIdleState>(cts.Token);
298+
await stateMachine.Execute<ShopPopupIdleState>(token);
299299

300300
return Transition.GoBack();
301301
}
@@ -618,11 +618,11 @@ public class RootGameplayState : StateBase
618618
private readonly IStateMachine _uiMachine;
619619
private readonly IStateMachine _logicMachine;
620620

621-
public GameplayState(IStateMachine uiMachine,
622-
IStateMachine logicMachine)
621+
public RootGameplayState(IStateMachine uiMachine,
622+
IStateMachine logicMachine)
623623
{
624624
_uiMachine = uiMachine;
625-
_logicMachine = _logicMachine;
625+
_logicMachine = logicMachine;
626626
}
627627

628628
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
@@ -904,7 +904,7 @@ Each state inherits from **`StateBase`** and returns a transition that drives th
904904
Debug.Log("Need to roll 5+. Rolling the dice...");
905905
await UniTask.Delay(TimeSpan.FromSeconds(2), cancellationToken: token);
906906

907-
var dice = Random.Range(0, 7);
907+
var dice = Random.Range(1, 7);
908908
Debug.Log($"Dice is {dice}");
909909

910910
if (dice > 4)
@@ -919,7 +919,7 @@ Each state inherits from **`StateBase`** and returns a transition that drives th
919919
{
920920
public override async UniTask<StateTransitionInfo> Execute(CancellationToken token)
921921
{
922-
Debug.Log("You lost. You will have a another chance in...");
922+
Debug.Log("You lost. You will have another chance in...");
923923

924924
Debug.Log("3 seconds");
925925
await UniTask.Delay(TimeSpan.FromSeconds(1), cancellationToken: token);
@@ -948,8 +948,7 @@ Each state inherits from **`StateBase`** and returns a transition that drives th
948948

949949
#### Step 2: Create entry point
950950

951-
DiceEntryPoint runs on scene start, converts IObjectResolver into an ITypeResolver, creates the state machine, and runs
952-
StartGameState.
951+
DiceEntryPoint runs on scene start, resolves the state machine, and runs StartGameState.
953952

954953
```csharp
955954
public class DiceEntryPoint : IStartable
@@ -971,7 +970,7 @@ StartGameState.
971970
#### Step 3: Configure VContainer
972971

973972
DiceScope is a LifetimeScope that registers the state machine and all states.
974-
The helper extensions RegisterStateMachine and RegisterState is used for registering.
973+
The helper extensions RegisterStateMachine and RegisterState are used for registering.
975974
Note that for a state machine you must register an interface (or abstract class) and an implementation, and resolve the
976975
interface, not the implementation.
977976

0 commit comments

Comments
 (0)