/** Runs modifiers on path \a p */ public void RunModifiers(ModifierPass pass, Path p) { // Sort the modifiers based on priority // Bubble sort works because it is a small list and it is always // going to be sorted anyway since the same list is // re-sorted every time this method is executed bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } // Call delegates if they exist switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } // No modifiers, then exit here if (modifiers.Count == 0) { return; } ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; // Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { // Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; // Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcess: // Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input.\nTry rearranging the modifier priorities on the Seeker."); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers(Seeker.ModifierPass pass, Path p) { bool flag = true; while (flag) { flag = false; for (int i = 0; i < this.modifiers.Count - 1; i++) { if (this.modifiers[i].Priority < this.modifiers[i + 1].Priority) { IPathModifier value = this.modifiers[i]; this.modifiers[i] = this.modifiers[i + 1]; this.modifiers[i + 1] = value; flag = true; } } } switch (pass) { case Seeker.ModifierPass.PreProcess: if (this.preProcessPath != null) { this.preProcessPath(p); } break; case Seeker.ModifierPass.PostProcessOriginal: if (this.postProcessOriginalPath != null) { this.postProcessOriginalPath(p); } break; case Seeker.ModifierPass.PostProcess: if (this.postProcessPath != null) { this.postProcessPath(p); } break; } if (this.modifiers.Count == 0) { return; } ModifierData modifierData = ModifierData.All; IPathModifier pathModifier = this.modifiers[0]; for (int j = 0; j < this.modifiers.Count; j++) { MonoModifier monoModifier = this.modifiers[j] as MonoModifier; if (!(monoModifier != null) || monoModifier.enabled) { switch (pass) { case Seeker.ModifierPass.PreProcess: this.modifiers[j].PreProcess(p); break; case Seeker.ModifierPass.PostProcessOriginal: this.modifiers[j].ApplyOriginal(p); break; case Seeker.ModifierPass.PostProcess: { ModifierData modifierData2 = ModifierConverter.Convert(p, modifierData, this.modifiers[j].input); if (modifierData2 != ModifierData.None) { this.modifiers[j].Apply(p, modifierData2); modifierData = this.modifiers[j].output; } else { UnityEngine.Debug.Log(string.Concat(new string[] { "Error converting ", (j <= 0) ? "original" : pathModifier.GetType().Name, "'s output to ", this.modifiers[j].GetType().Name, "'s input.\nTry rearranging the modifier priorities on the Seeker." })); modifierData = ModifierData.None; } pathModifier = this.modifiers[j]; break; } } if (modifierData == ModifierData.None) { break; } } } }
/** Runs modifiers on path \a p */ public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority (bubble sort (slow but since it's a small list, it works good)) var changed = true; while (changed) { changed = false; for (var i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { var tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } //Call eventual delegates switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } //No modifiers, then exit here if (modifiers.Count == 0) { return; } var prevOutput = ModifierData.All; var prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (var i = 0; i < modifiers.Count; i++) { //Cast to MonoModifier, i.e modifiers attached as scripts to the game object var mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //Convert the path if necessary to match the required input for the modifier var newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input.\nTry rearranging the modifier priorities on the Seeker."); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } ModifierData prevOutput = ModifierData.All; for (int i = 0; i < modifiers.Count; i++) { switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? modifiers[i - 1].GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input"); prevOutput = ModifierData.None; } break; } if (prevOutput == ModifierData.None) { break; } } }
public void RunModifiers(ModifierPass pass, Path p) { //Sort the modifiers based on priority bool changed = true; while (changed) { changed = false; for (int i = 0; i < modifiers.Count - 1; i++) { if (modifiers[i].Priority < modifiers[i + 1].Priority) { IPathModifier tmp = modifiers[i]; modifiers[i] = modifiers[i + 1]; modifiers[i + 1] = tmp; changed = true; } } } switch (pass) { case ModifierPass.PreProcess: if (preProcessPath != null) { preProcessPath(p); } break; case ModifierPass.PostProcessOriginal: if (postProcessOriginalPath != null) { postProcessOriginalPath(p); } break; case ModifierPass.PostProcess: if (postProcessPath != null) { postProcessPath(p); } break; } ModifierData prevOutput = ModifierData.All; IPathModifier prevMod = modifiers[0]; //Loop through all modifiers and apply post processing for (int i = 0; i < modifiers.Count; i++) { MonoModifier mMod = modifiers[i] as MonoModifier; //Ignore modifiers which are not enabled if (mMod != null && !mMod.enabled) { continue; } switch (pass) { case ModifierPass.PreProcess: modifiers[i].PreProcess(p); break; case ModifierPass.PostProcessOriginal: modifiers[i].ApplyOriginal(p); break; case ModifierPass.PostProcess: //UnityEngine.Debug.Log ("Applying Post"); //Convert the path if necessary to match the required input for the modifier ModifierData newInput = ModifierConverter.Convert(p, prevOutput, modifiers[i].input); if (newInput != ModifierData.None) { modifiers[i].Apply(p, newInput); prevOutput = modifiers[i].output; } else { UnityEngine.Debug.Log("Error converting " + (i > 0 ? prevMod.GetType().Name : "original") + "'s output to " + (modifiers[i].GetType().Name) + "'s input"); prevOutput = ModifierData.None; } prevMod = modifiers[i]; break; } if (prevOutput == ModifierData.None) { break; } } }