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 22
33namespace Adnc . FluidBT . Tasks {
44 public class RandomChance : ConditionBase {
5- private Random . State _state ;
6-
75 public float chance = 1 ;
86 public float outOf = 1 ;
97 public int seed ;
108
11- protected override void OnInit ( ) {
9+ protected override bool OnUpdate ( ) {
1210 var oldState = Random . state ;
1311
1412 if ( seed != 0 ) {
1513 Random . InitState ( seed ) ;
1614 }
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 ;
2515
2616 var percentage = chance / outOf ;
2717 var rng = Random . value ;
28-
29- Random . state = oldState ;
18+
19+ if ( seed != 0 ) {
20+ Random . state = oldState ;
21+ }
3022
3123 return rng <= percentage ;
3224 }
You can’t perform that action at this time.
0 commit comments