private void button1_Click(object sender, EventArgs e)
        {
            int gr = groups();

            if (gr == 0)
            {
                return;
            }
            try
            {
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    int vl = getValue(i);
                    if (vl != 0)
                    {
                        RabNetEngRabbit rr = null;
                        gr--;
                        if (gr == 0 && nudCount.Value == 0)
                        {
                            rr = r;
                        }
                        else
                        {
                            rr = Engine.get().getRabbit(r.ID);
                            rr = Engine.get().getRabbit(rr.Clone(vl));
                        }
                        rr.PlaceSuckerTo((int)listView1.Items[i].Tag);
                    }
                }
                Close();
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        /// <summary>
        /// Сохраняет операции, по пересадке кролика
        /// warning full vachanaliation and analizing troubles
        /// </summary>
        /// <param name="r">Строка кролика</param>
        /// <param name="id"></param>
        /// <param name="allowReplace">Уже перемещен</param>
        private void commitRabbit(RP rp, int id, bool allowReplace)
        {
            if (rp.Saved)
            {
                return;
            }

            if (rp.ID == 0)
            {
                //int[] a = getAddress(rp);
                Address a = _freeBuildings.SearchByMedName(rp.CurAddress);
                _rabERs[_replaceList.IndexOf(rp)].ReplaceRabbit(a.Farm, a.Floor, a.Section, rp.CurAddress);
                rp.Saved = true;
                return;
            }

            RabNetEngRabbit rb  = Engine.get().getRabbit(id == 0 ? rp.ID : id);
            RabNetEngRabbit par = null;

            if (rp.Younger)
            {
                par = Engine.get().getRabbit(rp.Parent);
            }
            if (rp.PlaceTo != null || rp.PlaceWith != null)
            {
                if (!allowReplace)
                {
                    return;
                }

                if (rp.PlaceWith != null)
                {
                    rb.CombineWidth(rp.PlaceWith.ID);
                    rp.Saved = true;
                    return;
                }
                if (rp.PlaceTo != null)
                {
                    rb.PlaceSuckerTo(rp.PlaceTo.ID);
                }
            }

            if (rp.Replaced && !allowReplace)
            {
                //int[] a = getAddress(rp);
                Address a = _freeBuildings.SearchByMedName(rp.CurAddress);
                //if (rp.Younger)
                //par.ReplaceYounger(rb.ID, a.Farm, a.Tier, a.Section, rp.CurAddress);
                //else
                rb.ReplaceRabbit(a.Farm, a.Floor, a.Section, rp.CurAddress);
            }

            if (rp.CanHaveNest)
            {
                if (!rp.Younger || (rp.Younger && rp.Replaced && rp.PlaceTo == null))
                {
                    RabNetEngRabbit   rr  = Engine.get().getRabbit(rb.ID);
                    RabNetEngBuilding rbe = Engine.get().getBuilding(rr.RawAddress);

                    string[] vals = rr.RawAddress.Split(','); ///todo ГОВНОКОД нужно переделывать движок построек
                    //BuildingType tp = Building.ParseType(vals[3]);
                    if (rbe.Type == BuildingType.Jurta || rbe.Type == BuildingType.Female)
                    {
                        rbe.setNest(rp.SetNest, 0);
                    }
                    else if (rbe.Type == BuildingType.DualFemale)
                    {
                        rbe.setNest(rp.SetNest, Int32.Parse(vals[2]));
                    }
                }
            }

            if (rp.NewSex != rp.Sex)
            {
                rb.SetSex(rp.NewSex);
            }

            /// рассаживаем отделеных
            while (rp.Clones.Count > 0)
            {
                RP      c   = rp.Clones[0];
                Address a   = _freeBuildings.SearchByMedName(c.CurAddress);
                int     cid = rb.Clone(c.Count, a.Farm, a.Floor, a.Section);
                c.ID = cid;
                commitRabbit(c, cid, allowReplace);
                if (_action == Action.ONE_GIRL_OUT && _girlout == 0 && c.Sex == Rabbit.SexType.FEMALE && c.Count == 1)
                {
                    _girlout = cid;
                }
                rp.Clones.RemoveAt(0);
            }
            rp.Saved = true;
        }