Example #1
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3 pos = behaviour.GetComponent <Transform>().GetPosition();
        KBatchedAnimController component = behaviour.GetComponent <KBatchedAnimController>();

        if ((Object)component != (Object)null)
        {
            pos = component.GetPivotSymbolPosition();
        }
        int    num           = Grid.PosToCell(pos);
        int    cell          = Grid.CellBelow(num);
        string audioCategory = GetAudioCategory(cell);
        string name          = StringFormatter.Combine(audioCategory, "_", base.name);
        string sound         = GlobalAssets.GetSound(name, true);

        if (sound == null)
        {
            name  = StringFormatter.Combine("Rock_", base.name);
            sound = GlobalAssets.GetSound(name, true);
            if (sound == null)
            {
                name  = base.name;
                sound = GlobalAssets.GetSound(name, true);
            }
        }
        if (!SoundEvent.IsLowPrioritySound(sound))
        {
            pos = SoundEvent.GetCameraScaledPosition(pos);
            if (Grid.Element != null)
            {
                bool  isLiquid = Grid.Element[num].IsLiquid;
                float num2     = 0f;
                if (isLiquid)
                {
                    num2 = SoundUtil.GetLiquidDepth(num);
                    string sound2 = GlobalAssets.GetSound("Liquid_footstep", true);
                    if (sound2 != null)
                    {
                        FMOD.Studio.EventInstance instance = SoundEvent.BeginOneShot(sound2, pos);
                        if (num2 > 0f)
                        {
                            instance.setParameterValue("liquidDepth", num2);
                        }
                        SoundEvent.EndOneShot(instance);
                    }
                }
                if (sound != null)
                {
                    FMOD.Studio.EventInstance instance2 = SoundEvent.BeginOneShot(sound, pos);
                    if (instance2.isValid())
                    {
                        if (num2 > 0f)
                        {
                            instance2.setParameterValue("liquidDepth", num2);
                        }
                        if (behaviour.currentAnimFile != null && behaviour.currentAnimFile.Contains("anim_loco_walk"))
                        {
                            instance2.setVolume(IDLE_WALKING_VOLUME_REDUCTION);
                        }
                        SoundEvent.EndOneShot(instance2);
                    }
                }
            }
        }
    }