diff options
author | Justin Clark-Casey (justincc) | 2011-08-03 04:19:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-03 04:19:19 +0100 |
commit | 6e4ec2972266ae250337867fe1ba1944131f212d (patch) | |
tree | db0d334a9d0cc871bbdd83b86d703260befa25b5 /OpenSim/Region/OptionalModules/World/NPC | |
parent | Improve z axis move to/autopilot so the avatar does alternative crouch/huzzah... (diff) | |
download | opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.zip opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.gz opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.bz2 opensim-SC_OLD-6e4ec2972266ae250337867fe1ba1944131f212d.tar.xz |
Do a partial fix/implementation of OSSL osNpcMoveTo()
Avatar moves and stops. However, will stop in mid stride.
And if the move to position is in the air, avatar will continue to make vain and quite hilarious attempts to take off (but never doing so).
Clearly more work is needed.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8cb8318..fcfacc6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -46,12 +46,54 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
46 | 46 | ||
47 | // private const bool m_enabled = false; | 47 | // private const bool m_enabled = false; |
48 | 48 | ||
49 | private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); | 49 | private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); |
50 | private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>(); | 50 | private Dictionary<UUID, AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>(); |
51 | 51 | ||
52 | public void Initialise(Scene scene, IConfigSource source) | 52 | public void Initialise(Scene scene, IConfigSource source) |
53 | { | 53 | { |
54 | scene.RegisterModuleInterface<INPCModule>(this); | 54 | scene.RegisterModuleInterface<INPCModule>(this); |
55 | scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; | ||
56 | } | ||
57 | |||
58 | public void HandleOnSignificantClientMovement(ScenePresence presence) | ||
59 | { | ||
60 | lock (m_avatars) | ||
61 | { | ||
62 | if (m_avatars.ContainsKey(presence.UUID)) | ||
63 | { | ||
64 | double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); | ||
65 | // m_log.DebugFormat( | ||
66 | // "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}", | ||
67 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); | ||
68 | |||
69 | // Check the error term of the current position in relation to the target position | ||
70 | if (distanceToTarget <= 1) | ||
71 | { | ||
72 | // m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); | ||
73 | // We are close enough to the target for now | ||
74 | presence.ResetMoveToPosition(); | ||
75 | presence.Velocity = Vector3.Zero; | ||
76 | |||
77 | // FIXME: This doesn't work | ||
78 | if (presence.PhysicsActor.Flying) | ||
79 | presence.Animator.TrySetMovementAnimation("HOVER"); | ||
80 | else | ||
81 | presence.Animator.TrySetMovementAnimation("STAND"); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | Vector3 agent_control_v3 = new Vector3(); | ||
86 | presence.DoMoveToPositionUpdate(ref agent_control_v3, presence.Rotation, false, true); | ||
87 | presence.AddNewMovement(agent_control_v3, presence.Rotation); | ||
88 | } | ||
89 | // | ||
90 | //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); | ||
91 | |||
92 | // | ||
93 | // | ||
94 | |||
95 | } | ||
96 | } | ||
55 | } | 97 | } |
56 | 98 | ||
57 | private AvatarAppearance GetAppearance(UUID target, Scene scene) | 99 | private AvatarAppearance GetAppearance(UUID target, Scene scene) |
@@ -141,15 +183,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
141 | ScenePresence sp; | 183 | ScenePresence sp; |
142 | scene.TryGetScenePresence(agentID, out sp); | 184 | scene.TryGetScenePresence(agentID, out sp); |
143 | 185 | ||
144 | // m_log.DebugFormat( | 186 | m_log.DebugFormat( |
145 | // "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); | 187 | "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); |
146 | // | 188 | |
147 | // List<string> targetArgs = new List<string>(); | 189 | sp.DoMoveToPosition(0, pos, m_avatars[agentID]); |
148 | // targetArgs.Add(pos.X); | ||
149 | // targetArgs.Add(pos.Y); | ||
150 | // targetArgs.Add(pos.Z); | ||
151 | // sp.DoMoveToPosition(null, "NPC", targetArgs); | ||
152 | // sp.DoMoveToPosition(0, pos, m_avatars[agentID]); | ||
153 | } | 190 | } |
154 | } | 191 | } |
155 | } | 192 | } |