From d358125cac4e01194dae4b1f0bc9afc87e463f76 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Thu, 22 Sep 2011 00:16:05 +0100
Subject: Reinstate option to land an npc when it reaches a target.
This is moved into ScenePresence for now as a general facility
---
OpenSim/Region/Framework/Scenes/Scene.cs | 6 +++---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 ++++++++++-
.../Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | 4 ++--
4 files changed, 16 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 000a6ed..eadec09 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5178,10 +5178,10 @@ namespace OpenSim.Region.Framework.Scenes
for (int i = 0; i < 5; i++)
presence.PhysicsActor.IsColliding = true;
-// Vector3 targetPos = presence.MoveToPositionTarget;
-// if (m_avatars[presence.UUID].LandAtTarget)
-// presence.PhysicsActor.Flying = false;
+ if (presence.LandAtTarget)
+ presence.PhysicsActor.Flying = false;
+// Vector3 targetPos = presence.MoveToPositionTarget;
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
// if (targetPos.Z - terrainHeight < 0.2)
// {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index e7f2491..980b01f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1599,7 +1599,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
- avatar.MoveToTarget(target, false);
+ avatar.MoveToTarget(target, false, false);
}
}
else
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 82d9abf..a7b189b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -220,6 +220,11 @@ namespace OpenSim.Region.Framework.Scenes
public bool MovingToTarget { get; private set; }
public Vector3 MoveToPositionTarget { get; private set; }
+ ///
+ /// Controls whether an avatar automatically moving to a target will land when it gets there (if flying).
+ ///
+ public bool LandAtTarget { get; private set; }
+
private bool m_followCamAuto;
private int m_movementUpdateCount;
@@ -1681,7 +1686,10 @@ namespace OpenSim.Region.Framework.Scenes
/// This is to allow movement to targets that are known to be on an elevated platform with a continuous path
/// from start to finish.
///
- public void MoveToTarget(Vector3 pos, bool noFly)
+ ///
+ /// If true and the avatar starts flying during the move then land at the target.
+ ///
+ public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget)
{
m_log.DebugFormat(
"[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}",
@@ -1720,6 +1728,7 @@ namespace OpenSim.Region.Framework.Scenes
else if (pos.Z > terrainHeight)
PhysicsActor.Flying = true;
+ LandAtTarget = landAtTarget;
MovingToTarget = true;
MoveToPositionTarget = pos;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index 5a85d7f..64c36ff 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -85,7 +85,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
Vector3 targetPos = startPos + new Vector3(0, 10, 0);
- sp.MoveToTarget(targetPos, false);
+ sp.MoveToTarget(targetPos, false, false);
Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
Assert.That(
@@ -110,7 +110,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Try a second movement
startPos = sp.AbsolutePosition;
targetPos = startPos + new Vector3(10, 0, 0);
- sp.MoveToTarget(targetPos, false);
+ sp.MoveToTarget(targetPos, false, false);
Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
Assert.That(
--
cgit v1.1