static bool Prefix(LargeWorldStreamer __instance, Bounds bb, Quaternion rot, bool isAdd = false, byte type = 1)
        {
            Bounds aaBB = bb;

            Vector3 min = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 max = new Vector3(float.MinValue, float.MinValue, float.MinValue);

            OrientedBounds.MinMaxBounds(OrientedBounds.TransformMatrix(bb.center, rot), Vector3.zero, bb.extents, ref min, ref max);

            aaBB.SetMinMax(min, max);

            Quaternion invRot = Quaternion.Inverse(rot);
            Vector3    c      = bb.center;

            __instance.PerformVoxelEdit(aaBB, (Vector3 wsPos) => VoxelandMisc.SignedDistToBox(bb, c + invRot * (wsPos - c)), isAdd, type);

            return(false);
        }
Exemplo n.º 2
0
        // Token: 0x06002B9F RID: 11167 RVA: 0x001044D0 File Offset: 0x001026D0
        private static void InitBounds(GameObject gameObject)
        {
            Transform transform = gameObject.transform;

            MultiplayerBuilder.CacheBounds(transform, gameObject, MultiplayerBuilder.bounds, false);
            MultiplayerBuilder._aaBounds.center  = Vector3.zero;
            MultiplayerBuilder._aaBounds.extents = Vector3.zero;
            int count = MultiplayerBuilder.bounds.Count;

            if (count > 0)
            {
                Vector3 vector = new Vector3(3.40282347E+38f, 3.40282347E+38f, 3.40282347E+38f);
                Vector3 a      = new Vector3(-3.40282347E+38f, -3.40282347E+38f, -3.40282347E+38f);
                for (int i = 0; i < count; i++)
                {
                    OrientedBounds orientedBounds      = MultiplayerBuilder.bounds[i];
                    Matrix4x4      boundsToLocalMatrix = OrientedBounds.TransformMatrix(orientedBounds.position, orientedBounds.rotation);
                    OrientedBounds.MinMaxBounds(boundsToLocalMatrix, Vector3.zero, orientedBounds.extents, ref vector, ref a);
                }
                MultiplayerBuilder._aaBounds.extents = (a - vector) * 0.5f;
                MultiplayerBuilder._aaBounds.center  = vector + MultiplayerBuilder.aaBounds.extents;
            }
        }