Exemplo n.º 1
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, delay.ToString(), false);

            if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MSSQL)
            {
                dbClient.runFastQuery("DELETE FROM trigger_rotation WHERE item_id = " + itemID);
                dbClient.setQuery("INSERT INTO trigger_rotation(item_id,rotation_status,movement_status) VALUES (@id,@rot_id,@mov_id)");
            }
            else
            {
                dbClient.setQuery("REPLACE INTO trigger_rotation SET item_id = @id, rotation_status = @rot_id,  movement_status = @mov_id");
            }
            dbClient.addParameter("id", (int)itemID);
            dbClient.addParameter("rot_id", (int)this.rotation);
            dbClient.addParameter("mov_id", (int)this.movement);
            dbClient.runQuery();

            lock (items)
            {
                dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.itemID + "'");
                foreach (RoomItem i in items)
                {
                    WiredUtillity.SaveTrigger(dbClient, (int)itemID, (int)i.Id);
                }
            }
        }
Exemplo n.º 2
0
        private void WriteFloorItem(Item Item, int UserID, bool HideWired)
        {
            WriteInteger(Item.Id);
            WriteInteger((HideWired && WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType) && (Item.GetBaseItem().InteractionType != InteractionType.highscore && Item.GetBaseItem().InteractionType != InteractionType.highscorepoints)) ? 31294061 : Item.GetBaseItem().SpriteId);
            WriteInteger(Item.GetX);
            WriteInteger(Item.GetY);
            WriteInteger(Item.Rotation);
            WriteString(String.Format("{0:0.00}", TextHandling.GetString(Item.GetZ)));
            WriteString(String.Empty);

            if (Item.LimitedNo > 0)
            {
                WriteInteger(1);
                WriteInteger(256);
                WriteString(Item.ExtraData);
                WriteInteger(Item.LimitedNo);
                WriteInteger(Item.LimitedTot);
            }
            else
            {
                ItemBehaviourUtility.GenerateExtradata(Item, this);
            }

            WriteInteger(-1); // to-do: check
            WriteInteger(1);  //(Item.GetBaseItem().Modes > 1) ? 1 : 0
            WriteInteger(UserID);
        }
Exemplo n.º 3
0
        public ObjectUpdateComposer(Item Item, int UserId, bool HideWired = false)
            : base(ServerPacketHeader.ObjectUpdateMessageComposer)
        {
            WriteInteger(Item.Id);
            WriteInteger((HideWired && WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType) && (Item.GetBaseItem().InteractionType != InteractionType.highscore && Item.GetBaseItem().InteractionType != InteractionType.highscorepoints)) ? 31294061 : Item.GetBaseItem().SpriteId);
            WriteInteger(Item.GetX);
            WriteInteger(Item.GetY);
            WriteInteger(Item.Rotation);
            WriteString(String.Format("{0:0.00}", TextHandling.GetString(Item.GetZ)));
            WriteString(String.Empty);

            if (Item.LimitedNo > 0)
            {
                WriteInteger(1);
                WriteInteger(256);
                WriteString(Item.ExtraData);
                WriteInteger(Item.LimitedNo);
                WriteInteger(Item.LimitedTot);
            }
            else
            {
                ItemBehaviourUtility.GenerateExtradata(Item, this);
            }

            WriteInteger(-1); // to-do: check
            WriteInteger(1);  //(Item.GetBaseItem().Modes > 1) ? 1 : 0
            WriteInteger(UserId);
        }
Exemplo n.º 4
0
        internal bool RemoveFromMap(RoomItem item)
        {
            if (room.GotWired() && WiredUtillity.TypeIsWired(item.GetBaseItem().InteractionType))
            {
                room.GetWiredHandler().RemoveFurniture(item);
            }

            return(RemoveFromMap(item, true));
        }
Exemplo n.º 5
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     lock (items)
     {
         dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.item.Id + "'");
         foreach (RoomItem i in items)
         {
             WiredUtillity.SaveTrigger(dbClient, (int)item.Id, (int)i.Id);
         }
     }
 }
Exemplo n.º 6
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, delay.ToString(), false);
     lock (items)
     {
         dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.itemID + "'");
         foreach (RoomItem i in items)
         {
             WiredUtillity.SaveTrigger(dbClient, (int)itemID, (int)i.Id);
         }
     }
 }
