mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-15 12:29:49 +07:00
Yields instructions
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace FTRuntime.Yields {
|
||||
public class SwfWaitPlayStopped : IEnumerator {
|
||||
SwfClipController _waitCtrl;
|
||||
|
||||
public SwfWaitPlayStopped(SwfClipController ctrl) {
|
||||
Subscribe(ctrl);
|
||||
}
|
||||
|
||||
public SwfWaitPlayStopped Reuse(SwfClipController ctrl) {
|
||||
return Subscribe(ctrl);
|
||||
}
|
||||
|
||||
//
|
||||
// Private
|
||||
//
|
||||
|
||||
SwfWaitPlayStopped Subscribe(SwfClipController ctrl) {
|
||||
(this as IEnumerator).Reset();
|
||||
if ( ctrl ) {
|
||||
_waitCtrl = ctrl;
|
||||
ctrl.OnPlayStoppedEvent += OnPlayStopped;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
void OnPlayStopped(SwfClipController ctrl) {
|
||||
(this as IEnumerator).Reset();
|
||||
}
|
||||
|
||||
//
|
||||
// IEnumerator
|
||||
//
|
||||
|
||||
bool IEnumerator.MoveNext() {
|
||||
return _waitCtrl != null;
|
||||
}
|
||||
|
||||
void IEnumerator.Reset() {
|
||||
if ( _waitCtrl != null ) {
|
||||
_waitCtrl.OnPlayStoppedEvent -= OnPlayStopped;
|
||||
_waitCtrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
object IEnumerator.Current {
|
||||
get { return null; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user