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 --- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 7 +-- .../Region/OptionalModules/World/NPC/NPCModule.cs | 72 +--------------------- 2 files changed, 4 insertions(+), 75 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 31e79fa..edb618e 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -37,11 +37,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public class NPCAvatar : IClientAPI { - /// - /// Signal whether the avatar should land when it reaches a move target - /// - public bool LandAtTarget { get; set; } - private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; @@ -333,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 6282245..bcd9e94 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -53,78 +53,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (config != null && config.GetBoolean("Enabled", false)) { scene.RegisterModuleInterface(this); -// scene.EventManager.OnSignificantClientMovement += 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); - - presence.Velocity = Vector3.Zero; - presence.AbsolutePosition = presence.MoveToPositionTarget; - presence.ResetMoveToTarget(); - - if (presence.PhysicsActor.Flying) - { - // A horrible hack to stop the NPC 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.PhysicsActor.IsColliding = true; - -// Vector3 targetPos = presence.MoveToPositionTarget; - if (m_avatars[presence.UUID].LandAtTarget) - presence.PhysicsActor.Flying = false; - -// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; -// if (targetPos.Z - terrainHeight < 0.2) -// { -// presence.PhysicsActor.Flying = false; -// } - } - -// m_log.DebugFormat( -// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}", -// presence.AgentControlFlags, presence.MovementFlag, presence.Name); - } - 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.AddNewMovement(agent_control_v3); - } -// -//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); - -// -// - - } } } public bool IsNPC(UUID agentId, Scene scene) { + // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect + // that directly). ScenePresence sp = scene.GetScenePresence(agentId); if (sp == null || sp.IsChildAgent) return false; @@ -218,8 +153,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); - m_avatars[agentID].LandAtTarget = landAtTarget; - sp.MoveToTarget(pos, noFly); + sp.MoveToTarget(pos, noFly, landAtTarget); return true; } -- cgit v1.1