public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3     position    = behaviour.GetComponent <Transform>().GetPosition();
        int         cell        = Grid.PosToCell(position);
        GameObject  gameObject  = null;
        BuildingDef buildingDef = null;

        if (Grid.IsValidCell(cell))
        {
            gameObject = Grid.Objects[cell, 1];
            if ((Object)gameObject != (Object)null && (Object)gameObject.GetComponent <Ladder>() != (Object)null)
            {
                Building component = gameObject.GetComponent <BuildingComplete>();
                if ((Object)component != (Object)null)
                {
                    buildingDef = component.Def;
                }
            }
        }
        if ((Object)buildingDef != (Object)null)
        {
            string name  = (!(buildingDef.PrefabID == "LadderFast")) ? base.name : StringFormatter.Combine(base.name, "_Plastic");
            string sound = GlobalAssets.GetSound(name, false);
            if (sound != null)
            {
                SoundEvent.PlayOneShot(sound, position);
            }
        }
    }
Ejemplo n.º 2
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3 position  = behaviour.GetComponent <Transform>().GetPosition();
        Worker  component = behaviour.GetComponent <Worker>();

        if ((UnityEngine.Object)component == (UnityEngine.Object)null)
        {
            SoundEvent.PlayOneShot(GlobalAssets.GetSound("Building_Dmg_Metal", false), position);
        }
        else
        {
            Workable workable = component.workable;
            if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
            {
                Building component2 = workable.GetComponent <Building>();
                if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                {
                    BuildingDef def   = component2.Def;
                    string      name  = StringFormatter.Combine(base.name, "_", def.AudioCategory);
                    string      sound = GlobalAssets.GetSound(name, false);
                    if (sound == null)
                    {
                        name  = "Building_Dmg_Metal";
                        sound = GlobalAssets.GetSound(name, false);
                    }
                    if (sound != null)
                    {
                        SoundEvent.PlayOneShot(sound, position);
                    }
                }
            }
        }
    }
 public override void OnPlay(AnimEventManager.EventPlayerData behaviour)
 {
     if (!string.IsNullOrEmpty(base.sound) && SoundEvent.ShouldPlaySound(behaviour.controller, base.sound, base.looping, isDynamic))
     {
         int        num        = -1;
         GameObject gameObject = behaviour.controller.gameObject;
         if (counterModulus >= -1)
         {
             HandleVector <int> .Handle h = GameComps.WhiteBoards.GetHandle(gameObject);
             if (!h.IsValid())
             {
                 h = GameComps.WhiteBoards.Add(gameObject);
             }
             num = (GameComps.WhiteBoards.HasValue(h, base.soundHash) ? ((int)GameComps.WhiteBoards.GetValue(h, base.soundHash)) : 0);
             int num2 = (counterModulus != -1) ? ((num + 1) % counterModulus) : 0;
             GameComps.WhiteBoards.SetValue(h, base.soundHash, num2);
         }
         Vector3       position = behaviour.GetComponent <Transform>().GetPosition();
         EventInstance instance = SoundEvent.BeginOneShot(base.sound, position);
         if (instance.isValid())
         {
             if (num >= 0)
             {
                 instance.setParameterValue("eventCount", (float)num);
             }
             SoundEvent.EndOneShot(instance);
         }
     }
 }
Ejemplo n.º 4
0
 protected bool IsFilteredOut(AnimEventManager.EventPlayerData behaviour)
 {
     if (file != null && behaviour.currentAnimFile != null && fileHash != behaviour.currentAnimFileHash)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        EventInstance instance = KFMOD.BeginOneShot(base.sound, Vector3.zero);

        if (instance.isValid())
        {
            instance.setParameterValue("frame", (float)base.frame);
            KFMOD.EndOneShot(instance);
        }
    }
Ejemplo n.º 6
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3       position = behaviour.GetComponent <Transform>().GetPosition();
        int           cell     = Grid.PosToCell(position);
        int           cell2    = Grid.CellBelow(cell);
        float         value    = (float)GetAudioCategory(cell2);
        EventInstance instance = SoundEvent.BeginOneShot(base.sound, position);

        instance.setParameterValue("material_ID", value);
        SoundEvent.EndOneShot(instance);
    }
