예제 #1
0
        public static GenCelestial.LightInfo GetLightSourceInfo(Map map, GenCelestial.LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

            if (type == GenCelestial.LightType.Shadow)
            {
                flag      = GenCelestial.IsDaytime(GenCelestial.CurCelestialSunGlow(map));
                intensity = GenCelestial.CurShadowStrength(map);
            }
            else if (type == GenCelestial.LightType.LightingSun)
            {
                flag      = true;
                intensity = Mathf.Clamp01((GenCelestial.CurCelestialSunGlow(map) - 0.6f + 0.2f) / 0.15f);
            }
            else if (type == GenCelestial.LightType.LightingMoon)
            {
                flag      = false;
                intensity = Mathf.Clamp01(-(GenCelestial.CurCelestialSunGlow(map) - 0.6f - 0.2f) / 0.15f);
            }
            else
            {
                Log.ErrorOnce("Invalid light type requested", 64275614, false);
                flag      = true;
                intensity = 0f;
            }
            float t;
            float num2;
            float num3;

            if (flag)
            {
                t    = num;
                num2 = -1.5f;
                num3 = 15f;
            }
            else
            {
                if (num > 0.5f)
                {
                    t = Mathf.InverseLerp(0.5f, 1f, num) * 0.5f;
                }
                else
                {
                    t = 0.5f + Mathf.InverseLerp(0f, 0.5f, num) * 0.5f;
                }
                num2 = -0.9f;
                num3 = 15f;
            }
            float num4 = Mathf.LerpUnclamped(-num3, num3, t);
            float y    = num2 - 2.5f * (num4 * num4 / 100f);

            return(new GenCelestial.LightInfo
            {
                vector = new Vector2(num4, y),
                intensity = intensity
            });
        }
예제 #2
0
        public static LightInfo GetLightSourceInfo(Map map, LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

            switch (type)
            {
            case LightType.Shadow:
                flag      = GenCelestial.IsDaytime(GenCelestial.CurCelestialSunGlow(map));
                intensity = GenCelestial.CurShadowStrength(map);
                break;

            case LightType.LightingSun:
                flag      = true;
                intensity = Mathf.Clamp01((float)((GenCelestial.CurCelestialSunGlow(map) - 0.60000002384185791 + 0.20000000298023224) / 0.15000000596046448));
                break;

            case LightType.LightingMoon:
                flag      = false;
                intensity = Mathf.Clamp01((float)((0.0 - (GenCelestial.CurCelestialSunGlow(map) - 0.60000002384185791 - 0.20000000298023224)) / 0.15000000596046448));
                break;

            default:
                Log.ErrorOnce("Invalid light type requested", 64275614);
                flag      = true;
                intensity = 0f;
                break;
            }
            float t;
            float num2;
            float num3;

            if (flag)
            {
                t    = num;
                num2 = -1.5f;
                num3 = 15f;
            }
            else
            {
                t    = (float)((!(num > 0.5)) ? (0.5 + Mathf.InverseLerp(0f, 0.5f, num) * 0.5) : (Mathf.InverseLerp(0.5f, 1f, num) * 0.5));
                num2 = -0.9f;
                num3 = 15f;
            }
            float     num4   = Mathf.LerpUnclamped((float)(0.0 - num3), num3, t);
            float     y      = (float)(num2 - 2.5 * (num4 * num4 / 100.0));
            LightInfo result = default(LightInfo);

            result.vector    = new Vector2(num4, y);
            result.intensity = intensity;
            return(result);
        }