Ejemplo n.º 1
0
        private void sex_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!_manual)
            {
                return;
            }

            if (MessageBox.Show(this, "Сменить пол?", "Смена пола", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                Rabbit.SexType sx = Rabbit.SexType.VOID;
                if (sex.SelectedIndex == 1)
                {
                    sx = Rabbit.SexType.MALE;
                }
                if (sex.SelectedIndex == 2)
                {
                    sx = Rabbit.SexType.FEMALE;
                }
                _rab.SetSex(sx);
                updateData();
            }
            else
            {
                if (_rab.Sex == Rabbit.SexType.VOID)   //todo switch
                {
                    setSex(0);
                }
                else if (_rab.Sex == Rabbit.SexType.MALE)
                {
                    setSex(1);
                }
                else if (_rab.Sex == Rabbit.SexType.FEMALE)
                {
                    setSex(2);
                }
            }
        }
Ejemplo n.º 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;
        }