Exemplo n.º 7
0
        public bool RemoveFromMap(Item item)
        {
            if (this.room.GotWired() && WiredUtillity.TypeIsWired(item.GetBaseItem().InteractionType))
            {
                this.room.GetWiredHandler().RemoveFurniture(item);
            }

            this.RemoveSpecialItem(item);

            bool flag = false;

            foreach (Point coord in item.GetCoords)
            {
                if (this.RemoveCoordinatedItem(item, coord))
                {
                    flag = true;
                }
            }

            Dictionary <Point, List <Item> > NoDoublons = new Dictionary <Point, List <Item> >();

            foreach (Point Tile in item.GetCoords.ToList())
            {
                Point point = new Point(Tile.X, Tile.Y);
                if (this.CoordinatedItems.ContainsKey(point))
                {
                    List <Item> list = (List <Item>) this.CoordinatedItems[point];
                    if (!NoDoublons.ContainsKey(Tile))
                    {
                        NoDoublons.Add(Tile, list);
                    }
                }
                this.SetDefaultValue(Tile.X, Tile.Y);
            }

            foreach (Point Coord in NoDoublons.Keys.ToList())
            {
                if (!NoDoublons.ContainsKey(Coord))
                {
                    continue;
                }

                List <Item> SubItems = NoDoublons[Coord];
                foreach (Item roomItem in SubItems.ToList())
                {
                    this.ConstructMapForItem(roomItem, Coord);
                }
            }
            NoDoublons.Clear();
            NoDoublons = null;

            return(flag);
        }
Exemplo n.º 8
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)item.Id, "integer", string.Empty, delay.ToString(), false);
     lock (items)
     {
         dbClient.runFastQuery("DELETE FROM trigger_in_place WHERE original_trigger = '" + this.item.Id + "'");
         foreach (RoomItem i in items)
         {
             WiredUtillity.SaveTrigger(dbClient, (int)item.Id, (int)i.Id);
         }
         //Logging.WriteLine("save trigger 'updatestate' items: " + items.Count);
     }
 }
Exemplo n.º 9
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            string triggerdata = "";

            int i = 0;

            foreach (KeyValuePair <string, int> score in this.item.Scores.OrderByDescending(x => x.Value).Take(20))
            {
                if (i != 0)
                {
                    triggerdata += ";";
                }

                triggerdata += score.Key + ":" + score.Value;

                i++;
            }

            WiredUtillity.SaveTriggerItem(dbClient, this.item.Id, string.Empty, triggerdata, false, null);
        }
Exemplo n.º 10
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            string rotationandmove = (int)this.rotation + ";" + (int)this.movement;

            WiredUtillity.SaveTriggerItem(dbClient, this.itemID, rotationandmove, this.Delay.ToString(), false, this.items);
        }
Exemplo n.º 11
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.itemID, string.Empty, string.Empty, false, this.items);
 }
Exemplo n.º 12
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.itemID, string.Empty, this.NameBot + '\t' + this.Look, false, null);
 }
