/// <summary> /// 计算指定地区的综合工作指数 /// /// 综合工作指数 = SUM(缩放平移过的建筑工作效率 * 建筑优先级) /// 厢房效率不计入统计 /// /// 由于必须在最开始执行,所以无法使用 prepared data /// </summary> /// <param name="partId"></param> /// <param name="placeId"></param> /// <returns></returns> private static float GetCompositeWorkIndex(int partId, int placeId) { float compositeWorkIndex = 0.0f; // 统计所有建筑的工作效率(厢房效率不计入统计) var buildings = DateFile.instance.homeBuildingsDate[partId][placeId]; foreach (int buildingIndex in buildings.Keys) { if (!Original.BuildingNeedsWorker(partId, placeId, buildingIndex)) { continue; } if (Bedroom.IsBedroom(partId, placeId, buildingIndex)) { continue; } if (DateFile.instance.actorsWorkingDate.ContainsKey(partId) && DateFile.instance.actorsWorkingDate[partId].ContainsKey(placeId) && DateFile.instance.actorsWorkingDate[partId][placeId].ContainsKey(buildingIndex)) { int workerId = DateFile.instance.actorsWorkingDate[partId][placeId][buildingIndex]; int workEffectiveness = Original.GetWorkEffectiveness(partId, placeId, buildingIndex, workerId); float scaledWorkEffectiveness = (workEffectiveness - 100f) / 100f; int priority = HumanResource.GetBuildingWorkingPriority(partId, placeId, buildingIndex); compositeWorkIndex += scaledWorkEffectiveness * priority; } } return(compositeWorkIndex); }
/// <summary> /// 获取当前据点需要工作人员的建筑,以及该建筑的工作相关信息 /// </summary> /// <returns></returns> private Dictionary <int, List <BuildingWorkInfo> > GetBuildingsNeedWorker() { // requiredAttrId -> [BuildingWorkInfo, ] var attrBuildings = new Dictionary <int, List <BuildingWorkInfo> >(); var buildings = DateFile.instance.homeBuildingsDate[this.partId][this.placeId]; var validBuildings = buildings.Where(entry => !this.excludedBuildings.Contains(entry.Key)); foreach (var entry in validBuildings) { int buildingIndex = entry.Key; int[] building = entry.Value; if (!Original.BuildingNeedsWorker(this.partId, this.placeId, buildingIndex)) { continue; } int baseBuildingId = building[0]; var baseBuilding = DateFile.instance.basehomePlaceDate[baseBuildingId]; int requiredAttrId = int.Parse(baseBuilding[33]); int[] requiredAttrValues = Original.GetRequiredAttributeValues(this.partId, this.placeId, buildingIndex); BuildingWorkInfo info = new BuildingWorkInfo { buildingIndex = buildingIndex, requiredAttrId = requiredAttrId, priority = HumanResource.GetBuildingWorkingPriority(this.partId, this.placeId, buildingIndex, withAdjacentBedrooms: true), halfWorkingAttrValue = requiredAttrValues[0], fullWorkingAttrValue = requiredAttrValues[1], }; if (!attrBuildings.ContainsKey(requiredAttrId)) { attrBuildings[requiredAttrId] = new List <BuildingWorkInfo>(); } attrBuildings[requiredAttrId].Add(info); } return(attrBuildings); }
public void OnPointerUp(PointerEventData eventData) { if (!Main.enabled) { return; } if (!Original.BuildingNeedsWorker(this.partId, this.placeId, this.buildingIndex)) { return; } // 1: 右键, 2: 中键 var button = (PointerEventData.InputButton)(Main.settings.exclusionMouseButton + 1); if (eventData.button == button && (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))) { BuildingExclusion.Toggle(partId, placeId, buildingIndex); } }
/// <summary> /// 计算指定地区的工作统计信息 /// /// 综合工作指数 = SUM(缩放平移过的建筑工作效率 * 建筑优先级) /// 厢房效率不计入统计 /// /// 由于必须在最开始执行,所以无法使用 prepared data /// </summary> /// <param name="partId"></param> /// <param name="placeId"></param> /// <returns></returns> private static WorkingStats GetWorkingStats(int partId, int placeId) { var stats = new WorkingStats(); // 统计所有建筑的工作效率(厢房效率不计入统计) var buildings = DateFile.instance.homeBuildingsDate[partId][placeId]; foreach (int buildingIndex in buildings.Keys) { if (!Original.BuildingNeedsWorker(partId, placeId, buildingIndex)) { continue; } if (Bedroom.IsBedroom(partId, placeId, buildingIndex)) { continue; } if (DateFile.instance.actorsWorkingDate.ContainsKey(partId) && DateFile.instance.actorsWorkingDate[partId].ContainsKey(placeId) && DateFile.instance.actorsWorkingDate[partId][placeId].ContainsKey(buildingIndex)) { int workerId = DateFile.instance.actorsWorkingDate[partId][placeId][buildingIndex]; int workEffectiveness = Original.GetWorkEffectiveness(partId, placeId, buildingIndex, workerId); float scaledWorkEffectiveness = (workEffectiveness - 100f) / 100f; float priority = HumanResource.GetBuildingWorkingPriority(partId, placeId, buildingIndex, withAdjacentBedrooms: false); ++stats.nProductiveBuildings; stats.avgWorkEffectiveness += workEffectiveness / 200f; stats.compositeWorkIndex += scaledWorkEffectiveness * priority; } } if (stats.nProductiveBuildings > 0) { stats.avgWorkEffectiveness /= stats.nProductiveBuildings; } return(stats); }