当前位置: 首页>>代码示例>>C#>>正文


C# IScriptInstance类代码示例

本文整理汇总了C#中IScriptInstance的典型用法代码示例。如果您正苦于以下问题:C# IScriptInstance类的具体用法?C# IScriptInstance怎么用?C# IScriptInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IScriptInstance类属于命名空间,在下文中一共展示了IScriptInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: llGetInventoryPermMask

        public int llGetInventoryPermMask(IScriptInstance script, string name, int mask)
        {
            LLPrimitive prim = script.Host as LLPrimitive;
            if (prim == null)
                return 0;

            LLInventoryTaskItem found = prim.Inventory.FindItem(item => item.Name == name);
            if (found != null)
            {
                switch (mask)
                {
                    case LSLConstants.MASK_BASE:
                        return (int)found.Permissions.BaseMask;
                    case LSLConstants.MASK_OWNER:
                        return (int)found.Permissions.OwnerMask;
                    case LSLConstants.MASK_GROUP:
                        return (int)found.Permissions.GroupMask;
                    case LSLConstants.MASK_EVERYONE:
                        return (int)found.Permissions.EveryoneMask;
                    case LSLConstants.MASK_NEXT:
                        return (int)found.Permissions.NextOwnerMask;
                }
            }

            return 0;
        }
开发者ID:thoys,项目名称:simian,代码行数:26,代码来源:Inventory.cs

示例2: llAvatarOnSitTarget

        public string llAvatarOnSitTarget(IScriptInstance script)
        {
            if (script.Host is LLPrimitive)
            {
                LLPrimitive prim = (LLPrimitive)script.Host;

                if (prim.SitPosition != Vector3.Zero)
                {
                    ILinkable[] children = ((ILinkable)script.Host).GetChildren();
                    for (int i = 0, len = children.Length; i < len; i++)
                    {
                        if (children[i] is LLAgent)
                        {
                            LLAgent childAgent = (LLAgent)children[i];
                            if (childAgent.RelativePosition == LLUtil.GetSitTarget(prim.SitPosition, childAgent.Scale))
                                return childAgent.ID.ToString();
                        }

                    }
                }
            }
            else
            {
                // TODO: Warning
            }

            return UUID.Zero.ToString();
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:28,代码来源:Prims.cs

示例3: llGetAccel

 public Vector3 llGetAccel(IScriptInstance script)
 {
     if (script.Host is IPhysical)
         return ((IPhysical)script.Host).Acceleration;
     else
         return Vector3.Zero;
 }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:7,代码来源:Prims.cs

示例4: OffsetTexture

        private void OffsetTexture(IScriptInstance script, LLPrimitive obj, float u, float v, int side)
        {
            int sides = GetNumberOfSides(obj);
            if (side >= 0 && side < sides)
            {
                // Change one face
                Primitive.TextureEntryFace face = obj.Prim.Textures.CreateFace((uint)side);
                face.OffsetU = u;
                face.OffsetV = v;

                obj.Scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.Textures);
            }
            else if (side == LSLConstants.ALL_SIDES)
            {
                // Change all of the faces
                for (uint i = 0; i < sides; i++)
                {
                    Primitive.TextureEntryFace face = obj.Prim.Textures.GetFace(i);
                    if (face != null)
                    {
                        face.OffsetU = u;
                        face.OffsetV = v;
                    }
                }

                obj.Scene.EntityAddOrUpdate(this, obj, 0, (uint)LLUpdateFlags.Textures);
            }
        }
开发者ID:thoys,项目名称:simian,代码行数:28,代码来源:PrimParams.cs

示例5: llGetInventoryNumber

        public int llGetInventoryNumber(IScriptInstance script, int type)
        {
            LLPrimitive prim = script.Host as LLPrimitive;
            if (prim == null)
                return 0;

            AssetType assetType = (AssetType)type;
            return prim.Inventory.FindAllItems(item => assetType == AssetType.Unknown || item.AssetType == assetType).Count;
        }
开发者ID:thoys,项目名称:simian,代码行数:9,代码来源:Inventory.cs

