diff options
author | Justin Clarke Casey | 2008-10-27 20:48:18 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-10-27 20:48:18 +0000 |
commit | 4b929804dc8a339db775602ce07d23171b7fb432 (patch) | |
tree | 68346b51f86aabaed6047810379a3d5072f76922 /OpenSim/Region/Modules | |
parent | * minor: remove mono compiler warnings (diff) | |
download | opensim-SC-4b929804dc8a339db775602ce07d23171b7fb432.zip opensim-SC-4b929804dc8a339db775602ce07d23171b7fb432.tar.gz opensim-SC-4b929804dc8a339db775602ce07d23171b7fb432.tar.bz2 opensim-SC-4b929804dc8a339db775602ce07d23171b7fb432.tar.xz |
* cleanup: Update the avatar factory (appearance module) in Region/Environment and use that instead of the Region/Modules/AvatarFactory
* Remove the AvatarFactory dll
Diffstat (limited to 'OpenSim/Region/Modules')
-rw-r--r-- | OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs | 219 | ||||
-rw-r--r-- | OpenSim/Region/Modules/AvatarFactory/Properties/AssemblyInfo.cs | 62 |
2 files changed, 0 insertions, 281 deletions
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs deleted file mode 100644 index cec2ec1..0000000 --- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs +++ /dev/null | |||
@@ -1,219 +0,0 @@ | |||
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 System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using System.Threading; | ||
33 | using OpenMetaverse; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenSim.Data.Base; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Region.Environment.Interfaces; | ||
40 | using OpenSim.Region.Environment.Scenes; | ||
41 | |||
42 | namespace OpenSim.Region.Modules.AvatarFactory | ||
43 | { | ||
44 | public class AvatarFactoryModule : IAvatarFactory, IRegionModule | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | private Scene m_scene = null; | ||
48 | private static readonly AvatarAppearance def = new AvatarAppearance(); | ||
49 | |||
50 | public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) | ||
51 | { | ||
52 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId); | ||
53 | //if ((profile != null) && (profile.RootFolder != null)) | ||
54 | if (profile != null) | ||
55 | { | ||
56 | appearance = m_scene.CommsManager.AvatarService.GetUserAppearance(avatarId); | ||
57 | if (appearance != null) | ||
58 | { | ||
59 | //SetAppearanceAssets(profile, ref appearance); | ||
60 | m_log.InfoFormat("[APPEARANCE] found : {0}", appearance.ToString()); | ||
61 | return true; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | appearance = CreateDefault(avatarId); | ||
66 | m_log.InfoFormat("[APPEARANCE] appearance not found for {0}, creating default", avatarId.ToString()); | ||
67 | return false; | ||
68 | |||
69 | } | ||
70 | |||
71 | private AvatarAppearance CreateDefault(UUID avatarId) | ||
72 | { | ||
73 | AvatarAppearance appearance = null; | ||
74 | AvatarWearable[] wearables; | ||
75 | byte[] visualParams; | ||
76 | GetDefaultAvatarAppearance(out wearables, out visualParams); | ||
77 | appearance = new AvatarAppearance(avatarId, wearables, visualParams); | ||
78 | |||
79 | return appearance; | ||
80 | } | ||
81 | |||
82 | public void Initialise(Scene scene, IConfigSource source) | ||
83 | { | ||
84 | scene.RegisterModuleInterface<IAvatarFactory>(this); | ||
85 | scene.EventManager.OnNewClient += NewClient; | ||
86 | |||
87 | if (m_scene == null) | ||
88 | { | ||
89 | m_scene = scene; | ||
90 | } | ||
91 | |||
92 | } | ||
93 | |||
94 | public void PostInitialise() | ||
95 | { | ||
96 | } | ||
97 | |||
98 | public void Close() | ||
99 | { | ||
100 | } | ||
101 | |||
102 | public string Name | ||
103 | { | ||
104 | get { return "Default Avatar Factory"; } | ||
105 | } | ||
106 | |||
107 | public bool IsSharedModule | ||
108 | { | ||
109 | get { return true; } | ||
110 | } | ||
111 | |||
112 | public void NewClient(IClientAPI client) | ||
113 | { | ||
114 | client.OnAvatarNowWearing += AvatarIsWearing; | ||
115 | } | ||
116 | |||
117 | public void RemoveClient(IClientAPI client) | ||
118 | { | ||
119 | // client.OnAvatarNowWearing -= AvatarIsWearing; | ||
120 | } | ||
121 | |||
122 | |||
123 | public void SetAppearanceAssets(CachedUserInfo profile, ref AvatarAppearance appearance) | ||
124 | { | ||
125 | if (profile.RootFolder != null) | ||
126 | { | ||
127 | for (int i = 0; i < 13; i++) | ||
128 | { | ||
129 | if (appearance.Wearables[i].ItemID == UUID.Zero) | ||
130 | { | ||
131 | appearance.Wearables[i].AssetID = UUID.Zero; | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | // UUID assetId; | ||
136 | |||
137 | InventoryItemBase baseItem = profile.RootFolder.FindItem(appearance.Wearables[i].ItemID); | ||
138 | |||
139 | if (baseItem != null) | ||
140 | { | ||
141 | appearance.Wearables[i].AssetID = baseItem.AssetID; | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | m_log.ErrorFormat("[APPEARANCE] Can't find inventory item {0}, setting to default", appearance.Wearables[i].ItemID); | ||
146 | appearance.Wearables[i].AssetID = def.Wearables[i].AssetID; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | else | ||
152 | { | ||
153 | m_log.Error("[APPEARANCE] you have no inventory, appearance stuff isn't going to work"); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | public void AvatarIsWearing(Object sender, AvatarWearingArgs e) | ||
158 | { | ||
159 | IClientAPI clientView = (IClientAPI)sender; | ||
160 | ScenePresence avatar = m_scene.GetScenePresence(clientView.AgentId); | ||
161 | if (avatar == null) { | ||
162 | m_log.Info("Avatar is child agent, ignoring AvatarIsWearing event"); | ||
163 | return; | ||
164 | } | ||
165 | |||
166 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); | ||
167 | |||
168 | AvatarAppearance avatAppearance = null; | ||
169 | if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) { | ||
170 | m_log.Info("We didn't seem to find the appearance, falling back to ScenePresense"); | ||
171 | avatAppearance = avatar.Appearance; | ||
172 | } | ||
173 | m_log.Info("Calling Avatar is Wearing"); | ||
174 | if (profile != null) | ||
175 | { | ||
176 | if (profile.RootFolder != null) | ||
177 | { | ||
178 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) | ||
179 | { | ||
180 | if (wear.Type < 13) | ||
181 | { | ||
182 | avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; | ||
183 | } | ||
184 | } | ||
185 | SetAppearanceAssets(profile, ref avatAppearance); | ||
186 | |||
187 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance); | ||
188 | avatar.Appearance = avatAppearance; | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | m_log.Error("Root Profile is null, we can't set the appearance"); | ||
193 | } | ||
194 | } | ||
195 | } | ||
196 | |||
197 | public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) | ||
198 | { | ||
199 | visualParams = GetDefaultVisualParams(); | ||
200 | wearables = AvatarWearable.DefaultWearables; | ||
201 | } | ||
202 | |||
203 | public void UpdateDatabase(UUID user, AvatarAppearance appearance) | ||
204 | { | ||
205 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(user, appearance); | ||
206 | } | ||
207 | |||
208 | private static byte[] GetDefaultVisualParams() | ||
209 | { | ||
210 | byte[] visualParams; | ||
211 | visualParams = new byte[218]; | ||
212 | for (int i = 0; i < 218; i++) | ||
213 | { | ||
214 | visualParams[i] = 100; | ||
215 | } | ||
216 | return visualParams; | ||
217 | } | ||
218 | } | ||
219 | } | ||
diff --git a/OpenSim/Region/Modules/AvatarFactory/Properties/AssemblyInfo.cs b/OpenSim/Region/Modules/AvatarFactory/Properties/AssemblyInfo.cs deleted file mode 100644 index 640b0b0..0000000 --- a/OpenSim/Region/Modules/AvatarFactory/Properties/AssemblyInfo.cs +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
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 System.Reflection; | ||
29 | using System.Runtime.InteropServices; | ||
30 | |||
31 | // General information about an assembly is controlled through the following | ||
32 | // set of attributes. Change these attribute values to modify the information | ||
33 | // associated with an assembly. | ||
34 | [assembly: AssemblyTitle("OpenSim.Region.Modules.AvatarFactory")] | ||
35 | [assembly: AssemblyDescription("")] | ||
36 | [assembly: AssemblyConfiguration("")] | ||
37 | [assembly: AssemblyCompany("")] | ||
38 | [assembly: AssemblyProduct("OpenSim.Region.Modules.AvatarFactory")] | ||
39 | [assembly: AssemblyCopyright("Copyright (c) 2008")] | ||
40 | [assembly: AssemblyTrademark("")] | ||
41 | [assembly: AssemblyCulture("")] | ||
42 | |||
43 | // Setting ComVisible to false makes the types in this assembly not visible | ||
44 | // to COM components. If you need to access a type in this assembly from | ||
45 | // COM, set the ComVisible attribute to true on that type. | ||
46 | [assembly: ComVisible(false)] | ||
47 | |||
48 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
49 | [assembly: Guid("8e369713-faf5-4e55-a789-f8f1a087d3ed")] | ||
50 | |||
51 | // Version information for an assembly consists of the following four values: | ||
52 | // | ||
53 | // Major Version | ||
54 | // Minor Version | ||
55 | // Build Number | ||
56 | // Revision | ||
57 | // | ||
58 | // You can specify all the values or you can default the Build and Revision Numbers | ||
59 | // by using the '*' as shown below: | ||
60 | // [assembly: AssemblyVersion("1.0.*")] | ||
61 | [assembly: AssemblyVersion("1.0.0.0")] | ||
62 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||