Пример #1
0
        private void farmDrawer1_ValueChanged(object sender, BuildingControl.BCEvent e)
        {
            try {
                RabNetEngBuilding b = Engine.get().getBuilding(e.tier);
                switch (e.type)
                {
                case BuildingControl.BCEvent.EVTYPE.REPAIR: b.setRepair(e.val()); break;

                case BuildingControl.BCEvent.EVTYPE.NEST: b.setNest(e.val(), 0); break;

                case BuildingControl.BCEvent.EVTYPE.NEST2: b.setNest(e.val(), 1); break;

                case BuildingControl.BCEvent.EVTYPE.HEATER: b.setHeater(e.value, 0); break;

                case BuildingControl.BCEvent.EVTYPE.HEATER2: b.setHeater(e.value, 1); break;

                case BuildingControl.BCEvent.EVTYPE.DELIM: b.SetOneDelim(e.val()); break;

                case BuildingControl.BCEvent.EVTYPE.DELIM1: b.SetDelim1(e.val()); break;

                case BuildingControl.BCEvent.EVTYPE.DELIM2: b.SetDelim2(e.val()); break;

                case BuildingControl.BCEvent.EVTYPE.DELIM3: b.SetDelim3(e.val()); break;

                case BuildingControl.BCEvent.EVTYPE.VIGUL: b.setVigul(e.value); break;
                }
            } catch (RabNetEngBuilding.ExFarmNotEmpty ex) {
                if (MessageBox.Show(this, ex.Message + ". Расселить ферму?", "Ферма не пуста", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    replaceMenuItem.PerformClick();
                }
            } catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
            }
            drawFarm(e.farm);
        }
Пример #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;
        }
Пример #3
0
        private DialogResult performJob(ZootehJob job, ref bool needUpdate)
        {
            DialogResult res = DialogResult.OK;

            switch (job.Type)
            {
            case JobType.NestOut:
                RabNetEngBuilding b = Engine.get().getBuilding(job.ID);
                b.setNest(false, (job.ID2 == 0 ? 0 : 1));
                needUpdate = false;
                break;

            case JobType.PreOkrol:
                Engine.get().preOkrol(job.ID);
                //_fullUpdate = false;
                break;

            case JobType.BoysOut:
            case JobType.GirlsOut:
                ReplaceForm rf = new ReplaceForm();
                rf.AddRabbit(job.ID);
                if (job.Type == JobType.BoysOut)
                {
                    rf.SetAction(ReplaceForm.Action.BOYSOUT);
                }
                res = rf.ShowDialog();
                break;

            case JobType.CountKids:
                RabNetEngRabbit rrr = Engine.get().getRabbit(job.ID);
                CountKids       ck  = new CountKids(job.ID);
                int             id2 = 0;
                for (int i = 0; i < rrr.Youngers.Count; i++)
                {
                    if (rrr.Youngers[i].ID == job.ID2)
                    {
                        id2 = i;
                    }
                }
                if (_makeFlag == 0)
                {
                    //rrr.CountKids(0, 0, 0, rrr.Youngers[id2].Group, rrr.Youngers[id2].Age, 0);
                    ck.MakeCount();
                    ck.Dispose();
                    needUpdate = false;
                }
                else
                {
                    //ck = new CountKids(job.ID, job.Flag == 1);
                    //ck.SetGroup(id2);
                    res = ck.ShowDialog();
                }
                break;

            case JobType.F**k:
                int id = job.ID;
                if (_makeFlag == -1)
                {
                    needUpdate = false;
                    Engine.db().SetRabbitVaccine(id, Vaccine.V_ID_LUST);
                    res = DialogResult.OK;
                    break;
                }

                if (job.Flag > 1)
                {
                    id = 0;
                    ReplaceBrideForm rb = new ReplaceBrideForm(job.ID);
                    res = rb.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        id = rb.getGirlOut();
                    }
                    res = DialogResult.Cancel;
                }
                if (id != 0)
                {
                    res = (new FuckForm(id)).ShowDialog();
                }
                break;

            case JobType.Okrol:
                res = (new OkrolForm(job.ID)).ShowDialog();
                break;

            case JobType.Vaccine:    //прививка
                RabNetEngRabbit rab = Engine.get().getRabbit(job.ID);
                AddRabVacForm   dlg = new AddRabVacForm(rab, false, job.ID2);
                res = dlg.ShowDialog();
                if (res == DialogResult.OK)
                {
                    rab.SetVaccine(dlg.VacID, dlg.VacDate, false);
                    if (rab.ParentID != 0 && Engine.opt().getBoolOption(Options.OPT_ID.VACC_MOTHER))
                    {
                        RabNetEngRabbit r2 = Engine.get().getRabbit(rab.ParentID);
                        r2.SetVaccine(dlg.VacID, dlg.VacDate, false);
                    }
                }
                needUpdate = false;
                break;

            case JobType.NestSet:    //установка гнездовья
                RabPlace rp = RabPlace.Parse(job.Rabplace);
                if (rp.CanHaveNest())
                {
                    RabNetEngBuilding rbe = RabNetEngBuilding.FromPlace(job.Rabplace, Engine.get());
                    rbe.setNest(true, rp.Section);
                    res        = DialogResult.OK;
                    needUpdate = false;
                    break;
                }
                ReplaceForm f = new ReplaceForm();
                f.AddRabbit(job.ID);
                f.SetAction(ReplaceForm.Action.SET_NEST);
                res = f.ShowDialog();
                break;

            case JobType.BoysByOne:
                f = new ReplaceForm();
                f.AddRabbit(job.ID);
                res = f.ShowDialog();
                break;

            case JobType.SpermTake:
                RabNetEngRabbit r = Engine.get().getRabbit(job.ID);
                r.SpermTake();
                needUpdate = false;
                break;
            }

            return(res);
        }