Exemplo n.º 13
0
        public void Parse(GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null || !Room.CheckRights(Session))
            {
                Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            if (Room.RoomData.SellPrice > 0)
            {
                Session.SendNotification(ButterflyEnvironment.GetLanguageManager().TryGetValue("roomsell.error.7", Session.Langue));
                return;
            }

            string RawData = Packet.PopString();

            string[] Data = RawData.Split(new char[1] {
                ' '
            });
            int ItemId = 0;

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            if (ItemId <= 0)
            {
                return;
            }

            Item userItem = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (userItem == null)
            {
                return;
            }

            if (userItem.GetBaseItem().InteractionType == InteractionType.BADGE_TROC)
            {
                if (Session.GetHabbo().GetBadgeComponent().HasBadge(userItem.ExtraData))
                {
                    Session.SendNotification("Vous posséder déjà ce badge !");
                    return;
                }

                using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                    queryreactor.RunQuery("DELETE FROM items WHERE id = " + ItemId);

                Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                Session.GetHabbo().GetBadgeComponent().GiveBadge(userItem.ExtraData, true);
                Session.SendPacket(new ReceiveBadgeComposer(userItem.ExtraData));

                Session.SendNotification("Vous avez reçu le badge: " + userItem.ExtraData + " !");
                return;
            }

            if (!userItem.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                if (Session.GetHabbo().forceRot > -1)
                {
                    Rotation = Session.GetHabbo().forceRot;
                }

                Item roomItem = new Item(userItem.Id, Room.Id, userItem.BaseItem, userItem.ExtraData, userItem.LimitedNo, userItem.LimitedTot, X, Y, 0.0, Rotation, "", Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, roomItem, X, Y, Rotation, true, false, true))
                {
                    using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                        queryreactor.RunQuery("UPDATE items SET room_id = " + Room.Id + ", user_id = " + Room.RoomData.OwnerId + " WHERE id = " + ItemId);

                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (WiredUtillity.TypeIsWired(userItem.GetBaseItem().InteractionType))
                    {
                        WiredSaver.HandleDefaultSave(userItem.Id, Room, roomItem);
                    }

                    ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_PLACE, 0);
                }
                else
                {
                    Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }


            else if (userItem.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;
                if (TrySetWallItem(CorrectedData, out WallPos))
                {
                    Item roomItem = new Item(userItem.Id, Room.Id, userItem.BaseItem, userItem.ExtraData, userItem.LimitedNo, userItem.LimitedTot, 0, 0, 0.0, 0, WallPos, Room);
                    if (Room.GetRoomItemHandler().SetWallItem(Session, roomItem))
                    {
                        using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
                            queryreactor.RunQuery("UPDATE items SET room_id = " + Room.Id + ", user_id = " + Room.RoomData.OwnerId + " WHERE id = " + ItemId);

                        Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                    }
                }
                else
                {
                    Session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }
Exemplo n.º 14
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)item.Id, "string", string.Empty, triggerMessage, isOwnerOnly);
 }
Exemplo n.º 15
0
        internal void LoadFurniture()
        {
            //this.Items.Clear();
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            DataTable Data;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("CALL getroomitems(@roomid)");
                dbClient.addParameter("roomid", room.RoomId);
                Data = dbClient.getTable();


                uint           itemID;
                decimal        x;
                decimal        y;
                sbyte          n;
                uint           baseID;
                int            dataType;
                string         extradata;
                WallCoordinate wallCoord;
                int            extra;
                foreach (DataRow dRow in Data.Rows)
                {
                    itemID = Convert.ToUInt32(dRow[0]);
                    x      = Convert.ToDecimal(dRow[1]);
                    y      = Convert.ToDecimal(dRow[2]);
                    n      = Convert.ToSByte(dRow[3]);
                    baseID = Convert.ToUInt32(dRow[4]);
                    IRoomItemData data;
                    if (DBNull.Value.Equals(dRow[5]))
                    {
                        data  = new StringData("");
                        extra = 0;
                    }
                    else
                    {
                        dataType  = Convert.ToInt32(dRow[5]);
                        extradata = (string)dRow[6];
                        extra     = Convert.ToInt32(dRow[7]);
                        switch (dataType)
                        {
                        case 0:
                            data = new StringData(extradata);
                            break;

                        case 1:
                            data = new MapStuffData();
                            break;

                        case 2:
                            data = new StringArrayStuffData();
                            break;

                        case 3:
                            data = new StringIntData();
                            break;

                        default:
                            data = new StringData(extradata);
                            break;
                        }
                        try
                        {
                            data.Parse(extradata);
                        }
                        catch
                        {
                            Logging.LogException(string.Format("Error in furni data! Item ID: \"{0}\" and data: \"{1}\"", itemID, extradata.Replace(Convert.ToChar(1).ToString(), "[1]")));
                            dbClient.runFastQuery(string.Format("DELETE FROM items_extradata WHERE item_id = {0}", itemID));
                        }
                    }

                    if (FirewindEnvironment.GetGame().GetItemManager().GetItem(baseID).Type == 'i') // Is wallitem
                    {
                        wallCoord = new WallCoordinate((double)x, (double)y, n);
                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, data, extra, wallCoord, room);

                        if (!mWallItems.ContainsKey(itemID))
                        {
                            mWallItems.Inner.Add(itemID, item);
                        }
                    }
                    else //Is flooritem
                    {
                        int coordX, coordY;
                        TextHandling.Split((double)x, out coordX, out coordY);

                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, data, extra, coordX, coordY, (double)y, n, room);
                        if (!mFloorItems.ContainsKey(itemID))
                        {
                            mFloorItems.Inner.Add(itemID, item);
                        }
                    }
                }

                foreach (RoomItem Item in mFloorItems.Values)
                {
                    if (Item.IsRoller)
                    {
                        mGotRollers = true;
                    }
                    else if (Item.GetBaseItem().InteractionType == Firewind.HabboHotel.Items.InteractionType.dimmer)
                    {
                        if (room.MoodlightData == null)
                        {
                            room.MoodlightData = new MoodlightData(Item.Id);
                        }
                    }
                    else if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                    {
                        WiredLoader.LoadWiredItem(Item, room, dbClient);
                        room.GetWiredHandler().AddWire(Item, Item.Coordinate, Item.Rot, Item.GetBaseItem().InteractionType);
                    }
                }
            }
        }
