diff options
Merge branch 'bigmerge' of ssh://3dhosting.de/var/git/careminster into bigmerge
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 72 |
1 files changed, 3 insertions, 69 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 2fdeeab..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 | } |