Ejemplo n.º 1
0
    private void Update()
    {
        if (!Game.Instance.timelapser.CapturingTimelapseScreenshot)
        {
            if (FreeCameraEnabled && cinemaCamEnabled)
            {
                CinemaCamUpdate();
            }
            else
            {
                NormalCamUpdate();
            }
        }
        Color color = infoText.color;

        if (color.a > 0f)
        {
            Color color2 = infoText.color;
            Color color3 = infoText.color;
            color2.a       = Mathf.Max(0f, color3.a - Time.unscaledDeltaTime * 0.5f);
            infoText.color = color2;
        }
        ConstrainToWorld();
        Vector3 vector    = PointUnderCursor(KInputManager.GetMousePos(), Camera.main);
        Vector3 position  = base.transform.GetPosition();
        float   x         = position.x;
        Vector3 position2 = base.transform.GetPosition();
        float   y         = position2.y;
        Vector3 position3 = base.transform.GetPosition();

        Shader.SetGlobalVector("_WorldCameraPos", new Vector4(x, y, position3.z, Camera.main.orthographicSize));
        Shader.SetGlobalVector("_WorldCursorPos", new Vector4(vector.x, vector.y, 0f, 0f));
        VisibleArea.Update();
        soundCuller = SoundCuller.CreateCuller();
    }
Ejemplo n.º 2
0
        public void RenderEveryTick(float dt)
        {
            SoundCuller soundCuller = CameraController.Instance.soundCuller;

            if (shouldPauseOnGamePause && Time.timeScale == 0f)
            {
                sound.setPaused(true);
                return;
            }

            bool audible = !enableCulling || (enableCameraScaling && soundCuller.IsAudible(transform.position, falloffDistanceSq)) || soundCuller.IsAudibleNoCameraScaling(transform.position, falloffDistanceSq);

            if (!audible)
            {
                sound.setPaused(true);
                return;
            }

            sound.setPaused(false);

            Vector3 soundPos = transform.position;

            soundPos.z = 0;

            float velocityScale = TuningData <LoopingSoundManager.Tuning> .Get().velocityScale;

            VECTOR scaledSoundPos = SoundEvent.GetCameraScaledPosition(soundPos, false).ToFMODVector();
            VECTOR scaledSoundVel = (velocity * velocityScale).ToFMODVector();

            sound.set3DAttributes(ref scaledSoundPos, ref scaledSoundVel);
        }
Ejemplo n.º 3
0
    public void RenderEveryTick(float dt)
    {
        ListPool <Sound, LoopingSoundManager> .PooledList pooledList = ListPool <Sound, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList2 = ListPool <int, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList3 = ListPool <int, LoopingSoundManager> .Allocate();

        List <Sound> dataList    = sounds.GetDataList();
        bool         flag        = Time.timeScale == 0f;
        SoundCuller  soundCuller = CameraController.Instance.soundCuller;

        for (int i = 0; i < dataList.Count; i++)
        {
            Sound sound = dataList[i];
            if ((UnityEngine.Object)sound.transform != (UnityEngine.Object)null)
            {
                sound.pos = sound.transform.GetPosition();
                if ((UnityEngine.Object)sound.animController != (UnityEngine.Object)null)
                {
                    Vector3 offset = sound.animController.Offset;
                    sound.pos.x += offset.x;
                    sound.pos.y += offset.y;
                }
            }
            bool flag2     = !sound.IsCullingEnabled || (sound.ShouldCameraScalePosition && soundCuller.IsAudible(sound.pos, sound.falloffDistanceSq)) || soundCuller.IsAudibleNoCameraScaling(sound.pos, sound.falloffDistanceSq);
            bool isPlaying = sound.IsPlaying;
            if (flag2)
            {
                pooledList.Add(sound);
                if (!isPlaying)
                {
                    SoundDescription soundDescription = GetSoundDescription(sound.path);
                    sound.ev    = KFMOD.CreateInstance(soundDescription.path);
                    dataList[i] = sound;
                    pooledList2.Add(i);
                }
            }
            else if (isPlaying)
            {
                pooledList3.Add(i);
            }
        }
        LoopingSoundParameterUpdater.Sound sound2;
        foreach (int item in pooledList2)
        {
            Sound            value             = dataList[item];
            SoundDescription soundDescription2 = GetSoundDescription(value.path);
            value.ev.setPaused(flag && value.ShouldPauseOnGamePaused);
            Vector2 v = value.pos;
            if (value.ShouldCameraScalePosition)
            {
                v = SoundEvent.GetCameraScaledPosition(v);
            }
            value.ev.set3DAttributes(RuntimeUtils.To3DAttributes(v));
            value.ev.start();
            value.flags |= Sound.Flags.PLAYING;
            if (value.firstParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.firstParameter), value.firstParameterValue);
            }
            if (value.secondParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.secondParameter), value.secondParameterValue);
            }
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value.ev;
            sound2.path        = value.path;
            sound2.description = soundDescription2;
            sound2.transform   = value.transform;
            LoopingSoundParameterUpdater.Sound sound3     = sound2;
            SoundDescription.Parameter[]       parameters = soundDescription2.parameters;
            for (int j = 0; j < parameters.Length; j++)
            {
                SoundDescription.Parameter   parameter = parameters[j];
                LoopingSoundParameterUpdater value2    = null;
                if (parameterUpdaters.TryGetValue(parameter.name, out value2))
                {
                    value2.Add(sound3);
                }
            }
            dataList[item] = value;
        }
        pooledList2.Recycle();
        foreach (int item2 in pooledList3)
        {
            Sound            value3            = dataList[item2];
            SoundDescription soundDescription3 = GetSoundDescription(value3.path);
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value3.ev;
            sound2.path        = value3.path;
            sound2.description = soundDescription3;
            sound2.transform   = value3.transform;
            LoopingSoundParameterUpdater.Sound sound4      = sound2;
            SoundDescription.Parameter[]       parameters2 = soundDescription3.parameters;
            for (int k = 0; k < parameters2.Length; k++)
            {
                SoundDescription.Parameter   parameter2 = parameters2[k];
                LoopingSoundParameterUpdater value4     = null;
                if (parameterUpdaters.TryGetValue(parameter2.name, out value4))
                {
                    value4.Remove(sound4);
                }
            }
            if (value3.ShouldCameraScalePosition)
            {
                value3.ev.stop(STOP_MODE.IMMEDIATE);
            }
            else
            {
                value3.ev.stop(STOP_MODE.ALLOWFADEOUT);
            }
            value3.flags &= ~Sound.Flags.PLAYING;
            value3.ev.release();
            dataList[item2] = value3;
        }
        pooledList3.Recycle();
        float velocityScale = TuningData <Tuning> .Get().velocityScale;

        foreach (Sound item3 in pooledList)
        {
            Sound         current3   = item3;
            ATTRIBUTES_3D attributes = SoundEvent.GetCameraScaledPosition(current3.pos).To3DAttributes();
            attributes.velocity = (current3.velocity * velocityScale).ToFMODVector();
            current3.ev.set3DAttributes(attributes);
        }
        foreach (KeyValuePair <HashedString, LoopingSoundParameterUpdater> parameterUpdater in parameterUpdaters)
        {
            parameterUpdater.Value.Update(dt);
        }
        pooledList.Recycle();
    }