Ejemplo n.º 1
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                if (worldCon.CrownHolder != null)
                {
                    worldCon.CrownHolder.HasCrown = false;
                }

                player.HasCrown      = true;
                worldCon.CrownHolder = player;
            }

            if (player != null)
            {
                CrownEvent crownEvent = new CrownEvent()
                {
                    Raw    = message,
                    Player = player
                };

                connectionBase.RaiseServerEvent <CrownEvent>(crownEvent);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            string username = message.GetString(0);
            string text     = message.GetString(1);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            Player          player   = worldCon.Players.GetPlayer(username);

            if (player == null)
            {
                player = worldCon.Client.GetPlayerByUsername(username);
            }

            ChatMessage chatMessage = new ChatMessage(player, text);

            if (!handled)
            {
                worldCon.Chat.Add(chatMessage);
            }

            OldSayEvent oldSayEvent = new OldSayEvent()
            {
                Raw         = message,
                ChatMessage = chatMessage
            };

            connectionBase.RaiseServerEvent <OldSayEvent>(oldSayEvent);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            string      title         = message.GetString(0);
            string      text          = message.GetString(1);
            ChatMessage systemMessage = new ChatMessage(null, string.Format("{0} {1}", title, text));

            if (connectionBase is LobbyConnection)
            {
                LobbyConnection lobbyCon = (LobbyConnection)connectionBase;

                if (!handled)
                {
                    lobbyCon.MessageOfTheDay = message.GetString(1);
                }
            }
            else if (connectionBase is WorldConnection)
            {
                if (!handled)
                {
                    WorldConnection worldCon = (WorldConnection)connectionBase;
                    worldCon.Chat.Add(systemMessage);
                }
            }

            InfoEvent infoEvent = new InfoEvent()
            {
                Raw           = message,
                SystemMessage = systemMessage
            };

            connectionBase.RaiseServerEvent <InfoEvent>(infoEvent);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection baes</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int  userId   = message.GetInt(0);
            int  potionId = message.GetInt(1);
            bool isActive = message.GetBoolean(2);

            Potion potion = (Potion)potionId;

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.SetPotion(potion, isActive ? PotionState.Active : PotionState.Inactive);
            }

            PotionEvent potionEvent = new PotionEvent()
            {
                Raw      = message,
                Player   = player,
                Potion   = potion,
                IsActive = isActive
            };

            connectionBase.RaiseServerEvent <PotionEvent>(potionEvent);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            WorldPlayer player = new WorldPlayer(worldCon, message.GetString(1), message.GetInt(0));

            player.Face        = (FaceID)message.GetInt(2);
            player.X           = message.GetInt(3);
            player.Y           = message.GetInt(4);
            player.InGodMode   = message.GetBoolean(5);
            player.IsModerator = message.GetBoolean(6);
            player.HasChat     = message.GetBoolean(7);
            player.GoldCoins   = message.GetInt(8);
            player.BlueCoins   = message.GetInt(9);

            //Message 10 will eventually be removed or changed
            //No need to get purple information

            player.IsFriendsWithYou = message.GetBoolean(11);
            player.HasBuildersClub  = message.GetBoolean(12);

            if (!handled)
            {
                worldCon.Players.Add(player);
            }

            AddEvent addEvent = new AddEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <AddEvent>(addEvent);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            List <KeyTrigger> triggers = new List <KeyTrigger>();

            for (uint i = 0; i < message.Count; i++)
            {
                if (message[i] is string)
                {
                    Key key = (Key)Enum.Parse(typeof(Key), message.GetString(i), true);
                    triggers.Add(new KeyTrigger(key));

                    if (!handled)
                    {
                        worldCon.Keys.SetKeyActive(key);
                    }
                }
            }

            ShowEvent showEvent = new ShowEvent()
            {
                Raw      = message,
                Triggers = triggers
            };

            connectionBase.RaiseServerEvent <ShowEvent>(showEvent);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int width      = message.GetInt(0);
            int height     = message.GetInt(1);
            int borderId   = message.GetInt(2);
            int workareaId = message.GetInt(3);

            if (!handled)
            {
                world.Clear(width, height, (BlockID)borderId, (BlockID)workareaId);
                foreach (KeyValuePair <int, WorldPlayer> player in worldCon.Players.GetDictionary())
                {
                    player.Value.Reset();
                }
            }

            BlockID borderID   = (BlockID)borderId;
            BlockID workareaID = (BlockID)workareaId;

            ClearEvent clearEvent = new ClearEvent()
            {
                Raw             = message,
                World           = world,
                BorderBlockID   = borderID,
                WorkareaBlockID = workareaID
            };

            connectionBase.RaiseServerEvent <ClearEvent>(clearEvent);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            bool allowed = message.GetBoolean(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;

            if (worldCon != null)
            {
                //Update each player's potions
                foreach (KeyValuePair <int, WorldPlayer> playerEntry in worldCon.Players.GetDictionary())
                {
                    foreach (KeyValuePair <Potion, PotionState> potionEntry in playerEntry.Value.Potions)
                    {
                        if (allowed)
                        {
                            if (potionEntry.Value == PotionState.Suspended)
                            {
                                playerEntry.Value.SetPotion(potionEntry.Key, PotionState.Active);
                            }
                        }
                        else
                        {
                            if (potionEntry.Value == PotionState.Active)
                            {
                                playerEntry.Value.SetPotion(potionEntry.Key, PotionState.Suspended);
                            }
                        }
                    }
                }
            }

            List <Potion> potions = new List <Potion>();

            for (uint i = 1; i < message.Count; i++)
            {
                int potionType = -1;
                if (int.TryParse(message.GetString(i), out potionType))
                {
                    Potion p = (Potion)potionType;
                    potions.Add(p);

                    if (!handled)
                    {
                        worldCon.Potions.SetEnabled(p, allowed);
                    }
                }
            }

            AllowPotionEvent allowPotionEvent = new AllowPotionEvent()
            {
                Raw        = message,
                Potions    = potions,
                AreEnabled = allowed
            };

            connectionBase.RaiseServerEvent <AllowPotionEvent>(allowPotionEvent);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            List <WorldPlayer> players = new List <WorldPlayer>();

            bool isWorldReset = message.GetBoolean(0);

            uint index = 1;

            while (index + 2 < message.Count)
            {
                WorldPlayer player = worldCon.Players.GetPlayer(message.GetInt(index));
                if (player != null)
                {
                    if (!handled)
                    {
                        Vector loc = new Vector(message.GetInt(index + 1), message.GetInt(index + 2));
                        player.SetLocationInternal(loc);

                        if (!isWorldReset)
                        {
                            player.Respawn();
                        }
                    }

                    players.Add(player);
                }

                index += 3;
            }

            if (isWorldReset)
            {
                ResetEvent resetEvent = new ResetEvent()
                {
                    Raw = message
                };

                connectionBase.RaiseServerEvent <ResetEvent>(resetEvent);
            }
            else
            {
                for (int i = 0; i < players.Count; i++)
                {
                    KillEvent killEvent = new KillEvent()
                    {
                        Raw    = message,
                        Player = players[i]
                    };

                    connectionBase.RaiseServerEvent <KillEvent>(killEvent);
                }
            }
        }
