I am coding in C# in Unity3D. This is my first question on Stack Overflow. I hope to be in order.
In my game I have two empty sub-classes that work as kind of an enum extension and that are exactly the same:
public class Condition {
public int ID { get; set; }
public int IDAsBitMask { get { return 1 << ID; } }
public string Name { get; set; }
public Sprite Picture { get; set; }
}
public class PositiveCondition : Condition { }
public class NegativeCondition : Condition { }
The reason for these two empty sub-classes is, so that I can only pass members of one sub-class to a method in my HarmfulTrap class:
public class HarmfulTrap {
int myBitMask;
public bool HasCondition(NegativeCondition condition) {
return (myBitMask & condition.IDAsBitMask) == condition.IDAsBitMask;
}
}
But it seems redundant to create two sub-classes that don't declare anything. Is there a way for me to avoid this code architecture? And still be able to only pass the negative Conditions as arguments to my HarmfulTrap method? I am looking for a way that works at compiling time. No validation checks within the HasCondition method at runtime.
Thank you.