Exemplo n.º 16
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.itemID, this.Delay.ToString(), this.message, false, null);
 }
Exemplo n.º 17
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)item.Id, "integer", string.Empty, scoreLevel.ToString(), false);
 }
Exemplo n.º 18
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", scoreToGive.ToString(), maxCountPerGame.ToString(), false);
 }
Exemplo n.º 19
0
        internal void LoadFurniture()
        {
            //this.Items.Clear();
            this.mFloorItems.Clear();
            this.mWallItems.Clear();
            DataTable Data;

            using (IQueryAdapter dbClient = PiciEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Pici.Storage.Database.DatabaseType.MySQL)
                {
                    dbClient.setQuery("CALL getroomitems(@roomid)");
                    dbClient.addParameter("roomid", room.RoomId);
                }
                else
                {
                    dbClient.setQuery("EXECUTE getroomitems " + room.RoomId);
                }

                Data = dbClient.getTable();


                uint           itemID;
                decimal        x;
                decimal        y;
                sbyte          n;
                uint           baseID;
                string         extradata;
                WallCoordinate wallCoord;
                foreach (DataRow dRow in Data.Rows)
                {
                    itemID = Convert.ToUInt32(dRow[0]);
                    x      = Convert.ToDecimal(dRow[1]);
                    y      = Convert.ToDecimal(dRow[2]);
                    n      = Convert.ToSByte(dRow[3]);
                    baseID = Convert.ToUInt32(dRow[4]);
                    if (DBNull.Value.Equals(dRow[5]))
                    {
                        extradata = string.Empty;
                    }
                    else
                    {
                        extradata = (string)dRow[5];
                    }

                    if (n > 6) // Is wallitem
                    {
                        wallCoord = new WallCoordinate((double)x, (double)y, n);
                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, wallCoord, room);

                        if (!mWallItems.ContainsKey(itemID))
                        {
                            mWallItems.Inner.Add(itemID, item);
                        }
                    }
                    else //Is flooritem
                    {
                        int coordX, coordY;
                        TextHandling.Split((double)x, out coordX, out coordY);

                        RoomItem item = new RoomItem(itemID, room.RoomId, baseID, extradata, coordX, coordY, (double)y, n, room);
                        if (!mFloorItems.ContainsKey(itemID))
                        {
                            mFloorItems.Inner.Add(itemID, item);
                        }
                    }
                }

                foreach (RoomItem Item in mFloorItems.Values)
                {
                    if (Item.IsRoller)
                    {
                        mGotRollers = true;
                    }
                    else if (Item.GetBaseItem().InteractionType == Pici.HabboHotel.Items.InteractionType.dimmer)
                    {
                        if (room.MoodlightData == null)
                        {
                            room.MoodlightData = new MoodlightData(Item.Id);
                        }
                    }
                    else if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                    {
                        WiredLoader.LoadWiredItem(Item, room, dbClient);
                    }

                    if (WiredHandler.TypeIsWire(Item.GetBaseItem().InteractionType))
                    {
                        room.GetWiredHandler().AddWire(Item, Item.Coordinate, Item.Rot, Item.GetBaseItem().InteractionType);
                    }
                }
            }
        }
