Пример #1
0
    private void InitEnvironmentEffects()
    {
        Config = Loader.Instance?.SimConfig;

        Sun   = Instantiate(SunGO, new Vector3(0f, 50f, 0f), Quaternion.Euler(90f, 0f, 0f)).GetComponent <Light>();
        SunHD = Sun.gameObject.GetComponent <HDAdditionalLightData>();

        Moon   = Instantiate(MoonGO, new Vector3(0f, 50f, 0f), Quaternion.Euler(90f, 0f, 0f)).GetComponent <Light>();
        MoonHD = Moon.gameObject.GetComponent <HDAdditionalLightData>();

        // AD Stack needs -90 degree map rotation so celestial bodies need rotated
        var CelestialBodyHolder = new GameObject("CelestialBodyHolder");

        CelestialBodyHolder.transform.SetPositionAndRotation(Vector3.zero, Quaternion.Euler(0f, -90f, 0f));
        Sun.transform.SetParent(CelestialBodyHolder.transform);
        Moon.transform.SetParent(CelestialBodyHolder.transform);

        Reset();

        PostPrecessingVolume = Instantiate(PostProcessingVolumePrefab);
        ActiveProfile        = PostPrecessingVolume.profile;

        ActiveProfile.TryGet(out VolumetricFog);
        ActiveProfile.TryGet(out PBS);

        CloudRenderer = Instantiate(CloudPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity).GetComponentInChildren <Renderer>();

        VFXRain = Instantiate(VFXRainPrefab);
        var origin = MapOrigin.Find();
        var trans  = VFXRain.transform;
        var pos    = trans.position;

        pos.y         += origin.transform.position.y;
        trans.position = pos;
        var agents = SimulatorManager.Instance.AgentManager.ActiveAgents;

        foreach (var agent in agents)
        {
            VFXRain.RegisterTrackedEntity(agent.AgentGO.transform);
        }

        WetObjects.AddRange(GameObject.FindGameObjectsWithTag("Road"));
        WetObjects.AddRange(GameObject.FindGameObjectsWithTag("Sidewalk"));
        var renderers = new List <Renderer>();
        var materials = new List <Material>();

        foreach (var obj in WetObjects)
        {
            obj.GetComponentsInChildren(renderers);
            renderers.ForEach(r =>
            {
                r.GetMaterials(materials);
                materials.ForEach(m =>
                {
                    if (r.GetComponent <ParticleSystem>() != null || r.GetComponent <ReflectionProbe>() != null)
                    {
                        return;
                    }

                    if (m == null)
                    {
                        Debug.Log($"Object {r.gameObject.name} has null material", r.gameObject);
                        return;
                    }
                    else
                    {
                        WetMaterials.Add(m);
                    }
                });
            });
        }
        UpdateWet();

        DamageObjects.AddRange(GameObject.FindGameObjectsWithTag("Road"));
        renderers.Clear();
        materials.Clear();
        foreach (var obj in DamageObjects)
        {
            obj.GetComponentsInChildren(renderers);
            renderers.ForEach(r =>
            {
                r.GetMaterials(materials);
                materials.ForEach(m =>
                {
                    if (r.GetComponent <ParticleSystem>() != null || r.GetComponent <ReflectionProbe>() != null)
                    {
                        return;
                    }

                    if (m == null)
                    {
                        Debug.Log($"Object {r.gameObject.name} has null material", r.gameObject);
                        return;
                    }
                    else
                    {
                        DamageMaterials.Add(m);
                    }
                });
            });
        }
        UpdateDamage();

        TimeOfDayLights.AddRange(FindObjectsOfType <TimeOfDayLight>());
        TimeOfDayLights.ForEach(x => x.Init(CurrentTimeOfDayState));
        Array.ForEach(FindObjectsOfType <TimeOfDayBuilding>(), x => x.Init(CurrentTimeOfDayState));
        TimeOfDayCycle();
    }
Пример #2
0
 public void InitRainVFX(Transform transform)
 {
     VFXRain.RegisterTrackedEntity(transform); // API
 }