Пример #1
0
 public CompoundItem(Compound name, string description, ElementState defaultState, CompoundClassification classification, Color gasColor, bool isPlaceableBar, ModLiquid liquid, float boilingPoint, float meltingPoint, Action <CompoundItem> elementsToAdd) : base(description, defaultState, gasColor, isPlaceableBar, liquid, boilingPoint, meltingPoint)
 {
     CompoundName   = name;
     Classification = classification;
     displayName    = CompoundUtils.CompoundName(name);
     elementsToAdd(this);
 }
Пример #2
0
        /// <summary>
        /// Registers a new CompoundItem.
        /// </summary>
        /// <param name="compound">The enum Compound 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 compound.</param>
        /// <param name="boilingPoint">The boiling point for this compound in Kelvin. Set to -1 for "unstable".</param>
        /// <param name="meltingPoint">The melting point for this compound in Kelvin. Set to -1 for "unstable".</param>
        /// <param name="elements">The Action for adding elements to this compound's recipe.</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 RegisterCompound(Compound compound, string description, Action <ModRecipe> recipe, int stackCrafted, Action <Item> defaults, ElementState state, CompoundClassification classification, float boilingPoint, float meltingPoint, Action <CompoundItem> elements, Color?gasColor = null, ModLiquid liquid = null, bool isPlaceableBar = false)
        {
            string       internalName = CompoundName(compound, false);
            CompoundItem item         = new CompoundItem(compound,
                                                         description,
                                                         state,
                                                         classification,
                                                         gasColor ?? Color.White,
                                                         isPlaceableBar,
                                                         liquid,
                                                         boilingPoint,
                                                         meltingPoint,
                                                         elements);

            mod.AddItem(internalName, item);

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

            //Cache the defaults and recipe so we can use it anytime
            TerraScience.CachedCompoundDefaults.Add(internalName, defaults);
            TerraScience.CachedCompoundRecipes.Add(internalName,
                                                   (r, e) => {
                recipe(r);

                for (int i = 0; i < item.Elements.Count; i++)
                {
                    Tuple <Element, int> pair = item.Elements[i];
                    r.AddIngredient(mod.ItemType(ElementUtils.ElementName(pair.Item1)), pair.Item2);
                }

                r.SetResult(e, stackCrafted);
                r.AddRecipe();
            });
        }