Best way to organize and access several distinct health values in one object

The Situation

Here’s the overall situation. I have a tank object with several hitboxes that are childed to a “hitboxmanager” object. Each hitbox uses an enum identifier to match it to it’s respective part (wheels, body, turret, barrel, etc).

When one of these hitboxes are struck, they report to the hitbox manager:

  1. Damage was received
  2. The damage amount
  3. The part that was hit (the one the individual hitbox is responsible for)

The Idea

Now that’s all well and good. But I am at a loss of how to store the data in the hitbox manager and access it reasonably.

The hitbox manager should, in the ideal situation:

  1. At Start(), use foreach to create an entry for each distinct enum in the children (may be more than one barrel hitbox, etc) along with an associated float for maximum health, and another float for current health.
  2. When a child reports they were hit, uses the child’s enum as a key and changes the current health accordingly.
  3. Sum current health and maximum health of all enum types (as in, the total current health of the object) for a percentage health display on the gui.

The Solution(???)

Now it sounds the best method would be to use a dictionary, but I’ve read that dictionaries don’t show up on the inspector so I can’t monitor it for debugging purposes. And I’ve looked into arrays and lists but those seem to be messy and restrictive (have to search each for the proper value instead of using a key)

I could just declare a boatload of public variables and write a massive if() statement to determine which to edit, but that’s messy and would be a problem with rapid hits and multiple objects in the scene.

Enums are also integers, which are perfect for indexing into arrays (just cast to int). If you store you part definitions and part instances in simple array whose length is the size of your enums, then it’ll “just work”. Here’s the basic idea:

enum PartSlots
{
   Chassis, // the first item in an enum is 0
   Turret, // then each item is one higher than the previous, so this is 1
   LeftWheel,
   RightWheel,
   // ... etc
   NumParts // put this special enum last
}

public PartInstance[] partInstances = new PartInstance[NumParts];
public PartDefinition[] partDefinition = new PartDefinition[NumParts];

void Start()
{
    for(int i = 0; i < NumParts; ++i)
    {
        if(partDefinitions *!= null)*

{
partInstances = CreatePartFromDefinition(partDefinitions*);*
}
}
}