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


C# ScenePresence.ResetMoveToTarget方法代码示例

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


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

示例1: HandleOnSignificantClientMovement

        public void HandleOnSignificantClientMovement(ScenePresence presence)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget)
                {
                    double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
//                            m_log.DebugFormat(
//                                "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}",
//                                presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);

                    // Check the error term of the current position in relation to the target position
                    if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
                    {
                        // We are close enough to the target
                        m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name);

                        if (presence.PhysicsActor.Flying)
                        {
                            Vector3 targetPos = presence.MoveToPositionTarget;
                            float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
                            if (targetPos.Z - terrainHeight < 0.2)
                            {
                                presence.PhysicsActor.Flying = false;
                            }
                        }

                        presence.Velocity = Vector3.Zero;
                        presence.AbsolutePosition = presence.MoveToPositionTarget;
                        presence.ResetMoveToTarget();

                        // FIXME: This doesn't work
                        if (presence.PhysicsActor.Flying)
                            presence.Animator.TrySetMovementAnimation("HOVER");
                        else
                            presence.Animator.TrySetMovementAnimation("STAND");
                    }
                    else
                    {
                        m_log.DebugFormat(
                            "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}",
                            presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);

                        Vector3 agent_control_v3 = new Vector3();
                        presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation);
                        presence.AddNewMovement(agent_control_v3, presence.Rotation);
                    }
//
////                    presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null);

//
//

                }
            }
        }
开发者ID:HGExchange,项目名称:opensim,代码行数:56,代码来源:NPCModule.cs

示例2: HandleOnSignificantClientMovement

        /// <summary>
        /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
        /// autopilot that moves an avatar to a sit target!.
        /// </summary>
        /// <remarks>
        /// This is not intended as a permament location for this method.
        /// </remarks>
        /// <param name="presence"></param>
        private void HandleOnSignificantClientMovement(ScenePresence presence)
        {
            if (presence.MovingToTarget)
            {
                double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
//                            m_log.DebugFormat(
//                                "[SCENE]: Abs pos of {0} is {1}, target {2}, distance {3}",
//                                presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);

                // Check the error term of the current position in relation to the target position
                if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
                {
                    // We are close enough to the target
//                        m_log.DebugFormat("[SCENEE]: Stopping autopilot of  {0}", presence.Name);

                    presence.Velocity = Vector3.Zero;
                    presence.AbsolutePosition = presence.MoveToPositionTarget;
                    presence.ResetMoveToTarget();

                    if (presence.Flying)
                    {
                        // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
                        // the target if flying.
                        // We really need to be more subtle (slow the avatar as it approaches the target) or at
                        // least be able to set collision status once, rather than 5 times to give it enough
                        // weighting so that that PhysicsActor thinks it really is colliding.
                        for (int i = 0; i < 5; i++)
                            presence.IsColliding = true;

                        if (presence.LandAtTarget)
                            presence.Flying = false;

//                            Vector3 targetPos = presence.MoveToPositionTarget;
//                            float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
//                            if (targetPos.Z - terrainHeight < 0.2)
//                            {
//                                presence.Flying = false;
//                            }
                    }

//                        m_log.DebugFormat(
//                            "[SCENE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
//                            presence.AgentControlFlags, presence.MovementFlag, presence.Name);
                }
                else
                {
//                        m_log.DebugFormat(
//                            "[SCENE]: Updating npc {0} at {1} for next movement to {2}",
//                            presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);

                    Vector3 agent_control_v3 = new Vector3();
                    presence.HandleMoveToTargetUpdate(1, ref agent_control_v3);
                    presence.AddNewMovement(agent_control_v3);
                }
            }
        }
开发者ID:CCIR,项目名称:opensim,代码行数:64,代码来源:Scene.cs

示例3: ForceAvatarToPosition

        private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
        {
            if (m_scene.Permissions.IsGod(avatar.UUID)) return;

            if (!position.HasValue)
                return;

            if(avatar.MovingToTarget)
                avatar.ResetMoveToTarget();
            avatar.AbsolutePosition = position.Value;
            avatar.lastKnownAllowedPosition = position.Value;
            avatar.Velocity = Vector3.Zero;
            if(avatar.IsSatOnObject)
                avatar.StandUp();
            forcedPosition.Add(avatar.UUID);
        }
开发者ID:nebadon2025,项目名称:opensimulator,代码行数:16,代码来源:LandManagementModule.cs


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