My objective is to have a system that is editor friendly for designers/artists on a team. I have come up with an initial system that works but would like to see if there is a better way, especially as more content is added.
The basic idea is that there are base Items. These base Items can be combined to make other items (let’s call them Ingredients and Products). To make these user-friendly I am using serialized enums for the Ingredients and scriptable objects for each Product to select a list of these Ingredients(enums).
The problem comes in at the next step where I want a class to be able to check for particular Items. The class needs to check for both Ingredients and Products, as either may be required. For the moment the idea is that only ONE Item will be required (but later might expand the idea/scope to require more than one).
So as part of the Product class, I have also created an enum of the different products. So what I have done so far is:
Item:
public class Item
{
public TypeOfItem ItemType { get; }
public Item(TypeOfItem itemType)
{
ItemType = itemType;
}
}
public enum TypeOfItem
{
Bread,
Ham,
Cheese,
HamSandwich,
CheeseSandwich
}
Ingredient:
public class Ingredient : Item
{
public Ingredient(TypeOfIngredient ingredient) : base((TypeOfItem)ingredient)
{
}
}
public enum TypeOfIngredient
{
Bread = TypeOfItem.Bread,
Ham = TypeOfItem.Ham,
Cheese = TypeOfItem.Cheese
}
Product:
public class Product : Item
{
public Product(TypeOfProduct product) : base((TypeOfItem)product)
{
}
}
public enum TypeOfProduct
{
HamSandwich = TypeOfItem.HamSandwich,
CheeseSandwich = TypeOfItem.CheeseSandwich
}
And when creating a new Ingredient or Product it automatically is caste to TypeOfItem enum so its easy to do checks etc
Again all the above works BUT I am double handling the creation of each Item and I can also see where errors could pop up. If I wasn’t wanting to expose these to the editor I could think of other ways of handling it.
Any thoughts on a better system would be much appreciated