예제 #1
0
파일: Prims.cs 프로젝트: jhurliman/simian
        public void llSetRemoteScriptAccessPin(IScriptInstance script, int pin)
        {
            LLPrimitive prim = script.Host as LLPrimitive;

            if (prim == null)
            {
                return;
            }

            prim.RemoteScriptAccessPIN = pin;
            script.AddSleepMS(200);
        }
예제 #2
0
파일: Prims.cs 프로젝트: jhurliman/simian
        public void llRotateTexture(IScriptInstance script, float angle, int side)
        {
            if (script.Host is LLPrimitive)
            {
                RotateTexture(script, (LLPrimitive)script.Host, angle, side);
            }
            script.AddSleepMS(200);

            if (m_lslScriptEngine != null)
            {
                m_lslScriptEngine.PostObjectEvent(script.Host.ID, "changed", new object[] { LSLConstants.CHANGED_TEXTURE }, null);
            }
        }
예제 #3
0
파일: Prims.cs 프로젝트: jhurliman/simian
        public void llSetColor(IScriptInstance script, Vector3 color, int side)
        {
            script.AddSleepMS(200);

            if (script.Host is LLPrimitive)
            {
                SetColor((LLPrimitive)script.Host, color, side);
                if (m_lslScriptEngine != null)
                {
                    m_lslScriptEngine.PostObjectEvent(script.Host.ID, "changed", new object[] { LSLConstants.CHANGED_COLOR }, null);
                }
            }
        }
예제 #4
0
파일: Sound.cs 프로젝트: jhurliman/simian
        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);
        }
예제 #5
0
파일: World.cs 프로젝트: jhurliman/simian
        public void llInstantMessage(IScriptInstance script, string user, string message)
        {
            if (m_messaging != null)
            {
                UUID toID;
                UUID.TryParse(user, out toID);

                // Keep a persistent messageID for all IMs from the host object to the target agent
                UUID messageID = UUID.Combine(script.Host.ID, toID);

                m_messaging.SendInstantMessage(messageID, toID, script.Host.Name,
                                               script.Host.ScenePosition, script.Host.Scene.ID, false,
                                               InstantMessageDialog.MessageFromObject, message, false, DateTime.UtcNow,
                                               Utils.EmptyBytes);
            }

            script.AddSleepMS(2000);
        }
예제 #6
0
파일: Prims.cs 프로젝트: thoys/simian
 public void llSetScale(IScriptInstance script, Vector3 scale)
 {
     SetScale(script.Host, scale);
     script.AddSleepMS(200);
 }
예제 #7
0
파일: Prims.cs 프로젝트: thoys/simian
 public void llSetText(IScriptInstance script, string text, Vector3 color, float alpha)
 {
     SetText(script.Host, text, color, alpha);
     script.AddSleepMS(200);
 }
예제 #8
0
파일: Prims.cs 프로젝트: thoys/simian
        public void llSetRemoteScriptAccessPin(IScriptInstance script, int pin)
        {
            LLPrimitive prim = script.Host as LLPrimitive;
            if (prim == null)
                return;

            prim.RemoteScriptAccessPIN = pin;
            script.AddSleepMS(200);
        }
예제 #9
0
파일: Prims.cs 프로젝트: thoys/simian
 public void llSetRot(IScriptInstance script, Quaternion rot)
 {
     SetRot(script.Host, rot);
     script.AddSleepMS(200);
 }
예제 #10
0
파일: Prims.cs 프로젝트: thoys/simian
 public void llSetLocalRot(IScriptInstance script, Quaternion rot)
 {
     script.Host.RelativeRotation = rot;
     script.Host.Scene.EntityAddOrUpdate(this, script.Host, UpdateFlags.Rotation, 0);
     script.AddSleepMS(200);
 }
예제 #11
0
파일: Prims.cs 프로젝트: thoys/simian
 public void llSetPos(IScriptInstance script, Vector3 pos)
 {
     SetPos(script.Host, pos);
     script.AddSleepMS(200);
 }
