コード例 #1
0
        private void _switchWorkPlaces(PlayerBuildingAI ai, int minimumSize, ref int wp0, ref int wp1, ref int wp2, ref int wp3)
        {
            int oldTotal           = wp0 + wp1 + wp2 + wp3;
            RI_EmployeeRatio ratio = RI_Data.GetEmployeeRatio(ai);

            if (oldTotal >= minimumSize)
            {
                decimal factor = RI_Data.GetFactorBuilding(ai).Workers;
                //Mod.DebugLine($"{ai.name} - AI: {ai.GetType().ToString()}, factor: {factor}x");
                //Mod.DebugLine($"    _switchWorkplaces: old={oldTotal}; wp0={wp0}, wp1={wp1}, wp2={wp2}, wp3={wp3}");
                wp0 = Convert.ToInt32(Math.Round(wp0 / factor));
                wp1 = Convert.ToInt32(Math.Round(wp1 / factor));
                wp2 = Convert.ToInt32(Math.Round(wp2 / factor));
                wp3 = Convert.ToInt32(Math.Round(wp3 / factor));
                //Mod.DebugLine($"    _switchWorkplaces: new={wp0 + wp1 + wp2 + wp3}; wp0={wp0}, wp1={wp1}, wp2={wp2}, wp3={wp3}");
                //Mod.DebugLine($"");
            }
        }
コード例 #2
0
        private void SwitchWorkPlaces(IndustryBuildingAI ai, int minimumSize = 10)
        {
            if (ai is ExtractingFacilityAI && Mod.IsField(ai)) // It's an extracting field
            {
                RI_EmployeeRatio ratio = RI_Data.GetEmployeeRatio(ai);
                int workPlaceTotal     = (int)Math.Ceiling(Math.Sqrt(ai.m_info.m_cellLength * ai.m_info.m_cellWidth) / 2);

                //int oldTotal = ai.m_workPlaceCount0 + ai.m_workPlaceCount1 + ai.m_workPlaceCount2 + ai.m_workPlaceCount3;

                ai.m_workPlaceCount0 = Convert.ToInt32(Math.Round(workPlaceTotal * ratio.GetModifier(0)));
                ai.m_workPlaceCount1 = Convert.ToInt32(Math.Round(workPlaceTotal * ratio.GetModifier(1)));
                ai.m_workPlaceCount2 = Convert.ToInt32(Math.Round(workPlaceTotal * ratio.GetModifier(2)));
                ai.m_workPlaceCount3 = Convert.ToInt32(Math.Round(workPlaceTotal * ratio.GetModifier(3)));
                //Mod.DebugLine($"_switchWorkplaces: maths={ratio.GetModifier(0)}x{workPlaceTotal}={workPlaceTotal * ratio.GetModifier(0)}, wpc0={ai.m_workPlaceCount0}");
                //Mod.DebugLine($"FARM FIELD:{ai.m_workPlaceCount0 + ai.m_workPlaceCount1 + ai.m_workPlaceCount2 + ai.m_workPlaceCount3} (was {oldTotal}, should be {workPlaceTotal})");
            }
            else
            {
                //Mod.DebugLine($"SWP: subservice={ai.m_info.m_class.m_subService}");
                _switchWorkPlaces(ai, minimumSize, ref ai.m_workPlaceCount0, ref ai.m_workPlaceCount1, ref ai.m_workPlaceCount2, ref ai.m_workPlaceCount3);
            }
        }