Beispiel #1
0
        /// <summary>
        /// Broacoasts the placement of a wall item to all room users.
        /// </summary>
        /// <param name="pItem">The wallItem instance of the wall item that is placed.</param>
        private void broadcoastWallItemPlacement(wallItem pItem)
        {
            serverMessage Message = new serverMessage(83); // "AS"

            Message.Append(pItem.ToString());
            this.sendMessage(Message);
        }
Beispiel #2
0
        /// <summary>
        /// Broadcoasts the state update of a given wall item to all active room users.
        /// </summary>
        /// <param name="pItem">The wallItem instance of the wall item that is updated.</param>
        private void broadcoastWallItemStateUpdate(wallItem pItem)
        {
            serverMessage Message = new serverMessage(85); // "AU"

            Message.Append(pItem.ToString());
            this.sendMessage(Message);
        }
Beispiel #3
0
        /// <summary>
        /// Tries to remove a wallitem from the room, broadcoasts the removal and updates the item, and optionally sends the item to the hand of a given user and returns a stripItem copy of the item with the out parameter.
        /// </summary>
        /// <param name="itemID">The database ID of the item to remove.</param>
        /// <param name="toUserID">The database ID of the user that should receive this item in his/her hand. Supply -1 to delete the item from the database.</param>
        /// <param name="handItemInstance">If toUserID > 0, then the stripItem copy of the removed item will be returned via the out parameter.</param>
        public stripItem pickupWallItem(int itemID, int toUserID)
        {
            wallItem pItem = this.getWallItem(itemID);

            if (pItem == null || (pItem.Definition.Behaviour.isPostIt && toUserID > 0))
            {
                return(null); // Can't pickup item to hand
            }
            broadcoastWallItemRemoval(itemID);
            this.unloadWallItem(itemID);

            if (toUserID > 0) // Item picked up to hand of user
            {
                pItem.roomID       = 0;
                pItem.ownerID      = toUserID;
                pItem.wallPosition = null;
                pItem.Update();
            }
            else
            {
                Engine.Game.Items.deleteItemInstance(itemID);
            }

            if (toUserID > 0)
            {
                return((stripItem)pItem);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Places a wall item in the room and makes it visible for all clients, and returns a boolean that holds true if the operation has succeeded.
        /// </summary>
        /// <param name="handItemInstance">The stripItem instance of the wall item that is being placed down.</param>
        /// <param name="Position">The new position of the wall item as a string.</param>
        public bool placeWallItem(stripItem handItemInstance, string Position)
        {
            if (this.containsWallItem(handItemInstance.ID))
            {
                return(false);
            }

            wallItem pItem = new wallItem();

            pItem.ID           = handItemInstance.ID;
            pItem.roomID       = this.roomID;
            pItem.ownerID      = handItemInstance.ownerID;
            pItem.Definition   = handItemInstance.Definition;
            pItem.customData   = handItemInstance.customData;
            pItem.wallPosition = Position;
            if (handItemInstance.Definition.Behaviour.isPostIt) // New post.it, set blank message data
            {
                pItem.postItMessage = String.Empty;
            }

            this.broadcoastWallItemPlacement(pItem);
            this.wallItems.Add(pItem);
            pItem.Update(); // Save position

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Removes a post.it wal item from the room and deletes it from the database.
        /// </summary>
        /// <param name="itemID">The database ID of the item.</param>
        public void removePostIt(int itemID)
        {
            wallItem pItem = this.getWallItem(itemID);

            if (pItem != null && pItem.Definition.Behaviour.isPostIt)
            {
                this.pickupWallItem(itemID, -1); // Remove from room and delete item
            }
        }
Beispiel #6
0
        /// <summary>
        /// Sets a new color and message for a post.it wall item, marks it as 'require update' and refreshes the item in the room.
        /// </summary>
        /// <param name="itemID">The database ID of the item.</param>
        /// <param name="Color">The new color value of the post.it.</param>
        /// <param name="Message">The new message of the post.it.</param>
        public void setPostItData(int itemID, string Color, ref string Message)
        {
            wallItem pItem = this.getWallItem(itemID);

            if (pItem != null && pItem.Definition.Behaviour.isPostIt)
            {
                pItem.customData     = Color;
                pItem.postItMessage  = Message;
                pItem.requiresUpdate = true;

                broadcoastWallItemStateUpdate(pItem);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 83 - "AS"
        /// </summary>
        public void G_IDATA()
        {
            int      itemID = int.Parse(Request.Content);
            wallItem pItem  = Session.roomInstance.getWallItem(itemID);

            if (pItem != null && pItem.Definition.Behaviour.isPostIt)
            {
                Response.Initialize(48);           // "@p"
                Response.appendTabbedValue(itemID.ToString());
                Response.Append(pItem.customData); // Color
                Response.Append(" ");
                Response.Append(pItem.postItMessage);
                sendResponse();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Attempts to set the custom data for a wall item, refreshes the item in the room and flags the item as 'requires update'.
        /// </summary>
        /// <param name="itemID">The database ID of the wall item.</param>
        /// <param name="sessionID">The ID of the session who's room user requests a state change.</param>
        /// <param name="State">The new state as an integer.</param>
        public void setWallItemState(int itemID, uint sessionID, int State)
        {
            wallItem pItem = this.getWallItem(itemID);

            if (pItem != null && pItem.Definition.canContainCustomData) // Valid item
            {
                if (pItem.Definition.Behaviour.requiresRightsForInteraction && !this.sessionHasRights(sessionID))
                {
                    return;  // This wall item requires rights for interaction and this session does not have room rights
                }
                if (pItem.Definition.Behaviour.customDataNumericOnOff && State != 1 && State != 2)
                {
                    return; // This wall item only accepts '1' or '2' for custom data, and the given number does not match
                }
                pItem.customData     = State.ToString();
                pItem.requiresUpdate = true;

                broadcoastWallItemStateUpdate(pItem);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 83 - "AS"
        /// </summary>
        public void G_IDATA()
        {
            int      itemID = int.Parse(Request.Content);
            wallItem pItem  = Session.roomInstance.getWallItem(itemID);

            if (pItem != null && pItem.Definition.Behaviour.isPostIt)
            {
                Response.Initialize(48);           // "@p"
                Response.appendTabbedValue(itemID.ToString());
                Response.Append(pItem.customData); // Color
                Response.Append(" ");
                Response.Append(pItem.postItMessage);
                sendResponse();

                // Read data aloud if message starts with '[!]'
                if (pItem.postItMessage.Length > 4 && pItem.postItMessage.Substring(1, 3) == "[!]")
                {
                    Response = FunUtils.CreateVoiceSpeakMessage(pItem.postItMessage.Substring(4));
                    sendResponse();
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Initializes all the item instances and adds them to the collections for items.
        /// </summary>
        private void loadItems()
        {
            if (this.floorItems != null)
            {
                this.floorItems.Clear();
            }
            if (this.wallItems != null)
            {
                this.wallItems.Clear();
            }
            if (this.roomPets != null)
            {
                this.roomPets.Clear();
            }

            this.floorItems = new List <floorItem>();
            if (this.Information.isUserFlat)
            {
                this.wallItems = new List <wallItem>();
                this.roomPets  = new List <roomPet>();
            }

            Database dbClient = new Database(false, true);

            dbClient.addParameterWithValue("roomid", this.roomID);

            dbClient.Open();
            if (!dbClient.Ready)
            {
                return; // Too bad
            }
            foreach (DataRow dRow in dbClient.getTable("SELECT * FROM items WHERE roomid = @roomid").Rows)
            {
                itemDefinition Definition = ObjectTree.Game.Items.getItemDefinition((int)dRow["definitionid"]);
                if (Definition == null) // Invalid item
                {
                    continue;
                }

                int    itemID     = (int)dRow["id"];
                string customData = null;
                if (dRow["customdata"] != DBNull.Value)
                {
                    customData = (string)dRow["customdata"];
                }

                if (Definition.Behaviour.isWallItem)
                {
                    wallItem pItem = new wallItem();
                    pItem.ID           = itemID;
                    pItem.Definition   = Definition;
                    pItem.roomID       = this.roomID;
                    pItem.ownerID      = this.Information.ownerID;
                    pItem.customData   = customData;
                    pItem.wallPosition = (string)dRow["wallposition"];
                    if (Definition.Behaviour.isPostIt)
                    {
                        pItem.postItMessage = (string)dRow["postit_message"];
                    }

                    this.wallItems.Add(pItem);
                }
                else
                {
                    floorItem pItem = new floorItem();
                    pItem.ID         = itemID;
                    pItem.Definition = Definition;
                    pItem.roomID     = this.roomID;
                    pItem.ownerID    = this.Information.ownerID;
                    pItem.customData = customData;
                    pItem.X          = byte.Parse(dRow["x"].ToString());
                    pItem.Y          = byte.Parse(dRow["y"].ToString());
                    pItem.Z          = (float)dRow["z"];
                    pItem.Rotation   = byte.Parse(dRow["rotation"].ToString());
                    if (pItem.Definition.Behaviour.isTeleporter) // Teleporter, initialize 'brother' ID
                    {
                        pItem.teleporterID = (int)dRow["teleporterid"];
                    }

                    this.floorItems.Add(pItem);
                }
            }
        }
Beispiel #11
0
        /// <summary>
        /// Initializes all the item instances and adds them to the collections for items.
        /// </summary>
        private void loadItems()
        {
            if (this.floorItems != null)
                this.floorItems.Clear();
            if (this.wallItems != null)
                this.wallItems.Clear();
            if (this.roomPets != null)
                this.roomPets.Clear();

            this.floorItems = new List<floorItem>();
            if (this.Information.isUserFlat)
            {
                this.wallItems = new List<wallItem>();
                this.roomPets = new List<roomPet>();
            }

            Database dbClient = new Database(false, true);
            dbClient.addParameterWithValue("roomid", this.roomID);

            dbClient.Open();
            if (!dbClient.Ready)
                return; // Too bad

            foreach (DataRow dRow in dbClient.getTable("SELECT * FROM items WHERE roomid = @roomid").Rows)
            {
                itemDefinition Definition = ObjectTree.Game.Items.getItemDefinition((int)dRow["definitionid"]);
                if (Definition == null) // Invalid item
                    continue;

                int itemID = (int)dRow["id"];
                string customData = null;
                if (dRow["customdata"] != DBNull.Value)
                    customData = (string)dRow["customdata"];

                if (Definition.Behaviour.isWallItem)
                {
                    wallItem pItem = new wallItem();
                    pItem.ID = itemID;
                    pItem.Definition = Definition;
                    pItem.roomID = this.roomID;
                    pItem.ownerID = this.Information.ownerID;
                    pItem.customData = customData;
                    pItem.wallPosition = (string)dRow["wallposition"];
                    if (Definition.Behaviour.isPostIt)
                        pItem.postItMessage = (string)dRow["postit_message"];

                    this.wallItems.Add(pItem);
                }
                else
                {
                    floorItem pItem = new floorItem();
                    pItem.ID = itemID;
                    pItem.Definition = Definition;
                    pItem.roomID = this.roomID;
                    pItem.ownerID = this.Information.ownerID;
                    pItem.customData = customData;
                    pItem.X = byte.Parse(dRow["x"].ToString());
                    pItem.Y = byte.Parse(dRow["y"].ToString());
                    pItem.Z = (float)dRow["z"];
                    pItem.Rotation = byte.Parse(dRow["rotation"].ToString());
                    if (pItem.Definition.Behaviour.isTeleporter) // Teleporter, initialize 'brother' ID
                        pItem.teleporterID = (int)dRow["teleporterid"];

                    this.floorItems.Add(pItem);
                }
            }
        }
Beispiel #12
0
 /// <summary>
 /// Broadcoasts the state update of a given wall item to all active room users.
 /// </summary>
 /// <param name="pItem">The wallItem instance of the wall item that is updated.</param>
 private void broadcoastWallItemStateUpdate(wallItem pItem)
 {
     serverMessage Message = new serverMessage(85); // "AU"
     Message.Append(pItem.ToString());
     this.sendMessage(Message);
 }
Beispiel #13
0
 /// <summary>
 /// Broacoasts the placement of a wall item to all room users.
 /// </summary>
 /// <param name="pItem">The wallItem instance of the wall item that is placed.</param>
 private void broadcoastWallItemPlacement(wallItem pItem)
 {
     serverMessage Message = new serverMessage(83); // "AS"
     Message.Append(pItem.ToString());
     this.sendMessage(Message);
 }
Beispiel #14
0
        /// <summary>
        /// Places a wall item in the room and makes it visible for all clients, and returns a boolean that holds true if the operation has succeeded.
        /// </summary>
        /// <param name="handItemInstance">The stripItem instance of the wall item that is being placed down.</param>
        /// <param name="Position">The new position of the wall item as a string.</param>
        public bool placeWallItem(stripItem handItemInstance, string Position)
        {
            if (this.containsWallItem(handItemInstance.ID))
                return false;

            wallItem pItem = new wallItem();
            pItem.ID = handItemInstance.ID;
            pItem.roomID = this.roomID;
            pItem.ownerID = handItemInstance.ownerID;
            pItem.Definition = handItemInstance.Definition;
            pItem.customData = handItemInstance.customData;
            pItem.wallPosition = Position;
            if (handItemInstance.Definition.Behaviour.isPostIt) // New post.it, set blank message data
            {
                pItem.postItMessage = String.Empty;
            }

            this.broadcoastWallItemPlacement(pItem);
            this.wallItems.Add(pItem);
            pItem.Update(); // Save position

            return true;
        }