当前位置: 首页>>代码示例>>C#>>正文


C# ScenePresence.IsAtTarget方法代码示例

本文整理汇总了C#中OpenSim.Region.Framework.Scenes.ScenePresence.IsAtTarget方法的典型用法代码示例。如果您正苦于以下问题:C# ScenePresence.IsAtTarget方法的具体用法?C# ScenePresence.IsAtTarget怎么用?C# ScenePresence.IsAtTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Region.Framework.Scenes.ScenePresence的用法示例。


在下文中一共展示了ScenePresence.IsAtTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextPosition

        public bool GetNextPosition(ScenePresence scenePresence, float closeToRange, TimeSpan diffFromLastFrame, float secondsBeforeForcedTeleport,
                                    out Vector3 position, out TravelMode state, out bool needsToTeleportToPosition, out bool changingNodes)
        {
            changingNodes = false;
            lock (m_lock)
            {
                while(true)
                {
                    //Initialize default values
                    position = Vector3.Zero;
                    state = TravelMode.None;
                    needsToTeleportToPosition = false;

                    //See if we have a valid position to attempt to move to
                    if(CurrentPos < m_listOfPositions.Count)
                    {
                        //Get the position/state and make sure that it is within the region
                        position = m_listOfPositions[CurrentPos];
                        Util.ForceValidRegionXYZ(ref position);
                        state = m_listOfStates[CurrentPos];

                        if (state == TravelMode.Wait)
                        {
                            if (!m_waitingSince.HasValue)//Has no value, so we're just starting to wait
                                m_waitingSince = DateTime.Now;
                            else
                            {
                                double ms = (DateTime.Now - m_waitingSince.Value).TotalMilliseconds;
                                if (ms > (position.X * 1000f))
                                {
                                    //We're done waiting, increment the position counter and go around the loop again
                                    m_waitingSince = null;
                                    CurrentPos++;
                                    changingNodes = true;
                                    m_timeSinceLastChangedPosition = TimeSpan.FromMilliseconds(0);
                                    continue;
                                }
                            }
                            return true;
                        }
                        else
                        {
                            //We are attempting to move somewhere
                            if (scenePresence.IsAtTarget(position, closeToRange))
                            {
                                //We made it to the position, begin proceeding towards the next position 
                                CurrentPos++;
                                changingNodes = true;
                                m_timeSinceLastChangedPosition = TimeSpan.FromMilliseconds(0);
                                continue;
                            }
                            else 
                            {
                                m_timeSinceLastChangedPosition = m_timeSinceLastChangedPosition.Add(diffFromLastFrame);
                                //We need to see if we should teleport to the next node rather than waiting for us to get there
                                if (m_timeSinceLastChangedPosition.TotalMilliseconds > (secondsBeforeForcedTeleport * 1000))
                                {
                                    changingNodes = true;
                                    m_timeSinceLastChangedPosition = TimeSpan.FromMilliseconds(0);
                                    needsToTeleportToPosition = true;
                                }
                            }
                            return true;
                        }
                    }
                    else
                    {
                        //We've finished all the states in the position list
                        m_timeSinceLastChangedPosition = TimeSpan.FromMilliseconds(0);

                        if (m_listOfPositions.Count == 0)//Sanity check
                            return false;

                        if (FollowIndefinitely)
                        {
                            //If we're following indefinitely, then the counter is reset to the beginning and we go around again
                            CurrentPos = 0;
                            changingNodes = true;
                            continue;
                        }
                        return false;
                    }
                }
            }
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:85,代码来源:NodeGraph.cs


注:本文中的OpenSim.Region.Framework.Scenes.ScenePresence.IsAtTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。