Yields instructions

This commit is contained in:
2017-02-11 20:57:49 +07:00
parent 290fd066b5
commit 21fe31585f
9 changed files with 527 additions and 343 deletions

View File

@@ -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; }
}
}
}