示例6: llGetPermissions

        public int llGetPermissions(IScriptInstance script)
        {
            if (script is LSLScriptInstance)
            {
                LSLScriptInstance lsl = (LSLScriptInstance)script;
                return (int)lsl.Permissions;
            }

            return 0; // TODO: Warning message
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:10,代码来源:ScriptPermissions.cs

示例7: llGetPermissionsKey

        public UUID llGetPermissionsKey(IScriptInstance script)
        {
            if (script is LSLScriptInstance)
            {
                LSLScriptInstance lsl = (LSLScriptInstance)script;
                return lsl.PermissionsKey;
            }

            return UUID.Zero; // TODO: Warning message
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:10,代码来源:ScriptPermissions.cs

示例8: llGetSubString

        public string llGetSubString(IScriptInstance script, string src, int start, int end)
        {
            if (start < 0)
                start = src.Length + start;

            if (end < 0)
                end = src.Length + end;

            // Conventional substring
            if (start <= end)
            {
                // Implies both bounds are out-of-range.
                if (end < 0 || start >= src.Length)
                    return String.Empty;

                // If end is positive, then it directly corresponds to the length of the substring needed (plus one of course).
                if (end >= src.Length)
                    end = src.Length - 1;

                if (start < 0)
                    return src.Substring(0, end + 1);

                // Both indices are positive
                return src.Substring(start, (end + 1) - start);
            }

            // Inverted substring (end < start)
            else
            {
                // Implies both indices are below the lower bound.
                // In the inverted case, that means the entire string will be returned unchanged.
                if (start < 0)
                    return src;

                // If both indices are greater than the upper bound the result may seem initially counter intuitive.
                if (end >= src.Length)
                    return src;

                if (end < 0)
                {
                    if (start < src.Length)
                        return src.Substring(start);

                    return String.Empty;
                }
                else
                {
                    if (start < src.Length)
                        return src.Substring(0, end + 1) + src.Substring(start);

                    return src.Substring(0, end + 1);
                }
            }
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:54,代码来源:Strings.cs

示例9: llDumpList2String

        public string llDumpList2String(IScriptInstance script, lsl_list src, string separator)
        {
            int len = src.Length;

            string[] arr = new string[len];

            for (int i = 0; i < len; i++)
                arr[i] = src.Data[i].ToString();

            return String.Join(separator, arr);
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:11,代码来源:Lists.cs

示例10: llAxes2Rot

        public Quaternion llAxes2Rot(IScriptInstance script, Vector3 fwd, Vector3 left, Vector3 up)
        {
            float s;
            float tr = fwd.X + left.Y + up.Z + 1.0f;

            if (tr >= 1.0)
            {
                s = 0.5f / (float)Math.Sqrt(tr);
                return new Quaternion(
                    (float)((left.Z - up.Y) * s),
                    (float)((up.X - fwd.Z) * s),
                    (float)((fwd.Y - left.X) * s),
                    (float)(0.25 / s));
            }
            else
            {
                float max = (left.Y > up.Z) ? left.Y : up.Z;

                if (max < fwd.X)
                {
                    s = (float)Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0f);
                    float x = s * 0.5f;
                    s = 0.5f / s;
                    return new Quaternion(
                        (float)x,
                        (float)((fwd.Y + left.X) * s),
                        (float)((up.X + fwd.Z) * s),
                        (float)((left.Z - up.Y) * s));
                }
                else if (max == left.Y)
                {
                    s = (float)Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0);
                    float y = s * 0.5f;
                    s = 0.5f / s;
                    return new Quaternion(
                        (float)((fwd.Y + left.X) * s),
                        (float)y,
                        (float)((left.Z + up.Y) * s),
                        (float)((up.X - fwd.Z) * s));
                }
                else
                {
                    s = (float)Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0);
                    float z = s * 0.5f;
                    s = 0.5f / s;
                    return new Quaternion(
                        (float)((up.X + fwd.Z) * s),
                        (float)((left.Z + up.Y) * s),
                        (float)z,
                        (float)((fwd.Y - left.X) * s));
                }
            }
        }
开发者ID:thoys,项目名称:simian,代码行数:53,代码来源:Math.cs

示例11: llAxes2Rot

        public Quaternion llAxes2Rot(IScriptInstance script, Vector3 fwd, Vector3 left, Vector3 up)
        {
            double s;
            double tr = fwd.X + left.Y + up.Z + 1.0;

            if (tr >= 1.0)
            {
                s = 0.5 / Math.Sqrt(tr);
                return new lsl_rotation(
                    (left.Z - up.Y) * s,
                    (up.X - fwd.Z) * s,
                    (fwd.Y - left.X) * s,
                    0.25 / s);
            }
            else
            {
                double max = (left.Y > up.Z) ? left.Y : up.Z;

                if (max < fwd.X)
                {
                    s = Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0);
                    double x = s * 0.5;
                    s = 0.5 / s;
                    return new lsl_rotation(
                        x,
                        (fwd.Y + left.X) * s,
                        (up.X + fwd.Z) * s,
                        (left.Z - up.Y) * s);
                }
                else if (max == left.Y)
                {
                    s = Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0);
                    double y = s * 0.5;
                    s = 0.5 / s;
                    return new lsl_rotation(
                        (fwd.Y + left.X) * s,
                        y,
                        (left.Z + up.Y) * s,
                        (up.X - fwd.Z) * s);
                }
                else
                {
                    s = Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0);
                    double z = s * 0.5;
                    s = 0.5 / s;
                    return new lsl_rotation(
                        (up.X + fwd.Z) * s,
                        (left.Z + up.Y) * s,
                        z,
                        (fwd.Y - left.X) * s);
                }
            }
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:53,代码来源:Math.cs