예제 #12
0
파일: Prims.cs 프로젝트: jhurliman/simian
        private void RezObject(IScriptInstance script, string inventory, Vector3 position, Vector3 vel, Quaternion rot, int param, bool atRoot)
        {
            // TODO: Test to make sure this actually rezzes from the root, and get the atRoot param working

            // Can't do this without an IAssetClient
            if (m_assetClient == null)
            {
                return;
            }

            // Sanity check the input rotation
            if (Single.IsNaN(rot.X) || Single.IsNaN(rot.Y) || Single.IsNaN(rot.Z) || Single.IsNaN(rot.W))
            {
                return;
            }

            // Sanity check the distance, silently fail at > 10m
            float dist = Vector3.Distance(script.Host.ScenePosition, position);

            if (dist > 10.0f)
            {
                return;
            }

            if (script.Host is LLPrimitive)
            {
                LLPrimitive         obj  = (LLPrimitive)script.Host;
                LLInventoryTaskItem item = obj.Inventory.FindItem(delegate(LLInventoryTaskItem match) { return(match.Name == inventory); });

                if (item != null)
                {
                    // Make sure this is an object
                    if (item.InventoryType != InventoryType.Object)
                    {
                        llSay(script, 0, "Unable to create requested object. Object is missing from database.");
                        return;
                    }

                    // Fetch the serialized linkset asset
                    Asset linksetAsset;
                    if (!m_assetClient.TryGetAsset(item.AssetID, LLUtil.LLAssetTypeToContentType((int)AssetType.Object), out linksetAsset))
                    {
                        llSay(script, 0, "Unable to create requested object. Object is missing from database.");
                        return;
                    }

                    // Deserialize the asset to LLSD
                    OSDMap linksetMap = null;
                    try { linksetMap = OSDParser.Deserialize(linksetAsset.Data) as OSDMap; }
                    catch (Exception ex) { m_log.Error("Failed to deserialize linkset from asset " + linksetAsset.ID + ": " + ex.Message); }

                    if (linksetMap == null)
                    {
                        llSay(script, 0, "Unable to create requested object. Object is corrupted in database.");
                        return;
                    }

                    // Deserialize the linkset
                    IList <LLPrimitive> linkset = LLPrimitive.DeserializeLinkset(linksetMap, obj.Scene, m_primMesher, true);

                    Vector3    velocity = vel;
                    Quaternion rotation = rot;
                    float      velMag   = velocity.Length();
                    float      mass     = (float)llGetMass(script);

                    // Rez the parent(s) first
                    for (int i = 0; i < linkset.Count; i++)
                    {
                        LLPrimitive prim = linkset[i];
                        if (prim.Parent == null)
                        {
                            // Objects rezzed with this method are DieAtEdge by default
                            prim.Prim.Flags |= PrimFlags.DieAtEdge;

                            // Set the position, rotation and velocity of the root prim in the scene
                            prim.RelativePosition = position;
                            prim.RelativeRotation = rotation;
                            if (prim.Prim.Flags.HasFlag(PrimFlags.Physics))
                            {
                                prim.FallStart = Util.TickCount();
                                prim.Velocity  = velocity;
                            }

                            obj.Scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                            m_log.Debug("Deserialized root prim " + prim.ID + " (" + prim.LocalID + ") from task inventory");
                        }
                    }

                    // Rez the children
                    for (int i = 0; i < linkset.Count; i++)
                    {
                        LLPrimitive prim = linkset[i];
                        if (prim.Parent != null)
                        {
                            obj.Scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                        }
                    }

                    // FIXME: Post an object_rez event

                    if (obj.Prim.Flags.HasFlag(PrimFlags.Physics))
                    {
                        obj.FallStart = Util.TickCount();
                        // FIXME: Recoil
                        //llApplyImpulse(script, new lsl_vector(velocity.X * mass, velocity.Y * mass, velocity.Z * mass), 0);
                    }

                    // Variable script delay (http://wiki.secondlife.com/wiki/LSL_Delay)
                    script.AddSleepMS((int)((mass * velMag) * 0.1f));
                    script.AddSleepMS(200);
                }
                else
                {
                    llSay(script, 0, "Could not find object " + inventory);
                }
            }
        }
