aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-09 03:51:34 +0100
committerJustin Clark-Casey (justincc)2011-08-09 03:51:34 +0100
commite869eeb0bfc48c769f680970f99e4c67dd5a1a70 (patch)
tree749440ee4ba12140b708e2fe68e98419710d6ea0 /OpenSim/Region/OptionalModules
parentfactor out common notecard caching code from 3 methods. (diff)
downloadopensim-SC_OLD-e869eeb0bfc48c769f680970f99e4c67dd5a1a70.zip
opensim-SC_OLD-e869eeb0bfc48c769f680970f99e4c67dd5a1a70.tar.gz
opensim-SC_OLD-e869eeb0bfc48c769f680970f99e4c67dd5a1a70.tar.bz2
opensim-SC_OLD-e869eeb0bfc48c769f680970f99e4c67dd5a1a70.tar.xz
Implement first draft functions for saving and loading NPC appearance from storage.
This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent. By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type. Notecards also allow different appearances to be swapped and manipulated easily. This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text. This works in my basic test but is not at all ready for user use or bug reporting yet.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs29
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs2
2 files changed, 30 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 4f21d9d..d966345 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -137,6 +137,35 @@ namespace OpenSim.Region.OptionalModules.World.NPC
137 } 137 }
138 } 138 }
139 139
140 public bool IsNPC(UUID agentId, Scene scene)
141 {
142 ScenePresence sp = scene.GetScenePresence(agentId);
143 if (sp == null || sp.IsChildAgent)
144 return false;
145
146 lock (m_avatars)
147 return m_avatars.ContainsKey(agentId);
148 }
149
150 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
151 {
152 ScenePresence sp = scene.GetScenePresence(agentId);
153 if (sp == null || sp.IsChildAgent)
154 return false;
155
156 lock (m_avatars)
157 if (!m_avatars.ContainsKey(agentId))
158 return false;
159
160 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
161 sp.Appearance = npcAppearance;
162
163 IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>();
164 module.SendAppearance(sp.UUID);
165
166 return true;
167 }
168
140 public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) 169 public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
141 { 170 {
142 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); 171 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index a0260a5..2ec354f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
72 // ScenePresence.SendInitialData() to reset our entire appearance. 72 // ScenePresence.SendInitialData() to reset our entire appearance.
73 scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); 73 scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
74 74
75 afm.SetAppearance(originalClient, originalTe, null); 75 afm.SetAppearanceFromClient(originalClient, originalTe, null);
76 76
77 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); 77 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
78 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); 78 UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId);