Ejemplo n.º 1
0
        protected GasSolidSeparatorRatingModel(IGasSolidSeparator owner) : base()
        {
            this.owner       = owner;
            this.ownerUnitOp = owner.MyUnitOperation;
            DryingGasStream     dgs = owner.GasInlet as DryingGasStream;
            DryingGasComponents dgc = dgs.GasComponents;
            SolidPhase          sp  = dgc.SolidPhase;

            if (sp == null)
            {
                particleProperties = new ParticleProperties();
            }
            else
            {
                ParticleSizeFractionAndEfficiency sfe;
                particleProperties = sp.ParticleProperties;
                ArrayList sizeAndFractionList = particleProperties.ParticleSizeAndFractionList;
                if (particleProperties.IsParticleDistributionsCalculated)
                {
                    foreach (ParticleSizeAndFraction psf in sizeAndFractionList)
                    {
                        sfe = new ParticleSizeFractionAndEfficiency(psf);
                        particleSizeFractionAndEfficiencyList.Add(sfe);
                    }
                }
            }

            this.ParticleDensity.Owner     = ownerUnitOp;
            this.ParticleBulkDensity.Owner = ownerUnitOp;
        }
Ejemplo n.º 2
0
        static INeuralNetwork BuildPsoNetwork()
        {
            var props = new NetworkProperties {
                InitWeightMin = -0.1,
                InitWeightMax = 0.1,
                NumHidden     = 2,
                NumInput      = 4,
                NumOutput     = 3
            };

            var particleProps = new ParticleProperties {
                MaxVDelta = 2.0,
                MinVDelta = -2.0,
                V         = 3.0,
                VSelf     = 2.0,
                VSocial   = 2.0
            };

            var netProps = new PsoNetworkProperties {
                DesiredAccuracy = 0.98,
                Iterations      = 1000,
                NumNetworks     = 4,
                ParticleProps   = particleProps
            };

            return(new PsoNetwork(netProps, props, new Random(0)));
        }
Ejemplo n.º 3
0
        public int CreateParticleEffect(string lib, string name, Vector3 pos, Vector3 rot, float scale, int attachedEntity = 0, int boneId = 0, int dimension = 0)
        {
            int localEntityHash;
            var obj = new ParticleProperties
            {
                EntityType     = (byte)EntityType.Particle,
                Position       = pos,
                Rotation       = rot,
                Alpha          = 255,
                Library        = lib,
                Name           = name,
                Scale          = scale,
                EntityAttached = attachedEntity,
                BoneAttached   = boneId,
                Dimension      = dimension
            };

            lock (ServerEntities)
            {
                localEntityHash = GetId();
                ServerEntities.Add(localEntityHash, obj);
            }

            var packet = new CreateEntity
            {
                EntityType = (byte)EntityType.Particle,
                Properties = obj,
                NetHandle  = localEntityHash
            };

            Program.ServerInstance.SendToAll(packet, PacketType.CreateEntity, true, ConnectionChannel.EntityBackend);

            return(localEntityHash);
        }
Ejemplo n.º 4
0
        public int CreateParticleEffect(string lib, string name, Vector3 pos, Vector3 rot, float scale, int attachedEntity = 0, int boneId = 0, int dimension = 0)
        {
            int localEntityHash;
            var obj = new ParticleProperties();

            obj.EntityType     = (byte)EntityType.Particle;
            obj.Position       = pos;
            obj.Rotation       = rot;
            obj.Alpha          = 255;
            obj.Library        = lib;
            obj.Name           = name;
            obj.Scale          = scale;
            obj.EntityAttached = attachedEntity;
            obj.BoneAttached   = boneId;
            obj.Dimension      = dimension;

            lock (ServerEntities)
            {
                localEntityHash = GetId();
                ServerEntities.Add(localEntityHash, obj);
            }

            var packet = new CreateEntity();

            packet.EntityType = (byte)EntityType.Particle;
            packet.Properties = obj;
            packet.NetHandle  = localEntityHash;

            Program.ServerInstance.SendToAll(packet, PacketType.CreateEntity, true, ConnectionChannel.EntityBackend);

            return(localEntityHash);
        }
Ejemplo n.º 5
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionSolidPhase", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.particleProperties = RecallStorableObject("ParticleProperties", typeof(ParticleProperties)) as ParticleProperties;
            }
        }
Ejemplo n.º 6
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionCyclone", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.particleProperties = RecallStorableObject("ParticleProperties", typeof(ParticleProperties)) as ParticleProperties;
                this.particleSizeFractionAndEfficiencyList = RecallArrayListObject("ParticleSizeFractionAndEfficiencyList");
            }
        }
Ejemplo n.º 7
0
        // Particle handling
        private void SpawnParticle(Point spawnPos)
        {
            // Define particle properties
            ParticleProperties pProperties = ((OptionBarControls.ParticleControl)optionBarControls[OptionBarTypes.ParticleControl]).GetParticleProperties();

            pProperties.xPos = spawnPos.X;
            pProperties.yPos = SimGrid.ActualHeight - spawnPos.Y;

            // Add particle to list view
            if (((ListViewItem)ParticleListView.Items[0]).Content as string == "None")
            {
                ParticleListView.Items.RemoveAt(0);
            }

            DockPanel itemContent = new DockPanel()
            {
                MinWidth = 180
            };

            itemContent.Children.Add(new TextBlock()
            {
                Text = "Particle " + currentParticles.Count.ToString()
            });
            Ellipse display = new Ellipse()
            {
                Fill   = new SolidColorBrush(pProperties.color),
                Width  = 10,
                Height = 10,
                Margin = new Thickness(5, 0, 5, 0),
                HorizontalAlignment = HorizontalAlignment.Right
            };

            DockPanel.SetDock(display, Dock.Left);
            itemContent.Children.Add(display);

            ParticleListView.Items.Add(new ListViewItem()
            {
                Content = itemContent
            });

            // Edit pProperties for engine and spawn particle
            pProperties.xVel *= 0.1;
            pProperties.yVel *= 0.1;

            Particle newParticle = simEngine.SpawnParticle(pProperties);

            currentParticles.Add(newParticle);

            // Update generic info panel
            NumParticlesLabel.Content = currentParticles.Count;

            lineTrails.Add(new LineTrail(newParticle.shape.shape, SimGrid, (int)ParticleTrailsSlider.Value));
        }
Ejemplo n.º 8
0
    void AddParticle(PARTICLE_TYPE pt, int x, int y)
    {
        int                id       = UnityEngine.Random.Range(1, int.MaxValue);
        Vector3            position = new Vector3(x, y, 0);
        ParticleProperties pp       = GetProperties(pt);
        ParticleData       data     = new ParticleData
        {
            id         = id,
            position   = position,
            color      = pp.color,
            properties = pp.properties
        };

        particleData.Add(id, data);
        ids.Add(id);
    }
Ejemplo n.º 9
0
        private void SpawnParticle(double?X = null, double?Y = null, ParticleProperties properties = null)
        {
            if (properties is null)
            {
                properties = (OptionBar as ParticleToolOptions).ParticleOptions;
            }
            if (X != null)
            {
                properties.X = (double)X;
            }
            if (Y != null)
            {
                properties.Y = (double)Y;
            }

            particleSim.CreateBody(properties);
        }
Ejemplo n.º 10
0
    private void OnSerializing()
    {
        List <Element> elements = ElementLoader.elements;
        Diseases       diseases = Db.Get().Diseases;

        serializedParticleProperties = new List <SerializedParticleProperties>();
        foreach (ParticleProperties particleProperty in particleProperties)
        {
            ParticleProperties           current = particleProperty;
            SerializedParticleProperties item    = default(SerializedParticleProperties);
            item.elementID    = elements[current.elementIdx].id;
            item.diseaseID    = ((current.diseaseIdx == 255) ? HashedString.Invalid : diseases[current.diseaseIdx].IdHash);
            item.mass         = current.mass;
            item.temperature  = current.temperature;
            item.diseaseCount = current.diseaseCount;
            serializedParticleProperties.Add(item);
        }
    }
Ejemplo n.º 11
0
    public Dictionary <int, float> GetInfo(int cell)
    {
        Dictionary <int, float> dictionary = new Dictionary <int, float>();
        int count = physics.Count;

        for (int i = 0; i < count; i++)
        {
            ParticlePhysics particlePhysics = physics[i];
            int             num             = Grid.PosToCell(particlePhysics.position);
            if (num == cell)
            {
                ParticleProperties particleProperties = this.particleProperties[i];
                float value = 0f;
                dictionary.TryGetValue(particleProperties.elementIdx, out value);
                value += particleProperties.mass;
                dictionary[particleProperties.elementIdx] = value;
            }
        }
        return(dictionary);
    }
Ejemplo n.º 12
0
        private void StartParticlePreview()
        {
            Point mousePos = Mouse.GetPosition(simCanvas);

            // Get and update option bar properties
            particlePreviewProps   = (OptionBar as ParticleToolOptions).ParticleOptions;
            particlePreviewProps.X = mousePos.X;
            particlePreviewProps.Y = simCanvas.ActualHeight - mousePos.Y;

            // Update particle preview
            particlePreview.Fill   = new SolidColorBrush(particlePreviewProps.color);
            particlePreview.Height = particlePreviewProps.size;
            particlePreview.Width  = particlePreviewProps.size;
            Canvas.SetLeft(particlePreview, mousePos.X - particlePreviewProps.radius);
            Canvas.SetBottom(particlePreview, simCanvas.ActualHeight - mousePos.Y - particlePreviewProps.radius);

            // Update velocity line preview
            velPreview.Stroke = new SolidColorBrush(particlePreviewProps.color);
            velPreview.X1     = mousePos.X;
            velPreview.Y1     = mousePos.Y;
        }
Ejemplo n.º 13
0
        public ParticleProperties GetParticleProperties()
        {
            ParticleProperties properties = new ParticleProperties
            {
                radius = 10,
                color  = ParticleColorPicker.SelectedColor ?? Colors.Red,
                xVel   = VelXUpDown.Value ?? 0,
                yVel   = VelYUpDown.Value ?? 0,
                mass   = MassUpDown.Value ?? 1,
                charge = (short)(ChargeUpDown.Value ?? 0)
            };

            if (RandomColorCheckBox.IsChecked ?? false)
            {
                ParticleColorPicker.R = (byte)getrandom.Next(1, 256);
                ParticleColorPicker.G = (byte)getrandom.Next(1, 256);
                ParticleColorPicker.B = (byte)getrandom.Next(1, 256);
            }

            return(properties);
        }
Ejemplo n.º 14
0
 private void OnDeserialized()
 {
     if (serializedParticleProperties != null)
     {
         Diseases diseases = Db.Get().Diseases;
         particleProperties.Clear();
         foreach (SerializedParticleProperties serializedParticleProperty in serializedParticleProperties)
         {
             SerializedParticleProperties current = serializedParticleProperty;
             ParticleProperties           item    = default(ParticleProperties);
             item.elementIdx   = (byte)ElementLoader.GetElementIndex(current.elementID);
             item.diseaseIdx   = (byte)((!(current.diseaseID != HashedString.Invalid)) ? 255 : diseases.GetIndex(current.diseaseID));
             item.mass         = current.mass;
             item.temperature  = current.temperature;
             item.diseaseCount = current.diseaseCount;
             particleProperties.Add(item);
         }
     }
     else
     {
         particleProperties = properties;
     }
     properties = null;
 }
        public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties)
        {
            // Z write doesn't work with fading
            bool hasZWrite = (material.GetInt("_ZWrite") != 0);

            if (!hasZWrite)
            {
                // Soft Particles
                {
                    EditorGUI.showMixedValue = properties.softParticlesEnabled.hasMixedValue;
                    var enabled = properties.softParticlesEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.softParticlesEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Soft Particles Enabled");
                        properties.softParticlesEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Surface Fade"),
                                                         properties.softParticlesNearFadeDistance,
                                                         Styles.softParticlesNearFadeDistanceText,
                                                         properties.softParticlesFarFadeDistance,
                                                         Styles.softParticlesFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Camera Fading
                {
                    EditorGUI.showMixedValue = properties.cameraFadingEnabled.hasMixedValue;
                    var enabled = properties.cameraFadingEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.cameraFadingEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Camera Fading Enabled");
                        properties.cameraFadingEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Distance"),
                                                         properties.cameraNearFadeDistance,
                                                         Styles.cameraNearFadeDistanceText,
                                                         properties.cameraFarFadeDistance,
                                                         Styles.cameraFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Distortion
                if (properties.distortionEnabled != null)
                {
                    EditorGUI.showMixedValue = properties.distortionEnabled.hasMixedValue;
                    var enabled = properties.distortionEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.distortionEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Distortion Enabled");
                        properties.distortionEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength);
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = properties.distortionStrength.hasMixedValue;
                        var blend = EditorGUILayout.Slider(Styles.distortionBlend, properties.distortionBlend.floatValue, 0f, 1f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            properties.distortionBlend.floatValue = blend;
                        }
                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.showMixedValue = false;
            }
        }
Ejemplo n.º 16
0
        public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties)
        {
            // Z write doesn't work with fading
            bool hasZWrite = (material.GetInt("_ZWrite") != 0);

            if (!hasZWrite)
            {
                // Soft Particles
                {
                    EditorGUI.showMixedValue = properties.softParticlesEnabled.hasMixedValue;
                    var enabled = properties.softParticlesEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.softParticlesEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Soft Particles Enabled");
                        properties.softParticlesEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        UniversalRenderPipelineAsset urpAsset = UniversalRenderPipeline.asset;
                        if (urpAsset != null && !urpAsset.supportsCameraDepthTexture)
                        {
                            GUIStyle warnStyle = new GUIStyle(GUI.skin.label);
                            warnStyle.fontStyle = FontStyle.BoldAndItalic;
                            warnStyle.wordWrap  = true;
                            EditorGUILayout.HelpBox("Soft Particles require depth texture. Please enable \"Depth Texture\" in the Universal Render Pipeline settings.", MessageType.Warning);
                        }

                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Surface Fade"),
                                                         properties.softParticlesNearFadeDistance,
                                                         Styles.softParticlesNearFadeDistanceText,
                                                         properties.softParticlesFarFadeDistance,
                                                         Styles.softParticlesFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Camera Fading
                {
                    EditorGUI.showMixedValue = properties.cameraFadingEnabled.hasMixedValue;
                    var enabled = properties.cameraFadingEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.cameraFadingEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Camera Fading Enabled");
                        properties.cameraFadingEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Distance"),
                                                         properties.cameraNearFadeDistance,
                                                         Styles.cameraNearFadeDistanceText,
                                                         properties.cameraFarFadeDistance,
                                                         Styles.cameraFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Distortion
                if (properties.distortionEnabled != null)
                {
                    EditorGUI.showMixedValue = properties.distortionEnabled.hasMixedValue;
                    var enabled = properties.distortionEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.distortionEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Distortion Enabled");
                        properties.distortionEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength);
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = properties.distortionStrength.hasMixedValue;
                        var blend = EditorGUILayout.Slider(Styles.distortionBlend, properties.distortionBlend.floatValue, 0f, 1f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            properties.distortionBlend.floatValue = blend;
                        }
                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.showMixedValue = false;
            }
        }
Ejemplo n.º 17
0
    public void Render()
    {
        List <Vector3> vertices = MeshUtil.vertices;
        List <Color32> colours  = MeshUtil.colours32;
        List <Vector2> uvs      = MeshUtil.uvs;
        List <int>     indices  = MeshUtil.indices;

        uvs.Clear();
        vertices.Clear();
        indices.Clear();
        colours.Clear();
        float   num  = particleSize.x * 0.5f;
        float   num2 = particleSize.y * 0.5f;
        Vector2 a    = new Vector2(0f - num, 0f - num2);
        Vector2 a2   = new Vector2(num, 0f - num2);
        Vector2 a3   = new Vector2(num, num2);
        Vector2 a4   = new Vector2(0f - num, num2);
        float   y    = 1f;
        float   y2   = 0f;
        int     num3 = Mathf.Min(physics.Count, 16249);

        if (num3 < physics.Count)
        {
            DebugUtil.LogWarningArgs("Too many water particles to render. Wanted", physics.Count, "but truncating to limit");
        }
        for (int i = 0; i < num3; i++)
        {
            ParticlePhysics    particlePhysics    = physics[i];
            Vector2            position           = particlePhysics.position;
            ParticleProperties particleProperties = this.particleProperties[i];
            float d = Mathf.Lerp(0.25f, 1f, Mathf.Clamp01(particleProperties.mass / particleMassToSplit));
            vertices.Add(position + a * d);
            vertices.Add(position + a2 * d);
            vertices.Add(position + a3 * d);
            vertices.Add(position + a4 * d);
            ParticlePhysics particlePhysics2 = physics[i];
            int             frame            = particlePhysics2.frame;
            float           x  = (float)frame * uvFrameSize.x;
            float           x2 = (float)(frame + 1) * uvFrameSize.x;
            uvs.Add(new Vector2(x, y2));
            uvs.Add(new Vector2(x2, y2));
            uvs.Add(new Vector2(x2, y));
            uvs.Add(new Vector2(x, y));
            ParticlePhysics particlePhysics3 = physics[i];
            Color32         colour           = particlePhysics3.colour;
            colours.Add(colour);
            colours.Add(colour);
            colours.Add(colour);
            colours.Add(colour);
            int num4 = i * 4;
            indices.Add(num4);
            indices.Add(num4 + 1);
            indices.Add(num4 + 2);
            indices.Add(num4);
            indices.Add(num4 + 2);
            indices.Add(num4 + 3);
        }
        mesh.Clear();
        mesh.SetVertices(vertices);
        mesh.SetUVs(0, uvs);
        mesh.SetColors(colours);
        mesh.SetTriangles(indices, 0);
        int layer = LayerMask.NameToLayer("Water");

        Graphics.DrawMesh(mesh, renderOffset, Quaternion.identity, material, layer, null, 0, propertyBlock);
    }
Ejemplo n.º 18
0
    private void AddToSim(int cell, int particleIdx, ref int num_particles)
    {
        bool flag = false;

        do
        {
            Element       element = Grid.Element[cell];
            Element.State state   = element.state & Element.State.Solid;
            if (state == Element.State.Solid || (Grid.Properties[cell] & 2) != 0)
            {
                cell += Grid.WidthInCells;
                if (!Grid.IsValidCell(cell))
                {
                    return;
                }
            }
            else
            {
                flag = true;
            }
        }while (!flag);
        ParticleProperties particleProperties = this.particleProperties[particleIdx];

        SimMessages.AddRemoveSubstance(cell, particleProperties.elementIdx, CellEventLogger.Instance.FallingWaterAddToSim, particleProperties.mass, particleProperties.temperature, particleProperties.diseaseIdx, particleProperties.diseaseCount, true, -1);
        RemoveParticle(particleIdx, ref num_particles);
        float time = GetTime();
        float num  = lastSpawnTime[cell];

        if (time - num >= minSpawnDelay)
        {
            lastSpawnTime[cell] = time;
            Vector3 vector = Grid.CellToPosCCC(cell, Grid.SceneLayer.TileMain);
            if (CameraController.Instance.IsAudibleSound(vector))
            {
                bool flag2 = true;
                if (splashSounds.TryGetValue(cell, out SoundInfo value))
                {
                    value.splashCount++;
                    if (value.splashCount > splashCountLoopThreshold)
                    {
                        if (value.handle == HandleVector <int> .InvalidHandle)
                        {
                            value.handle = LoopingSoundManager.StartSound(liquid_splash_loop, vector, true, true);
                        }
                        LoopingSoundManager.Get().UpdateFirstParameter(value.handle, HASH_LIQUIDDEPTH, SoundUtil.GetLiquidDepth(cell));
                        LoopingSoundManager.Get().UpdateSecondParameter(value.handle, HASH_LIQUIDVOLUME, GetParticleVolume(particleProperties.mass));
                        flag2 = false;
                    }
                }
                else
                {
                    value        = default(SoundInfo);
                    value.handle = HandleVector <int> .InvalidHandle;
                }
                value.startTime    = time;
                splashSounds[cell] = value;
                if (flag2)
                {
                    EventInstance instance = SoundEvent.BeginOneShot(liquid_splash_initial, vector);
                    instance.setParameterValue("liquidDepth", SoundUtil.GetLiquidDepth(cell));
                    instance.setParameterValue("liquidVolume", GetParticleVolume(particleProperties.mass));
                    SoundEvent.EndOneShot(instance);
                }
            }
        }
    }
Ejemplo n.º 19
0
 public SolidPhase(string name, ArrayList components) : base(name, components)
 {
     particleProperties = new ParticleProperties();
 }
Ejemplo n.º 20
0
        public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties)
        {
            // Z write doesn't work with fading
            bool hasZWrite = (material.GetFloat("_ZWrite") > 0.0f);

            if (!hasZWrite)
            {
                // Soft Particles
                {
                    materialEditor.ShaderProperty(properties.softParticlesEnabled, Styles.softParticlesEnabled);
                    if (properties.softParticlesEnabled.floatValue >= 0.5f)
                    {
                        UniversalRenderPipelineAsset urpAsset = UniversalRenderPipeline.asset;
                        if (urpAsset != null && !urpAsset.supportsCameraDepthTexture)
                        {
                            GUIStyle warnStyle = new GUIStyle(GUI.skin.label);
                            warnStyle.fontStyle = FontStyle.BoldAndItalic;
                            warnStyle.wordWrap  = true;
                            EditorGUILayout.HelpBox("Soft Particles require depth texture. Please enable \"Depth Texture\" in the Universal Render Pipeline settings.", MessageType.Warning);
                        }

                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(Styles.softParticlesFadeText,
                                                         properties.softParticlesNearFadeDistance,
                                                         Styles.softParticlesNearFadeDistanceText,
                                                         properties.softParticlesFarFadeDistance,
                                                         Styles.softParticlesFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Camera Fading
                {
                    materialEditor.ShaderProperty(properties.cameraFadingEnabled, Styles.cameraFadingEnabled);
                    if (properties.cameraFadingEnabled.floatValue >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(Styles.cameraFadingDistanceText,
                                                         properties.cameraNearFadeDistance,
                                                         Styles.cameraNearFadeDistanceText,
                                                         properties.cameraFarFadeDistance,
                                                         Styles.cameraFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Distortion
                if (properties.distortionEnabled != null)
                {
                    materialEditor.ShaderProperty(properties.distortionEnabled, Styles.distortionEnabled);
                    if (properties.distortionEnabled.floatValue >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength);
                        materialEditor.ShaderProperty(properties.distortionBlend, Styles.distortionBlend);
                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.showMixedValue = false;
            }
        }
Ejemplo n.º 21
0
    public void UpdateParticles(float dt)
    {
        if (!(dt <= 0f) && simUpdateDelay < 0)
        {
            offset = (offset + dt) % 360f;
            int     num_particles = physics.Count;
            Vector2 vector        = Physics.gravity * dt * gravityScale;
            for (int i = 0; i < num_particles; i++)
            {
                ParticlePhysics value   = physics[i];
                Vector3         vector2 = value.position;
                Grid.PosToXY(vector2, out int x, out int y);
                value.velocity += vector;
                Vector3 b = value.velocity * dt;
                Vector3 v = vector2 + b;
                value.position = v;
                physics[i]     = value;
                Grid.PosToXY(value.position, out int _, out int y2);
                int num  = (y <= y2) ? y2 : y;
                int num2 = (y <= y2) ? y : y2;
                for (int num3 = num; num3 >= num2; num3--)
                {
                    int num4 = num3 * Grid.WidthInCells + x;
                    int cell = (num3 + 1) * Grid.WidthInCells + x;
                    if (!Grid.IsValidCell(num4))
                    {
                        if (Grid.IsValidCell(cell))
                        {
                            ParticleProperties particleProperties = this.particleProperties[i];
                            SpawnLiquidSplash(value.position.x, cell, particleProperties.elementIdx, false);
                            AddToSim(cell, i, ref num_particles);
                        }
                        else
                        {
                            RemoveParticle(i, ref num_particles);
                        }
                        break;
                    }
                    Element       element = Grid.Element[num4];
                    Element.State state   = element.state & Element.State.Solid;
                    bool          flag    = false;
                    if (state == Element.State.Solid || (Grid.Properties[num4] & 2) != 0)
                    {
                        AddToSim(cell, i, ref num_particles);
                    }
                    else
                    {
                        switch (state)
                        {
                        case Element.State.Gas:
                            flag = true;
                            break;

                        case Element.State.Liquid:
                        {
                            ParticleProperties particleProperties2 = this.particleProperties[i];
                            Element            element2            = ElementLoader.elements[particleProperties2.elementIdx];
                            if (element2.id == element.id)
                            {
                                if (Grid.Mass[num4] <= element.defaultValues.mass)
                                {
                                    flag = true;
                                }
                                else
                                {
                                    SpawnLiquidSplash(value.position.x, cell, particleProperties2.elementIdx, false);
                                    AddToSim(num4, i, ref num_particles);
                                }
                            }
                            else if (element2.molarMass > element.molarMass)
                            {
                                flag = true;
                            }
                            else
                            {
                                SpawnLiquidSplash(value.position.x, cell, particleProperties2.elementIdx, false);
                                AddToSim(cell, i, ref num_particles);
                            }
                            break;
                        }

                        case Element.State.Vacuum:
                            if (element.id == SimHashes.Vacuum)
                            {
                                flag = true;
                            }
                            else
                            {
                                RemoveParticle(i, ref num_particles);
                            }
                            break;
                        }
                    }
                    if (!flag)
                    {
                        break;
                    }
                }
            }
            float time = GetTime();
            UpdateSounds(time);
            UpdateMistFX(Time.time);
        }
    }