mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
add script constant OS_APIVERSION, we should inc this on any change on any api. a few changes to os npc and avatar animation functions
This commit is contained in:
@@ -1128,15 +1128,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
|
||||
// Adam's super super custom animation functions
|
||||
public void osAvatarPlayAnimation(string avatar, string animation)
|
||||
public void osAvatarPlayAnimation(LSL_Key avatar, string animation)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarPlayAnimation");
|
||||
|
||||
AvatarPlayAnimation(avatar, animation);
|
||||
}
|
||||
|
||||
private void AvatarPlayAnimation(string avatar, string animation)
|
||||
{
|
||||
UUID avatarID;
|
||||
if(!UUID.TryParse(avatar, out avatarID))
|
||||
return;
|
||||
@@ -1166,44 +1161,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
target.Animator.AddAnimation(animID, m_host.UUID);
|
||||
}
|
||||
|
||||
public void osAvatarStopAnimation(string avatar, string animation)
|
||||
public void osAvatarStopAnimation(LSL_Key avatar, string animation)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAvatarStopAnimation");
|
||||
|
||||
AvatarStopAnimation(avatar, animation);
|
||||
}
|
||||
UUID avatarID;
|
||||
if(!UUID.TryParse(avatar, out avatarID))
|
||||
return;
|
||||
|
||||
private void AvatarStopAnimation(string avatar, string animation)
|
||||
{
|
||||
UUID avatarID = (UUID)avatar;
|
||||
ScenePresence target = World.GetScenePresence(avatarID);
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
// FIXME: What we really want to do here is factor out the similar code in llStopAnimation() to a common
|
||||
// method (though see that doesn't do the is animation check, which is probably a bug) and have both
|
||||
// these functions call that common code. However, this does mean navigating the brain-dead requirement
|
||||
// of calling InitLSL()
|
||||
if (World.Entities.ContainsKey(avatarID) && World.Entities[avatarID] is ScenePresence)
|
||||
UUID animID;
|
||||
if (!UUID.TryParse(animation, out animID))
|
||||
{
|
||||
ScenePresence target = (ScenePresence)World.Entities[avatarID];
|
||||
if (target != null)
|
||||
{
|
||||
UUID animID;
|
||||
|
||||
if (!UUID.TryParse(animation, out animID))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
|
||||
if (item != null && item.Type == (int)AssetType.Animation)
|
||||
animID = item.AssetID;
|
||||
else
|
||||
animID = UUID.Zero;
|
||||
}
|
||||
|
||||
|
||||
if (animID == UUID.Zero)
|
||||
target.Animator.RemoveAnimation(animation);
|
||||
else
|
||||
target.Animator.RemoveAnimation(animID, true);
|
||||
}
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
|
||||
if (item != null && item.Type == (int)AssetType.Animation)
|
||||
animID = item.AssetID;
|
||||
else
|
||||
animID = UUID.Zero;
|
||||
}
|
||||
|
||||
if (animID == UUID.Zero)
|
||||
target.Animator.RemoveAnimation(animation);
|
||||
else
|
||||
target.Animator.RemoveAnimation(animID, true);
|
||||
}
|
||||
|
||||
//Texture draw functions
|
||||
@@ -3340,13 +3323,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcPlayAnimation");
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcID = new UUID(npc.m_string);
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
if (module.CheckPermissions(npcID, m_host.OwnerID))
|
||||
AvatarPlayAnimation(npcID.ToString(), animation);
|
||||
UUID npcID;
|
||||
if(!UUID.TryParse(npc.m_string, out npcID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(npcID);
|
||||
if (target == null || !target.IsNPC)
|
||||
return;
|
||||
|
||||
if (!module.CheckPermissions(npcID, m_host.OwnerID))
|
||||
return;
|
||||
|
||||
UUID animID = UUID.Zero;
|
||||
m_host.TaskInventory.LockItemsForRead(true);
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
|
||||
{
|
||||
if (inv.Value.Type == (int)AssetType.Animation)
|
||||
{
|
||||
if (inv.Value.Name == animation)
|
||||
{
|
||||
animID = inv.Value.AssetID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_host.TaskInventory.LockItemsForRead(false);
|
||||
|
||||
if (animID == UUID.Zero)
|
||||
target.Animator.AddAnimation(animation, m_host.UUID);
|
||||
else
|
||||
target.Animator.AddAnimation(animID, m_host.UUID);
|
||||
}
|
||||
|
||||
public void osNpcStopAnimation(LSL_Key npc, string animation)
|
||||
@@ -3354,13 +3363,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
CheckThreatLevel(ThreatLevel.High, "osNpcStopAnimation");
|
||||
|
||||
INPCModule module = World.RequestModuleInterface<INPCModule>();
|
||||
if (module != null)
|
||||
{
|
||||
UUID npcID = new UUID(npc.m_string);
|
||||
if (module == null)
|
||||
return;
|
||||
|
||||
if (module.CheckPermissions(npcID, m_host.OwnerID))
|
||||
AvatarStopAnimation(npcID.ToString(), animation);
|
||||
UUID npcID;
|
||||
if (!UUID.TryParse(npc.m_string, out npcID))
|
||||
return;
|
||||
|
||||
ScenePresence target = World.GetScenePresence(npcID);
|
||||
if (target == null || !target.IsNPC)
|
||||
return;
|
||||
|
||||
if (!module.CheckPermissions(npcID, m_host.OwnerID))
|
||||
return;
|
||||
|
||||
UUID animID;
|
||||
if (!UUID.TryParse(animation, out animID))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(animation);
|
||||
if (item != null && item.Type == (int)AssetType.Animation)
|
||||
animID = item.AssetID;
|
||||
else
|
||||
animID = UUID.Zero;
|
||||
}
|
||||
|
||||
if (animID == UUID.Zero)
|
||||
target.Animator.RemoveAnimation(animation);
|
||||
else
|
||||
target.Animator.RemoveAnimation(animID, true);
|
||||
}
|
||||
|
||||
public void osNpcWhisper(LSL_Key npc, int channel, string message)
|
||||
|
||||
@@ -158,8 +158,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
|
||||
|
||||
// Animation commands
|
||||
void osAvatarPlayAnimation(string avatar, string animation);
|
||||
void osAvatarStopAnimation(string avatar, string animation);
|
||||
void osAvatarPlayAnimation(LSL_Key avatarId, string animation);
|
||||
void osAvatarStopAnimation(LSL_Key avatarId, string animation);
|
||||
|
||||
#region Attachment commands
|
||||
|
||||
|
||||
@@ -29,13 +29,14 @@ using System;
|
||||
using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
|
||||
using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
|
||||
using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
|
||||
using LSLString = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
{
|
||||
public partial class ScriptBaseClass
|
||||
{
|
||||
// SCRIPTS CONSTANTS
|
||||
public static readonly LSLInteger OS_APIVERSION = 1;
|
||||
|
||||
public static readonly LSLInteger TRUE = 1;
|
||||
public static readonly LSLInteger FALSE = 0;
|
||||
|
||||
|
||||
@@ -289,12 +289,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
|
||||
// Animation Functions
|
||||
|
||||
public void osAvatarPlayAnimation(string avatar, string animation)
|
||||
public void osAvatarPlayAnimation(LSL_Key avatar, string animation)
|
||||
{
|
||||
m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
|
||||
}
|
||||
|
||||
public void osAvatarStopAnimation(string avatar, string animation)
|
||||
public void osAvatarStopAnimation(LSL_Key avatar, string animation)
|
||||
{
|
||||
m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user