Beispiel #1
0
        public void sendMassSwirl(List <UUID> u, float dur)
        {
            ViewerEffectPacket p = new ViewerEffectPacket();

            p.AgentData           = new ViewerEffectPacket.AgentDataBlock();
            p.AgentData.AgentID   = rc.plugin.frame.AgentID;
            p.AgentData.SessionID = rc.plugin.frame.SessionID;
            p.Effect = new ViewerEffectPacket.EffectBlock[u.Count];
            for (int i = 0; i < u.Count; i++)
            {
                p.Effect[i]          = new ViewerEffectPacket.EffectBlock();
                p.Effect[i].AgentID  = rc.plugin.frame.AgentID;
                p.Effect[i].Duration = dur;
                p.Effect[i].ID       = UUID.Random();
                p.Effect[i].Type     = (byte)7;
                p.Effect[i].TypeData = new byte[56];
                Buffer.BlockCopy(u[i].GetBytes(), 0, p.Effect[i].TypeData, 0, 16);
                Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, p.Effect[i].TypeData, 16, 16);
                Buffer.BlockCopy(Vector3d.Zero.GetBytes(), 0, p.Effect[i].TypeData, 32, 24);
                //rc.plugin.proxy.writethis("sent in " + u[i].ToString(), ConsoleColor.Black, ConsoleColor.Cyan);
                p.Effect[i].Color = new byte[4];
                Buffer.BlockCopy(
                    rc.plugin.SharedInfo.rainbow[colorIndex], 0, p.Effect[i].Color, 0, 4);
            }
            p.Header.Reliable = true;

            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);

            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
        }
Beispiel #2
0
        public void sendParticleCircle(UUID who, float dur)
        {
            ViewerEffectPacket p = new ViewerEffectPacket();

            p.AgentData           = new ViewerEffectPacket.AgentDataBlock();
            p.AgentData.AgentID   = rc.plugin.frame.AgentID;
            p.AgentData.SessionID = rc.plugin.frame.SessionID;
            p.Effect             = new ViewerEffectPacket.EffectBlock[1];
            p.Effect[0]          = new ViewerEffectPacket.EffectBlock();
            p.Effect[0].AgentID  = rc.plugin.frame.AgentID;
            p.Effect[0].Duration = dur;
            p.Effect[0].ID       = UUID.Random();
            p.Effect[0].Type     = (byte)7;
            p.Effect[0].TypeData = new byte[56];
            Buffer.BlockCopy(who.GetBytes(), 0, p.Effect[0].TypeData, 0, 16);
            Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, p.Effect[0].TypeData, 16, 16);
            Buffer.BlockCopy(Vector3d.Zero.GetBytes(), 0, p.Effect[0].TypeData, 32, 24);
            p.Header.Reliable = true;
            p.Effect[0].Color = new byte[4];

            Buffer.BlockCopy(
                rc.plugin.SharedInfo.rainbow[colorIndex], 0, p.Effect[0].Color, 0, 4);



            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
        }
Beispiel #3
0
        public void sendSwirlPoint(Vector3d vec, byte[] color, float dur)
        {
            ViewerEffectPacket v = new ViewerEffectPacket();

            v.Type = PacketType.ViewerEffect;
            v.HasVariableBlocks   = true;
            v.AgentData           = new ViewerEffectPacket.AgentDataBlock();
            v.AgentData.AgentID   = frame.AgentID;
            v.AgentData.SessionID = frame.SessionID;
            v.Effect             = new ViewerEffectPacket.EffectBlock[1];
            v.Effect[0]          = new ViewerEffectPacket.EffectBlock();
            v.Effect[0].ID       = UUID.Random();
            v.Effect[0].AgentID  = frame.AgentID;
            v.Effect[0].Type     = (byte)EffectType.Beam;
            v.Effect[0].Duration = dur;
            v.Effect[0].Color    = color;
            v.Effect[0].TypeData = new byte[56];
            Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, v.Effect[0].TypeData, 0, 16);
            Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, v.Effect[0].TypeData, 16, 16);
            Buffer.BlockCopy(vec.GetBytes(), 0, v.Effect[0].TypeData, 32, 24);

            v.Header.Reliable = false;
            v.Header.Resent   = false;
            proxy.InjectPacket(v, Direction.Outgoing);
        }
Beispiel #4
0
        void ViewerEffectHandler(Packet packet, Agent agent)
        {
            ViewerEffectPacket effect = (ViewerEffectPacket)packet;

            effect.AgentData.AgentID   = UUID.Zero;
            effect.AgentData.SessionID = UUID.Zero;

            server.UDP.BroadcastPacket(effect, PacketCategory.State);
        }
Beispiel #5
0
        private void ViewerEffectHandler(Packet packet, LLAgent agent)
        {
            ViewerEffectPacket effect = (ViewerEffectPacket)packet;

            // Broadcast this viewer effect to everyone
            for (int i = 0; i < effect.Effect.Length; i++)
            {
                ViewerEffectPacket.EffectBlock block = effect.Effect[i];

                if (block.AgentID == agent.ID)
                {
                    m_scene.CreateInterestListEvent(new InterestListEvent(UUID.Combine(block.ID, EFFECT_EVENT_ID), VIEWER_EFFECT, agent.ScenePosition, Vector3.One, block));
                }
                else
                {
                    m_log.Warn("Skipping ViewerEffect block for " + block.AgentID + " from " + agent.ID + " (" + agent.Name + ")");
                }
            }
        }
Beispiel #6
0
        private void SendViewerEffectPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence)
        {
            if (!(presence is LLAgent) || presence.InterestList == null)
            {
                return;
            }
            LLAgent agent = (LLAgent)presence;

            ViewerEffectPacket packet = new ViewerEffectPacket();

            packet.Header.Reliable   = false;
            packet.AgentData.AgentID = presence.ID;
            packet.Effect            = new ViewerEffectPacket.EffectBlock[eventDatas.Length];

            for (int i = 0; i < eventDatas.Length; i++)
            {
                packet.Effect[i] = (ViewerEffectPacket.EffectBlock)eventDatas[i].Event.State;
            }

            m_udp.SendPacket(agent, packet, ThrottleCategory.Task, true);
        }