Ejemplo n.º 10
0
        private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash)
        {
            using (var pack = new Packet(SH3Type.WorldServerIP)) {
                pack.WriteByte((byte)wc.Status);

                pack.WriteString(wc.IP, 16);
                Log.WriteLine(LogLevel.Warn, "{0} - IP", wc.IP);
                pack.WriteUShort(wc.Port);
                pack.WriteString(hash, 32);
                pack.Fill(32, 0);
                pClient.SendPacket(pack);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            worldCon.HasAccess = true;

            AccessEvent accessEvent = new AccessEvent()
            {
                Raw = message
            };

            connectionBase.RaiseServerEvent <AccessEvent>(accessEvent);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            worldCon.HasAccess = false;

            LostAccessEvent lostAccessEvent = new LostAccessEvent()
            {
                Raw = message
            };

            connectionBase.RaiseServerEvent <LostAccessEvent>(lostAccessEvent);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            SavedEvent savedEvent = new SavedEvent()
            {
                Raw   = message,
                World = world
            };

            connectionBase.RaiseServerEvent <SavedEvent>(savedEvent);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            Layer   layer   = (Layer)message.GetInt(0);
            int     x       = message.GetInt(1);
            int     y       = message.GetInt(2);
            BlockID blockId = (BlockID)message.GetInt(3);

            Block block = null;

            if (message.Count > 4)
            {
                int userId = message.GetInt(4);

                WorldPlayer player = worldCon.Players.GetPlayer(userId);
                block = new Block(worldCon, blockId, layer, x, y)
                {
                    Placer = player
                };
            }
            else
            {
                block = new Block(worldCon, blockId, layer, x, y);
            }

            if (!handled)
            {
                if (blockId == 0)
                {
                    Block old = world[x, y, layer];
                    if (old.ID == BlockID.CoinGold ||
                        old.ID == BlockID.CoinBlue)
                    {
                        worldCon.Physics.RemoveCoin(old);
                    }
                }

                world.SetBlock(block);
            }

            worldCon.CheckBlock(block);
            BlockEvent blockEvent = new BlockEvent()
            {
                Raw   = message,
                Block = block
            };

            connectionBase.RaiseServerEvent <BlockEvent>(blockEvent);
        }
Ejemplo n.º 15
0
    public async ValueTask ConnectToWorldAsync(string characterId, CancellationToken cancellationToken)
    {
        CharacterId     = characterId;
        WorldConnection = _messageProcessorFactory.CreateMessageProcessorFor("http://127.0.0.1:30111/hub"); // world connection string.

        await WorldConnection.ConnectAsync(characterId, cancellationToken)
        .ConfigureAwait(false);

        _worldConnectionSubject.OnNext(WorldConnection);

        _worldStateSubscription = WorldConnection.Subscribe <WorldState>(message =>
        {
            _worldStateSubject.OnNext(message);
            return(default);
Ejemplo n.º 16
0
        private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash)
        {
            using (var pack = new Packet(SH3Type.WorldServerIP))
            {
                pack.WriteByte((byte)wc.Status);

                string ip = pClient.Host == "127.0.0.1" ? "127.0.0.1" : wc.IP;
                pack.WriteString(wc.IP, 16);

                pack.WriteUShort(wc.Port);
                pack.WriteString(hash, 32);
                pack.Fill(32, 0);
                pClient.SendPacket(pack);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection baes</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            WootUpEvent wootUpEvent = new WootUpEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <WootUpEvent>(wootUpEvent);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int      x        = message.GetInt(0);
            int      y        = message.GetInt(1);
            BlockID  blockId  = (BlockID)message.GetInt(2);
            Rotation rotation = (Rotation)message.GetUInt(3);

            uint portalId       = message.GetUInt(4);
            uint portalTargetId = message.GetUInt(5);

            Portal portal = null;

            if (message.Count > 6)
            {
                int         userId = message.GetInt(6);
                WorldPlayer player = worldCon.Players.GetPlayer(userId);

                portal = new Portal(worldCon, blockId, x, y, rotation, portalId, portalTargetId)
                {
                    Placer = player
                };
            }
            else
            {
                portal = new Portal(worldCon, blockId, x, y, rotation, portalId, portalTargetId);
            }

            if (!handled)
            {
                world.SetBlock(portal);
            }

            worldCon.CheckBlock(portal);
            PortalBlockEvent portalBlockEvent = new PortalBlockEvent()
            {
                Raw    = message,
                Portal = portal
            };

            connectionBase.RaiseServerEvent <PortalBlockEvent>(portalBlockEvent);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int     x        = message.GetInt(0);
            int     y        = message.GetInt(1);
            BlockID blockId  = (BlockID)message.GetInt(2);
            string  text     = message.GetString(3);
            string  hexColor = message.GetString(4);

            LabelBlock labelBlock = null;

            if (message.Count > 5)
            {
                int userId = message.GetInt(5);

                WorldPlayer player = worldCon.Players.GetPlayer(userId);
                labelBlock = new LabelBlock(worldCon, blockId, x, y, text, hexColor)
                {
                    Placer = player
                };
            }
            else
            {
                labelBlock = new LabelBlock(worldCon, blockId, x, y, text, hexColor);
            }

            if (!handled)
            {
                world.SetBlock(labelBlock);
            }

            worldCon.CheckBlock(labelBlock);
            LabelBlockEvent labelBlockEvent = new LabelBlockEvent()
            {
                Raw        = message,
                LabelBlock = labelBlock
            };

            connectionBase.RaiseServerEvent <LabelBlockEvent>(labelBlockEvent);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            uint argb = message.GetUInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            FluidColor      color    = new FluidColor(argb);

            if (!handled)
            {
                worldCon.World.BackgroundColor = color;
            }

            BackgroundColorChangedEvent backgroundColorChangedEvent = new BackgroundColorChangedEvent()
            {
                Raw   = message,
                Color = color
            };

            connectionBase.RaiseServerEvent <BackgroundColorChangedEvent>(backgroundColorChangedEvent);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.HasSilverCrown = true;
            }

            SilverCrownEvent silverCrownEvent = new SilverCrownEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <SilverCrownEvent>(silverCrownEvent);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            int userId = message.GetInt(0);

            WorldPlayer player = worldCon.Players.GetPlayer(userId);
            LeftEvent leftEvent = new LeftEvent()
            {
                Raw = message,
                Player = player
            };

            if (!handled)
            {
                worldCon.Players.Remove(userId);
            }

            connectionBase.RaiseServerEvent<LeftEvent>(leftEvent);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.m_deaths++;
            }

            KillEvent killEvent = new KillEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <KillEvent>(killEvent);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.InGuadianMode = !player.InGuadianMode;
            }

            GuardianModeEvent guardianModeEvent = new GuardianModeEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <GuardianModeEvent>(guardianModeEvent);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int     x       = message.GetInt(0);
            int     y       = message.GetInt(1);
            BlockID blockId = (BlockID)message.GetInt(2);
            uint    musicId = message.GetUInt(3);

            MusicBlock musicBlock = null;

            if (message.Count > 4)
            {
                int         userId = message.GetInt(4);
                WorldPlayer player = worldCon.Players.GetPlayer(userId);

                musicBlock = new MusicBlock(worldCon, blockId, x, y, musicId)
                {
                    Placer = player
                };
            }
            else
            {
                musicBlock = new MusicBlock(worldCon, blockId, x, y, musicId);
            }

            if (!handled)
            {
                world.SetBlock(musicBlock);
            }

            worldCon.CheckBlock(musicBlock);
            MusicBlockEvent musicBlockEvent = new MusicBlockEvent()
            {
                Raw        = message,
                MusicBlock = musicBlock
            };

            connectionBase.RaiseServerEvent <MusicBlockEvent>(musicBlockEvent);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int      x        = message.GetInt(0);
            int      y        = message.GetInt(1);
            BlockID  blockId  = (BlockID)message.GetInt(2);
            Rotation rotation = (Rotation)message.GetUInt(3);

            RotatableBlock rotatableBlock = null;

            if (message.Count > 4)
            {
                int         userId = message.GetInt(4);
                WorldPlayer player = worldCon.Players.GetPlayer(userId);

                rotatableBlock = new RotatableBlock(worldCon, blockId, x, y, rotation)
                {
                    Placer = player
                };
            }
            else
            {
                rotatableBlock = new RotatableBlock(worldCon, blockId, x, y, rotation);
            }

            if (!handled)
            {
                world.SetBlock(rotatableBlock);
            }

            worldCon.CheckBlock(rotatableBlock);
            RotatableBlockEvent rotatableBlockEvent = new RotatableBlockEvent()
            {
                Raw            = message,
                RotatableBlock = rotatableBlock
            };

            connectionBase.RaiseServerEvent <RotatableBlockEvent>(rotatableBlockEvent);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;
            World           world    = worldCon.World;

            int     x       = message.GetInt(0);
            int     y       = message.GetInt(1);
            BlockID blockId = (BlockID)message.GetInt(2);
            string  text    = message.GetString(3);

            TextBlock textBlock = null;

            if (message.Count > 4)
            {
                int userId = message.GetInt(4);

                WorldPlayer player = worldCon.Players.GetPlayer(userId);
                textBlock = new TextBlock(worldCon, blockId, x, y, text)
                {
                    Placer = player
                };
            }
            else
            {
                textBlock = new TextBlock(worldCon, blockId, x, y, text);
            }

            if (!handled)
            {
                world.SetBlock(textBlock);
            }

            worldCon.CheckBlock(textBlock);
            TextBlockEvent textBlockEvent = new TextBlockEvent()
            {
                Raw       = message,
                TextBlock = textBlock
            };

            connectionBase.RaiseServerEvent <TextBlockEvent>(textBlockEvent);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int  userId     = message.GetInt(0);
            bool godEnabled = message.GetBoolean(1);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.InGodMode = godEnabled;
            }

            GodEvent godEvent = new GodEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <GodEvent>(godEvent);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);
            int face   = message.GetInt(1);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (!handled && player != null)
            {
                player.Face = (FaceID)face;
            }

            FaceEvent faceEvent = new FaceEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <FaceEvent>(faceEvent);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            int userId = message.GetInt(0);

            WorldConnection worldCon = (WorldConnection)connectionBase;
            WorldPlayer     player   = worldCon.Players.GetPlayer(userId);

            if (player != null && !handled)
            {
                player.GoldCoins = message.GetInt(1);
                player.BlueCoins = message.GetInt(2);
            }

            CoinEvent coinEvent = new CoinEvent()
            {
                Raw    = message,
                Player = player
            };

            connectionBase.RaiseServerEvent <CoinEvent>(coinEvent);
        }