File tree Expand file tree Collapse file tree 1 file changed +12
-21
lines changed
Assets/Scripts/BehaviorTree/Base Expand file tree Collapse file tree 1 file changed +12
-21
lines changed Original file line number Diff line number Diff line change @@ -49,38 +49,29 @@ public void Detach(Node child)
4949
5050 public object GetData ( string key )
5151 {
52- object value = null ;
53- if ( _dataContext . TryGetValue ( key , out value ) )
54- return value ;
52+ object val = null ;
53+ if ( _data . TryGetValue ( key , out val ) )
54+ return val ;
5555
5656 Node node = _parent ;
57- while ( node != null )
58- {
59- value = node . GetData ( key ) ;
60- if ( value != null )
61- return value ;
62- node = node . _parent ;
63- }
64- return null ;
57+ if ( node != null )
58+ val = node . GetData ( key ) ;
59+ return val ;
6560 }
6661
6762 public bool ClearData ( string key )
6863 {
69- if ( _dataContext . ContainsKey ( key ) )
64+ bool cleared = false ;
65+ if ( _data . ContainsKey ( key ) )
7066 {
71- _dataContext . Remove ( key ) ;
67+ _data . Remove ( key ) ;
7268 return true ;
7369 }
7470
7571 Node node = _parent ;
76- while ( node != null )
77- {
78- bool cleared = node . ClearData ( key ) ;
79- if ( cleared )
80- return true ;
81- node = node . _parent ;
82- }
83- return false ;
72+ if ( node != null )
73+ cleared = node . ClearData ( key ) ;
74+ return cleared ;
8475 }
8576
8677 public void SetData ( string key , object value )
You can’t perform that action at this time.
0 commit comments