Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
    protected override void DeSerialise(byte[] buf, ref int o, int length)
    {
        AgentId   = BinarySerializer.DeSerializeGuid(buf, ref o, length);
        SessionId = BinarySerializer.DeSerializeGuid(buf, ref o, length);

        byte nEffects = buf[o++];

        for (byte i = 0; i < nEffects; i++)
        {
            Guid             effectId = BinarySerializer.DeSerializeGuid(buf, ref o, length);
            Guid             agentId  = BinarySerializer.DeSerializeGuid(buf, ref o, length);
            ViewerEffectType type     = (ViewerEffectType)buf[o++];
            float            duration = BinarySerializer.DeSerializeFloat_Le(buf, ref o, length);
            Color            color    = BinarySerializer.DeSerializeColor(buf, ref o, length);

            byte         typeDataLength = buf[o++];
            ViewerEffect effect         = null;
            switch (type)
            {
            case ViewerEffectType.Text:
                break;

            case ViewerEffectType.Icon:
                break;

            case ViewerEffectType.Connector:
                break;

            case ViewerEffectType.FlexibleObject:
                break;

            case ViewerEffectType.AnimalControls:
                break;

            case ViewerEffectType.LocalAnimationObject:
                break;

            case ViewerEffectType.Cloth:
                break;

            case ViewerEffectType.EffectBeam:
            case ViewerEffectType.EffectGlow:
            case ViewerEffectType.EffectPoint:
            case ViewerEffectType.EffectTrail:
            case ViewerEffectType.EffectSphere:
            case ViewerEffectType.EffectSpiral:
            case ViewerEffectType.EffectEdit:
                ViewerEffectSpiral spiralEffect = new ViewerEffectSpiral();
                spiralEffect.SourceObjectId = BinarySerializer.DeSerializeGuid(buf, ref o, length);
                spiralEffect.TargetObjectId = BinarySerializer.DeSerializeGuid(buf, ref o, length);
                spiralEffect.PositionGlobal = BinarySerializer.DeSerializeVector3Double(buf, ref o, length);
                effect = spiralEffect;
                break;

            case ViewerEffectType.EffectLookAt:
                ViewerEffectLookAt lookAtEffect = new ViewerEffectLookAt();
                lookAtEffect.SourceAvatarId = BinarySerializer.DeSerializeGuid(buf, ref o, length);
                lookAtEffect.TargetObjectId = BinarySerializer.DeSerializeGuid(buf, ref o, length);
                lookAtEffect.TargetPosition = BinarySerializer.DeSerializeVector3Double(buf, ref o, length);
                lookAtEffect.LookAtType     = (ViewerEffectLookAtType)buf[o++];
                effect = lookAtEffect;
                break;

            case ViewerEffectType.EffectPointAt:
                break;

            case ViewerEffectType.EffectVoiceViaualizer:
                break;

            case ViewerEffectType.NameTag:
                break;

            case ViewerEffectType.EffectBlob:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (effect == null)
            {
                throw new NotImplementedException($"ViewerEffectMessage: ViewerEffect type {type} is not implemented.");
            }

            effect.Id         = effectId;
            effect.AgentId    = agentId;
            effect.EffectType = type;
            effect.Duration   = duration;
            effect.Color      = color;
            Effects.Add(effect);
        }
    }