From a01b415d6c3fa2ee650b23b7d78432a2eac5a2a7 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 11 May 2008 21:27:12 +0000 Subject: 0001199: [PATCH] Add support for default animations From Melanie... Thanks Melanie! . --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 16 ++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 57 ++++++++++++++++++++++ .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 5 ++ .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 19 +++++--- 4 files changed, 89 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 8506912..68e1a0d 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 466b20a..c74cac3 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 42912e7..09553ca 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 87c0450..bac8f2a 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); } } } -- cgit v1.1