コード例 #1
0
        private string getItemExternalTextKey(itemDefinition pItem, int specialSpriteID)
        {
            string s = "";

            if (specialSpriteID == 0)
            {
                if (pItem.Behaviour.isWallItem)
                {
                    if (specialSpriteID == 0)
                    {
                        s = "wallitem";
                    }
                }
                else
                {
                    s = "furni";
                }

                s += "_";
            }

            s += pItem.Sprite;
            if (specialSpriteID > 0)
            {
                s += "_" + specialSpriteID;
            }

            return(s);
        }
コード例 #2
0
        /// <summary>
        /// Creates an instance of a given item definition for a given user, and places it in the hand of that user.
        /// </summary>
        /// <param name="definitionID">The definition ID of the item to create an instance of.</param>
        /// <param name="ownerID">The database ID of the user that is the owner of this item.</param>
        /// <param name="customData">Optional. Custom data to set for the new item instance.</param>
        public int createItemInstanceReturnID(int definitionID, int ownerID, string customData)
        {
            itemDefinition pItemDefinition = getItemDefinition(definitionID);

            if (pItemDefinition == null)
            {
                return(-1);
            }

            int      ID       = -1;
            Database Database = new Database(false, false);

            Database.addParameterWithValue("definitionid", definitionID);
            Database.addParameterWithValue("ownerid", ownerID);

            if (customData == null)
            {
                Database.addParameterWithValue("customdata", DBNull.Value);
            }
            else
            {
                Database.addParameterWithValue("customdata", customData);
            }

            Database.Open();
            if (Database.Ready)
            {
                Database.runQuery("INSERT INTO items(definitionid,ownerid,customdata) VALUES (@definitionid,@ownerid,@customdata)");
                ID = Database.getInteger("SELECT MAX(id) FROM items ORDER BY id DESC LIMIT 1");
                Database.Close();
            }

            return(ID);
        }
コード例 #3
0
 public string getItemDescription(itemDefinition pItem, int specialSpriteID)
 {
     if (pItem.Behaviour.isDecoration)
     {
         return(pItem.Sprite);
     }
     else
     {
         string extKey = this.getItemExternalTextKey(pItem, specialSpriteID) + "_desc";
         return(ObjectTree.Game.Externals.getTextEntry(extKey));
     }
 }
コード例 #4
0
        public stripItem createItemFromDefinition(itemDefinition pDefinition, int specialSpriteID)
        {
            stripItem pItem = new stripItem();

            pItem.Definition = pDefinition;
            if (specialSpriteID > 0)
            {
                pItem.customData = specialSpriteID.ToString();
            }

            return(pItem);
        }
コード例 #5
0
 public string getItemName(itemDefinition pItem, int specialSpriteID)
 {
     if (pItem.Behaviour.isDecoration)
     {
         return(pItem.Sprite);
     }
     else
     {
         string extKey = this.getItemExternalTextKey(pItem, specialSpriteID) + "_name";
         return(Engine.Game.Externals.getTextEntry(extKey));
     }
 }
コード例 #6
0
        /// <summary>
        /// Parses a complete System.Data.DataRow of an item definition to a full itemDefinition object. Null is returned on errors.
        /// </summary>
        /// <param name="dRow">The System.Data.DataRow with all the required fields.</param>
        public static itemDefinition Parse(DataRow dRow)
        {
            itemDefinition ret = new itemDefinition();

            ret.ID          = (int)dRow["id"];
            ret.directoryID = (int)dRow["cast_directory"];
            ret.Sprite      = (string)dRow["sprite"];
            ret.Color       = (string)dRow["color"];
            ret.Length      = byte.Parse(dRow["length"].ToString());
            ret.Width       = byte.Parse(dRow["width"].ToString());
            ret.topHeight   = float.Parse(dRow["topheight"].ToString());
            ret.Behaviour   = itemBehaviourContainer.Parse(dRow["behaviour"].ToString());
            return(ret);
        }
コード例 #7
0
        /// <summary>
        /// Loads all the item definitions from the database and stores them in the definition collection.
        /// </summary>
        public void loadDefinitions()
        {
            _Definitions.Clear(); // Clear old definitions from collection
            fuseStringBuilder spriteIndex = new fuseStringBuilder();

            Logging.Log("Loading item definitions...");

            Database dbClient = new Database(true, true);

            if (dbClient.Ready)
            {
                List <string>     includedSprites = new List <string>();
                DataRowCollection Definitions     = dbClient.getTable("SELECT * FROM items_definitions ORDER BY id ASC").Rows;

                spriteIndex.appendWired(Definitions.Count);

                foreach (DataRow dRow in Definitions)
                {
                    int            ID         = (int)dRow["id"];
                    itemDefinition Definition = itemDefinition.Parse(dRow);
                    Definition.directoryID = (int)dRow["cast_directory"];
                    _Definitions.Add(ID, Definition);

                    if (!includedSprites.Contains(Definition.Sprite))
                    {
                        spriteIndex.appendClosedValue(Definition.Sprite);
                        spriteIndex.appendWired(Definition.directoryID);
                        includedSprites.Add(Definition.Sprite);
                    }
                }

                _spriteIndex = spriteIndex.ToString();
                Logging.Log("Loaded " + Definitions.Count + " item definitions.");
            }
            else
            {
                Logging.Log("Failed to load the item definitions, database was not contactable!", Logging.logType.commonError);
            }
        }