Beispiel #7
0
    private Packet InViewerEffectHandler(Packet packet, IPEndPoint sim)
    {
        ViewerEffectPacket p = (ViewerEffectPacket)packet;

        foreach (ViewerEffectPacket.EffectBlock block in p.Effect)
        {
            if (block.Type == (byte)EffectType.PointAt)
            {
                if (block.TypeData.Length >= 56)
                {
                    Vector3d v = new Vector3d(block.TypeData, 32);
                    if ((v.X < -1024f) || (v.X > 1024f) || (v.Y < -1024f) || (v.Y > 1024f) || (v.Z < -1024f) || (v.Z > 1024f))
                    {
                        v = new Vector3d();
                        frame.SayToUser("Possible ViewerEffect crash packet from " + block.AgentID.ToString());
                    }
                    Buffer.BlockCopy(v.GetBytes(), 0, block.TypeData, 32, 24);
                }
            }
        }
        return((Packet)p);
    }
Beispiel #8
0
 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
 {
 }
Beispiel #9
0
        /// <summary>
        /// Start a particle stream between an agent and an object
        /// </summary>
        /// <param name="sourceAvatar"><seealso cref="UUID"/> Key of the source agent</param>
        /// <param name="targetObject"><seealso cref="UUID"/> Key of the target object</param>
        /// <param name="globalOffset"></param>
        /// <param name="type">The type from the <seealso cref="T:PointAtType"/> enum</param>
        /// <param name="effectID">A unique <seealso cref="UUID"/> for this effect</param>
        public void PointAtEffect(UUID sourceAvatar, UUID targetObject, Vector3d globalOffset, PointAtType type,
            UUID effectID)
        {
            ViewerEffectPacket effect = new ViewerEffectPacket();

            effect.AgentData.AgentID = Client.Self.AgentID;
            effect.AgentData.SessionID = Client.Self.SessionID;

            effect.Effect = new ViewerEffectPacket.EffectBlock[1];
            effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
            effect.Effect[0].AgentID = Client.Self.AgentID;
            effect.Effect[0].Color = new byte[4];
            effect.Effect[0].Duration = (type == PointAtType.Clear) ? 0.0f : Single.MaxValue / 4.0f;
            effect.Effect[0].ID = effectID;
            effect.Effect[0].Type = (byte)EffectType.PointAt;

            byte[] typeData = new byte[57];
            if (sourceAvatar != UUID.Zero)
                Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16);
            if (targetObject != UUID.Zero)
                Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16);
            Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);
            typeData[56] = (byte)type;

            effect.Effect[0].TypeData = typeData;

            Client.Network.SendPacket(effect);
        }
