Add state-based effect.
This commit is contained in:
@@ -35,10 +35,14 @@ namespace Cryville.Crtr {
|
||||
while (_endQueue.Count > 0) {
|
||||
var item = _endQueue[0];
|
||||
if (item.EndTime > _time) break;
|
||||
item.OnDone();
|
||||
_instances.Remove(item.Index);
|
||||
_pool.Return(item);
|
||||
_endQueue.RemoveAt(0);
|
||||
if (item.OnStateDone()) {
|
||||
QueueInstance(item);
|
||||
}
|
||||
else {
|
||||
_instances.Remove(item.Index);
|
||||
_pool.Return(item);
|
||||
}
|
||||
}
|
||||
foreach (var instance in _instances) {
|
||||
instance.Value.Tick(time);
|
||||
@@ -46,18 +50,21 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
public void Emit(float index) {
|
||||
EffectInstance instance;
|
||||
if (_instances.TryGetValue(index, out instance)) {
|
||||
var i = _endQueue.BinarySearch(instance);
|
||||
_endQueue.RemoveAt(i);
|
||||
}
|
||||
else {
|
||||
_instances.Add(index, instance = _pool.Rent());
|
||||
}
|
||||
instance.Rewind(_time);
|
||||
bool flag = _instances.TryGetValue(index, out instance);
|
||||
if (!flag) _instances.Add(index, instance = _pool.Rent());
|
||||
instance.Index = index;
|
||||
instance.OnEmit(_time);
|
||||
var i2 = ~_endQueue.BinarySearch(instance);
|
||||
_endQueue.Insert(i2, instance);
|
||||
if (instance.CanEmit()) {
|
||||
if (flag) {
|
||||
var i = _endQueue.BinarySearch(instance);
|
||||
_endQueue.RemoveAt(i);
|
||||
}
|
||||
instance.OnEmit(_time);
|
||||
QueueInstance(instance);
|
||||
}
|
||||
}
|
||||
void QueueInstance(EffectInstance i) {
|
||||
var index = ~_endQueue.BinarySearch(i);
|
||||
_endQueue.Insert(index, i);
|
||||
}
|
||||
public void Dispose() {
|
||||
_pool.DisposeAll();
|
||||
|
Reference in New Issue
Block a user