Exemplo n.º 1
0
        public static void SetupPortals()
        {
            if (setupPortals)
            {
                return;
            }
            setupPortals = true;

            Transform fogSphere = Camera.main.transform.FindChild("FOG SPHERE");

            if (fogSphere)
            {
                fogSphere.name       = "FOG SPHERE 1";
                fogSphere.localScale = Vector3.one * 1090f;
            }
            fogSphere = GameObject.Find("FOG SPHERE")?.transform;
            if (fogSphere)
            {
                fogSphere.name       = "FOG SPHERE 2";
                fogSphere.localScale = Vector3.one * 1090f;
            }

            Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 1);
            Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 3);
            Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 30);
            Camera.main.cullingMask = VidyaMod.RemoveFromLayerMask(Camera.main.cullingMask, 31);

            Camera.main.gameObject.AddComponent <MainCamTracker>();

            CreatePortal("Portal A", ref PortalA);
            CreatePortal("Portal B", ref PortalB);

            int portalAlayer             = 6;
            int portalBlayer             = 7;
            int portalAinsidePortalLayer = 1;
            int portalBinsidePortalLayer = 3;

            PortalA.Setup(0, portalAlayer, portalBlayer, portalAinsidePortalLayer, portalBinsidePortalLayer, 30, PortalB, 0f, 1f, 1f);
            PortalB.Setup(1, portalBlayer, portalAlayer, portalBinsidePortalLayer, portalAinsidePortalLayer, 31, PortalA, 0.5f, 1f, 0.7f);
            ResetPortal();
        }
        public void Setup(Camera source, Portal portal, Portal otherPortal, int[] remove, int[] add, PortalCameraControl par = null, float nearclipoffset = 0f, bool ignoreFog = false)
        {
            if (par)
            {
                hasParent    = true;
                parentCamera = par;
            }
            setUp               = true;
            this.source         = source;
            this.portal         = portal;
            this.otherPortal    = otherPortal;
            this.nearClipOffset = nearclipoffset;

            if (portalDummy == null)
            {
                portalDummy        = new GameObject(portal.name + " Dummy").transform;
                portalDummy.parent = portal.transform;
            }
            if (otherDummy == null)
            {
                otherDummy        = new GameObject(otherPortal.name + " Dummy").transform;
                otherDummy.parent = otherPortal.transform;
            }

            camera = gameObject.AddComponent <Camera>();
            camera.CopyFrom(Camera.main);
            int i;

            for (i = 0; i < remove.Length; i++)
            {
                camera.cullingMask = VidyaMod.RemoveFromLayerMask(camera.cullingMask, remove[i]);
                //camera.cullingMask = camera.cullingMask & ~(1 << remove[i]);//remove layer
            }
            for (i = 0; i < add.Length; i++)
            {
                camera.cullingMask = VidyaMod.AddToLayerMask(camera.cullingMask, add[i]);
                //camera.cullingMask = camera.cullingMask | (1 << add[i]);//add
            }
            camera.depth = -2;

            sourceBloom = Camera.main.GetComponent <BloomAndLensFlares>();
            sourceSsao  = Camera.main.GetComponent <SSAOPro>();
            sourceAa    = Camera.main.GetComponent <AntialiasingAsPostEffect>();
            sourceFog   = Camera.main.GetComponent <ColorfulFog>();

            bloom = ModUtility.CopyComponent <BloomAndLensFlares>(sourceBloom, gameObject);
            ssao  = ModUtility.CopyComponent <SSAOPro>(sourceSsao, gameObject);
            aa    = ModUtility.CopyComponent <AntialiasingAsPostEffect>(sourceAa, gameObject);
            fog   = ModUtility.CopyComponent <ColorfulFog>(sourceFog, gameObject);

            bloom.enabled = false;
            ssao.enabled  = sourceSsao.enabled;
            aa.enabled    = sourceAa.enabled;
            fog.enabled   = sourceFog.enabled;

            layer   = add[0];
            ignored = ignoreFog;
            ProcessFog();

            UpdateFOV();
            ReferenceMaster.onFOVChanged += UpdateFOV;
        }