public void Enqueue(PlayAtTimeInstruction instruction) { if (Count == instructions.Length) { Array.Resize(ref instructions, instructions.Length + bufferSizeIncrement); } if (Count == 0) { instruction = MovedToTopOfQueue(instruction, animationLayer.currentPlayedState, animationLayer.stateMixer, animationLayer.states); } instructions[Count] = instruction; Count++; }
private PlayAtTimeInstruction MovedToTopOfQueue(PlayAtTimeInstruction playAtTime, int currentState, AnimationMixerPlayable stateMixer, List <AnimationPlayerState> states) { switch (playAtTime.type) { case QueueStateType.WhenCurrentDone: { var(_, currentStateIsDoneAt) = GetCurrentStateTimeInfo(); playAtTime.isDoneTime = currentStateIsDoneAt; break; } case QueueStateType.AfterSeconds: if (!playAtTime.CountFromQueued) { playAtTime.isDoneTime = Time.time + playAtTime.Seconds; } break; case QueueStateType.BeforeCurrentDone_Seconds: { var(_, currentStateIsDoneAt) = GetCurrentStateTimeInfo(); playAtTime.isDoneTime = currentStateIsDoneAt - playAtTime.Seconds; break; } case QueueStateType.BeforeCurrentDone_Relative: { var(currentStateDuration, currentStateIsDoneAt) = GetCurrentStateTimeInfo(); playAtTime.isDoneTime = currentStateIsDoneAt - playAtTime.RelativeDuration * currentStateDuration; break; } default: throw new ArgumentOutOfRangeException(); } return(playAtTime); (float currentStateDuration, float currentStateDoneAt) GetCurrentStateTimeInfo() { var duration = states[currentState].Duration; var playedTime = (float)stateMixer.GetInput(currentState).GetTime(); var currentIsDoneTime = Time.time + (duration - playedTime); return(duration, currentIsDoneTime); } }
public void Enqueue(PlayAtTimeInstruction instruction) { if (Count == instructions.Length) { Array.Resize(ref instructions, instructions.Length + bufferSizeIncrement); } var toInsert = instruction; for (int i = 0; i < Count - 1; i++) { if (instruction.playAtTime < instructions[i].playAtTime) { var temp = toInsert; toInsert = instructions[i]; instructions[i] = temp; } } instructions[Count] = toInsert; Count++; }