예제 #13
0
파일: Prims.cs 프로젝트: jhurliman/simian
 public void llSetScale(IScriptInstance script, Vector3 scale)
 {
     SetScale(script.Host, scale);
     script.AddSleepMS(200);
 }
예제 #14
0
파일: PrimParams.cs 프로젝트: thoys/simian
 public void llSetPrimitiveParams(IScriptInstance script, object[] rules)
 {
     script.AddSleepMS(200);
     SetPrimParams(script, script.Host, rules);
 }
예제 #15
0
파일: World.cs 프로젝트: thoys/simian
        public void llInstantMessage(IScriptInstance script, string user, string message)
        {
            if (m_messaging != null)
            {
                UUID toID;
                UUID.TryParse(user, out toID);

                // Keep a persistent messageID for all IMs from the host object to the target agent
                UUID messageID = UUID.Combine(script.Host.ID, toID);

                m_messaging.SendInstantMessage(messageID, toID, script.Host.Name,
                    script.Host.ScenePosition, script.Host.Scene.ID, false,
                    InstantMessageDialog.MessageFromObject, message, false, DateTime.UtcNow,
                    Utils.EmptyBytes);
            }

            script.AddSleepMS(2000);
        }
예제 #16
0
파일: Prims.cs 프로젝트: jhurliman/simian
 public void llSetText(IScriptInstance script, string text, Vector3 color, float alpha)
 {
     SetText(script.Host, text, color, alpha);
     script.AddSleepMS(200);
 }
예제 #17
0
파일: Prims.cs 프로젝트: jhurliman/simian
 public void llSetPos(IScriptInstance script, Vector3 pos)
 {
     SetPos(script.Host, pos);
     script.AddSleepMS(200);
 }
예제 #18
0
파일: Prims.cs 프로젝트: jhurliman/simian
 public void llSetLocalRot(IScriptInstance script, Quaternion rot)
 {
     script.Host.RelativeRotation = rot;
     script.Host.Scene.EntityAddOrUpdate(this, script.Host, UpdateFlags.Rotation, 0);
     script.AddSleepMS(200);
 }
예제 #19
0
파일: Prims.cs 프로젝트: thoys/simian
        public void llSetTexture(IScriptInstance script, string texture, int side)
        {
            if (script.Host is LLPrimitive)
                SetTexture(script, (LLPrimitive)script.Host, texture, side);
            script.AddSleepMS(200);

            if (m_lslScriptEngine != null)
                m_lslScriptEngine.PostObjectEvent(script.Host.ID, "changed", new object[] { LSLConstants.CHANGED_TEXTURE }, null);
        }
예제 #20
0
파일: Prims.cs 프로젝트: thoys/simian
        public void llSetColor(IScriptInstance script, Vector3 color, int side)
        {
            script.AddSleepMS(200);

            if (script.Host is LLPrimitive)
            {
                SetColor((LLPrimitive)script.Host, color, side);
                if (m_lslScriptEngine != null)
                    m_lslScriptEngine.PostObjectEvent(script.Host.ID, "changed", new object[] { LSLConstants.CHANGED_COLOR }, null);
            }
        }
예제 #21
0
 public void llSetPrimitiveParams(IScriptInstance script, object[] rules)
 {
     script.AddSleepMS(200);
     SetPrimParams(script, script.Host, rules);
 }
예제 #22
0
파일: Prims.cs 프로젝트: jhurliman/simian
 public void llSetRot(IScriptInstance script, Quaternion rot)
 {
     SetRot(script.Host, rot);
     script.AddSleepMS(200);
 }
