Couple things in this update.
First, I wrote the Ship status code to use enumerators (enum). This allows me to use a single variable where each bit represents a different state. For example:
[Flags]
public enum ShipStatus
{
None = 0,
IsNotMoving = 1 << 0,
IsMoving = 1 << 1,
IsMovingUp = 1 << 2,
IsMovingRight = 1 << 3,
IsMovingDown = 1 << 4,
IsMovingLeft = 1 << 5,
IsFiring = 1 << 6,
SelectedWeaponGroupOne = 1 << 7,
SelectedWeaponGroupTwo = 1 << 8,
SelectedWeaponGroupThree = 1 << 9,
SelectedWeaponGroupFour = 1 << 10,
SelectedWeaponGroupFive = 1 << 11,
IsFullHealth = 1 << 12,
IsHealthThreeQuarters = 1 << 13,
IsHealthHalf = 1 << 14,
IsHealthOneQuarter = 1 << 15,
IsHitByProjectile = 1 << 16
}
All I have to do is make sure I'm updating each state correctly in the Ship class and I can create any ShipPart, Weapon, etc, instance to activate or deactivate on whatever state I want. It seems like an elegant solution to easily add whatever particular state I want to the Ship class. For example, I could have boss ships that start showing damage animations as their health meter drops. Or show different animations depending on which weapon is selected.
Second, added some basic enemies to test out multiple instances of ships and all the associated behaviors. Initially, I discovered a ton of bugs, particularly around the way I was calculating (or in some cases not calculating) positional and angular information for each instance of the Ship, ShipPart and Weapon classes. I fixed a lot of it, but it's made me realize my code is clumsy and things aren't encapsulated as well as they could be. I'll need to go through it and start mapping out the logic of how all the instances of classes should pass data around. The code needs a lot of streamlining and I'll need to tackle that before moving on to more complicated items like scripted enemy spawns, movement patterns and AI.