Ejemplo n.º 7
0
    public override void OnPlay(AnimEventManager.EventPlayerData behaviour)
    {
        if (!string.IsNullOrEmpty(base.sound) && SoundEvent.ShouldPlaySound(behaviour.controller, base.sound, base.looping, isDynamic))
        {
            int        num        = -1;
            GameObject gameObject = behaviour.controller.gameObject;
            if (counterModulus >= -1)
            {
                HandleVector <int> .Handle h = GameComps.WhiteBoards.GetHandle(gameObject);
                if (!h.IsValid())
                {
                    h = GameComps.WhiteBoards.Add(gameObject);
                }
                num = (GameComps.WhiteBoards.HasValue(h, base.soundHash) ? ((int)GameComps.WhiteBoards.GetValue(h, base.soundHash)) : 0);
                int num2 = (counterModulus != -1) ? ((num + 1) % counterModulus) : 0;
                GameComps.WhiteBoards.SetValue(h, base.soundHash, num2);
            }
            Vector3 position  = behaviour.GetComponent <Transform>().GetPosition();
            string  sound     = GlobalAssets.GetSound("Hammer_sculpture", false);
            Worker  component = behaviour.GetComponent <Worker>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                Workable workable = component.workable;
                if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
                {
                    Building component2 = workable.GetComponent <Building>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                    {
                        BuildingDef def = component2.Def;
                        switch (def.name)
                        {
                        case "MetalSculpture":
                            sound = GlobalAssets.GetSound("Hammer_sculpture_metal", false);
                            break;

                        case "MarbleSculpture":
                            sound = GlobalAssets.GetSound("Hammer_sculpture_marble", false);
                            break;
                        }
                    }
                }
            }
            EventInstance instance = SoundEvent.BeginOneShot(sound, position);
            if (instance.isValid())
            {
                if (num >= 0)
                {
                    instance.setParameterValue("eventCount", (float)num);
                }
                SoundEvent.EndOneShot(instance);
            }
        }
    }
    public override void OnPlay(AnimEventManager.EventPlayerData behaviour)
    {
        string sound = GlobalAssets.GetSound(StringFormatter.Combine(base.name, "_", GetChewSound(behaviour)), false);

        if (SoundEvent.ShouldPlaySound(behaviour.controller, sound, base.looping, isDynamic))
        {
            Vector3       position = behaviour.GetComponent <Transform>().GetPosition();
            EventInstance instance = SoundEvent.BeginOneShot(sound, position);
            if (behaviour.controller.gameObject.GetDef <BabyMonitor.Def>() != null)
            {
                instance.setParameterValue("isBaby", 1f);
            }
            SoundEvent.EndOneShot(instance);
        }
    }
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        string        sound     = base.sound;
        CreatureBrain component = behaviour.GetComponent <CreatureBrain>();

        if ((Object)component != (Object)null && !string.IsNullOrEmpty(component.symbolPrefix))
        {
            string sound2 = GlobalAssets.GetSound(StringFormatter.Combine(component.symbolPrefix, base.name), false);
            if (!string.IsNullOrEmpty(sound2))
            {
                sound = sound2;
            }
        }
        PlaySound(behaviour, sound);
    }
Ejemplo n.º 10
0
 public void Play(AnimEventManager.EventPlayerData behaviour)
 {
     if (!IsFilteredOut(behaviour))
     {
         if (behaviour.previousFrame < behaviour.currentFrame)
         {
             if (behaviour.previousFrame < frame && behaviour.currentFrame >= frame)
             {
                 OnPlay(behaviour);
             }
         }
         else if (behaviour.previousFrame > behaviour.currentFrame && (behaviour.previousFrame < frame || frame <= behaviour.currentFrame))
         {
             OnPlay(behaviour);
         }
     }
 }
Ejemplo n.º 11
0
 public bool StartSound(string asset, AnimEventManager.EventPlayerData behaviour, EffectorValues noiseValues, bool ignore_pause = false, bool enable_camera_scaled_position = true)
 {
     if (asset == null || asset == string.Empty)
     {
         Debug.LogWarning("Missing sound");
         return(false);
     }
     if (!IsSoundPlaying(asset))
     {
         LoopingSoundEvent loopingSoundEvent = default(LoopingSoundEvent);
         loopingSoundEvent.asset = asset;
         LoopingSoundEvent item     = loopingSoundEvent;
         Vector3           position = behaviour.GetComponent <Transform>().GetPosition();
         item.handle = LoopingSoundManager.Get().Add(asset, position, base.transform, !ignore_pause, true, enable_camera_scaled_position);
         loopingSounds.Add(item);
     }
     return(true);
 }
    private static string GetChewSound(AnimEventManager.EventPlayerData behaviour)
    {
        string result = DEFAULT_CHEW_SOUND;

        EatStates.Instance sMI = behaviour.controller.GetSMI <EatStates.Instance>();
        if (sMI != null)
        {
            Element latestMealElement = sMI.GetLatestMealElement();
            if (latestMealElement != null)
            {
                string creatureChewSound = latestMealElement.substance.GetCreatureChewSound();
                if (!string.IsNullOrEmpty(creatureChewSound))
                {
                    result = creatureChewSound;
                }
            }
        }
        return(result);
    }
Ejemplo n.º 13
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        Vector3  position = behaviour.GetComponent <Transform>().GetPosition();
        Workable workable = behaviour.GetComponent <Worker>().workable;

        if ((UnityEngine.Object)workable != (UnityEngine.Object)null)
        {
            Toggleable component = workable.GetComponent <Toggleable>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null)
            {
                IToggleHandler toggleHandlerForWorker = component.GetToggleHandlerForWorker(behaviour.GetComponent <Worker>());
                float          value = 1f;
                if (toggleHandlerForWorker != null && toggleHandlerForWorker.IsHandlerOn())
                {
                    value = 0f;
                }
                EventInstance instance = SoundEvent.BeginOneShot(base.sound, position);
                instance.setParameterValue("State", value);
                SoundEvent.EndOneShot(instance);
            }
        }
    }
Ejemplo n.º 14
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);
                    }
                }
            }
        }
    }
 public override void OnPlay(AnimEventManager.EventPlayerData behaviour)
 {
     behaviour.controller.GetSMI <SpeechMonitor.Instance>().PlaySpeech(base.name, null);
 }
Ejemplo n.º 16
0
 private void DebugAnimEvent(string ev_name, AnimEventManager.EventPlayerData behaviour)
 {
 }
Ejemplo n.º 17
0
 public virtual void OnUpdate(AnimEventManager.EventPlayerData behaviour)
 {
 }
Ejemplo n.º 18
0
 public virtual void Stop(AnimEventManager.EventPlayerData behaviour)
 {
 }