Exemplo n.º 20
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.itemID, string.Empty, this.NomBot + '\t' + this.message, this.IsMurmur, null);
 }
Exemplo n.º 21
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, (int)itemID, "integer", string.Empty, message, false);
 }
Exemplo n.º 22
0
        internal WiredLoaderSQL(RoomItem Item, Room Room, IQueryAdapter dbClient)
        {
            wiredItems     = new List <RoomItem>(5);
            StringSettings = new string[3] {
                "", "", ""
            };
            originalPositionList = new Dictionary <uint, OriginalItemLocation>();

            dbClient.setQuery("SELECT * FROM items_wired WHERE item_id = " + Item.Id + " LIMIT 1");
            DataRow dRow = dbClient.getRow();

            if (dRow == null)
            {
                return;
            }

            if (WiredUtillity.NeedsFurnitures(Item.GetBaseItem().InteractionType))
            {
                string result = (string)dRow["wired_to_item"];

                if (result.Contains(";"))
                {
                    foreach (string itemId in result.Split(';'))
                    {
                        RoomItem targetItem = Room.GetRoomItemHandler().GetItem(Convert.ToUInt32(itemId));
                        if (targetItem != null && !wiredItems.Contains(targetItem))
                        {
                            wiredItems.Add(targetItem);
                        }
                    }
                }
                else if (result.Length > 0)
                {
                    RoomItem targetItem = Room.GetRoomItemHandler().GetItem(Convert.ToUInt32(result));
                    if (targetItem != null && !wiredItems.Contains(targetItem))
                    {
                        wiredItems.Add(targetItem);
                    }
                }
            }

            if (WiredUtillity.HaveSettings(Item.GetBaseItem().InteractionType))
            {
                string result = (string)dRow["wired_data"];
                for (int i = 0; i < 3; i++)
                {
                    StringSettings[i] = result.Split(';')[i].ToString();
                }
            }

            if (WiredUtillity.HaveLocations(Item.GetBaseItem().InteractionType))
            {
                string result = (string)dRow["wired_original_location"];
                foreach (string value in result.Split(';'))
                {
                    try
                    {
                        uint   itemID    = Convert.ToUInt32(value.Split(',')[0]);
                        int    x         = Convert.ToInt32(value.Split(',')[1].ToString());
                        int    y         = Convert.ToInt32(value.Split(',')[2].ToString());
                        double height    = Double.Parse(value.Split(',')[4], OtanixEnvironment.cultureInfo);
                        int    rot       = Convert.ToInt32(value.Split(',')[3].ToString());
                        string extradata = (string)value.Split(',')[5];

                        originalPositionList.Add(itemID, new OriginalItemLocation(itemID, x, y, height, rot, extradata));
                    }
                    catch { }
                }
            }
        }
