}
// Find the chosen alternative for this block in this instance.
- size_t chosen_alternative = (chain_idx / block->cardinality_base) % block->alternatives.size();
- EffectType chosen_type = block->alternatives[chosen_alternative]->effect_type;
+ EffectType chosen_type = block->alternatives[block->chosen_alternative(chain_idx)]->effect_type;
Effect *effect;
switch (chosen_type) {
break;
}
default:
- effect = instantiate_effect(instantiation->chain.get(), block->alternatives[chosen_alternative]->effect_type);
+ effect = instantiate_effect(instantiation->chain.get(), chosen_type);
instantiation->chain->add_effect(effect, inputs);
break;
}
// (B_i is alternatives.size().) Not set before finalize() has run.
size_t cardinality_base = 0;
+ // Find the chosen alternative for this block in a given instance.
+ size_t chosen_alternative(size_t chain_idx) const {
+ return (chain_idx / cardinality_base) % alternatives.size();
+ }
+
std::vector<EffectBlueprint *> alternatives; // Must all have the same amount of inputs. Pointers to make things easier for Lua.
std::vector<Index> inputs; // One for each input of alternatives[0] (ie., typically 0 or 1, occasionally 2).
int currently_chosen_alternative = 0;