Exemple #1
0
        public static (float, float) GetFormationSpawnWidthAndDepth(
            FormationClass formationNo,
            int troopCount,
            bool considerCavalryAsInfantry = false)
        {
            bool  isMounted           = !considerCavalryAsInfantry && formationNo.IsMounted();
            float defaultUnitDiameter = Formation.GetDefaultUnitDiameter(isMounted);
            int   unitSpacing         = 1;
            float num1 = isMounted ? Formation.CavalryInterval(unitSpacing) : Formation.InfantryInterval(unitSpacing);
            float num2 = isMounted ? Formation.CavalryDistance(unitSpacing) : Formation.InfantryDistance(unitSpacing);
            int   num3 = Math.Max(1, (int)(((double)Math.Max(0, troopCount - 1) * ((double)num1 + (double)defaultUnitDiameter) + (double)defaultUnitDiameter) / Math.Sqrt((isMounted ? 24.0 : 12.0) * (double)troopCount + 1.0)));

            return(Math.Max(0.0f, (float)troopCount / (float)num3 - 1f) * (num1 + defaultUnitDiameter) + defaultUnitDiameter, (float)(num3 - 1) * (num2 + defaultUnitDiameter) + defaultUnitDiameter);
        }