Skip to content

Commit 5e607da

Browse files
committed
New pressure plate example
1 parent e39bf25 commit 5e607da

38 files changed

+6644
-2902
lines changed

Assets/FluidStateMachine/Examples/InteractiveDoor/InteractiveDoor.unity

Lines changed: 93 additions & 2884 deletions
Large diffs are not rendered by default.

Assets/FluidStateMachine/Examples/Prefabs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FluidStateMachine/Examples/Prefabs/Door.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FluidStateMachine/Examples/InteractiveDoor/Door.cs renamed to Assets/FluidStateMachine/Examples/Prefabs/Door/Door.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using UnityEngine;
32

43
namespace CleverCrow.FluidStateMachine.Examples {
@@ -10,7 +9,7 @@ public class Door : MonoBehaviour {
109
public bool Close { private get; set; }
1110
public bool ToggleLock { private get; set; }
1211

13-
private enum DoorState {
12+
public enum DoorState {
1413
Opened,
1514
Closed,
1615
}
@@ -25,14 +24,16 @@ private void Start () {
2524
.Owner(gameObject)
2625
.Default(DoorState.Closed)
2726
.State(DoorState.Opened, (open) => {
28-
open.SetTransition("close", DoorState.Closed)
27+
open
28+
.SetTransition("close", DoorState.Closed)
2929
.SetAnimatorBool("open", true)
3030
.Update((action) => {
3131
if (Close) action.Transition("close");
3232
});
3333
})
3434
.State(DoorState.Closed, (close) => {
35-
close.SetTransition("open", DoorState.Opened)
35+
close
36+
.SetTransition("open", DoorState.Opened)
3637
.SetAnimatorBool("open", false)
3738
.Update((action) => {
3839
if (Open && _lock.CurrentState.Id.Equals(LockState.Unlocked)) {
@@ -46,14 +47,16 @@ private void Start () {
4647
.Owner(gameObject)
4748
.Default(LockState.Unlocked)
4849
.State(LockState.Locked, (locked) => {
49-
locked.SetTransition("unlock", LockState.Unlocked)
50+
locked
51+
.SetTransition("unlock", LockState.Unlocked)
5052
.SetAnimatorBool("lock", true)
5153
.Update((action) => {
5254
if (ToggleLock) action.Transition("unlock");
5355
});
5456
})
5557
.State(LockState.Unlocked, (unlocked) => {
56-
unlocked.SetTransition("lock", LockState.Locked)
58+
unlocked
59+
.SetTransition("lock", LockState.Locked)
5760
.SetAnimatorBool("lock", false)
5861
.Update((action) => {
5962
if (ToggleLock && _door.CurrentState.Id.Equals(DoorState.Closed)) {
@@ -63,6 +66,10 @@ private void Start () {
6366
})
6467
.Build();
6568
}
69+
70+
public void SetDoorTransition (string transition) {
71+
_door.CurrentState.Transition(transition);
72+
}
6673

6774
private void Update () {
6875
_door.Tick();
@@ -73,4 +80,4 @@ private void Update () {
7380
ToggleLock = false;
7481
}
7582
}
76-
}
83+
}

0 commit comments

Comments
 (0)