diff options
author | Dr Scofield | 2009-02-10 13:10:57 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-10 13:10:57 +0000 |
commit | 180be7de07014aa33bc6066f12a0819b731c1c9d (patch) | |
tree | 3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/Environment/Modules/Avatar/AvatarFactory | |
parent | Stopgap measure: To use gridlaunch, or GUI, start opensim with (diff) | |
download | opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.zip opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2 opensim-SC_OLD-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz |
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what
has happened is that OpenSim.Region.Environment.Modules has been split
in two:
- OpenSim.Region.CoreModules: all those modules that are either
directly or indirectly referenced from other OpenSim packages, or
that provide functionality that the OpenSim developer community
considers core functionality:
CoreModules/Agent/AssetTransaction
CoreModules/Agent/Capabilities
CoreModules/Agent/TextureDownload
CoreModules/Agent/TextureSender
CoreModules/Agent/TextureSender/Tests
CoreModules/Agent/Xfer
CoreModules/Avatar/AvatarFactory
CoreModules/Avatar/Chat/ChatModule
CoreModules/Avatar/Combat
CoreModules/Avatar/Currency/SampleMoney
CoreModules/Avatar/Dialog
CoreModules/Avatar/Friends
CoreModules/Avatar/Gestures
CoreModules/Avatar/Groups
CoreModules/Avatar/InstantMessage
CoreModules/Avatar/Inventory
CoreModules/Avatar/Inventory/Archiver
CoreModules/Avatar/Inventory/Transfer
CoreModules/Avatar/Lure
CoreModules/Avatar/ObjectCaps
CoreModules/Avatar/Profiles
CoreModules/Communications/Local
CoreModules/Communications/REST
CoreModules/Framework/EventQueue
CoreModules/Framework/InterfaceCommander
CoreModules/Hypergrid
CoreModules/InterGrid
CoreModules/Scripting/DynamicTexture
CoreModules/Scripting/EMailModules
CoreModules/Scripting/HttpRequest
CoreModules/Scripting/LoadImageURL
CoreModules/Scripting/VectorRender
CoreModules/Scripting/WorldComm
CoreModules/Scripting/XMLRPC
CoreModules/World/Archiver
CoreModules/World/Archiver/Tests
CoreModules/World/Estate
CoreModules/World/Land
CoreModules/World/Permissions
CoreModules/World/Serialiser
CoreModules/World/Sound
CoreModules/World/Sun
CoreModules/World/Terrain
CoreModules/World/Terrain/DefaultEffects
CoreModules/World/Terrain/DefaultEffects/bin
CoreModules/World/Terrain/DefaultEffects/bin/Debug
CoreModules/World/Terrain/Effects
CoreModules/World/Terrain/FileLoaders
CoreModules/World/Terrain/FloodBrushes
CoreModules/World/Terrain/PaintBrushes
CoreModules/World/Terrain/Tests
CoreModules/World/Vegetation
CoreModules/World/Wind
CoreModules/World/WorldMap
- OpenSim.Region.OptionalModules: all those modules that are not core
modules:
OptionalModules/Avatar/Chat/IRC-stuff
OptionalModules/Avatar/Concierge
OptionalModules/Avatar/Voice/AsterixVoice
OptionalModules/Avatar/Voice/SIPVoice
OptionalModules/ContentManagementSystem
OptionalModules/Grid/Interregion
OptionalModules/Python
OptionalModules/SvnSerialiser
OptionalModules/World/NPC
OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/AvatarFactory')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 232 |
1 files changed, 0 insertions, 232 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs deleted file mode 100644 index 1ac0807..0000000 --- a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ /dev/null | |||
@@ -1,232 +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.Framework; | ||
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | |||
41 | namespace OpenSim.Region.Environment.Modules.Avatar.AvatarFactory | ||
42 | { | ||
43 | public class AvatarFactoryModule : IAvatarFactory, IRegionModule | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | private Scene m_scene = null; | ||
47 | private static readonly AvatarAppearance def = new AvatarAppearance(); | ||
48 | |||
49 | public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance) | ||
50 | { | ||
51 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(avatarId); | ||
52 | //if ((profile != null) && (profile.RootFolder != null)) | ||
53 | if (profile != null) | ||
54 | { | ||
55 | appearance = m_scene.CommsManager.AvatarService.GetUserAppearance(avatarId); | ||
56 | if (appearance != null) | ||
57 | { | ||
58 | //SetAppearanceAssets(profile, ref appearance); | ||
59 | //m_log.DebugFormat("[APPEARANCE]: Found : {0}", appearance.ToString()); | ||
60 | return true; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | appearance = CreateDefault(avatarId); | ||
65 | m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId); | ||
66 | return false; | ||
67 | } | ||
68 | |||
69 | private AvatarAppearance CreateDefault(UUID avatarId) | ||
70 | { | ||
71 | AvatarAppearance appearance = null; | ||
72 | AvatarWearable[] wearables; | ||
73 | byte[] visualParams; | ||
74 | GetDefaultAvatarAppearance(out wearables, out visualParams); | ||
75 | appearance = new AvatarAppearance(avatarId, wearables, visualParams); | ||
76 | |||
77 | return appearance; | ||
78 | } | ||
79 | |||
80 | public void Initialise(Scene scene, IConfigSource source) | ||
81 | { | ||
82 | scene.RegisterModuleInterface<IAvatarFactory>(this); | ||
83 | scene.EventManager.OnNewClient += NewClient; | ||
84 | |||
85 | if (m_scene == null) | ||
86 | { | ||
87 | m_scene = scene; | ||
88 | } | ||
89 | |||
90 | } | ||
91 | |||
92 | public void PostInitialise() | ||
93 | { | ||
94 | } | ||
95 | |||
96 | public void Close() | ||
97 | { | ||
98 | } | ||
99 | |||
100 | public string Name | ||
101 | { | ||
102 | get { return "Default Avatar Factory"; } | ||
103 | } | ||
104 | |||
105 | public bool IsSharedModule | ||
106 | { | ||
107 | get { return false; } | ||
108 | } | ||
109 | |||
110 | public void NewClient(IClientAPI client) | ||
111 | { | ||
112 | client.OnAvatarNowWearing += AvatarIsWearing; | ||
113 | } | ||
114 | |||
115 | public void RemoveClient(IClientAPI client) | ||
116 | { | ||
117 | // client.OnAvatarNowWearing -= AvatarIsWearing; | ||
118 | } | ||
119 | |||
120 | |||
121 | public void SetAppearanceAssets(CachedUserInfo profile, ref AvatarAppearance appearance) | ||
122 | { | ||
123 | if (profile.RootFolder != null) | ||
124 | { | ||
125 | for (int i = 0; i < 13; i++) | ||
126 | { | ||
127 | if (appearance.Wearables[i].ItemID == UUID.Zero) | ||
128 | { | ||
129 | appearance.Wearables[i].AssetID = UUID.Zero; | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | InventoryItemBase baseItem = profile.RootFolder.FindItem(appearance.Wearables[i].ItemID); | ||
134 | |||
135 | if (baseItem != null) | ||
136 | { | ||
137 | appearance.Wearables[i].AssetID = baseItem.AssetID; | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | m_log.ErrorFormat("[APPEARANCE]: Can't find inventory item {0}, setting to default", appearance.Wearables[i].ItemID); | ||
142 | appearance.Wearables[i].AssetID = def.Wearables[i].AssetID; | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | m_log.Error("[APPEARANCE]: you have no inventory, appearance stuff isn't going to work"); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /// <summary> | ||
154 | /// Update what the avatar is wearing using an item from their inventory. | ||
155 | /// </summary> | ||
156 | /// <param name="sender"></param> | ||
157 | /// <param name="e"></param> | ||
158 | public void AvatarIsWearing(Object sender, AvatarWearingArgs e) | ||
159 | { | ||
160 | IClientAPI clientView = (IClientAPI)sender; | ||
161 | ScenePresence avatar = m_scene.GetScenePresence(clientView.AgentId); | ||
162 | |||
163 | if (avatar == null) | ||
164 | { | ||
165 | m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(clientView.AgentId); | ||
170 | |||
171 | AvatarAppearance avatAppearance = null; | ||
172 | if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance)) | ||
173 | { | ||
174 | m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence"); | ||
175 | avatAppearance = avatar.Appearance; | ||
176 | } | ||
177 | |||
178 | //m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name); | ||
179 | |||
180 | if (profile != null) | ||
181 | { | ||
182 | if (profile.RootFolder != null) | ||
183 | { | ||
184 | foreach (AvatarWearingArgs.Wearable wear in e.NowWearing) | ||
185 | { | ||
186 | if (wear.Type < 13) | ||
187 | { | ||
188 | avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | SetAppearanceAssets(profile, ref avatAppearance); | ||
193 | |||
194 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(clientView.AgentId, avatAppearance); | ||
195 | avatar.Appearance = avatAppearance; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | m_log.WarnFormat( | ||
200 | "[APPEARANCE]: Inventory has not yet been received for {0}, cannot set wearables", | ||
201 | clientView.Name); | ||
202 | } | ||
203 | } | ||
204 | else | ||
205 | { | ||
206 | m_log.WarnFormat("[APPEARANCE]: Cannot set wearables for {0}, no user profile found", clientView.Name); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) | ||
211 | { | ||
212 | visualParams = GetDefaultVisualParams(); | ||
213 | wearables = AvatarWearable.DefaultWearables; | ||
214 | } | ||
215 | |||
216 | public void UpdateDatabase(UUID user, AvatarAppearance appearance) | ||
217 | { | ||
218 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(user, appearance); | ||
219 | } | ||
220 | |||
221 | private static byte[] GetDefaultVisualParams() | ||
222 | { | ||
223 | byte[] visualParams; | ||
224 | visualParams = new byte[218]; | ||
225 | for (int i = 0; i < 218; i++) | ||
226 | { | ||
227 | visualParams[i] = 100; | ||
228 | } | ||
229 | return visualParams; | ||
230 | } | ||
231 | } | ||
232 | } | ||