File tree Expand file tree Collapse file tree 1 file changed +5
-13
lines changed
Assets/FluidBehaviorTree/Scripts/Tasks/Conditions Expand file tree Collapse file tree 1 file changed +5
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Adnc . FluidBT . Tasks {
4
4
public class RandomChance : ConditionBase {
5
- private Random . State _state ;
6
-
7
5
public float chance = 1 ;
8
6
public float outOf = 1 ;
9
7
public int seed ;
10
8
11
- protected override void OnInit ( ) {
9
+ protected override bool OnUpdate ( ) {
12
10
var oldState = Random . state ;
13
11
14
12
if ( seed != 0 ) {
15
13
Random . InitState ( seed ) ;
16
14
}
17
-
18
- _state = Random . state ;
19
- Random . state = oldState ;
20
- }
21
-
22
- protected override bool OnUpdate ( ) {
23
- var oldState = Random . state ;
24
- Random . state = _state ;
25
15
26
16
var percentage = chance / outOf ;
27
17
var rng = Random . value ;
28
-
29
- Random . state = oldState ;
18
+
19
+ if ( seed != 0 ) {
20
+ Random . state = oldState ;
21
+ }
30
22
31
23
return rng <= percentage ;
32
24
}
You can’t perform that action at this time.
0 commit comments