Example #1
0
        protected override void OnReceive(int size, byte opcode, byte[] packet)
        {
            InPacket in_packet = InPacket.Parse((Opcode)opcode, packet);

            switch ((Opcode)opcode)
            {
            case Opcode.FAILURE:
                if (this.OnFailure != null)
                {
                    FailurePacket failure = (FailurePacket)in_packet;
                    this.OnFailure(failure.ErrorId, failure.ErrorDescription);
                }
                break;

            case Opcode.CREATE_SUCCESS:
                if (this.OnCreateSuccess != null)
                {
                    CreateSuccessPacket create_success = (CreateSuccessPacket)in_packet;
                    this.OnCreateSuccess(create_success.ObjectId, create_success.CharId);
                }
                break;

            case Opcode.TEXT:
                if (this.OnText != null)
                {
                    TextPacket text = (TextPacket)in_packet;
                    this.OnText(text.Name, text.ObjectId, text.ObjectType, text.Texture1Id, text.Texture2Id, text.NumStars, text.Recipient, text.Text, text.CleanText);
                }
                break;

            case Opcode.SHOOT:
                if (this.OnShoot != null)
                {
                    ShootPacket shoot = (ShootPacket)in_packet;
                    this.OnShoot(shoot.BulletId, shoot.OwnerId, shoot.ContainerType, shoot.StartingPosition, shoot.Angle, shoot.Damage);
                }
                break;

            case Opcode.DAMAGE:
                if (this.OnDamage != null)
                {
                    DamagePacket damage = (DamagePacket)in_packet;
                    this.OnDamage(damage.TargetId, damage.ConditionEffect, damage.DamageAmount, damage.BulletId, damage.ObjectId);
                }
                break;

            case Opcode.UPDATE:
                if (this.OnUpdate != null)
                {
                    UpdatePacket update = (UpdatePacket)in_packet;
                    this.OnUpdate(update.Tiles, update.NewObjects, update.Drops);
                }
                break;

            case Opcode.NOTIFICATION:
                if (this.OnNotification != null)
                {
                    NotificationPacket notification = (NotificationPacket)in_packet;
                    this.OnNotification(notification.ObjectId, notification.Text);
                }
                break;

            case Opcode.NEW_TICK:
                if (this.OnNewTick != null)
                {
                    NewTickPacket new_tick = (NewTickPacket)in_packet;
                    this.OnNewTick(new_tick.TickId, new_tick.TickTime, new_tick.Statuses);
                }
                break;

            case Opcode.MAPINFO:
                if (this.OnMapInfo != null)
                {
                    MapInfoPacket map_info = (MapInfoPacket)in_packet;
                    this.OnMapInfo(map_info.Width, map_info.Height, map_info.Name, map_info.FP, map_info.Background, map_info.AllowPlayerTeleport, map_info.ShowDisplays, map_info.ExtraXml);
                }
                break;
            }
        }