Exemplo n.º 23
0
        public void LoadFurniture(int RoomId = 0)
        {
            if (RoomId == 0)
            {
                this._floorItems.Clear();
                this._wallItems.Clear();
            }

            using (IQueryAdapter queryreactor = ButterflyEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                queryreactor.SetQuery("SELECT items.id, items.user_id, items.room_id, items.base_item, items.extra_data, items.x, items.y, items.z, items.rot, items.wall_pos, items_limited.limited_number, items_limited.limited_stack FROM items LEFT JOIN items_limited ON (items_limited.item_id = items.id) WHERE items.room_id = @roomid");
                queryreactor.AddParameter("roomid", (RoomId == 0) ? this.GetRoom.Id : RoomId);

                int    itemID;
                int    UserId;
                int    baseID;
                string ExtraData;
                int    x;
                int    y;
                double z;
                sbyte  n;
                string wallposs;
                int    Limited;
                int    LimitedTo;
                string wallCoord;

                foreach (DataRow dataRow in queryreactor.GetTable().Rows)
                {
                    itemID    = Convert.ToInt32(dataRow[0]);
                    UserId    = Convert.ToInt32(dataRow[1]);
                    baseID    = Convert.ToInt32(dataRow[3]);
                    ExtraData = !DBNull.Value.Equals(dataRow[4]) ? (string)dataRow[4] : string.Empty;
                    x         = Convert.ToInt32(dataRow[5]);
                    y         = Convert.ToInt32(dataRow[6]);
                    z         = Convert.ToDouble(dataRow[7]);
                    n         = Convert.ToSByte(dataRow[8]);
                    wallposs  = !DBNull.Value.Equals(dataRow[9]) ? (string)(dataRow[9]) : string.Empty;
                    Limited   = !DBNull.Value.Equals(dataRow[10]) ? Convert.ToInt32(dataRow[10]) : 0;
                    LimitedTo = !DBNull.Value.Equals(dataRow[11]) ? Convert.ToInt32(dataRow[11]) : 0;

                    ItemData Data = null;
                    ButterflyEnvironment.GetGame().GetItemManager().GetItem(baseID, out Data);

                    if (Data == null)
                    {
                        continue;
                    }

                    if (Data.Type.ToString() == "i")
                    {
                        if (string.IsNullOrEmpty(wallposs))
                        {
                            wallCoord = "w=0,0 l=0,0 l";
                        }
                        else
                        {
                            wallCoord = wallposs;//WallPositionCheck(":" + wallposs.Split(':')[1]);
                        }
                        Item roomItem = new Item(itemID, this.GetRoom.Id, baseID, ExtraData, Limited, LimitedTo, 0, 0, 0.0, 0, wallCoord, this.GetRoom);
                        if (!this._wallItems.ContainsKey(itemID))
                        {
                            this._wallItems.TryAdd(itemID, roomItem);
                        }

                        if (roomItem.GetBaseItem().InteractionType == InteractionType.MOODLIGHT)
                        {
                            if (this.GetRoom.MoodlightData == null)
                            {
                                this.GetRoom.MoodlightData = new MoodlightData(roomItem.Id);
                            }
                        }
                    }
                    else //Is flooritem
                    {
                        Item roomItem = new Item(itemID, this.GetRoom.Id, baseID, ExtraData, Limited, LimitedTo, x, y, (double)z, n, "", this.GetRoom);

                        if (!this._floorItems.ContainsKey(itemID))
                        {
                            this._floorItems.TryAdd(itemID, roomItem);
                        }
                    }
                }

                if (RoomId == 0)
                {
                    foreach (Item Item in _floorItems.Values)
                    {
                        if (WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                        {
                            WiredLoader.LoadWiredItem(Item, this.GetRoom, queryreactor);
                        }
                    }
                }
            }
        }
Exemplo n.º 24
0
        public bool AddItemToMap(Item Item)
        {
            if (this.room.GotWired() && WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
            {
                this.room.GetWiredHandler().AddFurniture(Item);
            }

            this.AddSpecialItems(Item);

            switch (Item.GetBaseItem().InteractionType)
            {
            case InteractionType.roller:
                if (!this.room.GetRoomItemHandler().GetRollers().Contains(Item))
                {
                    this.room.GetRoomItemHandler().TryAddRoller(Item.Id, Item);
                }
                break;

            case InteractionType.footballgoalgreen:
            case InteractionType.footballcountergreen:
            case InteractionType.banzaiscoregreen:
            case InteractionType.banzaigategreen:
            case InteractionType.freezegreencounter:
            case InteractionType.freezegreengate:
                this.room.GetGameManager().AddFurnitureToTeam(Item, Team.green);
                break;

            case InteractionType.footballgoalyellow:
            case InteractionType.footballcounteryellow:
            case InteractionType.banzaiscoreyellow:
            case InteractionType.banzaigateyellow:
            case InteractionType.freezeyellowcounter:
            case InteractionType.freezeyellowgate:
                this.room.GetGameManager().AddFurnitureToTeam(Item, Team.yellow);
                break;

            case InteractionType.footballgoalblue:
            case InteractionType.footballcounterblue:
            case InteractionType.banzaiscoreblue:
            case InteractionType.banzaigateblue:
            case InteractionType.freezebluecounter:
            case InteractionType.freezebluegate:
                this.room.GetGameManager().AddFurnitureToTeam(Item, Team.blue);
                break;

            case InteractionType.footballgoalred:
            case InteractionType.footballcounterred:
            case InteractionType.banzaiscorered:
            case InteractionType.banzaigatered:
            case InteractionType.freezeredcounter:
            case InteractionType.freezeredgate:
                this.room.GetGameManager().AddFurnitureToTeam(Item, Team.red);
                break;
            }
            if (Item.GetBaseItem().Type != 's')
            {
                return(true);
            }

            foreach (Point point in Item.GetCoords)
            {
                this.AddCoordinatedItem(Item, new Point(point.X, point.Y));
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.football)
            {
                return(true);
            }

            foreach (Point Coord in Item.GetCoords)
            {
                if (!this.ConstructMapForItem(Item, Coord))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 25
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.item.Id, string.Empty, this.Delay.ToString(), false, this.items);
 }
Exemplo n.º 26
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.item.Id, string.Empty, this.userName, false, null);
 }
