diff options
author | Dan Lake | 2011-09-21 16:24:48 -0700 |
---|---|---|
committer | Dan Lake | 2011-09-21 16:24:48 -0700 |
commit | 28a482a7ee2cebab1aa720477af175d7e26d702e (patch) | |
tree | 863fb4b43a571da4d1d963b5a1383538e6391ec8 /OpenSim/Region/OptionalModules | |
parent | Commented out new debug statements in ScenePresence (diff) | |
parent | Reinstate option to land an npc when it reaches a target. (diff) | |
download | opensim-SC_OLD-28a482a7ee2cebab1aa720477af175d7e26d702e.zip opensim-SC_OLD-28a482a7ee2cebab1aa720477af175d7e26d702e.tar.gz opensim-SC_OLD-28a482a7ee2cebab1aa720477af175d7e26d702e.tar.bz2 opensim-SC_OLD-28a482a7ee2cebab1aa720477af175d7e26d702e.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
3 files changed, 5 insertions, 76 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index c413634..f6656c2 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
806 | public event ScriptReset OnScriptReset; | 806 | public event ScriptReset OnScriptReset; |
807 | public event GetScriptRunning OnGetScriptRunning; | 807 | public event GetScriptRunning OnGetScriptRunning; |
808 | public event SetScriptRunning OnSetScriptRunning; | 808 | public event SetScriptRunning OnSetScriptRunning; |
809 | public event Action<Vector3, bool> OnAutoPilotGo; | 809 | public event Action<Vector3, bool, bool> OnAutoPilotGo; |
810 | public event TerrainUnacked OnUnackedTerrain; | 810 | public event TerrainUnacked OnUnackedTerrain; |
811 | public event ActivateGesture OnActivateGesture; | 811 | public event ActivateGesture OnActivateGesture; |
812 | public event DeactivateGesture OnDeactivateGesture; | 812 | public event DeactivateGesture OnDeactivateGesture; |
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 | |||
37 | { | 37 | { |
38 | public class NPCAvatar : IClientAPI | 38 | public class NPCAvatar : IClientAPI |
39 | { | 39 | { |
40 | /// <summary> | ||
41 | /// Signal whether the avatar should land when it reaches a move target | ||
42 | /// </summary> | ||
43 | public bool LandAtTarget { get; set; } | ||
44 | |||
45 | private readonly string m_firstname; | 40 | private readonly string m_firstname; |
46 | private readonly string m_lastname; | 41 | private readonly string m_lastname; |
47 | private readonly Vector3 m_startPos; | 42 | private readonly Vector3 m_startPos; |
@@ -333,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
333 | public event ScriptReset OnScriptReset; | 328 | public event ScriptReset OnScriptReset; |
334 | public event GetScriptRunning OnGetScriptRunning; | 329 | public event GetScriptRunning OnGetScriptRunning; |
335 | public event SetScriptRunning OnSetScriptRunning; | 330 | public event SetScriptRunning OnSetScriptRunning; |
336 | public event Action<Vector3, bool> OnAutoPilotGo; | 331 | public event Action<Vector3, bool, bool> OnAutoPilotGo; |
337 | 332 | ||
338 | public event TerrainUnacked OnUnackedTerrain; | 333 | public event TerrainUnacked OnUnackedTerrain; |
339 | 334 | ||
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 | |||
53 | if (config != null && config.GetBoolean("Enabled", false)) | 53 | if (config != null && config.GetBoolean("Enabled", false)) |
54 | { | 54 | { |
55 | scene.RegisterModuleInterface<INPCModule>(this); | 55 | scene.RegisterModuleInterface<INPCModule>(this); |
56 | // scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | public void HandleOnSignificantClientMovement(ScenePresence presence) | ||
61 | { | ||
62 | lock (m_avatars) | ||
63 | { | ||
64 | if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget) | ||
65 | { | ||
66 | double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
67 | // m_log.DebugFormat( | ||
68 | // "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}", | ||
69 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); | ||
70 | |||
71 | // Check the error term of the current position in relation to the target position | ||
72 | if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) | ||
73 | { | ||
74 | // We are close enough to the target | ||
75 | m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); | ||
76 | |||
77 | presence.Velocity = Vector3.Zero; | ||
78 | presence.AbsolutePosition = presence.MoveToPositionTarget; | ||
79 | presence.ResetMoveToTarget(); | ||
80 | |||
81 | if (presence.PhysicsActor.Flying) | ||
82 | { | ||
83 | // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot | ||
84 | // the target if flying. | ||
85 | // We really need to be more subtle (slow the avatar as it approaches the target) or at | ||
86 | // least be able to set collision status once, rather than 5 times to give it enough | ||
87 | // weighting so that that PhysicsActor thinks it really is colliding. | ||
88 | for (int i = 0; i < 5; i++) | ||
89 | presence.PhysicsActor.IsColliding = true; | ||
90 | |||
91 | // Vector3 targetPos = presence.MoveToPositionTarget; | ||
92 | if (m_avatars[presence.UUID].LandAtTarget) | ||
93 | presence.PhysicsActor.Flying = false; | ||
94 | |||
95 | // float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; | ||
96 | // if (targetPos.Z - terrainHeight < 0.2) | ||
97 | // { | ||
98 | // presence.PhysicsActor.Flying = false; | ||
99 | // } | ||
100 | } | ||
101 | |||
102 | // m_log.DebugFormat( | ||
103 | // "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}", | ||
104 | // presence.AgentControlFlags, presence.MovementFlag, presence.Name); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | // m_log.DebugFormat( | ||
109 | // "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", | ||
110 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
111 | |||
112 | Vector3 agent_control_v3 = new Vector3(); | ||
113 | presence.HandleMoveToTargetUpdate(ref agent_control_v3); | ||
114 | presence.AddNewMovement(agent_control_v3); | ||
115 | } | ||
116 | // | ||
117 | //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); | ||
118 | |||
119 | // | ||
120 | // | ||
121 | |||
122 | } | ||
123 | } | 56 | } |
124 | } | 57 | } |
125 | 58 | ||
126 | public bool IsNPC(UUID agentId, Scene scene) | 59 | public bool IsNPC(UUID agentId, Scene scene) |
127 | { | 60 | { |
61 | // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect | ||
62 | // that directly). | ||
128 | ScenePresence sp = scene.GetScenePresence(agentId); | 63 | ScenePresence sp = scene.GetScenePresence(agentId); |
129 | if (sp == null || sp.IsChildAgent) | 64 | if (sp == null || sp.IsChildAgent) |
130 | return false; | 65 | return false; |
@@ -218,8 +153,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
218 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 153 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
219 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | 154 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); |
220 | 155 | ||
221 | m_avatars[agentID].LandAtTarget = landAtTarget; | 156 | sp.MoveToTarget(pos, noFly, landAtTarget); |
222 | sp.MoveToTarget(pos, noFly); | ||
223 | 157 | ||
224 | return true; | 158 | return true; |
225 | } | 159 | } |