How do I work with two ENUMS

Well, I’m making a space shooter. Sometimes my ships create a formation. They do this by targeting a gameobject MainFormationObject that stores an array of empty gameobject WayPoints. The ships target the MainFormationObject and this object tells the ship which WayPoint will it target.
For the sake of keeping it short, I’ll call the ship that is targetting the leader waypoint the Leader and the ships that are targeting the escort waypoints the Escorts.
Now I’m trying to break the formation when certain conditions are met (by breaking the formation I mean: tell the ships to not target these WayPoints anymore / change their target).

I thought of using two enums:

  1. What triggers the break of the formation {

leader gets fired at,

escort gets fired at,

leader dies,

escort dies,

formation changes target,

formation’s target gets destroyed }

and

  1. How does the formation breaks {

escorts will target the ship that is firing at leader (only used if the leader is getting fired at),

make all the ships get a different target,

leader gets a different target,

escorts get a different target,

do nothing }

Basically, in the inspector I want a way of having the drop down menus for “What triggers the break of the formation” and then selecting by another drop down menu “How does the formation breaks” so its kind of user friendly.

I know how to code all that by using bools, but its a mess. I just don’t know how to relate one trigger of breaking the formation to the way I want the formation to break (I know how to hard code one trigger to one way of breaking the formation, but i don’t want that). Also, is this the most efficient way to do it? If you think of a more efficient way feel free to share it.

Thank you in advance.

A custom editor might be a good option but if you don’t want to go that path, something like this would probably work (if i understood you correctly)

	public enum BattleEvent
	{
		LeaderFiredAt,
		EscortFiredAt,
		LeaderDied,
		EscortDied,
		FormationTargetChanged,
		FormationTargetDestroyed
	}

	public enum Reaction
	{
		DefendLeader,
		FireAtWill,
		LeaderRetarget,
		EscortRetarget,
		None 
	}

	public Reaction LeaderFiredAtReaction;
	public Reaction EscortFiredAtReaction;
	public Reaction LeaderDiedReaction;
	public Reaction EscortDiedReaction;
	public Reaction FormationTargetChangedReaction;
	public Reaction FormationTargetDestroyedReaction;

	public Dictionary<BattleEvent, Reaction> ReactionMap = 
		new Dictionary<BattleEvent, Reaction>();

	void Start () {
		ReactionMap.Add(BattleEvent.LeaderFiredAt, LeaderFiredAtReaction);
		ReactionMap.Add(BattleEvent.EscortFiredAt, EscortFiredAtReaction);
		ReactionMap.Add(BattleEvent.LeaderDied, LeaderDiedReaction);
		ReactionMap.Add(BattleEvent.EscortDied, EscortDiedReaction);
		ReactionMap.Add(BattleEvent.FormationTargetChanged, FormationTargetChangedReaction);
		ReactionMap.Add(BattleEvent.FormationTargetDestroyed, FormationTargetDestroyedReaction);
	}
	
	public Reaction GetReactionTo(BattleEvent bEvent)
	{
		var react = Reaction.None;
		ReactionMap.TryGetValue(bEvent, out react);
		return react;
	}

@NoseKills

So I almost have it working, I think. Everytime that I meet any of the conditions I call

     public Reaction GetReactionTo(BattleEvent bEvent)
     {
         var react = Reaction.None;
         ReactionMap.TryGetValue(bEvent, out react);
         return react;
     }

and it returns the Reaction that I set on the inspector. But now, the problem that I have is that I actually don’t know what to do with it. I think its simpler if I explain it with an example:

Lets say that the designer built the behavior on the inspector in this way: The “Battle Event: Leader Gets Fired At” and the “Reaction: Everybody Breaks Formation”

I detected the Battle Event and called “public Reaction GetReactionTo(BattleEvent bEvent)” method.
I have the code for telling all the ships to break formation, but… WHERE DO I PUT IT?! What makes that code run? That’s what I’m missing.

Again, I’m super grateful for your time. I didn’t know about dictionaries and this is teaching me a lot about them. Thank you. thank you, thank you.