From c2863df49d3bd1f4f7c2f4c17d897d9f66b36b26 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Thu, 17 Jan 2008 02:23:48 +0000 Subject: * Added and implemented the LSL changed event. * An example changed event syntax is at: http://opensimulator.org/wiki/Changed_Event_Example * You can use this to trigger actions in your script if someone sits on your object_rez * You can use this to figure out all of the CHANGED_ constants except for CHANGED_REGION, CHANGED_TELEPORT, and CHANGED_ALLOW_DROP --- .../Region/Environment/Scenes/SceneObjectPart.cs | 59 ++++++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectPart.cs') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 7866739..0cb4ae7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -42,6 +42,23 @@ using OpenSim.Region.Physics.Manager; namespace OpenSim.Region.Environment.Scenes { + // I don't really know where to put this except here. + // Can't access the OpenSim.Region.ScriptEngine.Common.LSL_BaseClass.Changed constants + + [Flags] + public enum Changed : uint + { + INVENTORY = 1, + COLOR = 2, + SHAPE = 4, + SCALE = 8, + TEXTURE = 16, + LINK = 32, + ALLOWED_DROP = 64, + OWNER = 128 + } + + public partial class SceneObjectPart : IScriptHost { private const PermissionMask OBJFULL_MASK_GENERAL = @@ -94,7 +111,7 @@ namespace OpenSim.Region.Environment.Scenes private byte m_updateFlag; #region Properties - + public LLUUID CreatorID; public LLUUID ObjectCreator @@ -160,7 +177,7 @@ namespace OpenSim.Region.Environment.Scenes /// A Linked Child Prim objects position in world public LLVector3 GetWorldPosition() { - + Quaternion parentRot = new Quaternion( ParentGroup.RootPart.RotationOffset.W, ParentGroup.RootPart.RotationOffset.X, @@ -186,6 +203,7 @@ namespace OpenSim.Region.Environment.Scenes /// public LLQuaternion GetWorldRotation() { + Quaternion newRot; if (this.LinkNum == 0) @@ -277,6 +295,7 @@ namespace OpenSim.Region.Environment.Scenes { // Hack to get the child prim to update world positions in the physics engine ParentGroup.ResetChildPrimPhysicsPositions(); + } catch (System.NullReferenceException) { @@ -427,6 +446,8 @@ namespace OpenSim.Region.Environment.Scenes set { m_color = value; + TriggerScriptChangedEvent(Changed.COLOR); + /* ScheduleFullUpdate() need not be called b/c after * setting the color, the text will be set, so then * ScheduleFullUpdate() will be called. */ @@ -477,7 +498,12 @@ namespace OpenSim.Region.Environment.Scenes public int LinkNum { get { return m_linkNum; } - set { m_linkNum = value; } + set + { + m_linkNum = value; + TriggerScriptChangedEvent(Changed.LINK); + + } } private byte m_clickAction = 0; @@ -494,16 +520,35 @@ namespace OpenSim.Region.Environment.Scenes protected PrimitiveBaseShape m_shape; + public void TriggerScriptChangedEvent(Changed val) + { + if (m_parentGroup != null) + { + if (m_parentGroup.Scene != null) + m_parentGroup.Scene.TriggerObjectChanged(LocalID, (uint)val); + } + + } + public PrimitiveBaseShape Shape { get { return m_shape; } - set { m_shape = value; } + set + { + + m_shape = value; + TriggerScriptChangedEvent(Changed.SHAPE); + } } public LLVector3 Scale { - set { m_shape.Scale = value; } get { return m_shape.Scale; } + set + { + m_shape.Scale = value; + TriggerScriptChangedEvent(Changed.SCALE); + } } public bool Stopped @@ -692,6 +737,8 @@ namespace OpenSim.Region.Environment.Scenes { BaseMask = NextOwnerMask; OwnerMask = NextOwnerMask; + TriggerScriptChangedEvent(Changed.OWNER); + } public void ApplySanePermissions() @@ -918,6 +965,7 @@ namespace OpenSim.Region.Environment.Scenes public void SetAvatarOnSitTarget(LLUUID avatarID) { m_SitTargetAvatar = avatarID; + TriggerScriptChangedEvent(Changed.LINK); } public LLUUID GetAvatarOnSitTarget() @@ -1328,6 +1376,7 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateTextureEntry(byte[] textureEntry) { m_shape.TextureEntry = textureEntry; + TriggerScriptChangedEvent(Changed.TEXTURE); ScheduleFullUpdate(); } -- cgit v1.1