Beispiel #1
0
            /// <summary>
            /// Adds a new virtual flooritem to the manager at initialization.
            /// </summary>
            /// <param name="itemID">The ID of the new item.</param>
            /// <param name="templateID">The template ID of the new item.</param>
            /// <param name="X">The X position of the new item.</param>
            /// <param name="Y">The Y position of the new item.</param>
            /// <param name="Z">The Z [rotation] of the new item.</param>
            /// <param name="H">The H position [height] of the new item.</param>
            /// <param name="Var">The variable of the new item.</param>
            internal void addItem(int itemID, int templateID, int X, int Y, int Z, double H, string Var)
            {
                try
                {
                    catalogueManager.itemTemplate Template = catalogueManager.getTemplate(templateID);
                    if (stringManager.getStringPart(Template.Sprite, 0, 13) == "sound_machine")
                        soundMachineID = itemID;

                    int Length = 0;
                    int Width = 0;
                    if (Z == 2 || Z == 6)
                    {
                        Length = Template.Length;
                        Width = Template.Width;
                    }
                    else
                    {
                        Length = Template.Width;
                        Width = Template.Length;
                    }

                    for (int jX = X; jX < X + Width; jX++)
                        for (int jY = Y; jY < Y + Length; jY++)
                        {
                            furnitureStack Stack = _Room.sqSTACK[jX, jY];
                            if (Stack == null)
                            {
                                if (Template.typeID != 2 && Template.typeID != 3)
                                {
                                    Stack = new furnitureStack();
                                    Stack.Add(itemID);
                                }
                            }
                            else
                                Stack.Add(itemID);

                            _Room.sqSTATE[jX, jY] = (squareState)Template.typeID;
                            if (Template.typeID == 2 || Template.typeID == 3)
                            {
                                _Room.sqITEMHEIGHT[jX, jY] = H + Template.topH;
                                _Room.sqITEMROT[jX, jY] = Convert.ToByte(Z);
                            }
                            else
                            {
                                if (Template.typeID == 4)
                                    _Room.sqITEMHEIGHT[jX, jY] = H;
                            }
                            _Room.sqSTACK[jX, jY] = Stack;
                        }
                    if (Template.isDoor)
                    {
                        if (_Room.squareBlocked(X, Y, Length, Width))
                            return;
                        if (Var.ToLower() == "c")
                            _Room.setSquareState(X, Y, Length, Width, squareState.Blocked);
                        else if (Var.ToLower() == "o")
                            _Room.setSquareState(X, Y, Length, Width, squareState.Open);
                        else
                            _Room.setSquareState(X, Y, Length, Width, squareState.Blocked);
                    }

                    floorItem Item = new floorItem(itemID, templateID, X, Y, Z, H, Var);
                    _Items.Add(itemID, Item);
                }
                catch (Exception ex) { Out.WriteError("[" + ex.Source + "] Exception Error - " + ex.Message); }
            }
