Esempio n. 1
0
    //
    // remove specific effect
    public void RemoveEffect(AnimatorEffect effect,
                             bool snapToEnd   = false,
                             bool giveWarning = true)
    {
        // ensure effect in effects list
        int index = _effects.IndexOf(effect);

        if (index != -1)
        {
            if (snapToEnd)
            {
                effect.SnapEffectToEnd();
            }

            effect.Cleanup();

            // delete from _effects list
            _effects.Remove(effect);
        }
        else if (giveWarning)
        {
            Logger.Warning("Could not remove effect \"" + effect.Name + "\" on " + _target + ".\n" +
                           "Effects that were found were the following: " + DumpEffects() + ".", LogID.WARNING_CANT_REMOVE_EFFECT);
        }
    }
Esempio n. 2
0
 // add effect to anime that cycles a number of times.
 public AnimatorEffect CycleEffect(AnimatorEffect effect,
                                   int cycles,
                                   Callback callback = null,
                                   string name       = EffectString.REPLACE)
 {
     effect.Cycles = cycles;
     return(AddEffect(effect, callback, name));
 }
Esempio n. 3
0
 // add effect to an anime that triggers on a timestamp,
 //  which may be past or persent.
 public AnimatorEffect TimedEffect(AnimatorEffect effect,
                                   float timestamp,
                                   Callback callback = null,
                                   string name       = EffectString.REPLACE)
 {
     effect.StartTime = timestamp;
     return(AddEffect(effect, callback, name));
 }
Esempio n. 4
0
    //
    // The name string can be set to use a unique effect name ID,
    //  or use REPLACE to replace any effect with the same name ID,
    //  or use SNAP_REPLACE to replace and snap to end any effect with the same name ID,
    //  or AUTO_RENAME to automatically create a new and unique name ID
    //
    public AnimatorEffect AddEffect(AnimatorEffect effect,                    // effect being added
                                    Callback callback = null,                 // callback to call when done.
                                    string name       = EffectString.REPLACE) // name of effect, or use REPLACE, SNAP_REPLACE or AUTO_RENAME
    {
        //
        // name effect
        //  Note: renaming efects allows you to stack effects of the same type
        if (name != null &&
            name != EffectString.REPLACE &&
            name != EffectString.SNAP_REPLACE &&
            name != EffectString.AUTO_RENAME)
        {
            effect.Name = name;
        }

        //
        // deal with any existing effect with the same name
        AnimatorEffect existingEffect = GetEffect(effect.Name, false);

        if (existingEffect != null)
        {
            if (name == EffectString.REPLACE ||
                name == EffectString.SNAP_REPLACE)
            {
                Logger.Debug("Effect \"" + effect.Name + "\" being replaced on anime " + _target, LogID.DEBUG_EFFECT_BEING_REPLACED);

                // remove existing effect so no conflict occurs
                RemoveEffect(existingEffect, (name == EffectString.SNAP_REPLACE));
            }
            else if (name == EffectString.AUTO_RENAME)
            {
                // rename effect so no conflict occurs
                int    counter = 1;
                string newName;
                do
                {
                    ++counter;
                    newName = effect.Name + "_" + counter;
                } while (GetEffect(newName, false) != null);

                effect.Name = newName;
            }
            else
            {
                // can't replace existing effect
                throw new Exception("Effect \"" + effect.Name + "\" already exists on anime " + _target + ".\n" +
                                    "Rename your effect, or remove the existing effect using removeEffect(), before adding your new effect.");
            }
        }

        _effects.Add(effect);
        effect.Callback = callback;
        effect.Initailize(_animator, this);

        return(effect);
    }
Esempio n. 5
0
    public void RemoveEffect(string effectName,
                             bool snapToEnd   = false,
                             bool giveWarning = true)
    {
        AnimatorEffect effect = GetEffect(effectName, giveWarning);

        if (effect != null)
        {
            RemoveEffect(effect, snapToEnd);
        }
    }
Esempio n. 6
0
 //
 // The name string can be set to use a unique effect name ID,
 //  or use REPLACE to replace any effect with the same name ID,
 //  or use SNAP_REPLACE to replace and snap to end any effect with the same name ID,
 //  or AUTO_RENAME to automatically create a new and unique name ID
 //
 public AnimatorEffect AddEffect(AnimatorEffect effect,
                                 Callback callback = null,
                                 string name       = EffectString.REPLACE)
 {
     return(Anime(null).AddEffect(effect, callback, name));
 }