Ejemplo n.º 1
0
        public static async Task AnnouncementAsync(Player player, string title, string message)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "message");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, message);
            Amf3Helper.WriteText(writer, "title");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, title);
            Amf3Helper.WriteText(writer, "visible");

            writer.Write((byte)Amf3Type.True);
            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = "ToggleAnnounce"
            });
        }
Ejemplo n.º 2
0
        public static async Task MessageGuiAsync(this Player @this, string name, IDictionary <string, object> arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException(nameof(arguments));
            }

            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);

            foreach (var(key, value) in arguments)
            {
                Amf3Helper.WriteText(writer, key);

                switch (value)
                {
                case string str:
                    writer.Write((byte)Amf3Type.String);
                    Amf3Helper.WriteText(writer, str);
                    break;

                case int integer:
                    writer.Write((byte)Amf3Type.Integer);
                    Amf3Helper.WriteNumber2(writer, (uint)integer);
                    break;

                case uint unsigned:
                    writer.Write((byte)Amf3Type.Integer);
                    Amf3Helper.WriteNumber2(writer, unsigned);
                    break;

                case bool boolean:
                    writer.Write((byte)(boolean ? Amf3Type.True : Amf3Type.False));
                    break;

                case null:
                    writer.Write((byte)Amf3Type.Undefined);
                    break;
                }
            }

            writer.Write((byte)Amf3Type.Null);

            @this.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = @this,
                Content     = stream.ToArray(),
                MessageName = name
            });
        }
Ejemplo n.º 3
0
        public static async Task ToggleAsync(Player player, string name, bool value)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "visible");

            writer.Write((byte)(value ? Amf3Type.True : Amf3Type.False));
            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = name
            });
        }
Ejemplo n.º 4
0
        public static async Task CloneMailboxAsync(Player player)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "visible");

            writer.Write((byte)Amf3Type.False);
            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = "ToggleMail"
            });
        }
Ejemplo n.º 5
0
        public static async Task MessageGuiAsync(this Player @this, string name, IDictionary <string, object> arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException(nameof(arguments));
            }

            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            Amf3Helper.Write(writer, arguments);

            @this.Message(new UIMessageServerToSingleClientMessage
            {
                Associate   = @this,
                Content     = stream.ToArray(),
                MessageName = name
            });
        }
Ejemplo n.º 6
0
        public static async Task SetGuildNameAsync(Player player, string name)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "guildName");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, name);

            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = "SetGuildName"
            });
        }
Ejemplo n.º 7
0
        public static async Task SingleArgumentGuiAsync(this Player @this, string name, string argument, string value)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, argument);

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, value);

            writer.Write((byte)Amf3Type.Null);

            @this.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = @this,
                Content     = stream.ToArray(),
                MessageName = name
            });
        }
Ejemplo n.º 8
0
        public static async Task AddGuildMemberAsync(Player player, int index, GuildMember member)
        {
            await using var stream = new MemoryStream();
            using var writer       = new BitWriter(stream);

            writer.Write((byte)Amf3Type.Array);
            writer.Write <byte>(1);
            Amf3Helper.WriteText(writer, "name");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Name);
            Amf3Helper.WriteText(writer, "zone");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Zone);
            Amf3Helper.WriteText(writer, "rank");

            writer.Write((byte)Amf3Type.String);
            Amf3Helper.WriteText(writer, member.Rank);
            Amf3Helper.WriteText(writer, "online");

            writer.Write((byte)(member.Online ? Amf3Type.True : Amf3Type.False));
            Amf3Helper.WriteText(writer, "index");

            writer.Write((byte)Amf3Type.Integer);
            Amf3Helper.WriteNumber2(writer, (uint)index);

            writer.Write((byte)Amf3Type.Null);

            player.Message(new UiMessageServerToSingleClientMessage
            {
                Associate   = player,
                Content     = stream.ToArray(),
                MessageName = "AddGuildMember"
            });
        }