Beispiel #10
0
        /// <summary>
        /// Create a particle beam between an avatar and an primitive
        /// </summary>
        /// <param name="sourceAvatar"><seealso cref="T:libsecondlife.LLUUID"/> of sources avatar</param>
        /// <param name="targetObject"><seealso cref="T:libsecondlife.LLUUID"/> of the target</param>
        /// <param name="globalOffset"><seealso cref="T:libsecondlife.LLVector3d"/>global offset</param>
        /// <param name="color"><seealso cref="T:libsecondlife.LLColor"/>Color values of beam</param>
        /// <param name="duration">a float representing the duration the beam will last</param>
        /// <param name="effectID"><seealso cref="T:libsecondlife.LLUUID"/> of the Effect</param>
        public void BeamEffect(LLUUID sourceAvatar, LLUUID targetObject, LLVector3d globalOffset, LLColor color, 
            float duration, LLUUID effectID)
        {
            ViewerEffectPacket effect = new ViewerEffectPacket();

            effect.AgentData.AgentID = Client.Self.AgentID;
            effect.AgentData.SessionID = Client.Self.SessionID;

            effect.Effect = new ViewerEffectPacket.EffectBlock[1];
            effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
            effect.Effect[0].AgentID = Client.Self.AgentID;
            effect.Effect[0].Color = color.GetFloatBytes();
            effect.Effect[0].Duration = duration;
            effect.Effect[0].ID = effectID;
            effect.Effect[0].Type = (byte)EffectType.Beam;

            byte[] typeData = new byte[56];
            Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16);
            Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16);
            Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);

            effect.Effect[0].TypeData = typeData;

            Client.Network.SendPacket(effect);
        }
        /// <summary>
        /// Process an incoming effect
        /// </summary>
        private void ViewerEffectHandler(Packet packet, Simulator simulator)
        {
            ViewerEffectPacket effect = (ViewerEffectPacket)packet;

            foreach (ViewerEffectPacket.EffectBlock block in effect.Effect)
            {
                EffectType type = (EffectType)block.Type;

                //LLColor color;
                //if (block.Color.Length == 4)
                //{
                //    color = new LLColor(block.Color, 0);
                //}
                //else
                //{
                //    Client.Log("Received a ViewerEffect.EffectBlock.Color array with " + block.Color.Length +
                //        " bytes", Helpers.LogLevel.Warning);
                //    color = LLColor.Black;
                //}

                // Each ViewerEffect type uses it's own custom binary format for additional data. Fun eh?
                switch (type)
                {
                case EffectType.Text:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.Icon:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.Connector:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.FlexibleObject:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.AnimalControls:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.AnimationObject:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.Cloth:
                    Logger.Log("Received a ViewerEffect of type " + type.ToString() + ", implement me!",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.Glow:
                    Logger.Log("Received a Glow ViewerEffect which is not implemented yet",
                               Helpers.LogLevel.Warning, Client);
                    break;

                case EffectType.Beam:
                case EffectType.Point:
                case EffectType.Trail:
                case EffectType.Sphere:
                case EffectType.Spiral:
                case EffectType.Edit:
                    if (OnEffect != null)
                    {
                        if (block.TypeData.Length == 56)
                        {
                            LLUUID     sourceAvatar = new LLUUID(block.TypeData, 0);
                            LLUUID     targetObject = new LLUUID(block.TypeData, 16);
                            LLVector3d targetPos    = new LLVector3d(block.TypeData, 32);

                            try { OnEffect(type, sourceAvatar, targetObject, targetPos, block.Duration, block.ID); }
                            catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                        }
                        else
                        {
                            Logger.Log("Received a " + type.ToString() +
                                       " ViewerEffect with an incorrect TypeData size of " +
                                       block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                        }
                    }
                    break;

                case EffectType.LookAt:
                    if (OnLookAt != null)
                    {
                        if (block.TypeData.Length == 57)
                        {
                            LLUUID     sourceAvatar = new LLUUID(block.TypeData, 0);
                            LLUUID     targetObject = new LLUUID(block.TypeData, 16);
                            LLVector3d targetPos    = new LLVector3d(block.TypeData, 32);
                            LookAtType lookAt       = (LookAtType)block.TypeData[56];

                            try { OnLookAt(sourceAvatar, targetObject, targetPos, lookAt, block.Duration,
                                           block.ID); }
                            catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                        }
                        else
                        {
                            Logger.Log("Received a LookAt ViewerEffect with an incorrect TypeData size of " +
                                       block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                        }
                    }
                    break;

                case EffectType.PointAt:
                    if (OnPointAt != null)
                    {
                        if (block.TypeData.Length == 57)
                        {
                            LLUUID      sourceAvatar = new LLUUID(block.TypeData, 0);
                            LLUUID      targetObject = new LLUUID(block.TypeData, 16);
                            LLVector3d  targetPos    = new LLVector3d(block.TypeData, 32);
                            PointAtType pointAt      = (PointAtType)block.TypeData[56];

                            try { OnPointAt(sourceAvatar, targetObject, targetPos, pointAt, block.Duration,
                                            block.ID); }
                            catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); }
                        }
                        else
                        {
                            Logger.Log("Received a PointAt ViewerEffect with an incorrect TypeData size of " +
                                       block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                        }
                    }
                    break;

                default:
                    Logger.Log("Received a ViewerEffect with an unknown type " + type, Helpers.LogLevel.Warning, Client);
                    break;
                }
            }
        }
Beispiel #12
0
        private void SendViewerEffectPackets(QueuedInterestListEvent[] eventDatas, IScenePresence presence)
        {
            if (!(presence is LLAgent) || presence.InterestList == null)
                return;
            LLAgent agent = (LLAgent)presence;

            ViewerEffectPacket packet = new ViewerEffectPacket();
            packet.Header.Reliable = false;
            packet.AgentData.AgentID = presence.ID;
            packet.Effect = new ViewerEffectPacket.EffectBlock[eventDatas.Length];

            for (int i = 0; i < eventDatas.Length; i++)
                packet.Effect[i] = (ViewerEffectPacket.EffectBlock)eventDatas[i].Event.State;

            m_udp.SendPacket(agent, packet, ThrottleCategory.Task, true);
        }
Beispiel #13
0
 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
 {
     throw new System.NotImplementedException();
 }
Beispiel #14
0
        protected virtual void ProcessInPacket(Packet Pack)
        {
            ack_pack(Pack);
            if (debug)
            {
                if (Pack.Type != PacketType.AgentUpdate)
                {
                    Console.WriteLine(Pack.Type.ToString());
                }
            }

            if (this.ProcessPacketMethod(Pack))
            {
                //there is a handler registered that handled this packet type
                return;
            }
            else
            {
                System.Text.Encoding _enc = System.Text.Encoding.ASCII;

                switch (Pack.Type)
                {
                case PacketType.CompleteAgentMovement:
                    if (this.m_child)
                    {
                        this.UpgradeClient();
                    }
                    ClientAvatar.CompleteMovement(m_world);
                    ClientAvatar.SendInitialPosition();
                    break;

                case PacketType.RegionHandshakeReply:
                    m_world.SendLayerData(this);
                    break;

                case PacketType.AgentWearablesRequest:
                    ClientAvatar.SendInitialAppearance();
                    foreach (SimClient client in m_clientThreads.Values)
                    {
                        if (client.AgentID != this.AgentID)
                        {
                            ObjectUpdatePacket objupdate = client.ClientAvatar.CreateUpdatePacket();
                            this.OutPacket(objupdate);
                            client.ClientAvatar.SendAppearanceToOtherAgent(this);
                        }
                    }
                    m_world.GetInitialPrims(this);
                    break;

                case PacketType.AgentIsNowWearing:
                    AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack;
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.AgentSetAppearance:
                    AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
                    // Console.WriteLine(appear.ToString());
                    this.ClientAvatar.SetAppearance(appear);
                    break;

                case PacketType.ObjectAdd:
                    m_world.AddNewPrim((ObjectAddPacket)Pack, this);
                    break;

                case PacketType.ObjectLink:
                    OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString());
                    ObjectLinkPacket        link         = (ObjectLinkPacket)Pack;
                    uint                    parentprimid = 0;
                    OpenSim.world.Primitive parentprim   = null;
                    if (link.ObjectData.Length > 1)
                    {
                        parentprimid = link.ObjectData[0].ObjectLocalID;
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == parentprimid)
                            {
                                parentprim = (OpenSim.world.Primitive)ent;
                            }
                        }
                        for (int i = 1; i < link.ObjectData.Length; i++)
                        {
                            foreach (Entity ent in m_world.Entities.Values)
                            {
                                if (ent.localid == link.ObjectData[i].ObjectLocalID)
                                {
                                    ((OpenSim.world.Primitive)ent).MakeParent(parentprim);
                                }
                            }
                        }
                    }
                    break;

                case PacketType.ObjectScale:
                    OpenSim.Framework.Console.MainConsole.Instance.WriteLine(Pack.ToString());
                    break;

                case PacketType.ObjectShape:
                    ObjectShapePacket shape = (ObjectShapePacket)Pack;
                    for (int i = 0; i < shape.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == shape.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).UpdateShape(shape.ObjectData[i]);
                            }
                        }
                    }
                    break;

                case PacketType.RequestImage:
                    RequestImagePacket imageRequest = (RequestImagePacket)Pack;
                    for (int i = 0; i < imageRequest.RequestImage.Length; i++)
                    {
                        m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image);
                    }
                    break;

                case PacketType.TransferRequest:
                    //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request");
                    TransferRequestPacket transfer = (TransferRequestPacket)Pack;
                    m_assetCache.AddAssetRequest(this, transfer);
                    break;

                case PacketType.AgentUpdate:
                    ClientAvatar.HandleUpdate((AgentUpdatePacket)Pack);
                    break;

                case PacketType.ObjectImage:
                    ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
                    for (int i = 0; i < imagePack.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == imagePack.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).UpdateTexture(imagePack.ObjectData[i].TextureEntry);
                            }
                        }
                    }
                    break;

                case PacketType.ObjectFlagUpdate:
                    ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
                    foreach (Entity ent in m_world.Entities.Values)
                    {
                        if (ent.localid == flags.AgentData.ObjectLocalID)
                        {
                            ((OpenSim.world.Primitive)ent).UpdateObjectFlags(flags);
                        }
                    }
                    break;

                case PacketType.AssetUploadRequest:
                    AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
                    this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID));
                    break;

                case PacketType.RequestXfer:
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.SendXferPacket:
                    this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack);
                    break;

                case PacketType.CreateInventoryFolder:
                    CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
                    m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID);
                    //Console.WriteLine(Pack.ToString());
                    break;

                case PacketType.CreateInventoryItem:
                    //Console.WriteLine(Pack.ToString());
                    CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
                    if (createItem.InventoryBlock.TransactionID != LLUUID.Zero)
                    {
                        this.UploadAssets.CreateInventoryItem(createItem);
                    }
                    else
                    {
                        // Console.Write(Pack.ToString());
                        this.CreateInventoryItem(createItem);
                    }
                    break;

                case PacketType.FetchInventory:
                    //Console.WriteLine("fetch item packet");
                    FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack;
                    m_inventoryCache.FetchInventory(this, FetchInventory);
                    break;

                case PacketType.FetchInventoryDescendents:
                    FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
                    m_inventoryCache.FetchInventoryDescendents(this, Fetch);
                    break;

                case PacketType.UpdateInventoryItem:
                    UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
                    //Console.WriteLine(Pack.ToString());
                    for (int i = 0; i < update.InventoryData.Length; i++)
                    {
                        if (update.InventoryData[i].TransactionID != LLUUID.Zero)
                        {
                            AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
                            if (asset != null)
                            {
                                // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
                                m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
                            }
                            else
                            {
                                asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
                                if (asset != null)
                                {
                                    //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache");
                                    m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
                                }
                                else
                                {
                                    //Console.WriteLine("trying to update inventory item, but asset is null");
                                }
                            }
                        }
                        else
                        {
                            m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]);;
                        }
                    }
                    break;

                case PacketType.ViewerEffect:
                    ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
                    foreach (SimClient client in m_clientThreads.Values)
                    {
                        if (client.AgentID != this.AgentID)
                        {
                            viewer.AgentData.AgentID   = client.AgentID;
                            viewer.AgentData.SessionID = client.SessionID;
                            client.OutPacket(viewer);
                        }
                    }
                    break;

                case PacketType.RequestTaskInventory:
                    // Console.WriteLine(Pack.ToString());
                    RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
                    ReplyTaskInventoryPacket   replytask   = new ReplyTaskInventoryPacket();
                    bool foundent = false;
                    foreach (Entity ent in m_world.Entities.Values)
                    {
                        if (ent.localid == requesttask.InventoryData.LocalID)
                        {
                            replytask.InventoryData.TaskID   = ent.uuid;
                            replytask.InventoryData.Serial   = 0;
                            replytask.InventoryData.Filename = new byte[0];
                            foundent = true;
                        }
                    }
                    if (foundent)
                    {
                        this.OutPacket(replytask);
                    }
                    break;

                case PacketType.UpdateTaskInventory:
                    // Console.WriteLine(Pack.ToString());
                    UpdateTaskInventoryPacket updatetask  = (UpdateTaskInventoryPacket)Pack;
                    AgentInventory            myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
                    if (myinventory != null)
                    {
                        if (updatetask.UpdateData.Key == 0)
                        {
                            if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
                            {
                                if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
                                {
                                    LLUUID    noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
                                    AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
                                    if (assBase != null)
                                    {
                                        foreach (Entity ent in m_world.Entities.Values)
                                        {
                                            if (ent.localid == updatetask.UpdateData.LocalID)
                                            {
                                                if (ent is OpenSim.world.Primitive)
                                                {
                                                    this.m_world.AddScript(ent, Util.FieldToString(assBase.Data));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;

                case PacketType.AgentAnimation:
                    if (!m_child)
                    {
                        AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
                        for (int i = 0; i < AgentAni.AnimationList.Length; i++)
                        {
                            if (AgentAni.AnimationList[i].StartAnim)
                            {
                                ClientAvatar.current_anim = AgentAni.AnimationList[i].AnimID;
                                ClientAvatar.anim_seq     = 1;
                                ClientAvatar.SendAnimPack();
                            }
                        }
                    }
                    break;

                case PacketType.ObjectSelect:
                    ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
                    for (int i = 0; i < incomingselect.ObjectData.Length; i++)
                    {
                        foreach (Entity ent in m_world.Entities.Values)
                        {
                            if (ent.localid == incomingselect.ObjectData[i].ObjectLocalID)
                            {
                                ((OpenSim.world.Primitive)ent).GetProperites(this);
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
Beispiel #15
0
        public void VoiceEffect(float volumeLevel)
        {
            ViewerEffectPacket effect = new ViewerEffectPacket();

            effect.AgentData.AgentID = Client.Self.AgentID;
            effect.AgentData.SessionID = Client.Self.SessionID;

            effect.Effect = new ViewerEffectPacket.EffectBlock[1];
            effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
            effect.Effect[0].AgentID = Client.Self.AgentID;
            effect.Effect[0].Color = new byte[4];
            effect.Effect[0].Duration = 0.0f;
            effect.Effect[0].ID = new UUID("F6EB8CE4-1E08-4441-8AE7-762C8E6529AE");
            effect.Effect[0].Type = (byte)EffectType.VolumeLevel;

            byte[] typeData = new byte[24];
            Buffer.BlockCopy(Client.Self.AgentID.GetBytes(), 0, typeData, 0, 16);
            Buffer.BlockCopy(BitConverter.GetBytes(volumeLevel), 0, typeData, 16, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(Client.Self.LocalID), 0, typeData, 20, 4);

            effect.Effect[0].TypeData = typeData;

            Client.Network.SendPacket(effect);
        }
Beispiel #16
0
        private Packet OutViewerEffectHandler(Packet packet, IPEndPoint sim)
        {
            if (form.Mode != xtrafxMode.Disabled)
            {
                ViewerEffectPacket ViewerEffect = (ViewerEffectPacket)packet;
                bool inject = false;
                foreach (ViewerEffectPacket.EffectBlock effect in ViewerEffect.Effect)
                {
                    if (effect.Type == (byte)EffectType.Beam)
                    {
                        if (form.Mode == xtrafxMode.Speak)
                        {
                            oldTime = System.Environment.TickCount;
                            Vector3d newVec = new Vector3d(effect.TypeData, 32);

                            if (curentOn == false)
                            {
                                shoutOut(9000, "start");
                                curentOn = true;
                            }
                            if ((lastVec.Equals(newVec) == false))
                            {
                                lastVec = newVec;
                                shoutOut(9000, this.lastVec.ToString());
                            }
                            return(null);
                        }

                        inject = true;
                        Buffer.BlockCopy(
                            plugin.SharedInfo.rainbow[form.xtrafx_Index], 0, effect.Color, 0, 4);
                        form.xtrafx_Index++;

                        if (form.xtrafx_Index >= plugin.SharedInfo.rainbow.Length)
                        {
                            form.xtrafx_Index = 0;
                        }

                        if (form.Mode == xtrafxMode.Quad)
                        {
                            // trial: multi-beam
                            Vector3d position = new Vector3d(effect.TypeData, 32);
                            Logger.Log("Sending a effect to " + Utils.BytesToHexString(effect.TypeData, "effect"), Helpers.LogLevel.Info);
                            ViewerEffectPacket[][][] ve = new ViewerEffectPacket[2][][];
                            for (int x = 0; x < 2; x++)
                            {
                                ve[x] = new ViewerEffectPacket[2][];
                                for (int y = 0; y < 2; y++)
                                {
                                    ve[x][y] = new ViewerEffectPacket[2];
                                    for (int z = 0; z < 2; z++)
                                    {
                                        ve[x][y][z] = new ViewerEffectPacket();
                                        ve[x][y][z].HasVariableBlocks = true;
                                        ve[x][y][z].Type                = PacketType.ViewerEffect;
                                        ve[x][y][z].AgentData           = new ViewerEffectPacket.AgentDataBlock();
                                        ve[x][y][z].AgentData.AgentID   = frame.AgentID;
                                        ve[x][y][z].AgentData.SessionID = frame.SessionID;
                                        ve[x][y][z].Effect              = new ViewerEffectPacket.EffectBlock[1];
                                        ve[x][y][z].Effect[0]           = new ViewerEffectPacket.EffectBlock();
                                        ve[x][y][z].Effect[0].ID        = UUID.Random();
                                        ve[x][y][z].Effect[0].AgentID   = effect.AgentID;
                                        ve[x][y][z].Effect[0].Type      = effect.Type;
                                        ve[x][y][z].Effect[0].Duration  = effect.Duration;
                                        ve[x][y][z].Effect[0].Color     = effect.Color;
                                        ve[x][y][z].Effect[0].TypeData  = effect.TypeData;
                                        double   ox  = ((double)x - 0.5f);
                                        double   oy  = ((double)y - 0.5f);
                                        double   oz  = ((double)z - 0.5f);
                                        Vector3d pos = new Vector3d(ox + position.X, oy + position.Y, oz + position.Z);
                                        Buffer.BlockCopy(pos.GetBytes(), 0, ve[x][y][z].Effect[0].TypeData, 32, 24);
                                        ve[x][y][z].Header.Reliable = false;
                                        proxy.InjectPacket(ve[x][y][z], Direction.Outgoing);
                                    }
                                }
                            }
                        }
                        if (form.Mode == xtrafxMode.Circles)
                        {
                            Vector3d TargetPosition = new Vector3d(effect.TypeData, 32);
                            int      MapX           = ((int)(plugin.SharedInfo.RegionHandle >> 32));
                            int      MapY           = ((int)(plugin.SharedInfo.RegionHandle & 0x00000000FFFFFFFF));
                            Vector3d myPos          = new Vector3d(
                                MapX + plugin.SharedInfo.AvPosition.X,
                                MapY + plugin.SharedInfo.AvPosition.Y,
                                plugin.SharedInfo.AvPosition.Z);
                            Vector3d myLine   = TargetPosition - myPos;
                            float    duration = effect.Duration * (float)(((double)38 - (myLine.Length() * (2 / 3))) / 20);
                            if (duration > effect.Duration)
                            {
                                duration = effect.Duration;
                            }

                            //proxy.writethis("my pos is " + myPos.ToString() + " and target is " + TargetPosition.ToString() + " and myline is " + myLine.ToString(),ConsoleColor.Cyan,ConsoleColor.Black);
                            for (float i = 0; i < (float)Math.Round(myLine.Length()); i += 1.0F)
                            {
                                Vector3d circlePos = myPos + (Vector3d.Normalize(myLine) * i);
                                sendSwirlPoint(circlePos, effect.Color, duration);
                            }
                            sendSwirlPoint(TargetPosition, effect.Color, duration);
                        }
                    }
                    else
                    if (form.Mode == xtrafxMode.Speak)
                    {
                        return(null);
                    }
                }
                if (inject)
                {
                    packet = (Packet)ViewerEffect;
                }
            }
            return(packet);
        }
Beispiel #17
0
        public void TriggerEffects(object sender, ViewerEffect[] effects)
        {
            if (OnTriggerEffects != null)
            {
                OnTriggerEffects(sender, effects);
            }

            ViewerEffectPacket effect = new ViewerEffectPacket();
            effect.AgentData.AgentID = UUID.Zero;
            effect.AgentData.SessionID = UUID.Zero;

            effect.Effect = new ViewerEffectPacket.EffectBlock[effects.Length];

            for (int i = 0; i < effects.Length; i++)
            {
                ViewerEffect currentEffect = effects[i];
                ViewerEffectPacket.EffectBlock block = new ViewerEffectPacket.EffectBlock();

                block.AgentID = currentEffect.AgentID;
                block.Color = currentEffect.Color.GetBytes(true);
                block.Duration = currentEffect.Duration;
                block.ID = currentEffect.EffectID;
                block.Type = (byte)currentEffect.Type;
                block.TypeData = currentEffect.TypeData;

                effect.Effect[i] = block;
            }

            udp.BroadcastPacket(effect, PacketCategory.State);
        }
Beispiel #18
0
        /// <summary>
        /// Start a particle stream between an agent and an object
        /// </summary>
        /// <param name="sourceAvatar"><seealso cref="UUID"/> Key of the source agent</param>
        /// <param name="targetObject"><seealso cref="UUID"/> Key of the target object</param>
        /// <param name="globalOffset">A <seealso cref="Vector3d"/> representing the beams offset from the source</param>
        /// <param name="type">A <seealso cref="T:PointAtType"/> which sets the avatars lookat animation</param>
        /// <param name="effectID"><seealso cref="UUID"/> of the Effect</param>
        public void LookAtEffect(UUID sourceAvatar, UUID targetObject, Vector3d globalOffset, LookAtType type,
            UUID effectID)
        {
            ViewerEffectPacket effect = new ViewerEffectPacket();

            effect.AgentData.AgentID = Client.Self.AgentID;
            effect.AgentData.SessionID = Client.Self.SessionID;

            float duration;

            switch (type)
            {
                case LookAtType.Clear:
                    duration = 2.0f;
                    break;
                case LookAtType.Hover:
                    duration = 1.0f;
                    break;
                case LookAtType.FreeLook:
                    duration = 2.0f;
                    break;
                case LookAtType.Idle:
                    duration = 3.0f;
                    break;
                case LookAtType.AutoListen:
                case LookAtType.Respond:
                    duration = 4.0f;
                    break;
                case LookAtType.None:
                case LookAtType.Select:
                case LookAtType.Focus:
                case LookAtType.Mouselook:
                    duration = Single.MaxValue / 2.0f;
                    break;
                default:
                    duration = 0.0f;
                    break;
            }

            effect.Effect = new ViewerEffectPacket.EffectBlock[1];
            effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
            effect.Effect[0].AgentID = Client.Self.AgentID;
            effect.Effect[0].Color = new byte[4];
            effect.Effect[0].Duration = duration;
            effect.Effect[0].ID = effectID;
            effect.Effect[0].Type = (byte)EffectType.LookAt;

            byte[] typeData = new byte[57];
            Buffer.BlockCopy(sourceAvatar.GetBytes(), 0, typeData, 0, 16);
            Buffer.BlockCopy(targetObject.GetBytes(), 0, typeData, 16, 16);
            Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);
            typeData[56] = (byte)type;

            effect.Effect[0].TypeData = typeData;

            Client.Network.SendPacket(effect);
        }
Beispiel #19
0
        public void sendParticleCircle(UUID who, float dur)
        {
            ViewerEffectPacket p = new ViewerEffectPacket();
            p.AgentData = new ViewerEffectPacket.AgentDataBlock();
            p.AgentData.AgentID = rc.plugin.frame.AgentID;
            p.AgentData.SessionID = rc.plugin.frame.SessionID;
            p.Effect = new ViewerEffectPacket.EffectBlock[1];
            p.Effect[0] = new ViewerEffectPacket.EffectBlock();
            p.Effect[0].AgentID = rc.plugin.frame.AgentID;
            p.Effect[0].Duration = dur;
            p.Effect[0].ID = UUID.Random();
            p.Effect[0].Type = (byte)7;
            p.Effect[0].TypeData= new byte[56];
            Buffer.BlockCopy(who.GetBytes(),0,p.Effect[0].TypeData,0,16);
            Buffer.BlockCopy(UUID.Zero.GetBytes(),0,p.Effect[0].TypeData,16,16);
            Buffer.BlockCopy(Vector3d.Zero.GetBytes(), 0, p.Effect[0].TypeData, 32, 24);
            p.Header.Reliable = true;
            p.Effect[0].Color = new byte[4];

            Buffer.BlockCopy(
                rc.plugin.SharedInfo.rainbow[colorIndex], 0, p.Effect[0].Color, 0, 4);

            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
        }
Beispiel #20
0
        public void sendMassSwirl(List<UUID> u,float dur)
        {
            ViewerEffectPacket p = new ViewerEffectPacket();
            p.AgentData = new ViewerEffectPacket.AgentDataBlock();
            p.AgentData.AgentID = rc.plugin.frame.AgentID;
            p.AgentData.SessionID = rc.plugin.frame.SessionID;
            p.Effect = new ViewerEffectPacket.EffectBlock[u.Count];
            for(int i = 0;i<u.Count;i++)
            {
                p.Effect[i] = new ViewerEffectPacket.EffectBlock();
                p.Effect[i].AgentID = rc.plugin.frame.AgentID;
                p.Effect[i].Duration = dur;
                p.Effect[i].ID = UUID.Random();
                p.Effect[i].Type = (byte)7;
                p.Effect[i].TypeData= new byte[56];
                Buffer.BlockCopy(u[i].GetBytes(),0,p.Effect[i].TypeData,0,16);
                Buffer.BlockCopy(UUID.Zero.GetBytes(),0,p.Effect[i].TypeData,16,16);
                Buffer.BlockCopy(Vector3d.Zero.GetBytes(), 0, p.Effect[i].TypeData, 32, 24);
                //rc.plugin.proxy.writethis("sent in " + u[i].ToString(), ConsoleColor.Black, ConsoleColor.Cyan);
                p.Effect[i].Color = new byte[4];
                 Buffer.BlockCopy(
                rc.plugin.SharedInfo.rainbow[colorIndex], 0, p.Effect[i].Color, 0, 4);
            }
            p.Header.Reliable = true;

            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);

            rc.plugin.proxy.InjectPacket(p, Direction.Outgoing);
        }
Beispiel #21
0
        private Packet OutViewerEffectHandler(Packet packet, IPEndPoint sim)
        {
            if (form.Mode != xtrafxMode.Disabled)
            {
                ViewerEffectPacket ViewerEffect = (ViewerEffectPacket)packet;
                bool inject = false;
                foreach (ViewerEffectPacket.EffectBlock effect in ViewerEffect.Effect)
                {
                    if (effect.Type == (byte)EffectType.Beam)
                    {

                        if (form.Mode == xtrafxMode.Speak)
                        {
                            oldTime = System.Environment.TickCount;
                            Vector3d newVec = new Vector3d(effect.TypeData, 32);

                            if (curentOn == false)
                            {
                                shoutOut(9000, "start");
                                curentOn = true;
                            }
                            if ((lastVec.Equals(newVec) == false))
                            {

                                lastVec = newVec;
                                shoutOut(9000, this.lastVec.ToString());
                            }
                            return null;

                        }

                        inject = true;
                        Buffer.BlockCopy(
                            plugin.SharedInfo.rainbow[form.xtrafx_Index], 0, effect.Color, 0, 4);
                        form.xtrafx_Index++;

                        if (form.xtrafx_Index >= plugin.SharedInfo.rainbow.Length)
                        {
                            form.xtrafx_Index = 0;
                        }

                        if (form.Mode == xtrafxMode.Quad)
                        {
                            // trial: multi-beam
                            Vector3d position = new Vector3d(effect.TypeData, 32);
                            Logger.Log("Sending a effect to " + Utils.BytesToHexString(effect.TypeData,"effect"), Helpers.LogLevel.Info);
                            ViewerEffectPacket[][][] ve = new ViewerEffectPacket[2][][];
                            for (int x = 0; x < 2; x++)
                            {
                                ve[x] = new ViewerEffectPacket[2][];
                                for (int y = 0; y < 2; y++)
                                {
                                    ve[x][y] = new ViewerEffectPacket[2];
                                    for (int z = 0; z < 2; z++)
                                    {
                                        ve[x][y][z] = new ViewerEffectPacket();
                                        ve[x][y][z].HasVariableBlocks = true;
                                        ve[x][y][z].Type = PacketType.ViewerEffect;
                                        ve[x][y][z].AgentData = new ViewerEffectPacket.AgentDataBlock();
                                        ve[x][y][z].AgentData.AgentID = frame.AgentID;
                                        ve[x][y][z].AgentData.SessionID = frame.SessionID;
                                        ve[x][y][z].Effect = new ViewerEffectPacket.EffectBlock[1];
                                        ve[x][y][z].Effect[0] = new ViewerEffectPacket.EffectBlock();
                                        ve[x][y][z].Effect[0].ID = UUID.Random();
                                        ve[x][y][z].Effect[0].AgentID = effect.AgentID;
                                        ve[x][y][z].Effect[0].Type = effect.Type;
                                        ve[x][y][z].Effect[0].Duration = effect.Duration;
                                        ve[x][y][z].Effect[0].Color = effect.Color;
                                        ve[x][y][z].Effect[0].TypeData = effect.TypeData;
                                        double ox = ((double)x - 0.5f);
                                        double oy = ((double)y - 0.5f);
                                        double oz = ((double)z - 0.5f);
                                        Vector3d pos = new Vector3d(ox + position.X, oy + position.Y, oz + position.Z);
                                        Buffer.BlockCopy(pos.GetBytes(), 0, ve[x][y][z].Effect[0].TypeData, 32, 24);
                                        ve[x][y][z].Header.Reliable = false;
                                        proxy.InjectPacket(ve[x][y][z], Direction.Outgoing);
                                    }
                                }
                            }
                        }
                        if (form.Mode == xtrafxMode.Circles)
                        {
                            Vector3d TargetPosition = new Vector3d(effect.TypeData, 32);
                            int MapX = ((int)(plugin.SharedInfo.RegionHandle >> 32) );
                            int MapY = ((int)(plugin.SharedInfo.RegionHandle & 0x00000000FFFFFFFF) );
                            Vector3d myPos = new Vector3d(
                                MapX + plugin.SharedInfo.AvPosition.X,
                                MapY + plugin.SharedInfo.AvPosition.Y,
                                 plugin.SharedInfo.AvPosition.Z);
                            Vector3d myLine = TargetPosition - myPos;
                            float duration = effect.Duration * (float)(((double)38 - (myLine.Length()*(2/3))) / 20);
                            if (duration > effect.Duration) duration = effect.Duration;

                            //proxy.writethis("my pos is " + myPos.ToString() + " and target is " + TargetPosition.ToString() + " and myline is " + myLine.ToString(),ConsoleColor.Cyan,ConsoleColor.Black);
                            for (float i = 0; i < (float)Math.Round(myLine.Length()); i+=1.0F)
                            {
                                Vector3d circlePos = myPos + (Vector3d.Normalize(myLine)*i);
                               sendSwirlPoint(circlePos,effect.Color,duration);
                            }
                            sendSwirlPoint(TargetPosition,effect.Color, duration);
                        }

                    }
                    else
                        if (form.Mode == xtrafxMode.Speak)
                        {
                            return null;
                        }
                }
                if (inject)
                {
                    packet = (Packet)ViewerEffect;
                }
            }
            return packet;
        }
Beispiel #22
0
        public void sendSwirlPoint(Vector3d vec,byte[] color, float dur)
        {
            ViewerEffectPacket v = new ViewerEffectPacket();
            v.Type = PacketType.ViewerEffect;
            v.HasVariableBlocks = true;
            v.AgentData = new ViewerEffectPacket.AgentDataBlock();
            v.AgentData.AgentID = frame.AgentID;
            v.AgentData.SessionID = frame.SessionID;
            v.Effect = new ViewerEffectPacket.EffectBlock[1];
            v.Effect[0] = new ViewerEffectPacket.EffectBlock();
            v.Effect[0].ID = UUID.Random();
            v.Effect[0].AgentID = frame.AgentID;
            v.Effect[0].Type = (byte)EffectType.Beam;
            v.Effect[0].Duration = dur;
            v.Effect[0].Color = color;
            v.Effect[0].TypeData = new byte[56];
                Buffer.BlockCopy(UUID.Zero.GetBytes(),0,v.Effect[0].TypeData,0,16);
                Buffer.BlockCopy(UUID.Zero.GetBytes(),0,v.Effect[0].TypeData,16,16);
                Buffer.BlockCopy(vec.GetBytes(), 0, v.Effect[0].TypeData, 32, 24);

            v.Header.Reliable = false;
            v.Header.Resent = false;
            proxy.InjectPacket(v, Direction.Outgoing);
        }
Beispiel #23
0
        /// <summary>
        /// Create a particle swirl around a target position using a <seealso cref="ViewerEffectPacket"/> packet
        /// </summary>
        /// <param name="globalOffset">global offset</param>
        /// <param name="color">A <see cref="Color4"/> object containing the combined red, green, blue and alpha 
        /// color values of particle beam</param>
        /// <param name="duration">a float representing the duration the parcicle beam will last</param>
        /// <param name="effectID">A Unique ID for the beam</param>
        public void SphereEffect(Vector3d globalOffset, Color4 color, float duration, UUID effectID)
        {
            ViewerEffectPacket effect = new ViewerEffectPacket();

            effect.AgentData.AgentID = Client.Self.AgentID;
            effect.AgentData.SessionID = Client.Self.SessionID;

            effect.Effect = new ViewerEffectPacket.EffectBlock[1];
            effect.Effect[0] = new ViewerEffectPacket.EffectBlock();
            effect.Effect[0].AgentID = Client.Self.AgentID;
            effect.Effect[0].Color = color.GetBytes();
            effect.Effect[0].Duration = duration;
            effect.Effect[0].ID = effectID;
            effect.Effect[0].Type = (byte)EffectType.Sphere;

            byte[] typeData = new byte[56];
            Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, typeData, 0, 16);
            Buffer.BlockCopy(UUID.Zero.GetBytes(), 0, typeData, 16, 16);
            Buffer.BlockCopy(globalOffset.GetBytes(), 0, typeData, 32, 24);

            effect.Effect[0].TypeData = typeData;

            Client.Network.SendPacket(effect);
        }
Beispiel #24
0
        /// <summary>
        /// Process an incoming effect
        /// </summary>
        private void ViewerEffectHandler(object sender, PacketReceivedEventArgs e)
        {
            Simulator simulator = e.Simulator;
            var       packet    = e.Packet;

            if (!IsMaster(simulator))
            {
                return;
            }
            if (simulator != client.Network.CurrentSim)
            {
                //Debug("ViewerEffectHandler: from a differnt sim than current " + simulator);
            }
            if (!MaintainEffects)
            {
                return;
            }
            ViewerEffectPacket effect = (ViewerEffectPacket)packet;
            GridClient         Client = client;

            foreach (ViewerEffectPacket.EffectBlock block in effect.Effect)
            {
                EffectType type = (EffectType)block.Type;

                // most effect types have at least these properties
                UUID     sourceAvatar = CogbotHelpers.GetUUID(block.TypeData, 0);
                UUID     targetObject = CogbotHelpers.GetUUID(block.TypeData, 16);
                Vector3d targetPos    = new Vector3d(block.TypeData, 32);
                //Color4 color;
                //if (block.Color.Length == 4)
                //{
                //    color = new Color4(block.Color, 0);
                //}
                //else
                //{
                //    Client.Log("Received a ViewerEffect.EffectBlock.Color array with " + block.Color.Length +
                //        " bytes", Helpers.LogLevel.Warning);
                //    color = Color4.Black;
                //}
                if (sourceAvatar == UUID.Zero)
                {
                    var ag1 = Client.Self.AgentID;
                    var ag2 = block.AgentID;
                    var ag3 = effect.AgentData.AgentID;
                    Debug("Received a " + type.ToString() + " ViewerEffect sourceAvatar==NULL " + targetObject + " " + GetObject(ag1) + " " + GetObject(ag2) + " " + GetObject(ag3), Helpers.LogLevel.Warning, Client);
                }

                // Each ViewerEffect type uses it's own custom binary format for additional BVHData. Fun eh?
                switch (type)
                {
                case EffectType.Beam:
                case EffectType.Point:
                case EffectType.Trail:
                case EffectType.Sphere:
                case EffectType.Spiral:
                case EffectType.Edit:
                    // if (Avatars_OnEffect != null)
                {
                    if (block.TypeData.Length == 56)
                    {
                        PCode sourceType = PCode.Avatar;
                        if (type == EffectType.Edit || type == EffectType.Point || type == EffectType.Beam)
                        {
                            sourceType = PCode.Avatar;
                        }
                        try
                        {
                            SendEffect(simulator, sourceAvatar, targetObject, targetPos,
                                       "EffectType-" + type.ToString(), block.Duration, block.ID, sourceType);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex);
                        }
                    }
                    else
                    {
                        Debug("ERROR: Received a " + type.ToString() +
                              " ViewerEffect with an incorrect TypeData size of " +
                              block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                    }
                    return;
                }
                break;

                case EffectType.LookAt:
                    //if (OnLookAt != null)
                {
                    if (block.TypeData.Length == 57)
                    {
                        LookAtType lookAt = (LookAtType)block.TypeData[56];

                        try
                        {
                            SendEffect(simulator, sourceAvatar, targetObject, targetPos,
                                       "LookAtType-" + lookAt.ToString(), block.Duration, block.ID, PCode.Avatar);
                        }
                        catch (Exception ex)
                        {
                            Debug(ex.Message, Helpers.LogLevel.Error, Client, ex);
                        }
                        return;
                    }
                    else
                    {
                        Debug("Received a LookAt ViewerEffect with an incorrect TypeData size of " +
                              block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                    }
                }
                break;

                case EffectType.PointAt:
                    // if (Avatars_OnPointAt != null)
                {
                    if (block.TypeData.Length == 57)
                    {
                        PointAtType pointAt = (PointAtType)block.TypeData[56];

                        try
                        {
                            SendEffect(simulator, sourceAvatar, targetObject, targetPos,
                                       "PointAtType-" + pointAt.ToString(), block.Duration, block.ID,
                                       PCode.Avatar);
                        }
                        catch (Exception ex)
                        {
                            Debug(ex.Message, Helpers.LogLevel.Error, Client, ex);
                        }
                        return;
                    }
                    else
                    {
                        Debug("Received a PointAt ViewerEffect with an incorrect TypeData size of " +
                              block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client);
                    }
                }
                break;

                case EffectType.Text:
                case EffectType.Icon:
                case EffectType.Connector:
                case EffectType.FlexibleObject:
                case EffectType.AnimalControls:
                case EffectType.AnimationObject:
                case EffectType.Cloth:
                case EffectType.Glow:
                default:
                    SendNewRegionEvent(SimEventType.EFFECT, "OnViewerEffect", type, sourceAvatar, targetObject,
                                       targetPos);
                    break;
                }
                SendEffect(simulator, sourceAvatar, targetObject, targetPos, "EffectType." + type, 0.1f, block.ID,
                           PCode.None);
            }
        }