@@ -18,7 +18,6 @@ namespace Inferno
1818 /// </summary>
1919 public abstract class InfernoScript : Script
2020 {
21-
2221 protected Random Random = new Random ( ) ;
2322
2423 private readonly ReactiveProperty < bool > _isActiveReactiveProperty = new ReactiveProperty < bool > ( false ) ;
@@ -44,6 +43,7 @@ protected IScheduler InfernoScriptScheduler
4443 {
4544 throw new Exception ( "設定ファイル名が設定されていません" ) ;
4645 }
46+
4747 var loader = new InfernoConfigLoader < T > ( ) ;
4848 var dto = loader . LoadSettingFile ( ConfigFileName ) ;
4949 //バリデーションに引っかかったらデフォルト値を返す
@@ -62,7 +62,8 @@ protected bool IsActive
6262 /// <summary>
6363 /// IsActiveが変化したことを通知する
6464 /// </summary>
65- protected UniRx . IObservable < bool > IsActiveAsObservable => _isActiveReactiveProperty . AsObservable ( ) . DistinctUntilChanged ( ) ;
65+ protected UniRx . IObservable < bool > IsActiveAsObservable =>
66+ _isActiveReactiveProperty . AsObservable ( ) . DistinctUntilChanged ( ) ;
6667
6768 #region Chace
6869
@@ -72,21 +73,18 @@ protected bool IsActive
7273 public Ped PlayerPed => cahcedPlayerPed ?? Game . Player . Character ;
7374
7475 private Ped cahcedPlayerPed ;
75- public ReactiveProperty < Vehicle > PlayerVehicle = new ReactiveProperty < Vehicle > ( ) ;
76+ public readonly ReactiveProperty < Vehicle > PlayerVehicle = new ReactiveProperty < Vehicle > ( ) ;
7677
77- private Ped [ ] _cachedPeds = new Ped [ 0 ] ;
7878
7979 /// <summary>
8080 /// キャッシュされたプレイヤ周辺の市民
8181 /// </summary>
82- public Ped [ ] CachedPeds => _cachedPeds ;
83-
84- private Vehicle [ ] _cachedVehicles = new Vehicle [ 0 ] ;
85-
82+ public Ped [ ] CachedPeds => InfernoCore . Instance . PedsNearPlayer . Value ;
83+
8684 /// <summary>
8785 /// キャッシュされたプレイヤ周辺の車両
8886 /// </summary>
89- public ReadOnlyCollection < Vehicle > CachedVehicles => Array . AsReadOnly ( _cachedVehicles ?? new Vehicle [ 0 ] ) ;
87+ public Vehicle [ ] CachedVehicles => InfernoCore . Instance . VehicleNearPlayer . Value ;
9088
9189 #endregion Chace
9290
@@ -116,9 +114,10 @@ public UniRx.IObservable<KeyEventArgs> OnKeyDownAsObservable
116114 if ( _onKeyDownAsObservable != null ) return _onKeyDownAsObservable ;
117115 _onKeyDownAsObservable =
118116 Observable . FromEventPattern < KeyEventHandler , KeyEventArgs > ( h => h . Invoke , h => KeyDown += h ,
119- h => KeyDown -= h )
117+ h => KeyDown -= h )
120118 . Select ( e => e . EventArgs )
121- . Publish ( ) . RefCount ( ) ;
119+ . Publish ( )
120+ . RefCount ( ) ;
122121 return _onKeyDownAsObservable ;
123122 }
124123 }
@@ -149,7 +148,8 @@ protected UniRx.IObservable<Unit> CreateInputKeywordAsObservable(string keyword)
149148 . Select ( x => x . Aggregate ( ( p , c ) => p + c ) )
150149 . Where ( x => x == keyword . ToUpper ( ) ) //入力文字列を比較
151150 . Select ( _ => Unit . Default )
152- . First ( ) . Repeat ( ) //1回動作したらBufferをクリア
151+ . First ( )
152+ . Repeat ( ) //1回動作したらBufferをクリア
153153 . Publish ( )
154154 . RefCount ( ) ;
155155 }
@@ -161,6 +161,7 @@ protected UniRx.IObservable<Unit> CreateTickAsObservable(TimeSpan timeSpan)
161161 {
162162 return OnTickAsObservable . ThrottleFirst ( timeSpan , InfernoScriptScheduler ) . Share ( ) ;
163163 }
164+
164165 #endregion forEvents
165166
166167 #region forAbort
@@ -192,11 +193,11 @@ protected UniRx.IObservable<Unit> OnAbortAsync
192193 return _onAbortObservable ??
193194 ( _onAbortObservable =
194195 Observable . FromEventPattern < EventHandler , EventArgs > ( h => h . Invoke , h => Aborted += h ,
195- h => Aborted -= h ) . AsUnitObservable ( ) ) ;
196+ h => Aborted -= h )
197+ . AsUnitObservable ( ) ) ;
196198 }
197199 }
198200
199-
200201 #endregion
201202
202203 #region forCoroutine
@@ -219,7 +220,6 @@ protected void StopAllCoroutine()
219220 }
220221
221222
222-
223223 /// <summary>
224224 /// 指定秒数待機するIEnumerable
225225 /// </summary>
@@ -295,15 +295,14 @@ protected InfernoScript()
295295 . First ( )
296296 . Subscribe ( _ =>
297297 {
298- InfernoCore . Instance . PedsNearPlayer . Subscribe ( x => _cachedPeds = x ) ;
299- InfernoCore . Instance . VehicleNearPlayer . Subscribe ( x => _cachedVehicles = x ) ;
300298 InfernoCore . Instance . PlayerPed . Subscribe ( x => cahcedPlayerPed = x ) ;
301299 InfernoCore . Instance . PlayerVehicle . Subscribe ( x => PlayerVehicle . Value = x ) ;
302300 } ) ;
303301
304302 OnTickAsObservable =
305303 Observable . FromEventPattern < EventHandler , EventArgs > ( h => h . Invoke , h => Tick += h , h => Tick -= h )
306- . Select ( _ => Unit . Default ) . Share ( ) ; //Subscribeされたらイベントハンドラを登録する
304+ . Select ( _ => Unit . Default )
305+ . Share ( ) ; //Subscribeされたらイベントハンドラを登録する
307306
308307 OnThinnedTickAsObservable =
309308 OnTickAsObservable . ThrottleFirst ( TimeSpan . FromMilliseconds ( 100 ) , InfernoScriptScheduler )
@@ -324,6 +323,7 @@ protected InfernoScript()
324323 {
325324 SynchronizationContext . SetSynchronizationContext ( InfernoSynchronizationContext ) ;
326325 }
326+
327327 InfernoSynchronizationContext . Update ( ) ;
328328 } ) ;
329329
@@ -336,6 +336,7 @@ protected InfernoScript()
336336 {
337337 c . Update ( 100 ) ;
338338 }
339+
339340 //完了状態にあるタイマを全て削除
340341 _counterList . RemoveAll ( x => x . IsCompleted ) ;
341342 } ) ;
@@ -354,6 +355,7 @@ protected InfernoScript()
354355 {
355356 e . MarkAsNoLongerNeeded ( ) ;
356357 }
358+
357359 _autoReleaseEntities . Clear ( ) ;
358360 } ) ;
359361
@@ -385,4 +387,4 @@ public void LogWrite(string message)
385387
386388 #endregion Debug
387389 }
388- }
390+ }
0 commit comments