示例12: llPreloadSound

        public void llPreloadSound(IScriptInstance script, string sound)
        {
            UUID soundID = KeyOrName(script, sound, AssetType.Sound);
            if (soundID == UUID.Zero)
            {
                script.Host.Scene.EntityChat(this, script.Host, 0f, "Cannot find sound " + sound, Int32.MaxValue, EntityChatType.Debug);
                return;
            }

            if (m_sounds != null)
                m_sounds.PreloadSound(script.Host, soundID, DEFAULT_SOUND_RADIUS);

            script.AddSleepMS(1000);
        }
开发者ID:thoys,项目名称:simian,代码行数:14,代码来源:Sound.cs

示例13: llBase64ToString

        public string llBase64ToString(IScriptInstance script, string str)
        {
            try
            {
                Decoder utf8Decode = UTF8Encoding.UTF8.GetDecoder();

                byte[] data = Convert.FromBase64String(str);
                int charCount = utf8Decode.GetCharCount(data, 0, data.Length);
                char[] chars = new char[charCount];

                utf8Decode.GetChars(data, 0, data.Length, chars, 0);
                return new String(chars);
            }
            catch (Exception e)
            {
                throw new Exception("Error in base64Decode" + e.Message);
            }
        }
开发者ID:thoys,项目名称:simian,代码行数:18,代码来源:Strings.cs

示例14: llRequestPermissions

        public void llRequestPermissions(IScriptInstance script, UUID agentID, int perms)
        {
            if (script is LSLScriptInstance)
            {
                LSLScriptInstance lsl = (LSLScriptInstance)script;

                if (agentID != lsl.PermissionsKey)
                    lsl.Permissions = ScriptPermission.None;

                // TODO: Send script permission dialog to the user
                //script.Host.Scene.RequestScriptPermissions(this, script.Host, agentID, perms);

                // HACK: Automatically grant permissions and fire event, since we don't have a permission dialog yet
                lsl.PermissionsKey = agentID;
                lsl.Permissions = (ScriptPermission)perms;
                m_lslScriptEngine.PostObjectEvent(script.Host.ID, "run_time_permissions", new object[] { perms }, new DetectParams[0]);
            }
        }
开发者ID:osgrid,项目名称:openmetaverse,代码行数:18,代码来源:ScriptPermissions.cs

示例15: llGetInventoryName

        public string llGetInventoryName(IScriptInstance script, int type, int number)
        {
            LLPrimitive prim = script.Host as LLPrimitive;
            if (prim == null)
                return String.Empty;

            AssetType assetType = (AssetType)type;

            IList<LLInventoryTaskItem> items = prim.Inventory.FindAllItems(item => assetType == AssetType.Unknown || item.AssetType == assetType);
            if (items.Count >= number)
                return String.Empty;

            SortedList<string, LLInventoryTaskItem> sortedItems = new SortedList<string, LLInventoryTaskItem>(items.Count);
            for (int i = 0; i < items.Count; i++)
                sortedItems.Add(items[i].Name, items[i]);

            return sortedItems.Values[number].Name;
        }
开发者ID:thoys,项目名称:simian,代码行数:18,代码来源:Inventory.cs


注:本文中的IScriptInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。