diff options
author | Justin Clarke Casey | 2008-12-18 18:49:05 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-12-18 18:49:05 +0000 |
commit | 4f88f25913c2125b6797500932e7a20288b95bfc (patch) | |
tree | bfb13bbd9f295522a6f0c71d398df173cc31c337 /OpenSim/Region/Environment/Modules/Avatar/Gestures | |
parent | This may fix mantis #2855. There was a race condition on the TextureDownloadM... (diff) | |
download | opensim-SC_OLD-4f88f25913c2125b6797500932e7a20288b95bfc.zip opensim-SC_OLD-4f88f25913c2125b6797500932e7a20288b95bfc.tar.gz opensim-SC_OLD-4f88f25913c2125b6797500932e7a20288b95bfc.tar.bz2 opensim-SC_OLD-4f88f25913c2125b6797500932e7a20288b95bfc.tar.xz |
* refactor: move gestures code out from Scene into its own module
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Gestures')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs new file mode 100644 index 0000000..5f0f4f9 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Avatar/Gestures/GesturesModule.cs | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using log4net; | ||
29 | using Nini.Config; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Framework.Communications; | ||
33 | using OpenSim.Framework.Communications.Cache; | ||
34 | using OpenSim.Region.Environment.Interfaces; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using System.Reflection; | ||
37 | |||
38 | namespace OpenSim.Region.Environment.Modules.Avatar.Gestures | ||
39 | { | ||
40 | public class GesturesModule : IRegionModule, IGesturesModule | ||
41 | { | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | protected Scene m_scene; | ||
45 | |||
46 | public void Initialise(Scene scene, IConfigSource source) | ||
47 | { | ||
48 | m_scene = scene; | ||
49 | m_scene.RegisterModuleInterface<IGesturesModule>(this); | ||
50 | } | ||
51 | |||
52 | public void PostInitialise() {} | ||
53 | public void Close() {} | ||
54 | public string Name { get { return "Gestures Module"; } } | ||
55 | public bool IsSharedModule { get { return false; } } | ||
56 | |||
57 | public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId) | ||
58 | { | ||
59 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
60 | |||
61 | if (userInfo != null) | ||
62 | { | ||
63 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
64 | if (item != null) | ||
65 | { | ||
66 | item.Flags = 1; | ||
67 | userInfo.UpdateItem(item); | ||
68 | } | ||
69 | else | ||
70 | m_log.ErrorFormat( | ||
71 | "[GESTURES]: Unable to find gesture to activate {0} for {1}", gestureId, client.Name); | ||
72 | } | ||
73 | else | ||
74 | m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); | ||
75 | } | ||
76 | |||
77 | public virtual void DeactivateGesture(IClientAPI client, UUID gestureId) | ||
78 | { | ||
79 | CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(client.AgentId); | ||
80 | |||
81 | if (userInfo != null) | ||
82 | { | ||
83 | InventoryItemBase item = userInfo.RootFolder.FindItem(gestureId); | ||
84 | if (item != null) | ||
85 | { | ||
86 | item.Flags = 0; | ||
87 | userInfo.UpdateItem(item); | ||
88 | } | ||
89 | else | ||
90 | m_log.ErrorFormat( | ||
91 | "[GESTURES]: Unable to find gesture to deactivate {0} for {1}", gestureId, client.Name); | ||
92 | } | ||
93 | else | ||
94 | m_log.ErrorFormat("[GESTURES]: Unable to find user {0}", client.Name); | ||
95 | } | ||
96 | } | ||
97 | } \ No newline at end of file | ||