Beispiel #2
0
            internal void placeItem(int itemID, int templateID, int X, int Y, byte typeID, byte Z)
            {
                if (_Items.ContainsKey(itemID))
                    return;

                try
                {
                    catalogueManager.itemTemplate Template = catalogueManager.getTemplate(templateID);
                    bool isSoundMachine = (stringManager.getStringPart(Template.Sprite, 0, 13) == "sound_machine");
                    if (isSoundMachine && soundMachineID > 0)
                        return;

                    int Length = 0;
                    int Width = 0;
                    if (Z == 2 || Z == 6)
                    {
                        Length = Template.Length;
                        Width = Template.Width;
                    }
                    else
                    {
                        Length = Template.Width;
                        Width = Template.Length;
                    }

                    double testH = _Room.sqFLOORHEIGHT[X, Y];
                    double H = testH;
                    if (_Room.sqSTACK[X, Y] != null)
                    {
                        floorItem topItem = (floorItem)_Items[_Room.sqSTACK[X, Y].topItemID()];
                        H = topItem.H + catalogueManager.getTemplate(topItem.templateID).topH;
                    }

                    for (int jX = X; jX < X + Width; jX++)
                    {
                        for (int jY = Y; jY < Y + Length; jY++)
                        {
                            if (_Room.sqUNIT[jX, jY]) // Dynamical unit here
                                return;

                            squareState jState = _Room.sqSTATE[jX, jY];
                            if (jState != squareState.Open)
                            {
                                if (jState == squareState.Blocked)
                                {
                                    if (_Room.sqSTACK[jX, jY] == null) // Square blocked and no stack here
                                        return;
                                    else
                                    {
                                        floorItem topItem = (floorItem)_Items[_Room.sqSTACK[jX, jY].topItemID()];
                                        catalogueManager.itemTemplate topItemTemplate = catalogueManager.getTemplate(topItem.templateID);
                                        if (topItemTemplate.topH == 0 || topItemTemplate.typeID == 2 || topItemTemplate.typeID == 3) // No stacking on seat/bed
                                            return;
                                        else
                                        {
                                            if (topItem.H + topItemTemplate.topH > H) // Higher than previous topheight
                                                H = topItem.H + topItemTemplate.topH;
                                        }
                                    }
                                }
                                else if (jState == squareState.Rug && _Room.sqSTACK[jX, jY] != null)
                                {
                                    double jH = ((floorItem)_Items[_Room.sqSTACK[jX, jY].topItemID()]).H + 0.1;
                                    if (jH > H)
                                        H = jH;
                                }
                                else // Seat etc
                                    return;
                            }
                        }
                    }

                    if (H > Config.Items_Stacking_maxHeight)
                        H = Config.Items_Stacking_maxHeight;

                    for (int jX = X; jX < X + Width; jX++)
                    {
                        for (int jY = Y; jY < Y + Length; jY++)
                        {
                            furnitureStack Stack = null;
                            if (_Room.sqSTACK[jX, jY] == null)
                            {
                                if ((Template.typeID == 1 && Template.topH > 0) || Template.typeID == 4)
                                {
                                    Stack = new furnitureStack();
                                    Stack.Add(itemID);
                                }
                            }
                            else
                            {
                                Stack = _Room.sqSTACK[jX, jY];
                                Stack.Add(itemID);
                            }

                            _Room.sqSTATE[jX, jY] = (squareState)Template.typeID;
                            _Room.sqSTACK[jX, jY] = Stack;
                            if (Template.typeID == 2 || Template.typeID == 3)
                            {
                                _Room.sqITEMHEIGHT[jX, jY] = H + Template.topH;
                                _Room.sqITEMROT[jX, jY] = Z;
                                _Room.sqITEMROT[jX, jY] = Z;
                                if (Template.typeID == 3 && (jX != X || jY != Y))
                                    if (Width == 1)
                                        _Room.sqSTATE[jX, jY] = squareState.Blocked;
                                    else if ((Z == 2 && jX != X) || (Z == 0 && jY != Y))
                                        _Room.sqSTATE[jX, jY] = squareState.Blocked;
                            }
                            else if (Template.typeID == 4)
                                _Room.sqITEMHEIGHT[jX, jY] = H;
                        }
                    }
                    string Var;
                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                    {
                        Var = dbClient.getString("SELECT var FROM furniture WHERE id = '" + itemID + "'");
                        dbClient.runQuery("UPDATE furniture SET roomid = '" + _Room.roomID + "',x = '" + X + "',y = '" + Y + "',z = '" + Z + "',h = '" + H.ToString().Replace(',', '.') + "' WHERE id = '" + itemID + "' LIMIT 1");
                    }
                    floorItem Item = new floorItem(itemID, templateID, X, Y, Z, H, Var);
                    _Items.Add(itemID, Item);
                    _Room.sendData("A]" + Item.ToString());

                    if (isSoundMachine)
                        this.soundMachineID = itemID;
                }
                catch { }
            }
            /// <summary>
            /// Adds a new virtual flooritem to the manager at initialization.
            /// </summary>
            /// <param name="itemID">The ID of the new item.</param>
            /// <param name="templateID">The template ID of the new item.</param>
            /// <param name="X">The X position of the new item.</param>
            /// <param name="Y">The Y position of the new item.</param>
            /// <param name="Z">The Z [rotation] of the new item.</param>
            /// <param name="H">The H position [height] of the new item.</param>
            /// <param name="Var">The variable of the new item.</param>
            internal void addItem(int itemID, int templateID, int X, int Y, int Z, double H, string Var)
            {
                catalogueManager.itemTemplate Template = catalogueManager.getTemplate(templateID);
                if (stringManager.getStringPart(Template.Sprite, 0, 13) == "sound_machine")
                    soundMachineID = itemID;

                int Length = 0;
                int Width = 0;
                if (Z == 2 || Z == 6)
                {
                    Length = Template.Length;
                    Width = Template.Width;
                }
                else
                {
                    Length = Template.Width;
                    Width = Template.Length;
                }

                for (int jX = X; jX < X + Width; jX++)
                    for (int jY = Y; jY < Y + Length; jY++)
                    {
                        furnitureStack Stack = _Room.sqSTACK[jX,jY];
                        if (Stack == null)
                        {
                            if (Template.typeID != 2 && Template.typeID != 3)
                            {
                                Stack = new furnitureStack();
                                Stack.Add(itemID);
                            }
                        }
                        else
                            Stack.Add(itemID);

                        _Room.sqSTATE[jX, jY] = (squareState)Template.typeID;
                        if (Template.typeID == 2 || Template.typeID == 3)
                        {
                            _Room.sqITEMHEIGHT[jX, jY] = H + Template.topH;
                            _Room.sqITEMROT[jX, jY] = Convert.ToByte(Z);
                        }
                        else
                        {
                            if (Template.typeID == 4)
                                _Room.sqITEMHEIGHT[jX, jY] = H;
                        }
                        _Room.sqSTACK[jX, jY] = Stack;
                    }
                floorItem Item = new floorItem(itemID, templateID, X, Y, Z, H, Var);
                _Items.Add(itemID, Item);
            }