private void OnGUI() { if(_showMenu){ if(GUI.Button(new Rect(0,100,100,100), "Management")){ _showMenu = false; _selectedCitizen = null; } ShowCitizens(); if(_selectedCitizen!=null){ ShowCitizenInfo(_selectedCitizen); if(GUI.Button (new Rect(Screen.width / 2, 100, 100, 20), "Manage work")) { _showJobInfo = true; } if (_showJobInfo == true) { showJobInfo(_selectedCitizen); } } } else { if(GUI.Button(new Rect(0,100,100,100), "Management")){ _showMenu = true; } } }
void Start() { _chase = GetComponent<Chase>(); _citizen = GetComponent<Citizen>(); _player = GetComponent<Player>(); _clickToMoveTo = GetComponent<ClickToMoveTo>(); }
public void CompositeUserTypeConfig() { ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Citizen), typeof(SecondCitizen)); Recreate(); Citizen c = new Citizen(); c.Name = new string[] {"Jonh", "Doe"}; c.ManufacturerName = new string[] {"Acme", "Inc"}; c.InventorsName = new string[] {"Emmet", "Brown"}; c.SellersName = new string[] { "Big", "Tex"}; c.Create(); Citizen loaded = Citizen.Find(c.Id); Assert.IsNotNull(loaded); Assert.AreEqual("Jonh", loaded.Name[0]); Assert.AreEqual("Doe", loaded.Name[1]); Assert.AreEqual("Acme", loaded.ManufacturerName[0]); Assert.AreEqual("Emmet", loaded.InventorsName[0]); Assert.AreEqual("Brown", loaded.InventorsName[1]); Assert.AreEqual("Big", loaded.SellersName[0]); Assert.AreEqual("Tex", loaded.SellersName[1]); }
private void ShowCitizenInfo(Citizen citizen) { GUI.Box(new Rect(Screen.width/2 - 200 ,100, 200,20), "Name: " + citizen.name.ToString()); GUI.Box(new Rect(Screen.width/2 - 200, 120, 200,20), "Age: " + citizen.age.ToString()); GUI.Box(new Rect(Screen.width/2 - 200, 140,200,20), "hunger: " + citizen.hunger.ToString()); GUI.Box(new Rect(Screen.width / 2 - 200, 160, 200, 20), "Current Job: " + citizen.job.ToString()); GUI.Box(new Rect(Screen.width / 2 - 200, 180, 200, 20), "Income: " + citizen.income.ToString()); }
public static int HandleWorkers(PrivateBuildingAI thisAI, ushort buildingID, ref Building buildingData, ref Citizen.BehaviourData behaviour, ref int aliveWorkerCount, ref int totalWorkerCount, ref int workPlaceCount) { //Not messed with this code too much yet. Still requires cleaning up. int b = 0; int level0, level1, level2, level3; //Fix for crashing? Modification added for this statement if (thisAI != null) { GetWorkBehaviour(thisAI, buildingID, ref buildingData, ref behaviour, ref aliveWorkerCount, ref totalWorkerCount); thisAI.CalculateWorkplaceCount(new Randomizer((int)buildingID), buildingData.Width, buildingData.Length, out level0, out level1, out level2, out level3); workPlaceCount = level0 + level1 + level2 + level3; if ((int)buildingData.m_fireIntensity == 0) { HandleWorkPlaces(thisAI, buildingID, ref buildingData, level0, level1, level2, level3, ref behaviour, aliveWorkerCount, totalWorkerCount); if (aliveWorkerCount != 0 && workPlaceCount != 0) { int num = (behaviour.m_efficiencyAccumulation + aliveWorkerCount - 1) / aliveWorkerCount; b = 2 * num - 200 * num / ((100 * aliveWorkerCount + workPlaceCount - 1) / workPlaceCount + 100); } } Notification.Problem problems1 = Notification.RemoveProblems(buildingData.m_problems, Notification.Problem.NoWorkers | Notification.Problem.NoEducatedWorkers); int num1 = (level3 * 300 + level2 * 200 + level1 * 100) / (workPlaceCount + 1); int num2 = (behaviour.m_educated3Count * 300 + behaviour.m_educated2Count * 200 + behaviour.m_educated1Count * 100) / (aliveWorkerCount + 1); //Start of modification if (Chances.WorkHour()) { if (aliveWorkerCount < workPlaceCount >> 1) { buildingData.m_workerProblemTimer = (byte)Mathf.Min((int)byte.MaxValue, (int)buildingData.m_workerProblemTimer + 1); if ((int)buildingData.m_workerProblemTimer >= 128) problems1 = Notification.AddProblems(problems1, Notification.Problem.NoWorkers | Notification.Problem.MajorProblem); else if ((int)buildingData.m_workerProblemTimer >= 64) problems1 = Notification.AddProblems(problems1, Notification.Problem.NoWorkers); } else if (num2 < num1 - 50) { buildingData.m_workerProblemTimer = (byte)Mathf.Min((int)byte.MaxValue, (int)buildingData.m_workerProblemTimer + 1); if ((int)buildingData.m_workerProblemTimer >= 128) problems1 = Notification.AddProblems(problems1, Notification.Problem.NoEducatedWorkers | Notification.Problem.MajorProblem); else if ((int)buildingData.m_workerProblemTimer >= 64) problems1 = Notification.AddProblems(problems1, Notification.Problem.NoEducatedWorkers); } else buildingData.m_workerProblemTimer = (byte)0; } //End of modification buildingData.m_problems = problems1; } return Mathf.Max(1, b); }
public void SetCitizen(Citizen c) { if (c == _citizen) return; if (c != null && c.Equals(_citizen)) return; _citizen = c; LoadVoterData(); CheckAbilityToVote(); CitizenChanged.Invoke(); }
public void Show(Citizen c) { if (c == null) return; _view.QuestionsGrid.ItemsSource = new List<Quiz>(c.SecurityQuestions); _view.Cpr.Text = c.Cpr.Substring(1, 6) + " - " + c.Cpr.Substring(6, 4); _view.PassportNumber.Text = c.PassportNumber; _view.PlaceOfBirth.Text = c.PlaceOfBirth; _view.EliglbeToVote.Text = c.EligibleToVote ? "Yes" : "No"; _view.HasVoted.Text = c.HasVoted ? "Yes" : "No"; }
public void TestIsLastNameW() { //Arrange Citizen billy = new Citizen("Bill", "Walters", Convert.ToDateTime("01/05/1990")); Tax ErehwonTaxes = new Tax(); //Act ErehwonTaxes.IsLastNameW(billy.LastName); //Assert Assert.AreEqual(1, ErehwonTaxes.TaxDiscount); }
public RandomQuestionController(SecurityQuesitonView view, Citizen voter) { Contract.Requires(view != null); Contract.Requires(voter != null); _view = view; _questions = new Quiz[voter.SecurityQuestions.Count]; voter.SecurityQuestions.CopyTo(_questions); _usedCount = 0; RequestQuestion(null, null); QuestionRequest += RequestQuestion; _view._newQuestionBtn.Click += NewQuestionBtnEvent; }
/// <summary> /// What citizen would I get if I gave him/her this rawPersons information? /// </summary> /// <param name="person"></param> /// <param name="rawPerson"></param> /// <returns></returns> private Citizen UpdateCitizen(Citizen citizen, RawPerson rawPerson) { citizen.Name = rawPerson.Name; citizen.Cpr = rawPerson.CPR; citizen.Address = rawPerson.Address; citizen.PassportNumber = rawPerson.PassportNumber; citizen.PlaceOfBirth = rawPerson.Birthplace; citizen.EligibleToVote = Settings.Election.CitizenEligibleToVote(rawPerson); citizen.SecurityQuestions = this.GenerateSecurityQuestions(rawPerson); citizen.VotingPlace = Settings.Election.VotingVenueForCitizen(rawPerson); return citizen; }
public void TestIsFirstNameJ() { //Arrange Citizen jimmy = new Citizen("James", "McMurray", Convert.ToDateTime("01/05/1990")); Tax ErehwonTaxes = new Tax(); //Act ErehwonTaxes.IsFirstNameJ(jimmy.FirstName); //Assert Assert.AreEqual(0.16m, ErehwonTaxes.TaxRate); }
public void TestIsLessThanFive() { //Arrange Citizen billy = new Citizen("Bill", "McMurray", Convert.ToDateTime("01/05/2014")); Tax ErehwonTaxes = new Tax(); //Act ErehwonTaxes.IsLessThanFive(billy.BirthDate); //Assert Assert.AreEqual(0, ErehwonTaxes.TaxRate); }
public void TestCalculate1() { //Arrange Citizen billy = new Citizen("Bill", "McMurray", Convert.ToDateTime("01/05/1990")); Tax ErehwonTaxes = new Tax(); decimal price = 100.00m; //Act decimal total = ErehwonTaxes.Calculate(billy, price); //Assert Assert.AreEqual(108.00m, total); }
private void ShowCitizens() { List<Citizen> citizens = CitizenMaster.GetCitizens(); int i=0; foreach(Citizen citizen in citizens){ if(GUI.Button(new Rect(100,100+(i*20),100,20), citizen.name)){ _selectedCitizen = citizen; _selectedCitizenName = citizen.name; } i++; } }
public void TestIsTaxNonNegative() { //Arrange Citizen billy = new Citizen("Bill", "Walters", Convert.ToDateTime("01/05/1990")); Tax ErehwonTaxes = new Tax(); decimal price = 1.00m; //Act ErehwonTaxes.IsLastNameW(billy.LastName); ErehwonTaxes.IsTaxNonNegative(price); //Assert Assert.AreEqual(0, ErehwonTaxes.TaxDiscount); }
public static void UpdateLocation(ResidentAI resident, uint citizenID, ref Citizen data) { try { CitizenManager _citizenManager = Singleton<CitizenManager>.instance; if (data.m_homeBuilding == 0 && data.m_workBuilding == 0 && data.m_visitBuilding == 0 && data.m_instance == 0 && data.m_vehicle == 0) { _citizenManager.ReleaseCitizen(citizenID); } else { switch (data.CurrentLocation) { case Citizen.Location.Home: if (!ResidentLocationHandler.ProcessHome(ref resident, citizenID, ref data)) { return; } break; case Citizen.Location.Work: if (!ResidentLocationHandler.ProcessWork(ref resident, citizenID, ref data)) { return; } break; case Citizen.Location.Visit: if (!ResidentLocationHandler.ProcessVisit(ref resident, citizenID, ref data)) { return; } break; case Citizen.Location.Moving: if (!ResidentLocationHandler.ProcessMoving(ref resident, citizenID, ref data)) { return; } break; } data.m_flags &= ~Citizen.Flags.NeedGoods; } } catch (Exception ex) { Debug.LogWarning("Error on " + citizenID); Debug.LogException(ex); } }
private void showJobInfo(Citizen citizenJob) { if (GUI.Button(new Rect(Screen.width / 2 , 120, 200, 20), "Gold mine")) { Job.miningJob(citizenJob); } else if(GUI.Button(new Rect(Screen.width / 2 , 140, 200, 20), "Coffe farm")) { Job.CoffeFarm(citizenJob); } else if (GUI.Button(new Rect(Screen.width / 2, 160, 200, 20), "Get water")) { Job.QuitJob(citizenJob); Job.getWater(citizenJob); } }
/// <summary> /// Returns whether the citizen should go to work or not. /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether they should set off for work</returns> public static bool ShouldGoToWork(ref Citizen person) { bool shouldWork = false; SimulationManager _simulation = Singleton<SimulationManager>.instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: if (currentHour > m_minSchoolHour && currentHour < m_startSchoolHour) { uint startEarlyPercent = 40; shouldWork = _simulation.m_randomizer.UInt32(100) < startEarlyPercent; } else if (currentHour >= m_startSchoolHour && currentHour < m_maxSchoolAttemptHour) { shouldWork = true; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (currentHour > m_minWorkHour && currentHour < m_startWorkHour) { uint startEarlyPercent = 60; shouldWork = _simulation.m_randomizer.UInt32(100) < startEarlyPercent; } else if (currentHour >= m_startWorkHour && currentHour < m_maxWorkAtteptHour) { shouldWork = true; } break; } return shouldWork; }
public override void SimulationStep(uint citizenID, ref Citizen data) { if (data.Dead || !this.UpdateAge(citizenID, ref data)) { if (!data.Dead) { this.UpdateHome(citizenID, ref data); } if (!data.Sick && !data.Dead) { if (this.UpdateHealth(citizenID, ref data)) { return; } this.UpdateWellbeing(citizenID, ref data); this.UpdateWorkplace(citizenID, ref data); } this.UpdateLocation(citizenID, ref data); } }
protected void EnsureCitizenUnits(ushort buildingID, ref Building data, int homeCount, int workCount, int visitCount, int studentCount) { int totalWorkCount = (workCount + 4) / 5; int totalVisitCount = (visitCount + 4) / 5; int totalHomeCount = homeCount; int[] workersRequired = new int[] { 0, 0, 0, 0 }; if ((data.m_flags & (Building.Flags.Abandoned | Building.Flags.BurnedDown)) == Building.Flags.None) { Citizen.Wealth wealthLevel = Citizen.GetWealthLevel(this.m_info.m_class.m_level); uint num = 0u; uint num2 = data.m_citizenUnits; int num3 = 0; while (num2 != 0u) { CitizenUnit.Flags flags = citizenUnitArray[(int)((UIntPtr)num2)].m_flags; if ((ushort)(flags & CitizenUnit.Flags.Home) != 0) { citizenUnitArray[(int)((UIntPtr)num2)].SetWealthLevel(wealthLevel); homeCount--; } if ((ushort)(flags & CitizenUnit.Flags.Work) != 0) { workCount -= 5; for (int i = 0; i < 5; i++) { uint citizen = citizenUnitArray[(int)((UIntPtr)num2)].GetCitizen(i); if (citizen != 0u) { // Tick off education to see what is there workersRequired[(int)citizenArray[(int)((UIntPtr)citizen)].EducationLevel]--; } } } if ((ushort)(flags & CitizenUnit.Flags.Visit) != 0) { visitCount -= 5; } if ((ushort)(flags & CitizenUnit.Flags.Student) != 0) { studentCount -= 5; } num = num2; num2 = citizenUnitArray[(int)((UIntPtr)num2)].m_nextUnit; if (++num3 > 524288) { CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } // end while /* * homeCount = Mathf.Max(0, homeCount); * workCount = Mathf.Max(0, workCount); */ visitCount = Mathf.Max(0, visitCount); studentCount = Mathf.Max(0, studentCount); if (homeCount > 0 || workCount > 0 || visitCount > 0 || studentCount > 0) { uint num4 = 0u; if (citizenManager.CreateUnits(out num4, ref Singleton <SimulationManager> .instance.m_randomizer, buildingID, 0, homeCount, workCount, visitCount, 0, studentCount)) { if (num != 0u) { citizenUnitArray[(int)((UIntPtr)num)].m_nextUnit = num4; } else { data.m_citizenUnits = num4; } } } if (DataStore.strictCapacity) { // This is done to have the count in numbers of citizen units and only if the building is of a privateBuilding (Res, Com, Ind, Office) // There also appears to be an issue that without allowRemovalOfCitizens flag, the population will dip, then shoot up. //if (data.Info.GetAI() is PrivateBuildingAI) if (DataStore.allowRemovalOfCitizens && (data.Info.GetAI() is PrivateBuildingAI)) { // Stop incoming offers to get HandleWorkers() to start fresh TransferManager.TransferOffer offer = default(TransferManager.TransferOffer); offer.Building = buildingID; Singleton <TransferManager> .instance.RemoveIncomingOffer(TransferManager.TransferReason.Worker0, offer); Singleton <TransferManager> .instance.RemoveIncomingOffer(TransferManager.TransferReason.Worker1, offer); Singleton <TransferManager> .instance.RemoveIncomingOffer(TransferManager.TransferReason.Worker2, offer); Singleton <TransferManager> .instance.RemoveIncomingOffer(TransferManager.TransferReason.Worker3, offer); int worker0 = 0; int worker1 = 0; int worker2 = 0; int worker3 = 0; ItemClass.Level level = ((PrivateBuildingAI)data.Info.GetAI()).m_info.m_class.m_level; ((PrivateBuildingAI)data.Info.GetAI()).CalculateWorkplaceCount(level, new Randomizer((int)buildingID), data.Width, data.Length, out worker0, out worker1, out worker2, out worker3); // Update the workers required once figuring out how many are needed by the new building workersRequired[0] += worker0; workersRequired[1] += worker1; workersRequired[2] += worker2; workersRequired[3] += worker3; if (workCount < 0) { RemoveWorkerBuilding(buildingID, ref data, totalWorkCount); } else if (homeCount < 0) { RemoveHouseHold(buildingID, ref data, totalHomeCount); } /* * if (visitCount < 0) * { * RemoveVisitorsBuilding(buildingID, ref data, totalVisitCount); * } */ PromoteWorkers(buildingID, ref data, ref workersRequired); // Do nothing for students } // end if PrivateBuildingAI } // end strictCapacity } // end if good building } // end EnsureCitizenUnits
public static bool StartMoving(ResidentAI thisAI, uint citizenID, ref Citizen data, ushort sourceBuilding, ushort targetBuilding) { Debug.LogWarning("StartMoving is not overridden!"); return false; }
/// <summary> /// Has the person got to go work today? /// </summary> /// <param name="person">The citizen to check against.</param> /// <returns>Whether the person has a work day today</returns> public static bool WorkDay(ref Citizen person) { return(person.m_workBuilding != 0 && WorkDay()); }
static void Main(string[] args) { //P05 //var newcomers = new List<IIdentity>(); //string input; //while ((input = Console.ReadLine()) != "End") //{ // var inputParams = input.Split(); // IIdentity currentNewcomer; // if (inputParams.Length == 3) // { // currentNewcomer = new Citizen(inputParams[0], int.Parse(inputParams[1]), inputParams[2]); // } // else // { // currentNewcomer = new Robot(inputParams[0], inputParams[1]); // } // newcomers.Add(currentNewcomer); //} //var lastDigitsOfFakeIds = Console.ReadLine(); //var newcomersToDetain = newcomers.Where(m => m.Id.EndsWith(lastDigitsOfFakeIds)); //foreach (var member in newcomersToDetain) //{ // Console.WriteLine(member.Id); //} //P06 //var membersWithBirthdays = new List<IBirthdate>(); //string input; //while ((input = Console.ReadLine()) != "End") //{ // var inputParams = input.Split(); // IBirthdate currentMember; // if (inputParams[0] == "Pet") // { // var name = inputParams[1]; // var birthdate = DateTime.ParseExact(inputParams[2], "dd/MM/yyyy", CultureInfo.InvariantCulture); // currentMember = new Pet(name, birthdate); // membersWithBirthdays.Add(currentMember); // } // else if (inputParams[0] == "Citizen") // { // var name = inputParams[1]; // var age = int.Parse(inputParams[2]); // var id = inputParams[3]; // var birthdate = DateTime.ParseExact(inputParams[4], "dd/MM/yyyy", CultureInfo.InvariantCulture); // currentMember = new Citizen(name, age, id, birthdate); // membersWithBirthdays.Add(currentMember); // } //} //var yearFilter = int.Parse(Console.ReadLine()); //var filteredMembers = membersWithBirthdays // .Where(x => x.Birthdate.Year == yearFilter).ToList(); //foreach (var member in filteredMembers) //{ // var date = member.Birthdate.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture); // Console.WriteLine(date); //} //P07 var numberOfPeople = int.Parse(Console.ReadLine()); var buyers = new List <IBuyer>(); for (int i = 0; i < numberOfPeople; i++) { var inputParams = Console.ReadLine().Split(); IBuyer currentBuyer; if (inputParams.Length == 3) { var rebelName = inputParams[0]; var rebelAge = int.Parse(inputParams[1]); var group = inputParams[2]; currentBuyer = new Rebel(rebelName, rebelAge, group); buyers.Add(currentBuyer); } else if (inputParams.Length == 4) { var citizenName = inputParams[0]; var citizenAge = int.Parse(inputParams[1]); var id = inputParams[2]; var birdthday = DateTime.ParseExact(inputParams[3], "dd/MM/yyyy", CultureInfo.InvariantCulture); currentBuyer = new Citizen(citizenName, citizenAge, id, birdthday); buyers.Add(currentBuyer); } } string buyerName; while ((buyerName = Console.ReadLine()) != "End") { var buyer = buyers.FirstOrDefault(b => b.Name == buyerName); if (buyer != null) { buyer.BuyFood(); } } var totalFoodPurchased = buyers.Sum(b => b.Food); Console.WriteLine(totalFoodPurchased); }
public void AddToLine(ushort lineId, long income, long expense, ref Citizen citizenData, ushort citizenId) { IncrementInArray(lineId, ref m_linesDataLong, ref m_linesDataInt, (int)LineDataLong.INCOME, (int)LineDataLong.EXPENSE, (int)LineDataInt.TOTAL_PASSENGERS, (int)LineDataInt.TOURIST_PASSENGERS, (int)LineDataInt.STUDENT_PASSENGERS, income, expense, ref citizenData); if (!citizenData.Equals(default))
Citizen GenerateCitizen(CitizenClass _class) { //Housing, work and income will not be set here. Citizen newCitizen = new Citizen(); newCitizen.happiness = new Happiness(50); newCitizen.id = System.Guid.NewGuid(); //uint ageMin = 18; //uint ageMax = 40; float[] educationLevelPropability = new float[4] { 0.25f, 0.5f, 0.75f, 1.0f }; //4 elements conforming to EducationLevel order. int averageAge = 35; int ageRange = 10; long _savings = 1000; //public long savings; //{get; private set;} switch (_class) { case CitizenClass.low: educationLevelPropability = new float[4] { 0.1f, 0.25f, 0.9f, 1.0f }; //Any element following one with 1.0f probability will never happen (check the if-statements bellow) //This translates to: citizen has 10% chance of being illterate, 15% of having primary education, 75% secondary, 10 tertiar. averageAge = 32; ageRange = 14; _savings = Random.Range(800, 1200); break; case CitizenClass.middle: educationLevelPropability = new float[4] { 0.0f, 0.0f, 0.55f, 1.0f }; averageAge = 35; ageRange = 15; _savings = Random.Range(4000, 6000); break; case CitizenClass.high: educationLevelPropability = new float[4] { 0.0f, 0.0f, 0.1f, 1.0f }; averageAge = 35; ageRange = 10; _savings = Random.Range(15000, 25000); break; default: break; } float dieRoll = Random.Range(0.0f, 1.0f); if (dieRoll < educationLevelPropability[0]) { newCitizen.educationalLevel = EducationLevel.illiterate; } else if (dieRoll < educationLevelPropability[1]) { newCitizen.educationalLevel = EducationLevel.primary; } else if (dieRoll < educationLevelPropability[2]) { newCitizen.educationalLevel = EducationLevel.secondery; } else if (dieRoll < educationLevelPropability[3]) { newCitizen.educationalLevel = EducationLevel.tertiary; } dieRoll = Random.Range(0.0f, 1.0f); if (dieRoll < 0.5f) { newCitizen.gender = Gender.male; } else { newCitizen.gender = Gender.female; } newCitizen.birthDay = new System.DateTime(GameManager.simMan.date.Year - Random.Range(averageAge - ageRange, averageAge + ageRange), Random.Range(1, 12), Random.Range(1, 28)); newCitizen.savings = _savings; newCitizen.citizenClass = _class; return(newCitizen); }
static void SeedData1(RCCSContext context) { var citizen = new Citizen { FirstName = "Anker", LastName = "Larsen", CPR = 1203451679 }; var relative = new Relative { FirstName = "Lone", LastName = "Jensen", PhoneNumber = 78456598, Relation = "Datter", IsPrimary = true, Citizen = citizen }; var citizenOverview = new CitizenOverview { PurposeOfStay = "Genoptræning", CareNeed = "Stort plejebehov", NumberOfReevaluations = 3, Citizen = citizen }; var respiteCareHome = new RespiteCareHome { AvailableRespiteCareRooms = 4, RespiteCareRoomsTotal = 5, PhoneNumber = 45121225, Address = "Smørvej 14", Name = "Kærgården" }; var respiteCareRoom = new RespiteCareRoom { RoomNumber = 1, Type = "Alm. plejebolig", IsAvailable = false, RespiteCareHome = respiteCareHome, Citizen = citizen }; List <RespiteCareRoom> respiteCareRooms = new List <RespiteCareRoom>(); for (var i = 1; i <= respiteCareHome.AvailableRespiteCareRooms; i++) { respiteCareRooms.Add(new RespiteCareRoom { RoomNumber = i + 1, Type = "Demensbolig", IsAvailable = true, RespiteCareHome = respiteCareHome, Citizen = null }); } foreach (var careRoom in respiteCareRooms) { context.RespiteCareRooms.Add(careRoom); } var residentInfo = new ResidenceInformation { StartDate = new DateTime(2020, 3, 14), ReevaluationDate = new DateTime(2020, 4, 17), PlannedDischargeDate = new DateTime(2020, 4, 24), ProspectiveSituationStatusForCitizen = "Afklaret", Citizen = citizen }; var progressReport = new ProgressReport { Title = "Ingen ændring", Date = new DateTime(2020, 4, 17), Report = "Anker har etc.", ResponsibleCaretaker = "Dorte Hansen", Citizen = citizen }; //Adds citizen context.ProgressReports.Add(progressReport); context.Relatives.Add(relative); context.CitizenOverviews.Add(citizenOverview); context.ResidenceInformations.Add(residentInfo); //Adds room and home context.RespiteCareRooms.Add(respiteCareRoom); context.SaveChanges(); }
public void addResidentToBuilding(Citizen citizen) { citizensLivingInBuilding.Add(citizen); citizen.setHouse(this); }
public void TestScene(Citizen citizen) { Debug.Log(DialogueDatabase.LovelyWeather(citizen)); }
static void SeedData2(RCCSContext context) { var citizen1 = new Citizen { FirstName = "Jens", LastName = "Jensen", CPR = 3008378183 }; var relative1 = new Relative { FirstName = "Trine", LastName = "Sørensen", PhoneNumber = 85123298, Relation = "Kone", IsPrimary = true, Citizen = citizen1 }; var citizenOverview1 = new CitizenOverview { PurposeOfStay = "Genoptræning", CareNeed = "Stort plejebehov", NumberOfReevaluations = 3, Citizen = citizen1 }; var respiteCareHome1 = new RespiteCareHome { AvailableRespiteCareRooms = 14, RespiteCareRoomsTotal = 15, PhoneNumber = 45983256, Address = "Lindholmsvej 23", Name = "Lindholm" }; var respiteCareRoom1 = new RespiteCareRoom { RoomNumber = 1, Type = "Demensbolig", IsAvailable = false, CitizenCPR = citizen1.CPR, RespiteCareHome = respiteCareHome1 }; List <RespiteCareRoom> respiteCareRooms = new List <RespiteCareRoom>(); for (var i = 2; i <= respiteCareHome1.AvailableRespiteCareRooms; i++) { respiteCareRooms.Add(new RespiteCareRoom { RoomNumber = i, Type = "Alm. plejebolig", IsAvailable = true, RespiteCareHome = respiteCareHome1, Citizen = null }); } foreach (var careRoom in respiteCareRooms) { context.RespiteCareRooms.Add(careRoom); } var residentInfo1 = new ResidenceInformation { StartDate = new DateTime(2020, 5, 12), ReevaluationDate = new DateTime(2020, 5, 30), PlannedDischargeDate = new DateTime(2020, 7, 24), ProspectiveSituationStatusForCitizen = "Revurderingsbehov", Citizen = citizen1 }; var progressReport1 = new ProgressReport { Title = "I bedring", Date = new DateTime(2020, 5, 13), Report = "Jens er osv etc.", ResponsibleCaretaker = "Steen Steensen", Citizen = citizen1 }; //Adds citizen context.ProgressReports.Add(progressReport1); context.Relatives.Add(relative1); context.CitizenOverviews.Add(citizenOverview1); context.ResidenceInformations.Add(residentInfo1); //Adds room and home context.RespiteCareRooms.Add(respiteCareRoom1); context.SaveChanges(); }
/// <summary> /// 是否达到最低投票年龄 /// </summary> /// <param name="citizen"></param> /// <returns></returns> public static bool IsOverVotingAge(ref Citizen citizen) { return(IsOverVotingAge(Citizen.GetAgeGroup(citizen.m_age))); }
public void addCitizen(Citizen citizen) { citzens.Add(citizen); }
public async Task <ActionResult <Citizen> > PostCitizen(CreateCitizenViewModel ccvm) { Citizen citizen = new Citizen { FirstName = ccvm.FirstName, LastName = ccvm.LastName, CPR = ccvm.CPR }; Relative relative = new Relative { FirstName = ccvm.RelativeFirstName, LastName = ccvm.RelativeLastName, PhoneNumber = ccvm.PhoneNumber, Relation = ccvm.Relation, IsPrimary = ccvm.IsPrimary, Citizen = citizen }; ResidenceInformation residenceInformation = new ResidenceInformation { StartDate = ccvm.StartDate, ReevaluationDate = ccvm.ReevaluationDate, PlannedDischargeDate = ccvm.PlannedDischargeDate, ProspectiveSituationStatusForCitizen = ccvm.ProspectiveSituationStatusForCitizen, Citizen = citizen }; CitizenOverview citizenOverview = new CitizenOverview { CareNeed = ccvm.CareNeed, PurposeOfStay = ccvm.PurposeOfStay, NumberOfReevaluations = 0, Citizen = citizen }; var respiteCareHomeTemp = await _context.RespiteCareHomes.FirstOrDefaultAsync(rch => rch.Name == ccvm.RespiteCareHomeName); respiteCareHomeTemp.AvailableRespiteCareRooms = (respiteCareHomeTemp.AvailableRespiteCareRooms - 1); _context.Entry(respiteCareHomeTemp).State = EntityState.Modified; var rcrType = ""; switch (ccvm.Type) { case 0: rcrType = "Alm. plejebolig"; break; case 1: rcrType = "Demensbolig"; break; } var availableRespiteCareRoom = await _context.RespiteCareRooms .FirstOrDefaultAsync(rcr => (rcr.Type == rcrType) && (rcr.IsAvailable) && (rcr.RespiteCareHomeName == ccvm.RespiteCareHomeName)); availableRespiteCareRoom.CitizenCPR = ccvm.CPR; availableRespiteCareRoom.IsAvailable = false; _context.Entry(availableRespiteCareRoom).State = EntityState.Modified; await _context.Relatives.AddAsync(relative); await _context.ResidenceInformations.AddAsync(residenceInformation); await _context.CitizenOverviews.AddAsync(citizenOverview); try { await _context.SaveChangesAsync(); } catch (DbUpdateException e) { if (CitizenExists(citizen.CPR)) { return(Conflict()); } else { Console.WriteLine(e); throw; } } return(CreatedAtAction("PostCitizen", new { id = ccvm.CPR }, ccvm)); }
public bool IsPresidentOf(Citizen citizen, Country country) { return(country.PresidentID == citizen.ID); }
public void addCitizenToInsideBuilding(Citizen citizen) { citizensInBuilding.Add(citizen); }
#pragma warning disable SA1313 // Parameter names must begin with lower-case letter private static bool Prefix(ResidentAI __instance, uint citizenID, ref Citizen data) { RealTimeAI?.UpdateLocation(__instance, citizenID, ref data); return(false); }
private bool GetHuman() { _human = _instance.m_citizens.m_buffer[(int)_id]; if (_human.Dead) return false; if ((_human.m_flags & Citizen.Flags.Created) == Citizen.Flags.None) return false; if ((_human.m_flags & Citizen.Flags.DummyTraffic) != Citizen.Flags.None) return false; _info = _human.GetCitizenInfo(_id); if (_info == null) return false; if (_info.m_citizenAI.IsAnimal()) return false; return true; }
public MainWindowVM() { _model.PropertyChanged += (sender, args) => { RaisePropertyChanged(args.PropertyName); }; RefreshCitizenTable = new DelegateCommand(() => { _model.RefreshTables(); }); AddCitizen = new DelegateCommand(() => { AddCitizenWindow acw = new AddCitizenWindow(); acw.ShowDialog(); _model.RefreshTables(); }); EditCitizen = new DelegateCommand(() => { EditCitizenWindow ecw = new EditCitizenWindow(); ecw.DataContext = SelectedCitizen; Citizen ctz = SelectedCitizen; if (ecw.ShowDialog() == true) { using (var db = new CitizenDbContext()) { var citizen = (from i in db.Citizens where i.Id == ctz.Id select i).First(); citizen.Name = ctz.Name; citizen.Surname = ctz.Surname; citizen.Patronym = ctz.Patronym; db.SaveChanges(); } _model.RefreshTables(); } }); DeleteCitizen = new DelegateCommand(() => { using (var db = new CitizenDbContext()) { var citizen = (from i in db.Citizens where i.Id == SelectedCitizen.Id select i).First(); db.Citizens.Remove(citizen); db.SaveChanges(); } _model.RefreshTables(); }); AddPerson = new DelegateCommand(() => { AddPersonWindow apw = new AddPersonWindow(); apw.ShowDialog(); _model.RefreshTables(); }); EditPerson = new DelegateCommand(() => { EditPersonWindow epw = new EditPersonWindow(); Person prs = SelectedPerson; epw.DataContext = prs; if (epw.ShowDialog() == true) { using (var db = new CitizenDbContext()) { var person = (from i in db.Persons where i.Id == prs.Id select i).First(); person.Cypher = prs.Cypher; person.Inn = prs.Inn; person.Type = prs.Type; person.Date = prs.Date; person.CitizenId = prs.CitizenId; db.SaveChanges(); } _model.RefreshTables(); } }); DeletePerson = new DelegateCommand(() => { using (var db = new CitizenDbContext()) { var person = (from i in db.Persons where i.Id == SelectedPerson.Id select i).First(); db.Persons.Remove(person); db.SaveChanges(); } _model.RefreshTables(); }); AddDocument = new DelegateCommand(() => { AddDocumentWindow adw = new AddDocumentWindow(); adw.ShowDialog(); _model.RefreshTables(); }); EditDocument = new DelegateCommand(() => { EditDocumentWindow edw = new EditDocumentWindow(); Document doc = SelectedDocument; edw.DataContext = doc; if (edw.ShowDialog() == true) { using (var db = new CitizenDbContext()) { var document = (from i in db.Documents where i.Id == doc.Id select i).First(); document.Name = doc.Name; document.Serial = doc.Serial; document.WhereIssued = doc.WhereIssued; document.DateIssued = doc.DateIssued; document.CitizenId = doc.CitizenId; db.SaveChanges(); } _model.RefreshTables(); } }); DeleteDocument = new DelegateCommand(() => { using (var db = new CitizenDbContext()) { var document = (from i in db.Documents where i.Id == SelectedDocument.Id select i).First(); db.Documents.Remove(document); db.SaveChanges(); } _model.RefreshTables(); }); FindByCypher = new DelegateCommand(() => { FindByCypherWindow fbc = new FindByCypherWindow(); fbc.Show(); }); SaveToJSON = new DelegateCommand(() => { _model.SaveToJSON(Citizens, Persons, Documents); MessageBox.Show("Все сохранено"); }); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); Citizen ds = new Citizen(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "CitizenDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
public bool IsActiveDuty() { Citizen user = GetUser(); return(user?.Policeman != null && user?.Policeman.Rank != Rank.Trainee); }
public virtual int Update(Citizen dataSet) { return this.Adapter.Update(dataSet, "Citizen"); }
public ActionResult Create(Address address, string inlineDefaultRadiosExample, int?State) { string sssss = inlineDefaultRadiosExample; Session["asas"] = sssss; var stat = db.States.Find(State); string nationalId = ""; if (stat == null) { var fatherid1 = db.Citizens.Find(Convert.ToInt32(Session["FId"])); string a = fatherid1.citizen_national_id.Substring(0, 2); DateTime birthdate1 = Convert.ToDateTime(Session["BirthDate"]); nationalId = GenerateNationalId(a, birthdate1); } else { DateTime birthdate = Convert.ToDateTime(Session["BirthDate"]); nationalId = GenerateNationalId(stat.state_code, birthdate); } //-------------------------- Citizen s = new Citizen(); s.citizen_national_id = nationalId; if (Session["FId"] != null) { s.citizen_father_id = Convert.ToInt32(Session["FId"]); } if (Session["MId"] != null) { s.citizen_mother_id = Convert.ToInt32(Session["MId"]); } //---------------------------------------------------------- var fatherid = db.Citizens.Find(s.citizen_father_id); if (fatherid != null) { s.citizen_second_name = fatherid.citizen_first_name; //| s.citizen_third_name = fatherid.citizen_second_name; //| s.citizen_fourth_name = fatherid.citizen_third_name; s.citizen_second_name_arabic = fatherid.citizen_first_name_arabic; //| s.citizen_third_name_arabic = fatherid.citizen_second_name_arabic; //| s.citizen_fourth_name_arabic = fatherid.citizen_third_name_arabic; Session["second"] = fatherid.citizen_first_name; Session["third"] = fatherid.citizen_second_name; Session["fourth"] = fatherid.citizen_third_name; Session["secondArabic"] = fatherid.citizen_first_name_arabic; Session["thirdArabic"] = fatherid.citizen_second_name_arabic; Session["fourthArabic"] = fatherid.citizen_third_name_arabic; } //| //---------------------------------------------------------- s.citizen_birthDate = Convert.ToDateTime(Session["BirthDate"]); s.citizen_first_name = Session["FirstName"].ToString(); s.citizen_relegion = Session["relegion"].ToString(); s.citizen_gender = Session["gender"].ToString(); s.citizen_birthPlace = Session["BirthPlace"].ToString(); s.citizen_id = 0; db.Citizens.Add(s); Session["kjkj"] = s; // db.SaveChanges(); ViewBag.address_district_id = new SelectList(db.Districts, "district_id", "district_name", address.address_district_id); if (inlineDefaultRadiosExample == "WithF") { var data = ( from ad in db.AddressCitizens from cit in db.Citizens from addd in db.Addresses.Where(a => a.address_id == ad.CA_AddressId && s.citizen_father_id == ad.CA_CitizenId && a.address_isCurrent == true && s.citizen_father_id == cit.citizen_id ) select new { addd.address_district_id, addd.address_id, addd.address_isBirthPlace, addd.address_isCurrent, addd.address_isDelete, addd.address_street, addd.address_street_arabic } ).SingleOrDefault(); Session["fatherAddress"] = data; address.address_district_id = data.address_district_id; Session["FatherDistrictId"] = data.address_district_id; address.address_isBirthPlace = data.address_isBirthPlace; address.address_isCurrent = data.address_isCurrent; address.address_street = data.address_street; address.address_street_arabic = data.address_street_arabic; // db.Addresses.Add(address); //db.SaveChanges(); Session["AddressDistrictIdFF"] = address.address_district_id; Session["AddressIsBirthPlaceFF"] = address.address_isBirthPlace; Session["AddressIsCurrentFF"] = address.address_isCurrent; Session["AddresStreetFF"] = address.address_street; Session["AddresStreetFFArabic"] = address.address_street_arabic; } if (inlineDefaultRadiosExample == "WithM") { var data = ( from ad in db.AddressCitizens from cit in db.Citizens from addd in db.Addresses.Where(a => a.address_id == ad.CA_AddressId && s.citizen_mother_id == ad.CA_CitizenId && a.address_isCurrent == true && s.citizen_mother_id == cit.citizen_id ) select new { addd.address_district_id, addd.address_id, addd.address_isBirthPlace, addd.address_isCurrent, addd.address_isDelete, addd.address_street, addd.address_street_arabic } ).SingleOrDefault(); address.address_district_id = data.address_district_id; Session["motherdistrictid"] = data.address_district_id; address.address_isBirthPlace = data.address_isBirthPlace; address.address_isCurrent = data.address_isCurrent; address.address_street = data.address_street; address.address_street_arabic = data.address_street_arabic; //db.Addresses.Add(address); // db.SaveChanges(); Session["AddressDistrictIdMM"] = address.address_district_id; Session["AddressIsBirthPlaceMM"] = address.address_isBirthPlace; Session["AddressIsCurrentMM"] = address.address_isCurrent; Session["AddresStreetMM"] = address.address_street; Session["AddresStreetMMArabic"] = address.address_street_arabic; } if (inlineDefaultRadiosExample == "other") { address.address_isCurrent = true; Session["AddresStreetOO"] = address.address_street; Session["AddresStreetOOArabic"] = address.address_street_arabic; Session["IsCurrenOO"] = address.address_isCurrent; Session["disId"] = address.address_district_id; // db.Addresses.Add(address); // db.SaveChanges(); } AddressCitizen c = new AddressCitizen(); c.CA_AddressId = address.address_id; Session["address"] = address.address_id; c.CA_CitizenId = s.citizen_id; db.AddressCitizens.Add(c); //db.SaveChanges(); Session["CID"] = s.citizen_id; Session["Nai"] = nationalId; return(RedirectToAction("Create", "Document")); }
public static bool HasVoted(this CongressCandidateVoting voting, Citizen citizen) { return(voting.CongressCandidateVotes .Any(v => v.CitizenID == citizen.ID)); }
private void AddBuildings() { var allRooms = new Dictionary <Room, Point>(); var needRooms = CityBlockIds.Length * 3; foreach (var blockId in CityBlockIds) { var rooms = LayerHelper.GenerateRooms(World.Rnd, BaseMapBlock.Rect.Inflate(-2, -2).Offset(2, 2), new Point[0], blockId).OrderByDescending(_room => _room.RoomRectangle.Size); foreach (var room in rooms) { allRooms.Add(room, blockId); //if (allRooms.Count >= needRooms) //{ // break; //} } } var availableBuildings = Util.GetAllTypesOf <Building>().Select(_type => (Building)Activator.CreateInstance(_type, this)).ToArray(); var availableRoles = Util.GetAllTypesOf <AbstractCitizenRole>().Select(_type => (AbstractCitizenRole)Activator.CreateInstance(_type)).ToArray(); var buildings = new List <Building>(); var surface = Layer as Surface; if (surface == null) { throw new NotImplementedException(); } foreach (var abuilding in availableBuildings) { for (var i = 0; i < abuilding.MinCountInCity; i++) { var building = (Building)Activator.CreateInstance(abuilding.GetType(), this); var role = availableRoles.FirstOrDefault(_role => _role.BuildingType == building.BuildingType); if (role != null) { var citizen = new Citizen(Layer, World.Rnd, surface.GetNextCitizenName(new[] { ESex.MALE, ESex.FEMALE, }.RandomItem(World.Rnd))); var citizenRole = (AbstractCitizenRole)Activator.CreateInstance(role.GetType()); citizenRole.SetBuilding(citizen, building); citizen.AddRole(citizenRole); m_citizens.Add(citizen); } buildings.Add(building); } } while (buildings.Count < allRooms.Count) { foreach (var abuilding in availableBuildings) { var count = buildings.Count(_building => _building.GetType() == abuilding.GetType()); if (count >= abuilding.MaxCountInCity) { continue; } var building = (Building)Activator.CreateInstance(abuilding.GetType(), this); var role = availableRoles.FirstOrDefault(_role => _role.BuildingType == building.BuildingType); if (role != null) { Citizen citizen = null; if (building.BuildingType == EBuilding.HOUSE) { citizen = m_citizens.FirstOrDefault(_citizen => _citizen.Roles.OfType <AbstractCitizenRole>().All(_role => _role.BuildingType != EBuilding.HOUSE)); } if (citizen == null) { citizen = new Citizen(Layer, World.Rnd, surface.GetNextCitizenName(new[] { ESex.MALE, ESex.FEMALE, }.RandomItem(World.Rnd))); m_citizens.Add(citizen); } var citizenRole = (AbstractCitizenRole)Activator.CreateInstance(role.GetType()); citizenRole.SetBuilding(citizen, building); citizen.AddRole(citizenRole); } buildings.Add(building); } } buildings = buildings.OrderBy(_building => World.Rnd.Next()).ToList(); foreach (var building in buildings) { var pair = allRooms.First(_pair => building.IsFit(_pair.Key)); allRooms.Remove(pair.Key); building.SetRoom(pair.Key); m_buildings.Add(building); } }
public static TransferManager.TransferReason GetLeavingReason(TouristAI thisAI, uint citizenID, ref Citizen data) { Debug.LogWarning("GetLeavingReason is not overridden!"); return(0); }
public static void WriteLog(LoggingWrapper.LogArea logArea) { if (UserModSettings.Settings.Log_Citizen_Status) { lock (_logLockObject) { var activityValues = Enum.GetValues(typeof(Activity)); var output = new List <string>(); var citizenManager = CitizenManager.instance; var vehicleCount = VehicleManager.instance.m_vehicleCount; var citizenCount = CitizenManager.instance.m_instanceCount; var percentageVehicles = (vehicleCount / (double)VehicleManager.MAX_VEHICLE_COUNT) * 100d; var percentageCitizens = (citizenCount / (double)CitizenManager.MAX_CITIZEN_COUNT) * 100d; foreach (Activity activity in activityValues) { var citizensForActivity = _activitiesLog.Where(citizenLog => citizenLog.Value == activity); var agesForActivity = citizensForActivity.GroupBy(citizenLog => Citizen.GetAgeGroup(citizenManager.m_citizens.m_buffer[citizenLog.Key].Age)); var ageOutput = new List <string>(); var total = 0; foreach (var ageForActivity in agesForActivity) { ageOutput.Add($"[{ageForActivity.Count()} {ageForActivity.Key}]"); total += ageForActivity.Count(); } output.Add($"{activity.ToString()}: {string.Join(" ", ageOutput.ToArray())} (total: {total})"); } LoggingWrapper.Log(logArea, LoggingWrapper.LogType.Message, $"Current activities: \n{string.Join("\n", output.ToArray())}\nCitizen instances: {percentageCitizens}%, Vehicle instances: {percentageVehicles}%"); } } }
/// <summary> /// Returns true if citizen is actually candidating in not finished votings /// </summary> public bool IsActuallyCandidating(Citizen citizen) { return(presidentVotingRepository .NotFinishedVotings .Any(v => v.PresidentCandidates.Any(candidate => candidate.CandidateID == citizen.ID))); }
public void removeCitizenFromInsideBuilding(Citizen citizen) { citizensInBuilding.Remove(citizen); }
} // end RemoveWorkerBuilding /// <summary> /// Promote the workers to fit the education bill better. /// </summary> /// <param name="buildingID"></param> /// <param name="data"></param> /// <param name="workersRequired"></param> /// <param name="instance"></param> /// <param name="citizenUnitArray"></param> /// <param name="citizenArray"></param> private static void PromoteWorkers(ushort buildingID, ref Building data, ref int[] workersRequired) { if (workersRequired[0] == 0 && workersRequired[1] == 0 && workersRequired[2] == 0 && workersRequired[3] == 0) { // We are okay with employees, or it's residential. Return return; } //Debugging.writeDebugToFile(buildingID + ". Workers needed: " + workersRequired[0] + ", " + workersRequired[1] + ", " + workersRequired[2] + ", " + workersRequired[3]); // Crime and garbage are reset data.m_crimeBuffer = 0; data.m_garbageBuffer = 0; int loopCounter = 0; uint previousUnit = data.m_citizenUnits; uint currentUnit = data.m_citizenUnits; while (currentUnit != 0u) { // If this unit matches what we one, send the citizens away or remove citzens uint nextUnit = citizenUnitArray[currentUnit].m_nextUnit; // Only think about removing if it matches the flag if ((ushort)(CitizenUnit.Flags.Work & citizenUnitArray[currentUnit].m_flags) != 0) { // Send unit away like empty building for (int i = 0; i < 5; i++) { uint citizen = citizenUnitArray[(int)((UIntPtr)currentUnit)].GetCitizen(i); if (citizen != 0u) { // Do not shift back where possible. There should be enough staff turnover that the spaces aren't worth the intensive checking int citizenIndex = (int)((UIntPtr)citizen); ushort citizenInstanceIndex = citizenArray[citizenIndex].m_instance; CitizenInstance citData = citizenManager.m_instances.m_buffer[(int)citizenInstanceIndex]; // Get education level. Perform checks Citizen cit = citizenArray[(int)((UIntPtr)citizen)]; int education = (int)cit.EducationLevel; // -ve workersRequired means excess workers. Ignoring three schools // Checks if the citizen should be promoted or fire // Remove excess 0, 1, 2. However, give 20 - 50 % change to go up an education level. Don't touch lvl 3 educated (they'll disappear fast given the chance) if ((cit.EducationLevel != Citizen.Education.ThreeSchools) && (workersRequired[education] < 0 && workersRequired[education + 1] > 0)) { // Need to be above 50 to be promoted. However, each level is harder to get to, effectively (50, 65, 80) int number = Singleton <SimulationManager> .instance.m_randomizer.Int32(0, 100) - (education * 15); if (number > 50) { if (cit.EducationLevel == Citizen.Education.Uneducated) { cit.Education1 = true; workersRequired[0]++; workersRequired[1]--; } else if (cit.EducationLevel == Citizen.Education.OneSchool) { cit.Education2 = true; workersRequired[1]++; workersRequired[2]--; } else if (cit.EducationLevel == Citizen.Education.TwoSchools) { cit.Education3 = true; workersRequired[2]++; workersRequired[3]--; } } else { workersRequired[education]++; citizenManager.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_workBuilding = 0; RemoveFromCitizenUnit(currentUnit, i); } } else if (workersRequired[education] < 0) { workersRequired[education]++; citizenManager.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_workBuilding = 0; RemoveFromCitizenUnit(currentUnit, i); } // end if } // end citizen } // end for } // Flag match previousUnit = currentUnit; currentUnit = nextUnit; if (++loopCounter > 524288) { currentUnit = 0u; // Bail out loop } } // end while } // end PromoteWorkers
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { Citizen ds = new Citizen(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte())); ) { ; } if ((s1.Position == s1.Length)) { return type; } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return type; }
private void CreatePolice(ushort vehicleID, ref Vehicle data, Citizen.AgePhase agePhase) { SimulationManager instance = Singleton<SimulationManager>.instance; CitizenManager instance2 = Singleton<CitizenManager>.instance; CitizenInfo groupCitizenInfo = instance2.GetGroupCitizenInfo(ref instance.m_randomizer, this.m_info.m_class.m_service, Citizen.Gender.Male, Citizen.SubCulture.Generic, agePhase); if (groupCitizenInfo != null) { int family = instance.m_randomizer.Int32(256u); uint num = 0u; if (instance2.CreateCitizen(out num, 90, family, ref instance.m_randomizer, groupCitizenInfo.m_gender)) { ushort num2; if (instance2.CreateCitizenInstance(out num2, ref instance.m_randomizer, groupCitizenInfo, num)) { Vector3 randomDoorPosition = data.GetRandomDoorPosition(ref instance.m_randomizer, VehicleInfo.DoorType.Exit); groupCitizenInfo.m_citizenAI.SetCurrentVehicle(num2, ref instance2.m_instances.m_buffer[(int)num2], 0, 0u, randomDoorPosition); groupCitizenInfo.m_citizenAI.SetTarget(num2, ref instance2.m_instances.m_buffer[(int)num2], data.m_targetBuilding); instance2.m_citizens.m_buffer[(int)((UIntPtr)num)].SetVehicle(num, vehicleID, 0u); } else { instance2.ReleaseCitizen(num); } } } }
public virtual int Update(Citizen.CitizenDataTable dataTable) { return this.Adapter.Update(dataTable); }
/// <summary> /// Check whether the citizen wants to go find some entertainment or not /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether this citizen would like some entertainment</returns> public static bool ShouldGoFindEntertainment(ref Citizen person) { bool goFindEntertainment = false; SimulationManager _simulation = Singleton<SimulationManager>.instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: case Citizen.AgeGroup.Senior: if (currentHour < 15 && currentHour > 7) { uint wantEntertainmentPercent = 3; goFindEntertainment = _simulation.m_randomizer.UInt32(100) < wantEntertainmentPercent; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (currentHour < 18 && currentHour > 7) { uint wantEntertainmentPercent = 4; goFindEntertainment = _simulation.m_randomizer.UInt32(100) < wantEntertainmentPercent; } else { uint goingOutAtNightPercent = GoOutAtNight(person.Age); goFindEntertainment = _simulation.m_randomizer.UInt32(700) < goingOutAtNightPercent; } break; } return goFindEntertainment; }
/// <summary> /// Check whether the citizen is done with their day at work /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether they can leave work</returns> public static bool ShouldReturnFromWork(ref Citizen person) { bool returnFromWork = false; SimulationManager _simulation = Singleton<SimulationManager>.instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: if (currentHour >= m_endSchoolHour && currentHour < m_maxSchoolHour) { uint leaveOnTimePercent = 80; returnFromWork = _simulation.m_randomizer.UInt32(100) < leaveOnTimePercent; } else if (currentHour > m_maxSchoolHour || currentHour < m_minSchoolHour) { returnFromWork = true; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if (currentHour >= m_endWorkHour && currentHour < m_maxWorkHour) { uint leaveOnTimePercent = 50; returnFromWork = _simulation.m_randomizer.UInt32(100) < leaveOnTimePercent; } else if (currentHour > m_maxWorkHour || currentHour < m_minWorkHour) { returnFromWork = true; } break; default: returnFromWork = true; break; } return returnFromWork; }
public static bool StartMoving(TouristAI thisAI, uint citizenID, ref Citizen data, ushort sourceBuilding, ushort targetBuilding) { Debug.LogWarning("StartMoving is not overridden!"); return(false); }
/// <summary> /// Checks whether the citizen can stay out, or whether they'd prefer to come home /// </summary> /// <param name="person">The citizen to check</param> /// <returns>Whether the citizen would be able to stay out or not</returns> public static bool CanStayOut(ref Citizen person) { bool canStayOut = false; SimulationManager _simulation = Singleton<SimulationManager>.instance; Citizen.AgeGroup ageGroup = Citizen.GetAgeGroup(person.Age); float currentHour = _simulation.m_currentDayTimeHour; switch (ageGroup) { case Citizen.AgeGroup.Child: case Citizen.AgeGroup.Teen: case Citizen.AgeGroup.Senior: if (currentHour < 15 && currentHour > 7) { canStayOut = true; } break; case Citizen.AgeGroup.Young: case Citizen.AgeGroup.Adult: if ((currentHour < 18 && currentHour > 7) || GoOutAtNight(person.Age) != 0) { canStayOut = true; } break; } return canStayOut; }
public async Task <StatusResponse <bool> > CompleteRegister(CompleteRegisterDAO completeRegisterDAO) { var response = new StatusResponse <bool>(); try { using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var address = _mapper.Map <Address>(completeRegisterDAO.AddressInfo); var medical = _mapper.Map <MedicalRecord>(completeRegisterDAO.MedicalInfo); var contacts = _mapper.Map <List <EmergencyContact> >(completeRegisterDAO.ContactInfos); var validDevice = await _context.MobileDeviceRegistrationTemps .Where(x => x.DeviceId == completeRegisterDAO.DeviceId && x.IsCompleteRegister == false) .FirstOrDefaultAsync(); if (validDevice != null) { var user = await _context.appUsers.FindAsync(validDevice.AppUserId); user.Name = completeRegisterDAO.PersonalInfo.Name; user.MiddleName = completeRegisterDAO.PersonalInfo.MiddleName; user.LastName = completeRegisterDAO.PersonalInfo.LastName; //TODO: completar con datos de la tabla [AspNetUsers] de los campos de firebase para poder enviar y recibir notificaciones Citizen citizen = new Citizen { AspNetUserId = user.Id, appUser = user, CURP = completeRegisterDAO.PersonalInfo.Curp, DateOfBirth = completeRegisterDAO.PersonalInfo.DateOfBirth, Sex = completeRegisterDAO.PersonalInfo.Sex }; _context.Entry(user).State = EntityState.Modified; _context.citizens.Add(citizen); await _context.SaveChangesAsync(); var suburb = await _context.suburbs.FindAsync(address.SuburbId); if (suburb == null) { response.StatusCode = HttpStatusCode.NotFound; response.Message = "Validar envio de colonia para poder completar su registro"; response.Value = false; return(response); } address.CitizenId = citizen.CitizenId; address.citizen = citizen; medical.CitizenId = citizen.CitizenId; medical.citizen = citizen; contacts.ForEach(x => { x.CitizenId = citizen.CitizenId; x.citizen = citizen; }); await _context.addresses.AddAsync(address); await _context.medicalRecords.AddAsync(medical); await _context.emergencyContacts.AddRangeAsync(contacts); await _context.SaveChangesAsync(); } else { response.StatusCode = HttpStatusCode.NotFound; response.Message = "El dispositico donde incio el registro no es mismo, favor de verificar para continuar con el registro"; response.Value = false; return(response); } validDevice.IsCompleteRegister = true; _context.Entry(validDevice).State = EntityState.Modified; await _context.SaveChangesAsync(); scope.Complete(); response.StatusCode = HttpStatusCode.OK; response.Message = "Registro completado correctamente su cuenta sera validada en breve, agradecemos su comprensión"; response.Value = true; return(response); } } catch (Exception e) { SystemLog systemLog = new SystemLog(); systemLog.Description = e.ToMessageAndCompleteStacktrace(); systemLog.DateLog = DateTime.UtcNow.ToLocalTime(); systemLog.Controller = GetType().Name; systemLog.Action = UtilitiesAIO.GetCallerMemberName(); systemLog.Parameter = JsonConvert.SerializeObject(completeRegisterDAO); _customSystemLog.AddLog(systemLog); } return(null); }
public void addCitizenToGatheringResources(Citizen citizen) { citizensGatheringResources.Add(citizen); }
public bool IsPresidentExcludingCountries(Citizen citizen, params int[] excludedCountriesIDs) { return(countryRepository.Any (c => excludedCountriesIDs.Contains(c.ID) == false && c.PresidentID == citizen.ID)); }
protected override void ProduceGoods(ushort buildingID, ref Building buildingData, ref Building.Frame frameData, int productionRate, ref Citizen.BehaviourData behaviour, int aliveWorkerCount, int totalWorkerCount, int workPlaceCount, int aliveVisitorCount, int totalVisitorCount, int visitPlaceCount) { base.ProduceGoods (buildingID, ref buildingData, ref frameData, productionRate, ref behaviour, aliveWorkerCount, totalWorkerCount, workPlaceCount, aliveVisitorCount, totalVisitorCount, visitPlaceCount); int num = productionRate * this.m_noiseAccumulation / 100; if (num != 0) { Singleton<ImmaterialResourceManager>.instance.AddResource (ImmaterialResourceManager.Resource.NoisePollution, num, buildingData.m_position, this.m_noiseRadius); } base.HandleDead (buildingID, ref buildingData, ref behaviour, totalWorkerCount); TransferManager.TransferReason vehicleReason = this.m_transportInfo.m_vehicleReason; if (vehicleReason != TransferManager.TransferReason.None) { int num2 = (productionRate * this.m_maxVehicleCount + 99) / 100; if (this.m_transportInfo.m_transportType == TransportInfo.TransportType.Taxi) { DistrictManager instance = Singleton<DistrictManager>.instance; byte district = instance.GetDistrict (buildingData.m_position); District[] expr_B4_cp_0_cp_0 = instance.m_districts.m_buffer; byte expr_B4_cp_0_cp_1 = district; expr_B4_cp_0_cp_0 [(int)expr_B4_cp_0_cp_1].m_productionData.m_tempTaxiCapacity = expr_B4_cp_0_cp_0 [(int)expr_B4_cp_0_cp_1].m_productionData.m_tempTaxiCapacity + (uint)num2; } int num3 = 0; int num4 = 0; ushort num5 = 0; VehicleManager instance2 = Singleton<VehicleManager>.instance; ushort num6 = buildingData.m_ownVehicles; int num7 = 0; while (num6 != 0) { if ((TransferManager.TransferReason)instance2.m_vehicles.m_buffer [(int)num6].m_transferType == vehicleReason) { VehicleInfo info = instance2.m_vehicles.m_buffer [(int)num6].Info; int num8; int num9; info.m_vehicleAI.GetSize (num6, ref instance2.m_vehicles.m_buffer [(int)num6], out num8, out num9); num3++; if ((instance2.m_vehicles.m_buffer [(int)num6].m_flags & Vehicle.Flags.GoingBack) != Vehicle.Flags.None) { num4++; } else { if ((instance2.m_vehicles.m_buffer [(int)num6].m_flags & Vehicle.Flags.WaitingTarget) != Vehicle.Flags.None) { num5 = num6; } else { if (instance2.m_vehicles.m_buffer [(int)num6].m_targetBuilding != 0) { num5 = num6; } } } } num6 = instance2.m_vehicles.m_buffer [(int)num6].m_nextOwnVehicle; if (++num7 > 65536) { CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace); break; } } if (this.m_maxVehicleCount < 65536 && num3 - num4 > num2 && num5 != 0) { VehicleInfo info2 = instance2.m_vehicles.m_buffer [(int)num5].Info; info2.m_vehicleAI.SetTarget (num5, ref instance2.m_vehicles.m_buffer [(int)num5], buildingID); } if (num3 < num2) { TransferManager.TransferOffer offer = default(TransferManager.TransferOffer); offer.Priority = 0; offer.Building = buildingID; offer.Position = buildingData.m_position; offer.Amount = Mathf.Min (2, num2 - num3); offer.Active = true; Singleton<TransferManager>.instance.AddOutgoingOffer (vehicleReason, offer); } } }
public void removeCitizenFromGatheringResources(Citizen citizen) { citizensGatheringResources.Remove(citizen); }