Пример #1
0
    protected override void OnUpdate()
    {
        var waterParts = _entityQuery.ToComponentDataArray <WaterMeshComponent>(Allocator.TempJob);
        var entities   = _entityQuery.ToEntityArray(Allocator.TempJob);

        MeshFilter[] meshes = _entityQuery.ToComponentArray <MeshFilter>();

        EntityArchetype waterPointArchetype = EntityManager.CreateArchetype(typeof(WaterPoint));

        for (var i = 0; i < waterParts.Length; i++)
        {
            _vertices = new Vector3[waterParts.Length][];

            WaterMeshComponent waterMeshComponent = waterParts[i];

            waterMeshComponent.PartId = i;

            MeshFilter meshFilter = meshes[i];

            int pointCount = Mathf.FloorToInt(waterMeshComponent.Size.x / waterMeshComponent.Step);

            meshFilter.mesh = GenerateWaterMesh(pointCount, waterMeshComponent.Step, waterMeshComponent.Size.y,
                                                waterMeshComponent.BottomColor, waterMeshComponent.TopColor);

            _vertices[i] = new Vector3[meshFilter.mesh.vertexCount];

            float height = meshFilter.mesh.vertices[1].y;

            waterMeshComponent.PointsRange = new int2(_pointIndex, _pointIndex + pointCount);

            _pointIndex += pointCount;

            for (int j = 0; j < pointCount; j++)
            {
                Entity entity = EntityManager.CreateEntity(waterPointArchetype);

                var waterPoint = new WaterPoint {
                    PartId = i, TargetHeight = height
                };

                EntityManager.SetComponentData(entity, waterPoint);
            }

            waterParts[i] = waterMeshComponent;

            PostUpdateCommands.AddComponent(entities[i], new Initialized());
        }

        _entityQuery.CopyFromComponentDataArray(waterParts);

        entities.Dispose();
        waterParts.Dispose();
    }
Пример #2
0
        public List <WaterPoint> CreateList()
        {
            List <WaterPoint> WPList = new List <WaterPoint>();

            while (dr.Read())
            {
                WaterPoint ent = new WaterPoint();
                ent = createEntityFromReader(dr);
                WPList.Add(ent);
            }
            return(WPList);
        }
Пример #3
0
        public override UniversalEntity createEntity()
        {
            UniversalEntity ue = new UniversalEntity();

            while (dr.Read())
            {
                WaterPoint ent = new WaterPoint();
                ent = createEntityFromReader(dr);
                ue.Add(ent);
            }
            return(ue);
        }
Пример #4
0
 void AddParametersToSqlCommand(WaterPoint ent, ref SqlCommand sc)
 {
     sc.Parameters.Add("@LocationID", ent.LocationID);
     sc.Parameters.Add("@Title", ent.Title);
     sc.Parameters.Add("@LF", ent.LineFirst);
     sc.Parameters.Add("@LS", ent.LineSecond);
     sc.Parameters.Add("@D", ent.D);
     sc.Parameters.Add("@DCalc", ent.DCalc);
     sc.Parameters.Add("@Qmin", ent.QMin);
     sc.Parameters.Add("@Qmax", ent.QMax);
     sc.Parameters.Add("@Comment", ent.Comment);
     sc.Parameters.Add("@TypeID", ent.Wptype);
 }
Пример #5
0
        public int Create(WaterPoint ent, string xml)
        {
            int           createdid = 0;
            WaterPointDAO entDAO    = new WaterPointDAO();

            sc             = new SqlCommand("CreateWaterPoint");
            sc.CommandType = CommandType.StoredProcedure;
            addParameters(ent);
            if (!string.IsNullOrEmpty(xml))
            {
                sc.Parameters.Add("@Devicesxml", xml);
            }
            else
            {
                sc.Parameters.Add("@Devicesxml", DBNull.Value);
            }
            createdid = entDAO.createEntity(sc);
            return(createdid);
        }
Пример #6
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            WaterPoint wp = new WaterPoint();

            wp.Title      = tbTitle.Text.Trim();
            wp.LocationID = Utilities.ConvertToInt(radddlWPLocation.SelectedValue);
            wp.LineFirst  = Utilities.ConvertToDouble(tbLF.Text.Trim());
            wp.LineSecond = Utilities.ConvertToDouble(tbLS.Text.Trim());
            wp.D          = Utilities.ConvertToInt(tbD.Text);
            wp.DCalc      = Utilities.ConvertToInt(tbDCalc.Text);
            wp.QMin       = Utilities.ConvertToInt(tbQmin.Text);
            wp.QMax       = Utilities.ConvertToInt(tbQmax.Text);
            wp.Wptype     = Utilities.ConvertToInt(radddlTypeDevice.SelectedValue);
            wp.Comment    = tbComment.Text.Trim();

            WaterPointDO  wpDO = new WaterPointDO();
            int           rez  = 0;
            StringBuilder xml  = new StringBuilder();
            List <int>    dev  = new List <int>();

            if (Session["Devices"] != null)
            {
                xml.Append("<devices>");
                dev = Session["Devices"] as List <int>;
                foreach (int i in dev)
                {
                    xml.Append("<id>" + i.ToString() + "</id>");
                }
                xml.Append("</devices>");
            }

            rez = wpDO.Create(wp, xml.ToString());
            if (rez > 0)
            {
                nlWP.SetCleanNotification("Водовод успешно добавлен.");
            }
            else
            {
                nlWP.SetDirtyNotification("Произошла ошибка при добавлении водовода.");
            }
        }
Пример #7
0
 void addParameters(WaterPoint ent)
 {
     AddParametersToSqlCommand(ent, ref sc);
 }
Пример #8
0
        public WaterPoint createEntityFromReader(SqlDataReader dr)
        {
            WaterPoint ent = new WaterPoint();

            if (!dr.IsDBNull(dr.GetOrdinal("ID")))
            {
                ent.ID = Convert.ToInt32(dr["ID"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("WPLocationID")))
            {
                ent.LocationID = Convert.ToInt32(dr["WPLocationID"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("Title")))
            {
                ent.Title = dr["Title"].ToString();
            }

            if (!dr.IsDBNull(dr.GetOrdinal("LineFirst")))
            {
                ent.LineFirst = Convert.ToDouble(dr["LineFirst"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("LineSecond")))
            {
                ent.LineSecond = Convert.ToDouble(dr["LineSecond"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("D")))
            {
                ent.D = Convert.ToInt32(dr["D"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("DCalc")))
            {
                ent.DCalc = Convert.ToInt32(dr["DCalc"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("QMin")))
            {
                ent.QMin = Convert.ToInt32(dr["QMin"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("QMax")))
            {
                ent.QMax = Convert.ToInt32(dr["QMax"]);
            }

            if (!dr.IsDBNull(dr.GetOrdinal("Comment")))
            {
                ent.Comment = dr["Comment"].ToString();
            }

            if (!dr.IsDBNull(dr.GetOrdinal("WPType")))
            {
                ent.Wptype = Utilities.ConvertToInt(dr["WPType"].ToString());
            }

            return(ent);
        }