Exemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Item">A SimpleItem object holding a type which is the intended result of this recipe.</param>
        /// <param name="strLimitType">The limitType, a.k.a. NPCTypeKey is essentially a group of recipes associated with a block and an NPC. Ex: pipliz.crafter</param>
        public SimpleRecipe(SimpleItem Item, string strLimitType = null)
        {
            if (Item == null || Item.Name == null || Item.Name.Length < 1)
            {
                throw new ArgumentException(NAMESPACE == null ? "" : NAMESPACE + ": Simple recipe cannot initialize when given a null Item or an Item with a Name of less than one character.");
            }
            else
            {
                limitType      = strLimitType;
                this.NAMESPACE = Item.NAMESPACE;
                this.Name      = Item.Name;
                addResult(Item);

                Pipliz.Log.Write("{0}: Initialized Recipe {1} (it is not yet registered.)", NAMESPACE == null ? "" : NAMESPACE, Name);
                try
                {
                    if (!Variables.Recipes.Contains(this))
                    {
                        Variables.Recipes.Add(this);
                    }
                }
                catch (Exception)
                {
                    Pipliz.Log.Write("{0} : WARNING : Recipe {1} could not be automatically added to auto-load list. Make sure you explicityly added it.", NAMESPACE == null ? "" : NAMESPACE, this.Name);
                }

                if (strLimitType == null)
                {
                    userCraftable = true;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Adds an item required by this recipe using a valid SimpleItem reference.
 /// </summary>
 /// <param name="requiredItem">Instantiated SimpleItem object.</param>
 /// <param name="amount">Number of items required.</param>
 public void addResult(SimpleItem resultItem, int amount = 1)
 {
     if (resultItem != null && resultItem.Name.Length > 0)
     {
         Results.Add(new ItemShell(resultItem, amount));
         if (!resultItem.enabled)
         {
             this.enabled = false;
         }
     }
     else
     {
         Pipliz.Log.Write("{0} WARNING: Recipe {1}'s addResult() method was called but was given a null or invalid SimpleItem object.", NAMESPACE == null ? "" : NAMESPACE, this.Name);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add an item required for each research 'crafting' cycle.
 /// </summary>
 /// <param name="requiredItem">Valid item as SimpleItem. </param>
 /// <param name="amount">Number of item required.</param>
 public void addRequirement(SimpleItem requiredItem, int amount = 1)
 {
     if (requiredItem == null || requiredItem.Name.Length < 1)
     {
         Pipliz.Log.Write("{0}: Research {1} was given a null or invalid SimpleItem object.", NAMESPACE == null ? "" : NAMESPACE, this.Name);
     }
     else
     {
         IterationRequirements.Add(new ItemShell(requiredItem.ID, amount));
         if (!requiredItem.enabled)
         {
             this.enabled = false;
         }
     }
 }
Exemplo n.º 4
0
 public ItemShell(SimpleItem asThis, int amount = 1)
 {
     asSimpleItem = asThis;
     intAmount    = amount;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Populates and registers rotated types. Called by registerItem().
        /// </summary>
        /// <param name="items">The server's item database (a Dictionary object). Will be passed to the afterAddingBaseTypes callback method.</param>
        protected void Rotate(Dictionary <string, ItemTypesServer.ItemTypeRaw> items)
        {
            try
            {
                Pipliz.Log.Write("{0}: Generating rotated variants of block {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name);
                // Rotated x+
                XP             = new SimpleItem(this.Name + "x+", this.NAMESPACE, false);
                XP.parentType  = this.ID;
                XP.isPlaceable = true;
                XP.Drops       = this.Drops;
                // sideall remains untouched.
                XP.sideAll = this.sideAll;
                // sides get switched around
                if (debug)
                {
                    XP.sideFront = NAMESPACE == null ? "" : XP.ID;
                }
                else
                {
                    XP.sideFront = XP.sideRight;
                }
                XP.sideRight = this.sideFront;
                XP.sideBack  = this.sideLeft;
                XP.sideLeft  = this.sideBack;
                if (grpSideTop == null)
                {
                    XP.sideTop = this.sideTop;
                }
                else
                {
                    XP.sideTop = this.grpSideTop.getTexture(Rotation.counter90d).ID;
                }
                if (grpSideBottom == null)
                {
                    XP.sideBottom = this.sideBottom;
                }
                else
                {
                    XP.sideBottom = grpSideBottom.getTexture(Rotation.counter90d).ID;
                }
                // use proper mesh
                XP.mesh = this.mesh;

                // Rotated z+
                ZP             = new SimpleItem(this.Name + "z+", this.NAMESPACE, false);
                ZP.parentType  = this.ID;
                ZP.isPlaceable = true;
                ZP.Drops       = this.Drops;
                // sideall remains untouched.
                ZP.sideAll = this.sideAll;
                // sides get switched around
                if (debug)
                {
                    ZP.sideFront = NAMESPACE == null ? "" : ZP.ID;
                }
                else
                {
                    ZP.sideFront = this.sideFront;
                }
                ZP.sideRight = this.sideLeft;
                ZP.sideBack  = this.sideBack;
                ZP.sideLeft  = this.sideRight;
                if (grpSideTop == null)
                {
                    ZP.sideTop = this.sideTop;
                }
                else
                {
                    ZP.sideTop = this.grpSideTop.getTexture(Rotation.counter180d).ID;
                }
                if (grpSideBottom == null)
                {
                    ZP.sideBottom = this.sideBottom;
                }
                else
                {
                    ZP.sideBottom = grpSideBottom.getTexture(Rotation.zero).ID;
                }
                Pipliz.Log.Write("DEBUG: Setting ZP bottom texture to {0}", XP.sideBottom);
                // use proper mesh
                ZP.mesh = this.meshZP;

                // Rotated x-
                XM             = new SimpleItem(this.Name + "x-", this.NAMESPACE, false);
                XM.parentType  = this.ID;
                XM.isPlaceable = true;
                XM.Drops       = this.Drops;
                // sideall remains untouched.
                XM.sideAll = this.sideAll;
                // sides get switched around
                if (debug)
                {
                    XM.sideFront = NAMESPACE == null ? "" : XM.ID;
                }
                else
                {
                    XM.sideFront = this.sideLeft;
                }
                XM.sideRight = this.sideBack;
                XM.sideBack  = this.sideRight;
                XM.sideLeft  = this.sideFront;
                if (this.grpSideTop == null)
                {
                    XM.sideTop = this.sideTop;
                }
                else
                {
                    XM.sideTop = this.grpSideTop.getTexture(Rotation.counter270d).ID;
                }
                if (grpSideBottom == null)
                {
                    XM.sideBottom = this.sideBottom;
                }
                else
                {
                    XM.sideBottom = grpSideBottom.getTexture(Rotation.counter270d).ID;
                }
                Pipliz.Log.Write("DEBUG: Setting XM bottom texture to {0}", XP.sideBottom);
                // use proper mesh
                XM.mesh = this.meshXM;

                // Rotated z-
                ZM             = new SimpleItem(this.Name + "z-", this.NAMESPACE, false);
                ZM.parentType  = this.ID;
                ZM.isPlaceable = true;
                ZM.Drops       = this.Drops;
                // sideall remains untouched.
                ZM.sideAll = this.sideAll;
                // sides get switched around
                if (debug)
                {
                    ZM.sideFront = NAMESPACE == null ? "" : ZM.ID;
                }
                else
                {
                    ZM.sideFront = this.sideBack;
                }
                ZM.sideRight = this.sideRight;
                ZM.sideBack  = this.sideFront;
                ZM.sideLeft  = this.sideLeft;
                if (grpSideTop == null)
                {
                    ZM.sideTop = this.sideTop;
                }
                else
                {
                    ZM.sideTop = this.grpSideTop.getTexture(Rotation.zero).ID;
                }
                if (grpSideBottom == null)
                {
                    ZM.sideBottom = this.sideBottom;
                }
                else
                {
                    ZM.sideBottom = grpSideBottom.getTexture(Rotation.counter180d).ID;
                }
                Pipliz.Log.Write("DEBUG: Setting ZM bottom texture to {0}", XP.sideBottom);
                // use proper mesh
                ZM.mesh = this.meshZM;

                Pipliz.Log.Write("{0}: Registering rotated variants of type {1}", NAMESPACE == null ? "" : NAMESPACE, this.Name);
                this.XM.registerItem(items);
                this.XP.registerItem(items);
                this.ZP.registerItem(items);
                this.ZM.registerItem(items);
            }
            catch (Exception ex)
            {
                Pipliz.Log.Write("{0}: CRITICAL ERROR! Generating rotated variants of block {1} caused the following exception: {2}", NAMESPACE == null ? "" : NAMESPACE, this.Name, ex.Message);
                this.isRotatable = false;
            }
        }