Пример #1
0
        public static PropertyValues UpdateFamily(this ElementFamily fam, VaultAliases vaultAlias, int cateId, int modelId)
        {
            var pvs = new PropertyValues();

            AddProperties(fam, pvs, vaultAlias, cateId, modelId);

            return(pvs);
        }
Пример #2
0
        public static ObjVer CreateFamily(this ElementFamily fam, VaultAliases vaultAlias, int cateId, int modelId, AccessControlList acl)
        {
            var objTypeId = vaultAlias.ObDict[OB.Family];
            var classId   = vaultAlias.CsDict[CS.Family];

            var pvs = new PropertyValues();

            AddProperties(fam, pvs, vaultAlias, cateId, modelId);
            return(BaseElementExtensions.CreateBasicObject(objTypeId, classId, pvs, vaultAlias.Vault, acl));
        }
Пример #3
0
        public static void AddProperties(this ElementFamily fam, PropertyValues pvs, VaultAliases vaultAlias, int cateId, int modelId)
        {
            fam.AddBasicProperties(pvs, vaultAlias, modelId);
            var catePV = new PropertyValue {
                PropertyDef = vaultAlias.PdDict[PD.PartCategory]
            };

            catePV.Value.SetValue(MFDataType.MFDatatypeLookup, cateId);
            pvs.Add(-1, catePV);
            if (fam.Parameters.Count > 0)
            {
                var pPV = BaseElementExtensions.CreateParameterProp(fam.Parameters, vaultAlias);
                pvs.Add(-1, pPV);
            }
        }
Пример #4
0
        public static ElementFamily GetFamily(this Family fam, Document doc)
        {
            var f = new ElementFamily {
                Id = fam.Id.IntegerValue, Guid = fam.UniqueId, Name = fam.Name
            };

#if R2014
            if (fam.FamilyCategory != null)
            {
                f.Category = new ElementCategory
                {
                    Id   = fam.FamilyCategory.Id.IntegerValue,
                    Name = fam.FamilyCategory.Name
                };
            }
#else
            if (fam.FamilyCategory != null)
            {
                f.Category = new ElementCategory
                {
                    Id   = fam.FamilyCategory.Id.IntegerValue,
                    Name = fam.FamilyCategory.Name
                };
            }
#endif
            var famPIter = fam.Parameters.ForwardIterator();
            while (famPIter.MoveNext())
            {
                var param = GetParameter((Parameter)famPIter.Current, doc);
                f.Parameters.Add(param);
            }
            if (String.IsNullOrEmpty(f.Name) && f.Category != null) //族文件中族的名称可能为空
            {
                f.Name = f.Category.Name;
            }
            return(f);
        }
Пример #5
0
        /// <summary>
        /// Registers a new ElementItem.
        /// </summary>
        /// <param name="name">The enum Element value for this item.</param>
        /// <param name="description">The tooltip for this item.</param>
        /// <param name="recipe">The recipe for this item.</param>
        /// <param name="stackCrafted">How much of this item is crafted per recipe.</param>
        /// <param name="defaults">The defaults set for this item's <seealso cref="Item"/> item field.</param>
        /// <param name="state">The default ElementState for this element.</param>
        /// <param name="family">What periodic family this element belongs to.</param>
        /// <param name="boilingPoint">The boiling point for this element in Kelvin.</param>
        /// <param name="meltingPoint">The melting point for this element in Kelvin.</param>
        /// <param name="gasColor">Optional.  Determines the colour for the gas drawn for this element when in the world.</param>
        /// <param name="liquid">Optional.  The ModLiquid for this element.</param>
        /// <param name="isPlaceableBar">Optional.  Determines if this metal element is a placeable bar.</param>
        internal static void RegisterElement(Element name, string description, Action <ModRecipe> recipe, int stackCrafted, Action <Item> defaults, ElementState state, ElementFamily family, float boilingPoint, float meltingPoint, Color?gasColor = null, ModLiquid liquid = null, bool isPlaceableBar = false)
        {
            string      internalName = ElementName(name);
            ElementItem item         = new ElementItem(name,
                                                       description,
                                                       state,
                                                       family,
                                                       gasColor ?? Color.White,
                                                       isPlaceableBar,
                                                       liquid,
                                                       boilingPoint,
                                                       meltingPoint
                                                       );

            mod.AddItem(internalName, item);

            //Add the corresponding bar tile if it should exist
            if (isPlaceableBar)
            {
                mod.AddTile(internalName, new ScienceBar(), $"TerraScience/Content/Tiles/{internalName}");
            }

            //Cache the defaults and recipe so we can use it anytime
            TerraScience.CachedElementDefaults.Add(internalName, defaults);
            TerraScience.CachedElementRecipes.Add(internalName,
                                                  (r, e) => {
                recipe(r);
                r.SetResult(e, stackCrafted);
                r.AddRecipe();
            });
        }
Пример #6
0
 public InvalidFamilyException(string elementName, ElementFamily family) : base($"The element \"{elementName}\" doesn't exist in the {Enum.GetName(typeof(ElementFamily), family)} family!")
 {
 }
Пример #7
0
 /// <summary>
 /// Creates a new element item.
 /// </summary>
 public ElementItem(Element name, string description, ElementState defaultState, ElementFamily family, Color gasColor, bool isPlaceableBar, ModLiquid liquid, float boilingPoint, float meltingPoint) : base(description, defaultState, gasColor, isPlaceableBar, liquid, boilingPoint, meltingPoint)
 {
     ElementName = name;
     displayName = ElementUtils.ElementName(name, false);
     Family      = family;
 }