Exemplo n.º 1
0
        /// <summary>
        /// Gets a UnitType by looking it up or by loading it from SLK
        /// </summary>
        /// <param name="uid">The uid to get</param>
        /// <returns>The UnitType</returns>
        public static UnitType GetUnitType(string uid)
        {
            UnitType type = (Types.ContainsKey(uid) ? Types[uid] : new UnitType(uid));

            if (!Types.ContainsKey(uid))
            {
                Types.Add(uid, type);
                type.FinishConstruction();
            }
            return(type);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new UnitType based on another. Used by UnitEd to derrive
        /// UnitTypes.
        /// </summary>
        /// <param name="uid">The new Uid</param>
        /// <param name="baseuid">The Uid to base the copy on</param>
        /// <returns>The new UnitType</returns>
        public static UnitType NewUnitType(string uid, string baseuid)
        {
            UnitType type = (Types.ContainsKey(uid) ? Types[baseuid] : new UnitType(baseuid));

            if (!Types.ContainsKey(baseuid))
            {
                Types.Add(baseuid, type);
                type.FinishConstruction();
            }
            UnitType newtype = (UnitType)type.MemberwiseClone();

            newtype.Uid = uid;
            Types.Add(uid, newtype);
            return(type);
        }