예제 #23
0
파일: Prims.cs 프로젝트: thoys/simian
        private void RezObject(IScriptInstance script, string inventory, Vector3 position, Vector3 vel, Quaternion rot, int param, bool atRoot)
        {
            // TODO: Test to make sure this actually rezzes from the root, and get the atRoot param working

            // Can't do this without an IAssetClient
            if (m_assetClient == null)
                return;

            // Sanity check the input rotation
            if (Single.IsNaN(rot.X) || Single.IsNaN(rot.Y) || Single.IsNaN(rot.Z) || Single.IsNaN(rot.W))
                return;

            // Sanity check the distance, silently fail at > 10m
            float dist = Vector3.Distance(script.Host.ScenePosition, position);
            if (dist > 10.0f)
                return;

            if (script.Host is LLPrimitive)
            {
                LLPrimitive obj = (LLPrimitive)script.Host;
                LLInventoryTaskItem item = obj.Inventory.FindItem(delegate(LLInventoryTaskItem match) { return match.Name == inventory; });

                if (item != null)
                {
                    // Make sure this is an object
                    if (item.InventoryType != InventoryType.Object)
                    {
                        llSay(script, 0, "Unable to create requested object. Object is missing from database.");
                        return;
                    }

                    // Fetch the serialized linkset asset
                    Asset linksetAsset;
                    if (!m_assetClient.TryGetAsset(item.AssetID, LLUtil.LLAssetTypeToContentType((int)AssetType.Object), out linksetAsset))
                    {
                        llSay(script, 0, "Unable to create requested object. Object is missing from database.");
                        return;
                    }

                    // Deserialize the asset to LLSD
                    OSDMap linksetMap = null;
                    try { linksetMap = OSDParser.Deserialize(linksetAsset.Data) as OSDMap; }
                    catch (Exception ex) { m_log.Error("Failed to deserialize linkset from asset " + linksetAsset.ID + ": " + ex.Message); }

                    if (linksetMap == null)
                    {
                        llSay(script, 0, "Unable to create requested object. Object is corrupted in database.");
                        return;
                    }

                    // Deserialize the linkset
                    IList<LLPrimitive> linkset = LLPrimitive.DeserializeLinkset(linksetMap, obj.Scene, m_primMesher, true);

                    Vector3 velocity = vel;
                    Quaternion rotation = rot;
                    float velMag = velocity.Length();
                    float mass = (float)llGetMass(script);

                    // Rez the parent(s) first
                    for (int i = 0; i < linkset.Count; i++)
                    {
                        LLPrimitive prim = linkset[i];
                        if (prim.Parent == null)
                        {
                            // Objects rezzed with this method are DieAtEdge by default
                            prim.Prim.Flags |= PrimFlags.DieAtEdge;

                            // Set the position, rotation and velocity of the root prim in the scene
                            prim.RelativePosition = position;
                            prim.RelativeRotation = rotation;
                            if (prim.Prim.Flags.HasFlag(PrimFlags.Physics))
                            {
                                prim.FallStart = Util.TickCount();
                                prim.Velocity = velocity;
                            }

                            obj.Scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                            m_log.Debug("Deserialized root prim " + prim.ID + " (" + prim.LocalID + ") from task inventory");
                        }
                    }

                    // Rez the children
                    for (int i = 0; i < linkset.Count; i++)
                    {
                        LLPrimitive prim = linkset[i];
                        if (prim.Parent != null)
                            obj.Scene.EntityAddOrUpdate(this, prim, UpdateFlags.FullUpdate, 0);
                    }

                    // FIXME: Post an object_rez event

                    if (obj.Prim.Flags.HasFlag(PrimFlags.Physics))
                    {
                        obj.FallStart = Util.TickCount();
                        // FIXME: Recoil
                        //llApplyImpulse(script, new lsl_vector(velocity.X * mass, velocity.Y * mass, velocity.Z * mass), 0);
                    }

                    // Variable script delay (http://wiki.secondlife.com/wiki/LSL_Delay)
                    script.AddSleepMS((int)((mass * velMag) * 0.1f));
                    script.AddSleepMS(200);
                }
                else
                {
                    llSay(script, 0, "Could not find object " + inventory);
                }
            }
        }
예제 #24
0
파일: Sound.cs 프로젝트: thoys/simian
        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);
        }