/// <inheritdoc/> public override IEnumerator Apply(PlaybackPanel playbackPanel, TriggerEffector triggerEffector, ITriggerAgent triggerAgent) { if (!(triggerEffector is WaitingPointEffector waitingPointEffector)) { ScenarioManager.Instance.logPanel.EnqueueError( $"Invalid trigger effector passed to the {GetType().Name}."); yield break; } var egos = ScenarioManager.Instance.GetExtension <ScenarioAgentsManager>().Agents .Where(a => a.Source.AgentType == AgentType.Ego).ToArray(); //Make parent npc wait until any ego is closer than the max distance var lowestDistance = float.PositiveInfinity; do { foreach (var ego in egos) { var distance = Vector3.Distance(waitingPointEffector.ActivatorPoint, ego.TransformForPlayback.position); if (distance < lowestDistance) { lowestDistance = distance; } } yield return(null); } while (lowestDistance > waitingPointEffector.PointRadius); }
/// <inheritdoc/> public override IEnumerator Apply(PlaybackPanel playbackPanel, TriggerEffector triggerEffector, ITriggerAgent triggerAgent) { ScenarioManager.Instance.logPanel.EnqueueInfo( $"{OverriddenEffectorType.Name} is omitted in the playback mode."); yield break; }
/// <inheritdoc/> public override IEnumerator Apply(PlaybackPanel playbackPanel, TriggerEffector triggerEffector, ITriggerAgent triggerAgent) { if (!(triggerEffector is TimeToCollisionEffector ttcEffector)) { ScenarioManager.Instance.logPanel.EnqueueError( $"Invalid trigger effector passed to the {GetType().Name}."); yield break; } var egos = ScenarioManager.Instance.GetExtension <ScenarioAgentsManager>().Agents .Where(a => a.Source.AgentType == AgentType.Ego); ScenarioAgent collisionEgo = null; var lowestTTC = TimeToCollisionEffector.TimeToCollisionLimit; foreach (var ego in egos) { var ttc = ttcEffector.CalculateTTC(ego, triggerAgent, triggerAgent.MovementSpeed); if (ttc >= lowestTTC || ttc < 0.0f) { continue; } lowestTTC = ttc; collisionEgo = ego; } yield return(playbackPanel.StartCoroutine(ttcEffector.Apply(lowestTTC, collisionEgo, triggerAgent))); }
private bool HotkeyPrevFrame() { if (PlaybackPanel != null) { PlaybackPanel.btnPrevFrame_Click(this, null); } return(true); }
private bool HotkeyFirstFrame() { if (PlaybackPanel != null) { PlaybackPanel.btnFirst_Click(this, null); } return(true); }
/// <summary> /// Play the action starting from the initial playback time /// </summary> /// <param name="coroutinesParent"><see cref="PlaybackPanel"/> that will run the nested coroutines</param> /// <param name="initialTime">Playback initial time</param> /// <returns>Coroutine IEnumerator</returns> public virtual IEnumerator Playback(PlaybackPanel coroutinesParent, float initialTime) { for (var t = initialTime; t < EndTime; t += Time.deltaTime) { Perform(t); yield return(null); } Perform(EndTime); }
public virtual void SetFrame(int index) { if (index < 0) { return; } NW4RAnimationNode node = TargetAnimation; int loopMax = _maxFrame + (node != null && node.Loop && Interpolated.Contains(node.GetType()) ? 1 : 0); if (index > loopMax) { return; } CurrentFrame = index; if (PlaybackPanel != null) { if (PlaybackPanel.InvokeRequired) { Action <int, int> d = new Action <int, int>(PlaybackPanel.UpdateInterface); this.Invoke(d, new object[] { _animFrame, loopMax }); } else { PlaybackPanel.UpdateInterface(_animFrame, loopMax); } } if (!_playing) { if (InterpolationEditor != null && InterpolationEditor.Visible) { InterpolationEditor.Frame = CurrentFrame; } if (KeyframePanel != null) { KeyframePanel.numFrame_ValueChanged(); } } }
private bool HotkeyPrevFrame() { PlaybackPanel?.btnPrevFrame_Click(this, null); return(true); }
private bool HotkeyFirstFrame() { PlaybackPanel?.btnFirst_Click(this, null); return(true); }
/// <summary> /// Overridden apply method for the playback mode /// </summary> /// <param name="playbackPanel">Playback panel that will run coroutines</param> /// <param name="triggerEffector">Trigger effector that was overridden by this script</param> /// <param name="triggerAgent">Trigger agent affected by the effector</param> /// <returns>Coroutine IEnumerator</returns> public abstract IEnumerator Apply(PlaybackPanel playbackPanel, TriggerEffector triggerEffector, ITriggerAgent triggerAgent);
/// <summary> /// Precache whole playback while playing the simulation in coroutine /// </summary> /// <param name="playbackPanel">Playback panel that will run coroutines</param> /// <returns>Coroutine IEnumerator</returns> public abstract IEnumerator PrecachePlayback(PlaybackPanel playbackPanel);