Esempio n. 1
0
        // Token: 0x06002BB1 RID: 11185 RVA: 0x00104CFC File Offset: 0x00102EFC
        private static bool CheckDistance(Vector3 worldPosition, float minDistance)
        {
            Transform aimTransform = MultiplayerBuilder.GetAimTransform();
            float     magnitude    = (worldPosition - aimTransform.position).magnitude;

            return(magnitude >= minDistance);
        }
Esempio n. 2
0
        // Token: 0x06002B9C RID: 11164 RVA: 0x001040F8 File Offset: 0x001022F8
        private static bool UpdateAllowed()
        {
            //MultiplayerBuilder.SetDefaultPlaceTransform(ref MultiplayerBuilder.placePosition, ref MultiplayerBuilder.placeRotation);
            bool flag = false;
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();
            bool flag2;

            if (componentInParent != null)
            {
                Transform transform = componentInParent.transform;
                transform.position = MultiplayerBuilder.placePosition;
                transform.rotation = MultiplayerBuilder.placeRotation;
                flag2 = componentInParent.UpdateGhostModel(MultiplayerBuilder.GetAimTransform(), MultiplayerBuilder.ghostModel, default(RaycastHit), out flag);
                //MultiplayerBuilder.placePosition = transform.position;
                //MultiplayerBuilder.placeRotation = transform.rotation;
                if (flag)
                {
                    MultiplayerBuilder.renderers = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial);
                    MultiplayerBuilder.InitBounds(MultiplayerBuilder.ghostModel);
                }
            }
            else
            {
                flag2 = MultiplayerBuilder.CheckAsSubModule();
            }
            if (flag2)
            {
                List <GameObject> list = new List <GameObject>();
                MultiplayerBuilder.GetObstacles(MultiplayerBuilder.placePosition, MultiplayerBuilder.placeRotation, MultiplayerBuilder.bounds, list);
                flag2 = (list.Count == 0);
                list.Clear();
            }
            return(flag2);
        }
Esempio n. 3
0
        // Token: 0x06002BAD RID: 11181 RVA: 0x00104B6C File Offset: 0x00102D6C
        private static bool CheckAsSubModule()
        {
            if (!Constructable.CheckFlags(MultiplayerBuilder.allowedInBase, MultiplayerBuilder.allowedInSub, MultiplayerBuilder.allowedOutside))
            {
                return(false);
            }

            Transform aimTransform = MultiplayerBuilder.GetAimTransform();

            MultiplayerBuilder.placementTarget = null;
            RaycastHit hit;

            if (!Physics.Raycast(aimTransform.position, aimTransform.forward, out hit, MultiplayerBuilder.placeMaxDistance, MultiplayerBuilder.placeLayerMask.value, QueryTriggerInteraction.Ignore))
            {
                return(false);
            }

            MultiplayerBuilder.placementTarget = hit.collider.gameObject;
            MultiplayerBuilder.SetPlaceOnSurface(hit, ref MultiplayerBuilder.placePosition, ref MultiplayerBuilder.placeRotation);
            if (!MultiplayerBuilder.CheckTag(hit.collider))
            {
                return(false);
            }

            if (!MultiplayerBuilder.CheckSurfaceType(MultiplayerBuilder.GetSurfaceType(hit.normal)))
            {
                return(false);
            }

            if (!MultiplayerBuilder.CheckDistance(hit.point, MultiplayerBuilder.placeMinDistance))
            {
                return(false);
            }

            if (!MultiplayerBuilder.allowedOnConstructables && MultiplayerBuilder.HasComponent <Constructable>(hit.collider.gameObject))
            {
                return(false);
            }

            if (!Player.main.IsInSub())
            {
                GameObject entityRoot = UWE.Utils.GetEntityRoot(MultiplayerBuilder.placementTarget);
                if (!entityRoot)
                {
                    entityRoot = MultiplayerBuilder.placementTarget;
                }

                if (!MultiplayerBuilder.ValidateOutdoor(entityRoot))
                {
                    return(false);
                }
            }

            return(MultiplayerBuilder.CheckSpace(MultiplayerBuilder.placePosition, MultiplayerBuilder.placeRotation, MultiplayerBuilder.bounds, MultiplayerBuilder.placeLayerMask.value, hit.collider));
        }
Esempio n. 4
0
        // Token: 0x06002BB4 RID: 11188 RVA: 0x00104DDC File Offset: 0x00102FDC
        private static void SetPlaceOnSurface(RaycastHit hit, ref Vector3 position, ref Quaternion rotation)
        {
            Transform aimTransform = MultiplayerBuilder.GetAimTransform();
            Vector3   vector       = Vector3.forward;
            Vector3   vector2      = Vector3.up;

            if (MultiplayerBuilder.forceUpright)
            {
                vector   = -aimTransform.forward;
                vector.y = 0f;
                vector.Normalize();
                vector2 = Vector3.up;
            }
            else
            {
                SurfaceType surfaceType = MultiplayerBuilder.GetSurfaceType(hit.normal);
                if (surfaceType != SurfaceType.Wall)
                {
                    if (surfaceType != SurfaceType.Ceiling)
                    {
                        if (surfaceType == SurfaceType.Ground)
                        {
                            vector2   = hit.normal;
                            vector    = -aimTransform.forward;
                            vector.y -= Vector3.Dot(vector, vector2);
                            vector.Normalize();
                        }
                    }
                    else
                    {
                        vector     = hit.normal;
                        vector2    = -aimTransform.forward;
                        vector2.y -= Vector3.Dot(vector2, vector);
                        vector2.Normalize();
                    }
                }
                else
                {
                    vector  = hit.normal;
                    vector2 = Vector3.up;
                }
            }

            position = hit.point;
            rotation = Quaternion.LookRotation(vector, vector2);
            if (MultiplayerBuilder.rotationEnabled)
            {
                rotation = Quaternion.AngleAxis(MultiplayerBuilder.additiveRotation, vector2) * rotation;
            }
        }
Esempio n. 5
0
        // Token: 0x06002BB3 RID: 11187 RVA: 0x00104D2C File Offset: 0x00102F2C
        private static void SetDefaultPlaceTransform(ref Vector3 position, ref Quaternion rotation)
        {
            Transform aimTransform = MultiplayerBuilder.GetAimTransform();

            position = aimTransform.position + aimTransform.forward * MultiplayerBuilder.placeDefaultDistance;
            Vector3 forward;
            Vector3 up;

            if (MultiplayerBuilder.forceUpright)
            {
                forward   = -aimTransform.forward;
                forward.y = 0f;
                forward.Normalize();
                up = Vector3.up;
            }
            else
            {
                forward = -aimTransform.forward;
                up      = aimTransform.up;
            }

            rotation = Quaternion.LookRotation(forward, up);
            if (MultiplayerBuilder.rotationEnabled)
            {
                rotation = Quaternion.AngleAxis(MultiplayerBuilder.additiveRotation, up) * rotation;
            }

            if (MultiplayerBuilder.overridePosition != null)
            {
                position = MultiplayerBuilder.overridePosition;
            }

            if (MultiplayerBuilder.overrideQuaternion != null)
            {
                rotation = MultiplayerBuilder.overrideQuaternion;
            }
        }