diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index a01ee0bc28..a7f6e23a52 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -914,6 +914,7 @@ namespace OpenSim.Framework void SendSunPos(LLVector3 sunPos, LLVector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition); void SendViewerTime(int phase); + LLUUID GetDefaultAnimation(string name); void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, LLUUID partnerID); diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 85069122bf..68e1a0df44 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -96,6 +96,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP private byte[] m_channelVersion = Helpers.StringToField("OpenSimulator 0.5"); // Dummy value needed by libSL + private Dictionary m_defaultAnimations = new Dictionary(); + + /* protected variables */ protected static Dictionary PacketHandlers = @@ -326,6 +329,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_channelVersion = Helpers.StringToField(scene.GetSimulatorVersion()); + InitDefaultAnimations(); + + m_scene = scene; m_assetCache = assetCache; @@ -3097,6 +3103,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(scriptQuestion, ThrottleOutPacketType.Task); } + private void InitDefaultAnimations() + { + } + + public LLUUID GetDefaultAnimation(string name) + { + if(m_defaultAnimations.ContainsKey(name)) + return m_defaultAnimations[name]; + return LLUUID.Zero; + } protected virtual bool Logout(IClientAPI client, Packet packet) { diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 466b20aa38..c74cac33a3 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -1156,6 +1156,63 @@ namespace OpenSim.Region.Environment.Scenes } } } + public void AddAnimation(string name) + { + if(m_isChildAgent) + return; + + // Don't let this animation become the movement animation + if(m_animations.Count < 1) + SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); + + LLUUID animID=m_controllingClient.GetDefaultAnimation(name); + if(animID == LLUUID.Zero) + return; + + if (!m_animations.Contains(animID)) + { + m_animations.Add(animID); + m_animationSeqs.Add(m_controllingClient.NextAnimationSequenceNumber); + SendAnimPack(); + } + } + + public void RemoveAnimation(string name) + { + if(m_isChildAgent) + return; + + LLUUID animID=m_controllingClient.GetDefaultAnimation(name); + if(animID == LLUUID.Zero) + return; + + if (m_animations.Contains(animID)) + { + if (m_animations[0] == animID) + { + SetMovementAnimation(Animations.AnimsLLUUID["STAND"]); + } + else + { + // What a HACK!! Anim list really needs to be an object! + int idx; + + for(idx=0;idx < m_animations.Count;idx++) + { + if(m_animations[idx] == animID) + { + int seq=m_animationSeqs[idx]; + + m_animations.Remove(animID); + m_animationSeqs.Remove(seq); + SendAnimPack(); + break; + } + } + } + } + } + public void HandleStartAnim(IClientAPI remoteClient, LLUUID animID) { diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index 42912e70f1..09553ca11c 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -449,6 +449,11 @@ namespace OpenSim.Region.Examples.SimpleModule { } + public LLUUID GetDefaultAnimation(string name) + { + return LLUUID.Zero; + } + public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) { } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 87c04504bf..bac8f2a2da 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2136,15 +2136,15 @@ namespace OpenSim.Region.ScriptEngine.Common if ((m_host.TaskInventory[invItemID].PermsMask & BuiltIn_Commands_BaseClass.PERMISSION_TRIGGER_ANIMATION) != 0) { - // Do NOT try to parse LLUUID, animations cannot be triggered by ID - LLUUID animID=InventoryKey(anim, (int)AssetType.Animation); - if (animID == LLUUID.Zero) - return; - if (World.m_innerScene.ScenePresences.ContainsKey(m_host.TaskInventory[invItemID].PermsGranter)) { ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[invItemID].PermsGranter]; - presence.AddAnimation(animID); + // Do NOT try to parse LLUUID, animations cannot be triggered by ID + LLUUID animID=InventoryKey(anim, (int)AssetType.Animation); + if (animID == LLUUID.Zero) + presence.AddAnimation(anim); + else + presence.AddAnimation(animID); } } } @@ -2170,12 +2170,15 @@ namespace OpenSim.Region.ScriptEngine.Common } if (animID == LLUUID.Zero) - return; + return; if (World.m_innerScene.ScenePresences.ContainsKey(m_host.TaskInventory[invItemID].PermsGranter)) { ScenePresence presence = World.m_innerScene.ScenePresences[m_host.TaskInventory[invItemID].PermsGranter]; - presence.RemoveAnimation(animID); + if (animID == LLUUID.Zero) + presence.RemoveAnimation(anim); + else + presence.RemoveAnimation(animID); } } }