diff options
author | Mic Bowman | 2011-08-19 14:49:16 -0700 |
---|---|---|
committer | Mic Bowman | 2011-08-19 14:49:16 -0700 |
commit | 384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f (patch) | |
tree | 5e557eac5d4d3d4ad95b9e3e70a2a661e5745ec3 /OpenSim/Region/OptionalModules | |
parent | BulletSim: add runtime setting of physics parameters. Update default values. (diff) | |
parent | Get rid of HttpServer.dll to avoid confusion since we use HttpServer_OpenSim.... (diff) | |
download | opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.zip opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.gz opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.bz2 opensim-SC-384cb79a1a27c47bb3fdbdef6d601a3dcb9dfb0f.tar.xz |
Merge branch 'master' into bulletsim
Conflicts:
OpenSim/Region/Framework/Scenes/SceneManager.cs
Diffstat (limited to 'OpenSim/Region/OptionalModules')
6 files changed, 148 insertions, 79 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a0c1ab1..c413634 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
677 | public event DeRezObject OnDeRezObject; | 677 | public event DeRezObject OnDeRezObject; |
678 | public event Action<IClientAPI> OnRegionHandShakeReply; | 678 | public event Action<IClientAPI> OnRegionHandShakeReply; |
679 | public event GenericCall1 OnRequestWearables; | 679 | public event GenericCall1 OnRequestWearables; |
680 | public event GenericCall1 OnCompleteMovementToRegion; | 680 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
681 | public event UpdateAgent OnPreAgentUpdate; | 681 | public event UpdateAgent OnPreAgentUpdate; |
682 | public event UpdateAgent OnAgentUpdate; | 682 | public event UpdateAgent OnAgentUpdate; |
683 | public event AgentRequestSit OnAgentRequestSit; | 683 | public event AgentRequestSit OnAgentRequestSit; |
@@ -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> OnAutoPilotGo; | 809 | public event Action<Vector3, 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; |
@@ -893,7 +893,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
893 | 893 | ||
894 | public void Start() | 894 | public void Start() |
895 | { | 895 | { |
896 | Scene.AddNewClient(this); | 896 | Scene.AddNewClient(this, PresenceType.User); |
897 | 897 | ||
898 | // Mimicking LLClientView which gets always set appearance from client. | 898 | // Mimicking LLClientView which gets always set appearance from client. |
899 | Scene scene = (Scene)Scene; | 899 | Scene scene = (Scene)Scene; |
@@ -913,7 +913,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
913 | 913 | ||
914 | if (OnCompleteMovementToRegion != null) | 914 | if (OnCompleteMovementToRegion != null) |
915 | { | 915 | { |
916 | OnCompleteMovementToRegion(this); | 916 | OnCompleteMovementToRegion(this, true); |
917 | } | 917 | } |
918 | } | 918 | } |
919 | 919 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index ee52a39..d2f6327 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -47,16 +47,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
47 | [Test] | 47 | [Test] |
48 | public void TestBasic() | 48 | public void TestBasic() |
49 | { | 49 | { |
50 | TestHelper.InMethod(); | 50 | TestHelpers.InMethod(); |
51 | // log4net.Config.XmlConfigurator.Configure(); | 51 | // log4net.Config.XmlConfigurator.Configure(); |
52 | 52 | ||
53 | TestScene scene = SceneSetupHelpers.SetupScene(); | 53 | TestScene scene = SceneHelpers.SetupScene(); |
54 | IConfigSource configSource = new IniConfigSource(); | 54 | IConfigSource configSource = new IniConfigSource(); |
55 | IConfig config = configSource.AddConfig("Groups"); | 55 | IConfig config = configSource.AddConfig("Groups"); |
56 | config.Set("Enabled", true); | 56 | config.Set("Enabled", true); |
57 | config.Set("Module", "GroupsModule"); | 57 | config.Set("Module", "GroupsModule"); |
58 | config.Set("DebugEnabled", true); | 58 | config.Set("DebugEnabled", true); |
59 | SceneSetupHelpers.SetupSceneModules( | 59 | SceneHelpers.SetupSceneModules( |
60 | scene, configSource, new object[] { new MockGroupsServicesConnector() }); | 60 | scene, configSource, new object[] { new MockGroupsServicesConnector() }); |
61 | } | 61 | } |
62 | } | 62 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index 05c729a..963d1e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | |||
@@ -126,6 +126,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
126 | m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; | 126 | m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; |
127 | m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; | 127 | m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded; |
128 | 128 | ||
129 | if(m_uri != string.Empty) | ||
130 | { | ||
131 | RRAlert("shutdown"); | ||
132 | } | ||
133 | |||
129 | m_scene = null; | 134 | m_scene = null; |
130 | } | 135 | } |
131 | 136 | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index dfc624d..31e79fa 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -37,6 +37,11 @@ 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 | |||
40 | private readonly string m_firstname; | 45 | private readonly string m_firstname; |
41 | private readonly string m_lastname; | 46 | private readonly string m_lastname; |
42 | private readonly Vector3 m_startPos; | 47 | private readonly Vector3 m_startPos; |
@@ -190,7 +195,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
190 | public event DeRezObject OnDeRezObject; | 195 | public event DeRezObject OnDeRezObject; |
191 | public event Action<IClientAPI> OnRegionHandShakeReply; | 196 | public event Action<IClientAPI> OnRegionHandShakeReply; |
192 | public event GenericCall1 OnRequestWearables; | 197 | public event GenericCall1 OnRequestWearables; |
193 | public event GenericCall1 OnCompleteMovementToRegion; | 198 | public event Action<IClientAPI, bool> OnCompleteMovementToRegion; |
194 | public event UpdateAgent OnPreAgentUpdate; | 199 | public event UpdateAgent OnPreAgentUpdate; |
195 | public event UpdateAgent OnAgentUpdate; | 200 | public event UpdateAgent OnAgentUpdate; |
196 | public event AgentRequestSit OnAgentRequestSit; | 201 | public event AgentRequestSit OnAgentRequestSit; |
@@ -328,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
328 | public event ScriptReset OnScriptReset; | 333 | public event ScriptReset OnScriptReset; |
329 | public event GetScriptRunning OnGetScriptRunning; | 334 | public event GetScriptRunning OnGetScriptRunning; |
330 | public event SetScriptRunning OnSetScriptRunning; | 335 | public event SetScriptRunning OnSetScriptRunning; |
331 | public event Action<Vector3> OnAutoPilotGo; | 336 | public event Action<Vector3, bool> OnAutoPilotGo; |
332 | 337 | ||
333 | public event TerrainUnacked OnUnackedTerrain; | 338 | public event TerrainUnacked OnUnackedTerrain; |
334 | 339 | ||
@@ -745,12 +750,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
745 | { | 750 | { |
746 | OnRegionHandShakeReply(this); | 751 | OnRegionHandShakeReply(this); |
747 | } | 752 | } |
748 | |||
749 | if (OnCompleteMovementToRegion != null) | ||
750 | { | ||
751 | OnCompleteMovementToRegion(this); | ||
752 | } | ||
753 | } | 753 | } |
754 | |||
754 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) | 755 | public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) |
755 | { | 756 | { |
756 | } | 757 | } |
@@ -841,6 +842,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
841 | 842 | ||
842 | public void Close() | 843 | public void Close() |
843 | { | 844 | { |
845 | // Remove ourselves from the scene | ||
846 | m_scene.RemoveClient(AgentId, false); | ||
844 | } | 847 | } |
845 | 848 | ||
846 | public void Start() | 849 | public void Start() |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 4f21d9d..c1da803 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -45,7 +45,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); | 47 | private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); |
48 | private Dictionary<UUID, AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>(); | ||
49 | 48 | ||
50 | public void Initialise(Scene scene, IConfigSource source) | 49 | public void Initialise(Scene scene, IConfigSource source) |
51 | { | 50 | { |
@@ -75,35 +74,44 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
75 | // We are close enough to the target | 74 | // We are close enough to the target |
76 | m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); | 75 | m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); |
77 | 76 | ||
78 | if (presence.PhysicsActor.Flying) | ||
79 | { | ||
80 | Vector3 targetPos = presence.MoveToPositionTarget; | ||
81 | float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; | ||
82 | if (targetPos.Z - terrainHeight < 0.2) | ||
83 | { | ||
84 | presence.PhysicsActor.Flying = false; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | presence.Velocity = Vector3.Zero; | 77 | presence.Velocity = Vector3.Zero; |
89 | presence.AbsolutePosition = presence.MoveToPositionTarget; | 78 | presence.AbsolutePosition = presence.MoveToPositionTarget; |
90 | presence.ResetMoveToTarget(); | 79 | presence.ResetMoveToTarget(); |
91 | 80 | ||
92 | // FIXME: This doesn't work | ||
93 | if (presence.PhysicsActor.Flying) | 81 | if (presence.PhysicsActor.Flying) |
94 | presence.Animator.TrySetMovementAnimation("HOVER"); | 82 | { |
95 | else | 83 | // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot |
96 | presence.Animator.TrySetMovementAnimation("STAND"); | 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); | ||
97 | } | 105 | } |
98 | else | 106 | else |
99 | { | 107 | { |
100 | m_log.DebugFormat( | 108 | // m_log.DebugFormat( |
101 | "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", | 109 | // "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", |
102 | presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); | 110 | // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); |
103 | 111 | ||
104 | Vector3 agent_control_v3 = new Vector3(); | 112 | Vector3 agent_control_v3 = new Vector3(); |
105 | presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); | 113 | presence.HandleMoveToTargetUpdate(ref agent_control_v3); |
106 | presence.AddNewMovement(agent_control_v3, presence.Rotation); | 114 | presence.AddNewMovement(agent_control_v3); |
107 | } | 115 | } |
108 | // | 116 | // |
109 | //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); | 117 | //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); |
@@ -115,29 +123,48 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
115 | } | 123 | } |
116 | } | 124 | } |
117 | 125 | ||
118 | private AvatarAppearance GetAppearance(UUID target, Scene scene) | 126 | public bool IsNPC(UUID agentId, Scene scene) |
127 | { | ||
128 | ScenePresence sp = scene.GetScenePresence(agentId); | ||
129 | if (sp == null || sp.IsChildAgent) | ||
130 | return false; | ||
131 | |||
132 | lock (m_avatars) | ||
133 | return m_avatars.ContainsKey(agentId); | ||
134 | } | ||
135 | |||
136 | public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) | ||
119 | { | 137 | { |
120 | if (m_appearanceCache.ContainsKey(target)) | 138 | ScenePresence sp = scene.GetScenePresence(agentId); |
121 | return m_appearanceCache[target]; | 139 | if (sp == null || sp.IsChildAgent) |
140 | return false; | ||
122 | 141 | ||
123 | ScenePresence originalPresence = scene.GetScenePresence(target); | 142 | lock (m_avatars) |
143 | if (!m_avatars.ContainsKey(agentId)) | ||
144 | return false; | ||
124 | 145 | ||
125 | if (originalPresence != null) | 146 | // FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it |
126 | { | 147 | List<SceneObjectGroup> attachments = sp.Attachments; |
127 | AvatarAppearance originalAppearance = originalPresence.Appearance; | 148 | lock (attachments) |
128 | m_appearanceCache.Add(target, originalAppearance); | ||
129 | return originalAppearance; | ||
130 | } | ||
131 | else | ||
132 | { | 149 | { |
133 | m_log.DebugFormat( | 150 | foreach (SceneObjectGroup att in attachments) |
134 | "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); | 151 | scene.DeleteSceneObject(att, false); |
135 | 152 | ||
136 | return new AvatarAppearance(); | 153 | attachments.Clear(); |
137 | } | 154 | } |
155 | |||
156 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); | ||
157 | sp.Appearance = npcAppearance; | ||
158 | sp.RezAttachments(); | ||
159 | |||
160 | IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>(); | ||
161 | module.SendAppearance(sp.UUID); | ||
162 | |||
163 | return true; | ||
138 | } | 164 | } |
139 | 165 | ||
140 | public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) | 166 | public UUID CreateNPC( |
167 | string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) | ||
141 | { | 168 | { |
142 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); | 169 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); |
143 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); | 170 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); |
@@ -152,8 +179,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
152 | acd.lastname = lastname; | 179 | acd.lastname = lastname; |
153 | acd.ServiceURLs = new Dictionary<string, object>(); | 180 | acd.ServiceURLs = new Dictionary<string, object>(); |
154 | 181 | ||
155 | AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); | 182 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); |
156 | AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); | ||
157 | acd.Appearance = npcAppearance; | 183 | acd.Appearance = npcAppearance; |
158 | 184 | ||
159 | // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) | 185 | // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) |
@@ -164,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
164 | // } | 190 | // } |
165 | 191 | ||
166 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | 192 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
167 | scene.AddNewClient(npcAvatar); | 193 | scene.AddNewClient(npcAvatar, PresenceType.Npc); |
168 | 194 | ||
169 | ScenePresence sp; | 195 | ScenePresence sp; |
170 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 196 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
@@ -172,13 +198,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
172 | m_log.DebugFormat( | 198 | m_log.DebugFormat( |
173 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | 199 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); |
174 | 200 | ||
175 | // Shouldn't call this - temporary. | 201 | sp.CompleteMovement(npcAvatar, false); |
176 | sp.CompleteMovement(npcAvatar); | ||
177 | |||
178 | // sp.SendAppearanceToAllOtherAgents(); | ||
179 | // | ||
180 | // // Send animations back to the avatar as well | ||
181 | // sp.Animator.SendAnimPack(); | ||
182 | } | 202 | } |
183 | else | 203 | else |
184 | { | 204 | { |
@@ -193,7 +213,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
193 | return npcAvatar.AgentId; | 213 | return npcAvatar.AgentId; |
194 | } | 214 | } |
195 | 215 | ||
196 | public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) | 216 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) |
197 | { | 217 | { |
198 | lock (m_avatars) | 218 | lock (m_avatars) |
199 | { | 219 | { |
@@ -203,34 +223,70 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
203 | scene.TryGetScenePresence(agentID, out sp); | 223 | scene.TryGetScenePresence(agentID, out sp); |
204 | 224 | ||
205 | m_log.DebugFormat( | 225 | m_log.DebugFormat( |
206 | "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); | 226 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
227 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | ||
228 | |||
229 | m_avatars[agentID].LandAtTarget = landAtTarget; | ||
230 | sp.MoveToTarget(pos, noFly); | ||
231 | |||
232 | return true; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | return false; | ||
237 | } | ||
238 | |||
239 | public bool StopMoveToTarget(UUID agentID, Scene scene) | ||
240 | { | ||
241 | lock (m_avatars) | ||
242 | { | ||
243 | if (m_avatars.ContainsKey(agentID)) | ||
244 | { | ||
245 | ScenePresence sp; | ||
246 | scene.TryGetScenePresence(agentID, out sp); | ||
207 | 247 | ||
208 | sp.MoveToTarget(pos); | 248 | sp.Velocity = Vector3.Zero; |
249 | sp.ResetMoveToTarget(); | ||
250 | |||
251 | return true; | ||
209 | } | 252 | } |
210 | } | 253 | } |
254 | |||
255 | return false; | ||
211 | } | 256 | } |
212 | 257 | ||
213 | public void Say(UUID agentID, Scene scene, string text) | 258 | public bool Say(UUID agentID, Scene scene, string text) |
214 | { | 259 | { |
215 | lock (m_avatars) | 260 | lock (m_avatars) |
216 | { | 261 | { |
217 | if (m_avatars.ContainsKey(agentID)) | 262 | if (m_avatars.ContainsKey(agentID)) |
218 | { | 263 | { |
264 | ScenePresence sp; | ||
265 | scene.TryGetScenePresence(agentID, out sp); | ||
266 | |||
219 | m_avatars[agentID].Say(text); | 267 | m_avatars[agentID].Say(text); |
268 | |||
269 | return true; | ||
220 | } | 270 | } |
221 | } | 271 | } |
272 | |||
273 | return false; | ||
222 | } | 274 | } |
223 | 275 | ||
224 | public void DeleteNPC(UUID agentID, Scene scene) | 276 | public bool DeleteNPC(UUID agentID, Scene scene) |
225 | { | 277 | { |
226 | lock (m_avatars) | 278 | lock (m_avatars) |
227 | { | 279 | { |
228 | if (m_avatars.ContainsKey(agentID)) | 280 | if (m_avatars.ContainsKey(agentID)) |
229 | { | 281 | { |
230 | scene.RemoveClient(agentID); | 282 | scene.RemoveClient(agentID, false); |
231 | m_avatars.Remove(agentID); | 283 | m_avatars.Remove(agentID); |
284 | |||
285 | return true; | ||
232 | } | 286 | } |
233 | } | 287 | } |
288 | |||
289 | return false; | ||
234 | } | 290 | } |
235 | 291 | ||
236 | public void PostInitialise() | 292 | public void PostInitialise() |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c9dddba..78296a4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -34,6 +34,7 @@ using OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
37 | using OpenSim.Region.CoreModules.Framework.UserManagement; | ||
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -49,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
49 | [Test] | 50 | [Test] |
50 | public void TestCreate() | 51 | public void TestCreate() |
51 | { | 52 | { |
52 | TestHelper.InMethod(); | 53 | TestHelpers.InMethod(); |
53 | // log4net.Config.XmlConfigurator.Configure(); | 54 | // log4net.Config.XmlConfigurator.Configure(); |
54 | 55 | ||
55 | IConfigSource config = new IniConfigSource(); | 56 | IConfigSource config = new IniConfigSource(); |
@@ -57,13 +58,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
57 | config.Configs["NPC"].Set("Enabled", "true"); | 58 | config.Configs["NPC"].Set("Enabled", "true"); |
58 | 59 | ||
59 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 60 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
60 | TestScene scene = SceneSetupHelpers.SetupScene(); | 61 | UserManagementModule umm = new UserManagementModule(); |
61 | SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); | 62 | |
62 | TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); | 63 | TestScene scene = SceneHelpers.SetupScene(); |
64 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); | ||
65 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
63 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 66 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
64 | 67 | ||
65 | // 8 is the index of the first baked texture in AvatarAppearance | 68 | // 8 is the index of the first baked texture in AvatarAppearance |
66 | UUID originalFace8TextureId = TestHelper.ParseTail(0x10); | 69 | UUID originalFace8TextureId = TestHelpers.ParseTail(0x10); |
67 | Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); | 70 | Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); |
68 | Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); | 71 | Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); |
69 | originalTef.TextureID = originalFace8TextureId; | 72 | originalTef.TextureID = originalFace8TextureId; |
@@ -72,21 +75,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
72 | // ScenePresence.SendInitialData() to reset our entire appearance. | 75 | // ScenePresence.SendInitialData() to reset our entire appearance. |
73 | scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); | 76 | scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); |
74 | 77 | ||
75 | afm.SetAppearance(originalClient, originalTe, null); | 78 | afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null); |
76 | 79 | ||
77 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 80 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
78 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); | 81 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); |
79 | 82 | ||
80 | ScenePresence npc = scene.GetScenePresence(npcId); | 83 | ScenePresence npc = scene.GetScenePresence(npcId); |
81 | 84 | ||
82 | Assert.That(npc, Is.Not.Null); | 85 | Assert.That(npc, Is.Not.Null); |
83 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); | 86 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); |
87 | Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); | ||
84 | } | 88 | } |
85 | 89 | ||
86 | [Test] | 90 | [Test] |
87 | public void TestMove() | 91 | public void TestMove() |
88 | { | 92 | { |
89 | TestHelper.InMethod(); | 93 | TestHelpers.InMethod(); |
90 | // log4net.Config.XmlConfigurator.Configure(); | 94 | // log4net.Config.XmlConfigurator.Configure(); |
91 | 95 | ||
92 | IConfigSource config = new IniConfigSource(); | 96 | IConfigSource config = new IniConfigSource(); |
@@ -94,14 +98,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
94 | config.AddConfig("NPC"); | 98 | config.AddConfig("NPC"); |
95 | config.Configs["NPC"].Set("Enabled", "true"); | 99 | config.Configs["NPC"].Set("Enabled", "true"); |
96 | 100 | ||
97 | TestScene scene = SceneSetupHelpers.SetupScene(); | 101 | TestScene scene = SceneHelpers.SetupScene(); |
98 | SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule()); | 102 | SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); |
99 | TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); | 103 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
100 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 104 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
101 | 105 | ||
102 | Vector3 startPos = new Vector3(128, 128, 30); | 106 | Vector3 startPos = new Vector3(128, 128, 30); |
103 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 107 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
104 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId); | 108 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); |
105 | 109 | ||
106 | ScenePresence npc = scene.GetScenePresence(npcId); | 110 | ScenePresence npc = scene.GetScenePresence(npcId); |
107 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 111 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
@@ -113,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
113 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 117 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
114 | 118 | ||
115 | Vector3 targetPos = startPos + new Vector3(0, 0, 10); | 119 | Vector3 targetPos = startPos + new Vector3(0, 0, 10); |
116 | npcModule.MoveToTarget(npc.UUID, scene, targetPos); | 120 | npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); |
117 | 121 | ||
118 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 122 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
119 | 123 | ||
@@ -131,11 +135,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
131 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); | 135 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); |
132 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); | 136 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); |
133 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); | 137 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); |
138 | Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); | ||
134 | 139 | ||
135 | // Try a second movement | 140 | // Try a second movement |
136 | startPos = npc.AbsolutePosition; | 141 | startPos = npc.AbsolutePosition; |
137 | targetPos = startPos + new Vector3(10, 0, 0); | 142 | targetPos = startPos + new Vector3(10, 0, 0); |
138 | npcModule.MoveToTarget(npc.UUID, scene, targetPos); | 143 | npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); |
139 | 144 | ||
140 | scene.Update(); | 145 | scene.Update(); |
141 | 146 | ||