Exemple #1
0
//	Toggles the nth (0-based) FxProc with the specified procID,
//	or all FxProcs with the specified procID if n < 0.
//	If me has no FxProc with the specified procID, appends a new one.
//	The procID must be one of the Core.Render.Fx.KnownProcIDs.
//	For this change to be applied, call FxEffect.UpdateRoutine() subsequently.
func (me *FxProcs) Toggle(procID string, n int) {
	var matcher ustr.Matcher
	matcher.AddPatterns(procID)
	idx, found, all := -1, false, n < 0
	for i := 0; i < len(*me); i++ {
		if matcher.IsMatch((*me)[i].procID) {
			if idx++; all || idx == n {
				(*me)[i].Toggle()
			}
			if found = true; !all {
				break
			}
		}
	}
	if (!found) && !matcher.HasWildcardPatterns() {
		*me = append(*me, FxProc{})
		(*me)[len(*me)-1].init(procID, idx+1)
	}
}