Exemplo n.º 1
0
        /// <summary>
        /// Called when the room metadata changes (such as title, woots or plays).
        /// </summary>
        /// <param name="m">
        /// The message.
        /// </param>
        public void OnUpdateMeta(Message m)
        {
            // Extract data.
            string ownerName = m.GetString(0), roomName = m.GetString(1);

            int plays = m.GetInteger(2), woots = m.GetInteger(3), totalWoots = m.GetInteger(4);

            // Update relevant objects.
            this._in.Source.Owner.Name = ownerName;
            this._in.Source.Name = roomName;
            this._in.Source.Plays = plays;
            this._in.Source.Woots = woots;
            this._in.Source.TotalWoots = totalWoots;

            // Fire the event.
            var e = new RoomEventArgs(this._in.Source, m);

            this._in.Source.Pull.Meta.UpdateMetaEvent(e);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when [initialize].
        /// </summary>
        /// <param name="m">
        /// The m.
        /// </param>
        private void OnInit(Message m)
        {
            // Extract data
            string owner = m.GetString(0),
                   name = m.GetString(1),
                   worldKey = Tools.Derot(m.GetString(5)),
                   botName = m.GetString(9);

            int plays = m.GetInteger(2),
                woots = m.GetInteger(3),
                totalWoots = m.GetInteger(4),
                botId = m.GetInteger(6),
                width = m.GetInteger(12),
                height = m.GetInteger(13);

            double botX = m.GetDouble(7), botY = m.GetDouble(8), gravityMultiplier = m.GetDouble(15);

            bool isTutorialRoom = m.GetBoolean(14),
                 potions = m.GetBoolean(16),
                 hasAccess = m.GetBoolean(10),
                 isOwner = m.GetBoolean(11);

            // Update relevant objects
            this._initMessage = m;

            this.Bot.Name = botName;
            this.Bot.Id = botId;
            this.Bot.X = botX;
            this.Bot.Y = botY;
            this.Bot.HasAccess = hasAccess;

            // Bot.IsOwner = isOwner;
            this.Bot.PlayingIn = this.Source;

            this.Source.OnlineBots.Add(this.Bot);

            if (this.Source.IsInitialized)
            {
                // You don't need to get the room data multiple times. Save time by returning.
                return;
            }

            // Update the room data.
            this.Source.Name = name;
            this.Source.Owner = Tools.GetPlayer(owner, this.Source);
            this.Source.Plays = plays;
            this.Source.Woots = woots;
            this.Source.TotalWoots = totalWoots;
            this.Source.RoomKey = worldKey;
            this.Source.Height = height;
            this.Source.Width = width;
            RoomAccessor.Width = width;
            RoomAccessor.Height = height;
            this.Source.PotionsAllowed = potions;
            this.Source.IsTutorialRoom = isTutorialRoom;
            this.Source.GravityMultiplier = gravityMultiplier;

            this.Source.IsInitialized = true;

            // Execute the messages that came prematurely.
            foreach (Message msg in this._prematureMessages)
            {
                this.OnMessage(this, msg);
            }

            this._prematureMessages.Clear();

            // Begin loading blocks.
            this.LoadBlocks();

            this.Source.BlocksLoaded = true;

            // Begin updating physics.
            this._playerPhysicsThread = new Thread(this.UpdatePhysics);
            this._playerPhysicsThread.Start();

            // Fire the event.
            var e = new RoomEventArgs(this.Source, m);

            this.Source.Pull.InitEvent(e);
        }