Example #1
0
        /// <summary>
        /// Activates a room user and makes it appear in the door of the room.
        /// </summary>
        /// <param name="Session">The Woodpecker.Sessions.Session object of the user that is ready to interact with the room.</param>
        public void startUser(Session Session)
        {
            if (!enteringSessions.Contains(Session.ID)) // Invalid entry
            {
                return;
            }

            roomUser newUser = new roomUser(Session);

            if (Session.authenticatedTeleporter == 0)
            {
                roomModel Model = this.getModel();
                if (Model == null)
                {
                    return;
                }
                newUser.X = Model.doorX;
                newUser.Y = Model.doorY;
                newUser.Z = Model.doorZ;
            }
            else
            {
                Items.floorItem pItem = this.getFloorItem(Session.authenticatedTeleporter);
                if (pItem != null && pItem.Definition.Behaviour.isTeleporter)
                {
                    newUser.X = pItem.X;
                    newUser.Y = pItem.Y;
                    newUser.Z = pItem.Z;
                    Session.authenticatedTeleporter = 0;

                    this.broadcoastTeleportActivity(pItem.ID, Session.User.Username, false);
                }
                else
                {
                    return; // Invalid item used to enter flat
                }
            }
            newUser.ID = this.getFreeRoomUnitIdentifier();

            if (this.Information.isUserFlat)
            {
                newUser.isOwner = (Session.User.Username == this.Information.Owner ||
                                   Session.User.hasFuseRight("fuse_any_room_controller"));

                newUser.hasRights = (newUser.isOwner ||
                                     this.Information.superUsers ||
                                     Engine.Game.Rooms.userHasRightsInRoom(Session.User.ID, this.roomID));

                newUser.refreshRights();
            }

            // User has entered
            Session.roomID = this.roomID;

            this.enteringSessions.Remove(Session.ID);
            this.roomUsers.Add(Session.ID, newUser);

            this.castRoomUnit(newUser.ToString());
            this.updateUserAmount();
        }
Example #2
0
        /// <summary>
        /// Tries to load a bot from the database and makes it visible in the room. If the X and Y parameters are not both zero, then the bot will be placed at the new position.
        /// </summary>
        /// <param name="nestID">The database ID of the nest item of the bot to load.</param>
        /// <param name="newX">The new X position of the bot. Supply 0 to set the last saved X position of the bot.</param>
        /// <param name="newY">The new Y position of the bot. Supply 0 to set the last saved Y position of the bot.</param>
        public void loadRoomBot(int botID, byte newX, byte newY)
        {
            if (this.roomBots != null)
            {
                bInfo = Engine.Game.Items.getBotInformation(botID);
                if (bInfo != null)
                {
                    roomUser bUser = new roomUser(bInfo);
                    bUser.ID = this.getFreeRoomUnitIdentifier();

                    bUser.X = bInfo.startX;
                    bUser.Y = bInfo.startY;

                    bUser.Z = this.gridHeight[bUser.X, bUser.Y];
                    this.gridUnit[bUser.X, bUser.Y] = true;
                    this.roomBots.Add(bUser);
                    //this.roomUsers.Add((uint)bUser.ID, bUser);
                    Woodpecker.Core.Logging.Log("We tried jeeves.");
                    castRoomUnit(bUser.ToString());
                    refreshRoomUnitOnTile((byte)0, (byte)0);
                    refreshRoomUnitOnTile(bInfo.startX, bInfo.startY);
                }
            }
        }