當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。