Exemplo n.º 27
0
        internal bool AddItemToMap(RoomItem Item, bool handleGameItem)
        {
            if (handleGameItem)
            {
                if (room.GotWired() && WiredUtillity.TypeIsWired(Item.GetBaseItem().InteractionType))
                {
                    room.GetWiredHandler().AddFurniture(Item);
                }

                AddSpecialItems(Item);

                switch (Item.GetBaseItem().InteractionType)
                {
                case InteractionType.footballgoalred:
                case InteractionType.footballcounterred:
                case InteractionType.banzaiscorered:
                case InteractionType.freezeredcounter:
                case InteractionType.freezeredgate:
                {
                    room.GetGameManager().AddFurnitureToTeam(Item, Games.Team.red);
                    break;
                }

                case InteractionType.footballgoalgreen:
                case InteractionType.footballcountergreen:
                case InteractionType.banzaiscoregreen:
                case InteractionType.freezegreencounter:
                case InteractionType.freezegreengate:
                {
                    room.GetGameManager().AddFurnitureToTeam(Item, Games.Team.green);
                    break;
                }

                case InteractionType.footballgoalblue:
                case InteractionType.footballcounterblue:
                case InteractionType.banzaiscoreblue:
                case InteractionType.freezebluecounter:
                case InteractionType.freezebluegate:
                {
                    room.GetGameManager().AddFurnitureToTeam(Item, Games.Team.blue);
                    break;
                }

                case InteractionType.footballgoalyellow:
                case InteractionType.footballcounteryellow:
                case InteractionType.banzaiscoreyellow:
                case InteractionType.freezeyellowcounter:
                case InteractionType.freezeyellowgate:
                {
                    room.GetGameManager().AddFurnitureToTeam(Item, Games.Team.yellow);
                    break;
                }

                case InteractionType.freezeexit:
                {
                    room.GetFreeze().ExitTeleport = Item;
                    break;
                }

                case InteractionType.roller:
                {
                    if (!room.GetRoomItemHandler().mRollers.ContainsKey(Item.Id))
                    {
                        room.GetRoomItemHandler().mRollers.Add(Item.Id, Item);
                    }
                    break;
                }
                }
            }

            if (Item.GetBaseItem().Type != 's')
            {
                return(true);
            }

            foreach (Point coord in Item.GetCoords)
            {
                Point point = new Point(coord.X, coord.Y);
                AddCoordinatedItem(Item, point);
            }

            if (Item.GetX > (Model.MapSizeX - 1))
            {
                Model.AddX();
                GenerateMaps();
                return(false);
            }

            if (Item.GetY > (Model.MapSizeY - 1))
            {
                Model.AddY();
                GenerateMaps();
                return(false);
            }


            foreach (Point coord in Item.GetCoords)
            {
                if (!ConstructMapForItem(Item, coord))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 28
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.item.Id, string.Empty, this.triggerMessage, this.isOwnerOnly, null);
 }
Exemplo n.º 29
0
 public void SaveToDatabase(IQueryAdapter dbClient)
 {
     WiredUtillity.SaveTriggerItem(dbClient, this.itemID, string.Empty, ((int)this.team).ToString(), false, null);
 }
Exemplo n.º 30
0
        public void SaveToDatabase(IQueryAdapter dbClient)
        {
            string SaveRoomCount = this.RoomCountMin + ":" + this.RoomCountMax;

            WiredUtillity.SaveTriggerItem(dbClient, this.Item.Id, string.Empty, SaveRoomCount, false, null);
        }