Пример #1
0
    public static void SetAmbience(AmbienceType _ambience)
    {
        switch (_ambience)
        {
        case AmbienceType.MENU:
        {
            instance.above_source.FadeVolume(0.10f, 1);
            instance.below_source.FadeVolume(0.50f, 1);
        } break;

        case AmbienceType.ABOVE:
        {
            instance.above_source.FadeVolume(0.75f, 2.0f);
            instance.below_source.FadeVolume(0.10f, 1.0f);
        } break;

        case AmbienceType.BELOW:
        {
            instance.above_source.FadeVolume(0.10f, 1.0f);
            instance.below_source.FadeVolume(0.75f, 2.0f);
        } break;
        }
    }
    public override void FixedUpdate(float dt)
    {
        Tuning tuning = TuningData <Tuning> .Get();

        float num = tuning.maxVelocity * tuning.maxVelocity;

        for (int i = 0; i < data.Count; i++)
        {
            GravityComponent value = data[i];
            if (!(value.elapsedTime < 0f) && !((UnityEngine.Object)value.transform == (UnityEngine.Object)null))
            {
                Vector3 position     = value.transform.GetPosition();
                Vector2 vector       = position;
                Vector2 vector2      = new Vector2(value.velocity.x, value.velocity.y + -9.8f * dt);
                float   sqrMagnitude = vector2.sqrMagnitude;
                if (sqrMagnitude > num)
                {
                    vector2 *= tuning.maxVelocity / Mathf.Sqrt(sqrMagnitude);
                }
                int  num2 = Grid.PosToCell(vector);
                bool flag = Grid.IsVisiblyInLiquid(vector + new Vector2(0f, value.radius));
                if (flag)
                {
                    flag = true;
                    float num3 = (float)(value.transform.GetInstanceID() % 1000) / 1000f * 0.25f;
                    float num4 = tuning.maxVelocityInLiquid + num3 * tuning.maxVelocityInLiquid;
                    if (sqrMagnitude > num4 * num4)
                    {
                        float num5 = Mathf.Sqrt(sqrMagnitude);
                        vector2 = vector2 / num5 * Mathf.Lerp(num5, num3, dt * (5f + 5f * num3));
                    }
                }
                value.velocity     = vector2;
                value.elapsedTime += dt;
                Vector2 vector3 = vector + vector2 * dt;
                Vector2 pos     = vector3;
                pos.y -= value.radius;
                bool flag2 = Grid.IsVisiblyInLiquid(vector3 + new Vector2(0f, value.radius));
                if (!flag && flag2)
                {
                    KBatchedAnimController kBatchedAnimController = FXHelpers.CreateEffect("splash_step_kanim", new Vector3(vector3.x, vector3.y, 0f) + new Vector3(-0.38f, 0.75f, -0.1f), null, false, Grid.SceneLayer.FXFront, false);
                    kBatchedAnimController.Play("fx1", KAnim.PlayMode.Once, 1f, 0f);
                    kBatchedAnimController.destroyOnAnimComplete = true;
                }
                int num6 = Grid.PosToCell(pos);
                if (Grid.IsValidCell(num6))
                {
                    if (vector2.sqrMagnitude > 0.2f && Grid.IsValidCell(num2) && !Grid.Element[num2].IsLiquid && Grid.Element[num6].IsLiquid)
                    {
                        AmbienceType ambience = Grid.Element[num6].substance.GetAmbience();
                        if (ambience != AmbienceType.None)
                        {
                            string text = Sounds.Instance.OreSplashSoundsMigrated[(int)ambience];
                            if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null && CameraController.Instance.IsAudibleSound(vector3, text))
                            {
                                SoundEvent.PlayOneShot(text, vector3);
                            }
                        }
                    }
                    bool flag3 = Grid.Solid[num6];
                    if (!flag3 && value.landOnFakeFloors && Grid.FakeFloor[num6])
                    {
                        Navigator component = value.transform.GetComponent <Navigator>();
                        if ((bool)component)
                        {
                            flag3 = component.NavGrid.NavTable.IsValid(num6, NavType.Floor);
                            if (!flag3)
                            {
                                int cell = Grid.CellAbove(num6);
                                flag3 = component.NavGrid.NavTable.IsValid(cell, NavType.Hover);
                            }
                        }
                    }
                    if (flag3)
                    {
                        Vector3 vector4 = Grid.CellToPosCBC(Grid.CellAbove(num6), Grid.SceneLayer.Move);
                        vector3.y         = vector4.y + value.radius;
                        value.velocity.x  = 0f;
                        value.elapsedTime = -1f;
                        value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                        data[i] = value;
                        value.transform.gameObject.Trigger(1188683690, vector2);
                        if (value.onLanded != null)
                        {
                            value.onLanded();
                        }
                    }
                    else
                    {
                        Vector2 pos2 = vector3;
                        pos2.x -= value.radius;
                        int num7 = Grid.PosToCell(pos2);
                        if (Grid.IsValidCell(num7) && Grid.Solid[num7])
                        {
                            vector3.x        = Mathf.Floor(vector3.x - value.radius) + (1f + value.radius);
                            value.velocity.x = -0.1f * value.velocity.x;
                            data[i]          = value;
                        }
                        else
                        {
                            Vector3 pos3 = vector3;
                            pos3.x += value.radius;
                            int num8 = Grid.PosToCell(pos3);
                            if (Grid.IsValidCell(num8) && Grid.Solid[num8])
                            {
                                vector3.x        = Mathf.Floor(vector3.x + value.radius) - value.radius;
                                value.velocity.x = -0.1f * value.velocity.x;
                                data[i]          = value;
                            }
                        }
                        value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                        data[i] = value;
                    }
                }
                else
                {
                    value.transform.SetPosition(new Vector3(vector3.x, vector3.y, position.z));
                    data[i] = value;
                }
            }
        }
    }
        public void Update(Vector2I min, Vector2I max, Vector3 emitter_position)
        {
            emitterPosition = emitter_position;
            totalTileCount  = 0;
            for (int i = 0; i < allLayers.Count; i++)
            {
                Layer layer = allLayers[i];
                layer.Reset();
            }
            for (int j = min.y; j < max.y; j++)
            {
                if (j % 2 != 1)
                {
                    for (int k = min.x; k < max.x; k++)
                    {
                        if (k % 2 != 0)
                        {
                            int num = Grid.XYToCell(k, j);
                            if (Grid.IsValidCell(num))
                            {
                                totalTileCount++;
                                if (Grid.IsVisible(num))
                                {
                                    if (Grid.GravitasFacility[num])
                                    {
                                        facilityLayer.tileCount += 8;
                                    }
                                    else
                                    {
                                        Element element = Grid.Element[num];
                                        if (element != null)
                                        {
                                            if (element.IsLiquid && Grid.IsSubstantialLiquid(num, 0.35f))
                                            {
                                                AmbienceType ambience = element.substance.GetAmbience();
                                                if (ambience != AmbienceType.None)
                                                {
                                                    liquidLayers[(int)ambience].tileCount++;
                                                    liquidLayers[(int)ambience].averageTemperature += Grid.Temperature[num];
                                                }
                                            }
                                            else if (element.IsGas)
                                            {
                                                AmbienceType ambience2 = element.substance.GetAmbience();
                                                if (ambience2 != AmbienceType.None)
                                                {
                                                    gasLayers[(int)ambience2].tileCount++;
                                                    gasLayers[(int)ambience2].averageTemperature += Grid.Temperature[num];
                                                }
                                            }
                                            else if (element.IsSolid)
                                            {
                                                SolidAmbienceType solidAmbience = element.substance.GetSolidAmbience();
                                                if (Grid.Foundation[num])
                                                {
                                                    solidAmbience = SolidAmbienceType.Tile;
                                                    solidLayers[(int)solidAmbience].tileCount += TuningData <Tuning> .Get().foundationTileValue;

                                                    spaceLayer.tileCount -= TuningData <Tuning> .Get().foundationTileValue;
                                                }
                                                else if ((UnityEngine.Object)Grid.Objects[num, 2] != (UnityEngine.Object)null)
                                                {
                                                    solidAmbience = SolidAmbienceType.Tile;
                                                    solidLayers[(int)solidAmbience].tileCount += TuningData <Tuning> .Get().backwallTileValue;

                                                    spaceLayer.tileCount -= TuningData <Tuning> .Get().backwallTileValue;
                                                }
                                                else if (solidAmbience != SolidAmbienceType.None)
                                                {
                                                    solidLayers[(int)solidAmbience].tileCount++;
                                                }
                                                else if (element.id == SimHashes.Regolith || element.id == SimHashes.MaficRock)
                                                {
                                                    spaceLayer.tileCount++;
                                                }
                                            }
                                            else if (element.id == SimHashes.Vacuum && CellSelectionObject.IsExposedToSpace(num))
                                            {
                                                if ((UnityEngine.Object)Grid.Objects[num, 1] != (UnityEngine.Object)null)
                                                {
                                                    spaceLayer.tileCount -= TuningData <Tuning> .Get().buildingTileValue;
                                                }
                                                spaceLayer.tileCount++;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    fogLayer.tileCount++;
                                }
                            }
                        }
                    }
                }
            }
            Vector2I vector2I   = max - min;
            int      cell_count = vector2I.x * vector2I.y;

            for (int l = 0; l < allLayers.Count; l++)
            {
                Layer layer2 = allLayers[l];
                layer2.UpdatePercentage(cell_count);
            }
            loopingLayers.Sort();
            topLayers.Clear();
            for (int m = 0; m < loopingLayers.Count; m++)
            {
                Layer layer3 = loopingLayers[m];
                if (m < 3 && layer3.tilePercentage > 0f)
                {
                    layer3.Start(emitter_position);
                    layer3.UpdateAverageTemperature();
                    layer3.UpdateParameters(emitter_position);
                    topLayers.Add(layer3);
                }
                else
                {
                    layer3.Stop();
                }
            }
            oneShotLayers.Sort();
            for (int n = 0; n < activeSolidLayerCount; n++)
            {
                if (solidTimers[n].ShouldPlay() && oneShotLayers[n].tilePercentage > 0f)
                {
                    oneShotLayers[n].Start(emitter_position);
                }
            }
        }