private static void PromoteSoftware(SoftwareWorkItem item) { AutoDevWorkItem autoDev = GetAutoDevWorkItem(item); AutoDevWorkItem.AutoDevItem autoDevItem = null; if (autoDev != null) { autoDevItem = autoDev.Items.FirstOrDefault(adi => adi.Alpha == item); } if (autoDev == null || autoDevItem == null) { Console.LogError("Could not find auto dev task for current work item"); return; } if (item is SoftwareAlpha) { SoftwareAlpha alpha = item as SoftwareAlpha; if (alpha.InBeta) { autoDevItem.AlreadyDev = autoDevItem.MonthsToSpend; } if (!alpha.InDelay) { item.PromoteAction(); Console.Log("Manually moving out of alpha"); //if (!alpha.InDelay) { Console.Log("PrintingCopies target = " + autoDev.PrintingCopies); if (autoDev.PrintingCopies > 0U && !autoDevItem.hasPrinted) { uint num = autoDev.PrintingCopies; if (autoDev.PrintingCopyRel) { num = (uint)(item.Followers * (autoDev.PrintingCopies / 100.0)); } Console.Log("PrintingCopies num = " + num); autoDevItem.hasPrinted = true; PrintJob printJob = new PrintJob(alpha.ForceID(), 1f) { Limit = num }; GameSettings.Instance.PrintOrders[printJob.ID] = printJob; HUD.Instance.distributionWindow.RefreshOrders(); } } } } }
private void Update() { long hash = 0; if (!shown) { return; } hash += GameSettings.Instance.MyCompany.WorkItems.Where(wi => wi.AutoDev) .Sum(item => (long)((float)item.GetHashCode() * 0.0001f)); if (hash == _lastHash) { return; } Console.Log(string.Format("Refreshing list {0}/{1}", hash, _lastHash)); _lastHash = hash; AssignDevItems(); AssignSupportItems(); AssignMarketingItems(); }
public bool TransferBestAvailableStaff(Team team, Team[] sourceTeams, out string error) { IEnumerable <SoftwareWorkItem> software = team.WorkItems.Where(wi => wi is SoftwareWorkItem).Cast <SoftwareWorkItem>(); if (!software.Any()) { error = "Team has no projects"; return(false); } // Setup HR so that the correct number of employees are hired, should anyone leave if (AdjustDepartment != 0) { int MaxArt = 0; int MaxCode = 0; int MaxDesign = 0; foreach (SoftwareWorkItem workItem in software) { Console.Log("Category 2: " + workItem.SWCategory); SoftwareProduct softwareProduct = workItem.SequelTo; SoftwareProduct sequelTo = softwareProduct == null || !softwareProduct.Traded ? softwareProduct : (SoftwareProduct)null; float devTime = workItem.Type.DevTime(workItem.GetFeatures(), workItem.SWCategory, null, null, null, null, false, sequelTo); if (workItem.Type.OSSpecific) { devTime += Mathf.Max(workItem.OSs.Length - 1, 0); } int[] employeeRatio = SoftwareType.GetOptimalEmployeeCount(devTime); if ((AdjustDepartment & AdjustHRFlags.Art) != 0) { MaxArt = Mathf.Max(MaxArt, Mathf.CeilToInt(employeeRatio[1] * (1f - workItem.CodeArtRatio))); } if ((AdjustDepartment & AdjustHRFlags.Code) != 0) { MaxCode = Mathf.Max(MaxCode, Mathf.CeilToInt(employeeRatio[1] * workItem.CodeArtRatio)); } if ((AdjustDepartment & AdjustHRFlags.Design) != 0) { MaxDesign = Mathf.Max(MaxDesign, employeeRatio[0]); } } if (AdjustHR) { if ((AdjustDepartment & AdjustHRFlags.Art) != 0) { team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)] = MaxArt; } if ((AdjustDepartment & AdjustHRFlags.Code) != 0) { team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)] = MaxCode; } if ((AdjustDepartment & AdjustHRFlags.Design) != 0) { team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)] = MaxDesign; } } Console.Log(string.Format("Total staff required: C: {0} D: {1} A: {2}", team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)], team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)], team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)])); } // Switch team members around so that the team has the correct number of staff with the correct skills Dictionary <string, float> specializationMonths = null; foreach (SoftwareWorkItem workItem in software) { SoftwareProduct softwareProduct = workItem.SequelTo; SoftwareProduct sequelTo = softwareProduct == null || !softwareProduct.Traded ? softwareProduct : (SoftwareProduct)null; var months = workItem.Type.GetSpecializationMonths(workItem.GetFeatures(), workItem.SWCategory, workItem.OSs, sequelTo); if (specializationMonths == null) { specializationMonths = months; } else { // Merge dictionaries foreach (KeyValuePair <string, float> valuePair in months) { if (specializationMonths.ContainsKey(valuePair.Key)) { specializationMonths[valuePair.Key] = Mathf.Max(specializationMonths[valuePair.Key], valuePair.Value); } else { specializationMonths.Add(valuePair.Key, valuePair.Value); } } } } float totalMonths = specializationMonths.Sum(s => s.Value); List <Actor> chosenEmployees = new List <Actor>(); IEnumerable <Actor> actors = GameSettings.Instance.sActorManager.Actors.Where(a => (!IdleOnly || a.IsIdle) && (sourceTeams.Any(t => t == a.GetTeam()) || a.GetTeam() == team || a.GetTeam() == null)); Console.Log("Available employees : " + actors.Count()); foreach (KeyValuePair <string, float> specialization in specializationMonths) { int numCodersRequired = Mathf.CeilToInt((specialization.Value / totalMonths) * team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)]); int numDesignersRequired = Mathf.CeilToInt((specialization.Value / totalMonths) * team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)]); int numArtistsRequired = Mathf.CeilToInt((specialization.Value / totalMonths) * team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)]); Console.Log( string.Format("Num {0} staff required: C: {1} D: {2} A: {3}", specialization.Key, numCodersRequired, numDesignersRequired, numArtistsRequired)); // Coders if ((AdjustDepartment & AdjustHRFlags.Code) != 0) { chosenEmployees.AddRange(actors .OrderByDescending(a => a.employee != null ? a.employee .GetSpecialization(Employee.EmployeeRole.Programmer, specialization.Key, a) : (float?)null) .Take(numCodersRequired)); } // Designers if ((AdjustDepartment & AdjustHRFlags.Design) != 0) { chosenEmployees.AddRange(actors .OrderByDescending(a => a.employee != null ? a.employee .GetSpecialization(Employee.EmployeeRole.Designer, specialization.Key, a) : (float?)null) .Take(numDesignersRequired)); } // Artists if ((AdjustDepartment & AdjustHRFlags.Art) != 0) { chosenEmployees.AddRange(actors .OrderByDescending(a => a.employee != null ? a.employee .GetSpecialization(Employee.EmployeeRole.Artist, specialization.Key, a) : (float?)null) .Take(numArtistsRequired)); } } chosenEmployees = chosenEmployees.Distinct().ToList(); // Remove old team members foreach (Actor actor in GameSettings.Instance.sActorManager.Actors.Where(a => a.GetTeam() == team)) { // Don't kick out the lead if (actor.employee.IsRole(Employee.RoleBit.Lead)) { continue; } if ((AdjustDepartment & AdjustHRFlags.Art) == 0 && actor.employee.IsRole(Employee.RoleBit.Artist)) { continue; } if ((AdjustDepartment & AdjustHRFlags.Code) == 0 && actor.employee.IsRole(Employee.RoleBit.Programmer)) { continue; } if ((AdjustDepartment & AdjustHRFlags.Design) == 0 && actor.employee.IsRole(Employee.RoleBit.Designer)) { continue; } actor.Team = null; } // Make sure team has enough staff var unattachedStaff = GameSettings .Instance.sActorManager.Actors.Where(a => a.GetTeam() == null); if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Programmer)) < team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Programmer)]) { chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a => a.employee != null ? a.employee.GetSkill(Employee .EmployeeRole .Programmer) : (float?)null) .Take(team.HR.MaxEmployees [EmployeeIndex(Employee.EmployeeRole.Programmer)])); } if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Designer)) < team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Designer)]) { chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a => a.employee != null ? a.employee.GetSkill(Employee .EmployeeRole .Designer) : (float?)null) .Take(team.HR.MaxEmployees [EmployeeIndex(Employee.EmployeeRole.Designer)])); } if (chosenEmployees.Count(a => a.employee.IsRole(Employee.EmployeeRole.Artist)) < team.HR.MaxEmployees[EmployeeIndex(Employee.EmployeeRole.Artist)]) { chosenEmployees.AddRange(unattachedStaff.OrderByDescending(a => a.employee != null ? a.employee.GetSkill(Employee .EmployeeRole .Artist) : (float?)null) .Take(team.HR.MaxEmployees [EmployeeIndex(Employee.EmployeeRole.Artist)])); } chosenEmployees = chosenEmployees.Distinct().ToList(); // Find how many staff we have stolen from each team IEnumerable <Actor> newActors = chosenEmployees.Where(e => e.GetTeam() != team && e.GetTeam() != null); Console.Log("newActors = " + newActors.Count()); try { List <GroupCounts> teamCounts = newActors.GroupBy(e => e.Team) .Select(group => new GroupCounts() { Key = group.Key, Count = group.Count() }).ToList(); Console.Log("teamCounts = " + teamCounts.Count); // Add new team members foreach (Actor employee in chosenEmployees) { employee.Team = team.Name; } // Which staff are still unattached foreach (var teamCount in teamCounts) { unattachedStaff = unattachedStaff.Where(e => e.GetTeam() == null); Console.Log(string.Format("After reassignment, {0} staff are unassigned.", unattachedStaff.Count())); Console.Log(string.Format("Team {0} missing {1} staff.", teamCount.Key, teamCount.Count)); IEnumerable <Actor> takenStaff = unattachedStaff.Take(Mathf.Min(unattachedStaff.Count(), teamCount.Count)); foreach (Actor employee in takenStaff) { employee.Team = teamCount.Key; } } } catch (Exception e) { Debug.LogException(e); throw; } unattachedStaff = unattachedStaff.Where(e => e.GetTeam() == null); Console.Log(string.Format("After final reassignment, {0} staff are unassigned.", unattachedStaff.Count())); if (unattachedStaff.Any()) { HUD.Instance.AddPopupMessage( unattachedStaff.Count() + " staff are without a team following reassignemnt", "Cogs", PopupManager.PopUpAction.None, 0, PopupManager.NotificationSound.Issue, 0f, PopupManager.PopupIDs.None, 0); } error = null; return(true); }