Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 /// <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;
 }
Exemplo n.º 3
0
        /// <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)));
        }
Exemplo n.º 4
0
 private bool HotkeyPrevFrame()
 {
     if (PlaybackPanel != null)
     {
         PlaybackPanel.btnPrevFrame_Click(this, null);
     }
     return(true);
 }
Exemplo n.º 5
0
 private bool HotkeyFirstFrame()
 {
     if (PlaybackPanel != null)
     {
         PlaybackPanel.btnFirst_Click(this, null);
     }
     return(true);
 }
Exemplo n.º 6
0
                /// <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);
                }
Exemplo n.º 7
0
        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();
                }
            }
        }
Exemplo n.º 8
0
        private bool HotkeyPrevFrame()
        {
            PlaybackPanel?.btnPrevFrame_Click(this, null);

            return(true);
        }
Exemplo n.º 9
0
        private bool HotkeyFirstFrame()
        {
            PlaybackPanel?.btnFirst_Click(this, null);

            return(true);
        }
Exemplo n.º 10
0
 /// <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);
Exemplo n.º 11
0
 /// <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);