Exemplo n.º 1
0
        /// <summary>
        /// Returns the specified parquet.
        /// </summary>
        /// <param name="in_id">A valid, defined parquet identifier.</param>
        /// <typeparam name="T">The type of parquet sought.  Must correspond to the given ID.</typeparam>
        /// <returns>The specified parquet.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// Thrown when the given ID is not a valid parquet ID.
        /// </exception>
        /// <exception cref="System.InvalidCastException">
        /// Thrown when the specified type does not correspond to the given ID.
        /// </exception>
        public static T Get <T>(EntityID in_id) where T : ParquetParent
        {
            if (!in_id.IsValidForRange(AssemblyInfo.ParquetIDs))
            {
                throw new ArgumentOutOfRangeException(nameof(in_id));
            }

            return((T)ParquetDefinitions.Get(in_id));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Select a collectible to paint with.
 /// </summary>
 /// <param name="in_collectibleID">The parquet ID to select.  Must represent a valid Collectible.</param>
 public void SetCollectibleToPaint(EntityID in_collectibleID)
 {
     if (in_collectibleID.IsValidForRange(AssemblyInfo.CollectibleIDs))
     {
         _collectibleToPaint = in_collectibleID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Collectible {in_collectibleID} as if it were a Collectible.");
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Select a furnishing to paint with.
 /// </summary>
 /// <param name="in_furnishingID">The parquet ID to select.  Must represent a valid Furnishing.</param>
 public void SetFurnishingToPaint(EntityID in_furnishingID)
 {
     if (in_furnishingID.IsValidForRange(AssemblyInfo.FurnishingIDs))
     {
         _furnishingToPaint = in_furnishingID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Furnishing {in_furnishingID} as if it were a Furnishing.");
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Select a block to paint with.
 /// </summary>
 /// <param name="in_blockID">The parquet ID to select.  Must represent a valid Block.</param>
 public void SetBlockToPaint(EntityID in_blockID)
 {
     if (in_blockID.IsValidForRange(AssemblyInfo.BlockIDs))
     {
         _blockToPaint = in_blockID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Block {in_blockID} as if it were a Block.");
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Select a floor to paint with.
 /// </summary>
 /// <param name="in_floorID">The parquet ID to select.  Must represent a valid Floor.</param>
 public void SetFloorToPaint(EntityID in_floorID)
 {
     //Adds bounds-checking using the Ranges defined in Assembly.
     if (in_floorID.IsValidForRange(AssemblyInfo.FloorIDs))
     {
         _floorToPaint = in_floorID;
     }
     else
     {
         Error.Handle($"Cannot paint non-Floor {in_floorID} as if it were a Floor.");
     }
 }
Exemplo n.º 6
0
        public void InvalidSubrangeValuesAreInvalidInDiscreteRangeCollectionTest()
        {
            var firstRange     = new Range <EntityID>(firstLowerBound, firstUpperBound);
            var secondRange    = new Range <EntityID>(secondLowerBound, secondUpperBound);
            var discreteRanges = new List <Range <EntityID> > {
                firstRange, secondRange
            };

            EntityID firstLesser   = firstRange.Minimum - 1;
            EntityID firstGreater  = firstRange.Maximum + 1;
            EntityID secondLesser  = secondRange.Minimum - 1;
            EntityID secondGreater = secondRange.Maximum + 1;

            Assert.False(firstLesser.IsValidForRange(discreteRanges));
            Assert.False(firstGreater.IsValidForRange(discreteRanges));
            Assert.False(secondLesser.IsValidForRange(discreteRanges));
            Assert.False(secondGreater.IsValidForRange(discreteRanges));
        }
Exemplo n.º 7
0
        public void OnlySubrangeValuesOutsideOverlappedRangesAreInvalidInOverlappingRangeCollectionTest()
        {
            var firstRange        = new Range <EntityID>(firstLowerBound, firstUpperBound);
            var overlappingRange  = new Range <EntityID>(overlapLowerBound, overlapUpperBound);
            var overlappingRanges = new List <Range <EntityID> > {
                firstRange, overlappingRange
            };

            EntityID firstLesser   = firstRange.Minimum - 1;
            EntityID firstGreater  = firstRange.Maximum + 1;
            EntityID secondLesser  = overlappingRange.Minimum - 1;
            EntityID secondGreater = overlappingRange.Maximum + 1;

            Assert.True(firstGreater.IsValidForRange(overlappingRanges));
            Assert.True(secondLesser.IsValidForRange(overlappingRanges));

            Assert.False(firstLesser.IsValidForRange(overlappingRanges));
            Assert.False(secondGreater.IsValidForRange(overlappingRanges));
        }
Exemplo n.º 8
0
        public void ValidSubrangeValuesAreValidInOverlappingRangeCollectionTest()
        {
            var firstRange        = new Range <EntityID>(firstLowerBound, firstUpperBound);
            var overlappingRange  = new Range <EntityID>(overlapLowerBound, overlapUpperBound);
            var overlappingRanges = new List <Range <EntityID> > {
                firstRange, overlappingRange
            };

            EntityID firstLower    = firstRange.Minimum;
            EntityID firstAverage  = (firstRange.Minimum + firstRange.Maximum) / 2;
            EntityID firstUpper    = firstRange.Maximum;
            EntityID secondLower   = overlappingRange.Minimum;
            EntityID secondAverage = (overlappingRange.Minimum + overlappingRange.Maximum) / 2;
            EntityID secondUpper   = overlappingRange.Maximum;

            Assert.True(firstLower.IsValidForRange(overlappingRanges));
            Assert.True(firstAverage.IsValidForRange(overlappingRanges));
            Assert.True(firstUpper.IsValidForRange(overlappingRanges));
            Assert.True(secondLower.IsValidForRange(overlappingRanges));
            Assert.True(secondAverage.IsValidForRange(overlappingRanges));
            Assert.True(secondUpper.IsValidForRange(overlappingRanges));
        }
Exemplo n.º 9
0
        public void ValidSubrangeValuesAreValidInDiscreteRangeCollectionTest()
        {
            var firstRange     = new Range <EntityID>(firstLowerBound, firstUpperBound);
            var secondRange    = new Range <EntityID>(secondLowerBound, secondUpperBound);
            var discreteRanges = new List <Range <EntityID> > {
                firstRange, secondRange
            };

            EntityID firstLower    = firstRange.Minimum;
            EntityID firstAverage  = (firstRange.Minimum + firstRange.Maximum) / 2;
            EntityID firstUpper    = firstRange.Maximum;
            EntityID secondLower   = secondRange.Minimum;
            EntityID secondAverage = (secondRange.Minimum + secondRange.Maximum) / 2;
            EntityID secondUpper   = secondRange.Maximum;

            Assert.True(firstLower.IsValidForRange(discreteRanges));
            Assert.True(firstAverage.IsValidForRange(discreteRanges));
            Assert.True(firstUpper.IsValidForRange(discreteRanges));
            Assert.True(secondLower.IsValidForRange(discreteRanges));
            Assert.True(secondAverage.IsValidForRange(discreteRanges));
            Assert.True(secondUpper.IsValidForRange(discreteRanges));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CraftingRecipe"/> struct.
        /// </summary>
        /// <param name="in_itemProduced">The type of item created by following this recipe.</param>
        /// <param name="in_quantityProduced">The number of items created by following this recipe.</param>
        /// <param name="in_ingredients">All items needed to follow this recipe once.</param>
        /// <param name="in_panelPattern">The arrangment of panels encompassed by this recipe.</param>
        /// <exception cref="ArgumentNullException">Thrown when in_ingredients is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when in_panelPattern is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when in_quantityProduced is less than 1.</exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown when in_itemProduced is not within the <c see="AssemblyInfo.ItemIDs"/> range.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown when any in_ingredients are not within the <c see="AssemblyInfo.ItemIDs"/> range.
        /// </exception>
        /// <exception cref="IndexOutOfRangeException">Thrown when in_ingredients is empty.</exception>
        /// <exception cref="IndexOutOfRangeException">
        /// Thrown when in_panelPattern has dimensions other than those given by
        /// <see cref="AssemblyInfo.PanelPatternWidth"/> and <see cref="AssemblyInfo.PanelPatternHeight"/>.
        /// </exception>
        public CraftingRecipe(EntityID in_itemProduced, int in_quantityProduced,
                              List <EntityID> in_ingredients, StrikePanel[,] in_panelPattern)
        {
            if (!in_itemProduced.IsValidForRange(AssemblyInfo.ItemIDs))
            {
                throw new ArgumentOutOfRangeException(nameof(in_itemProduced));
            }
            if (in_quantityProduced < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(in_quantityProduced));
            }
            foreach (var ingredient in in_ingredients)
            {
                if (!ingredient.IsValidForRange(AssemblyInfo.ItemIDs))
                {
                    throw new ArgumentOutOfRangeException(nameof(in_ingredients));
                }
            }
            if (null == in_ingredients)
            {
                throw new ArgumentNullException(nameof(in_ingredients));
            }
            if (in_ingredients.Count < 1)
            {
                throw new IndexOutOfRangeException(nameof(in_ingredients));
            }
            if (in_panelPattern.GetLength(0) != AssemblyInfo.PanelPatternWidth ||
                in_panelPattern.GetLength(1) != AssemblyInfo.PanelPatternHeight)
            {
                throw new IndexOutOfRangeException(nameof(in_panelPattern));
            }

            ItemProduced     = in_itemProduced;
            QuantityProduced = in_quantityProduced;
            Ingredients      = in_ingredients;
            PanelPattern     = in_panelPattern ?? throw new ArgumentNullException(nameof(in_panelPattern));
        }