Ejemplo n.º 1
0
 internal static void OnTravellerEnterPortal(PortalTraveller traveller, Portal this_portal)
 {
     if (!this_portal.TrackedTravellers.Contains(item: traveller))
     {
         traveller.EnterPortalThreshold();
         traveller.PreviousOffsetFromPortal = traveller.transform.position - this_portal.transform.position;
         this_portal.TrackedTravellers.Add(item: traveller);
     }
 }
Ejemplo n.º 2
0
        static void UpdateSliceParams(PortalTraveller traveller, Portal portal, Camera receiver)
        {
            // Calculate slice normal
            var side               = SideOfPortal(pos: traveller.transform.position, portal: portal);
            var slice_normal       = portal.transform.forward * -side;
            var clone_slice_normal = portal.linkedPortal.transform.forward * side;

            // Calculate slice centre
            var slice_pos       = portal.transform.position;
            var clone_slice_pos = portal.linkedPortal.transform.position;

            // Adjust slice offset so that when player standing on other side of portal to the object, the slice doesn't clip through
            float slice_offset_dst       = 0;
            float clone_slice_offset_dst = 0;
            var   screen_thickness       = portal.PortalRenderer.Thickness;

            var player_same_side_as_traveller = SameSideOfPortal(pos_a: receiver.transform.position,
                                                                 pos_b: traveller.transform.position,
                                                                 portal: portal);

            if (!player_same_side_as_traveller)
            {
                slice_offset_dst = -screen_thickness;
            }

            var player_same_side_as_clone_appearing =
                side != SideOfPortal(pos: receiver.transform.position, portal: portal.linkedPortal);

            if (!player_same_side_as_clone_appearing)
            {
                clone_slice_offset_dst = -screen_thickness;
            }

            // Apply parameters
            for (var i = 0; i < traveller.OriginalMaterials.Length; i++)
            {
                traveller.OriginalMaterials[i].SetVector(nameID: Portal._Slice_Centre, value: slice_pos);
                traveller.OriginalMaterials[i].SetVector(nameID: Portal._Slice_Normal, value: slice_normal);
                traveller.OriginalMaterials[i].SetFloat(nameID: Portal._Slice_Offset_Dst, value: slice_offset_dst);

                traveller.CloneMaterials[i].SetVector(nameID: Portal._Slice_Centre, value: clone_slice_pos);
                traveller.CloneMaterials[i].SetVector(nameID: Portal._Slice_Normal, value: clone_slice_normal);
                traveller.CloneMaterials[i]
                .SetFloat(nameID: Portal._Slice_Offset_Dst, value: clone_slice_offset_dst);
            }
        }