Пример #1
0
        private bool OnPieceRayTest(On.Player.orig_PieceRayTest orig, Player self, out Vector3 point, out Vector3 normal, out Piece piece, out Heightmap heightmap, out Collider waterSurface, bool water)
        {
            bool result = orig(self, out point, out normal, out piece, out heightmap, out waterSurface, water);

            lastHoveredPiece = piece;
            if (result && placementOffset != 0)
            {
                point += new Vector3(0, placementOffset, 0);
            }
            return(result);
        }
Пример #2
0
        private bool Player_PieceRayTest(On.Player.orig_PieceRayTest orig, Player self, out Vector3 point, out Vector3 normal, out Piece piece, out Heightmap heightmap, out Collider waterSurface, bool water)
        {
            int layerMask = self.m_placeRayMask;

            if (water)
            {
                layerMask = self.m_placeWaterRayMask;
            }
            if (Physics.Raycast(GameCamera.instance.transform.position, GameCamera.instance.transform.forward, out var hitInfo, 50f, layerMask) &&
                hitInfo.collider &&
                (!hitInfo.collider.attachedRigidbody || hitInfo.collider.attachedRigidbody.GetComponent <MoveableBaseRoot>() != null) &&
                Vector3.Distance(self.m_eye.position, hitInfo.point) < self.m_maxPlaceDistance)
            {
                point     = hitInfo.point;
                normal    = hitInfo.normal;
                piece     = hitInfo.collider.GetComponentInParent <Piece>();
                heightmap = hitInfo.collider.GetComponent <Heightmap>();
                if (hitInfo.collider.gameObject.layer == LayerMask.NameToLayer("Water"))
                {
                    waterSurface = hitInfo.collider;
                }
                else
                {
                    waterSurface = null;
                }
                m_lastRayPiece = piece;
                return(true);
            }
            point          = Vector3.zero;
            normal         = Vector3.zero;
            piece          = null;
            heightmap      = null;
            waterSurface   = null;
            m_lastRayPiece = piece;
            return(false);
        }