本文整理汇总了C#中OpenSim.Region.Framework.Scenes.ScenePresence.HandleMoveToTargetUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# ScenePresence.HandleMoveToTargetUpdate方法的具体用法?C# ScenePresence.HandleMoveToTargetUpdate怎么用?C# ScenePresence.HandleMoveToTargetUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.ScenePresence
的用法示例。
在下文中一共展示了ScenePresence.HandleMoveToTargetUpdate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
//
//
}
}
}
示例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);
}
}
}