Exemplo n.º 1
0
 /// <summary>
 /// Creates a new Science item.
 /// </summary>
 public ScienceItem(string description, ElementState defaultState, Color gasColor, bool isPlaceableBar, ModLiquid liquid, float boilingPoint, float meltingPoint)
 {
     this.description = description;
     BaseState        = defaultState;
     CurrentState     = BaseState;
     GasColor         = gasColor;
     IsPlaceableBar   = isPlaceableBar;
     LiquidForm       = liquid;
     BoilingPoint     = boilingPoint;
     MeltingPoint     = meltingPoint;
 }
Exemplo n.º 2
0
 public override void LoadLiquids(ModLiquidFactory liquidFactory)
 {
     mercuryLiquid = liquidFactory.Create("Mercury", "Mercury", new DefaultTemperature(8, 5, 4, 6));
 }
Exemplo n.º 3
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();
            });
        }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
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();
            });
        }
Exemplo n.º 6
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);
 }