Пример #1
0
 private SimGeneric DeclareGroupRole(UUID groupID, UUID key)
 {
     // Create a non UUID.Zero for the "Everyone" GroupRole
     if (key == UUID.Zero)
     {
         byte[] i = groupID.GetBytes();
         for (int index = 0; index < i.Length; index++)
         {
             i[index] ^= 0xff;
         }
         key = CogbotHelpers.GetUUID(i, 0);
     }
     return(DeclareGeneric("GroupRole", key, "DeclareGroupRole"));
 }
Пример #2
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);
            }
        }