Exemplo n.º 1
0
 // Token: 0x06003105 RID: 12549 RVA: 0x0012DC88 File Offset: 0x0012BE88
 public static bool CheckSpace(Vector3 position, Quaternion rotation, List <OrientedBounds> localBounds, int layerMask, Collider allowedCollider)
 {
     if (rotation.IsDistinguishedIdentity())
     {
         rotation = Quaternion.identity;
     }
     for (int i = 0; i < localBounds.Count; i++)
     {
         OrientedBounds orientedBounds = localBounds[i];
         if (orientedBounds.rotation.IsDistinguishedIdentity())
         {
             orientedBounds.rotation = Quaternion.identity;
         }
         orientedBounds.position = position + rotation * orientedBounds.position;
         orientedBounds.rotation = rotation * orientedBounds.rotation;
         if (!MultiplayerBuilder.CheckSpace(orientedBounds.position, orientedBounds.rotation, orientedBounds.extents, layerMask, allowedCollider))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 2
0
        // Token: 0x06003101 RID: 12545 RVA: 0x0012DA08 File Offset: 0x0012BC08
        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(float.MaxValue, float.MaxValue, float.MaxValue);
                Vector3 a      = new Vector3(float.MinValue, float.MinValue, float.MinValue);
                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;
            }
        }
Exemplo n.º 3
0
 // Token: 0x06003108 RID: 12552 RVA: 0x00021B87 File Offset: 0x0001FD87
 public static void GetOverlappedObjects(Vector3 position, Quaternion rotation, Vector3 extents, List <GameObject> results)
 {
     MultiplayerBuilder.GetOverlappedColliders(position, rotation, extents, MultiplayerBuilder.sCollidersList);
     MultiplayerBuilder.GetRootObjects(MultiplayerBuilder.sCollidersList, results);
     MultiplayerBuilder.sCollidersList.Clear();
 }
Exemplo n.º 4
0
        // Token: 0x060030FF RID: 12543 RVA: 0x0012D7E8 File Offset: 0x0012B9E8
        public static bool TryPlace(out GameObject outObject, out Constructable outConstructable)
        {
            outObject        = null;
            outConstructable = null;

            MultiplayerBuilder.Initialize();

            if (MultiplayerBuilder.prefab == null)
            {
                return(false);
            }

            Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                MultiplayerBuilder.Update();
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();

                component.Place();
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                componentInParent.transform.position = overridePosition;
                componentInParent.transform.rotation = overrideRotation;

                outObject        = componentInParent.gameObject;
                outConstructable = componentInParent;
            }
            else
            {
                MultiplayerBuilder.placementTarget = GuidHelper.Find(targetGuid);

                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                bool       flag       = false;
                bool       flag2      = false;

                SubRoot currentSub = Player.main.GetCurrentSub();
                if (currentSub != null)
                {
                    flag  = currentSub.isBase;
                    flag2 = currentSub.isCyclops;
                    gameObject.transform.parent = currentSub.GetModulesRoot();
                }
                else if (MultiplayerBuilder.placementTarget != null && MultiplayerBuilder.allowedOutside)
                {
                    SubRoot componentInParent2 = MultiplayerBuilder.placementTarget.GetComponentInParent <SubRoot>();
                    if (componentInParent2 != null)
                    {
                        gameObject.transform.parent = componentInParent2.GetModulesRoot();
                    }
                }
                Transform transform = gameObject.transform;
                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                if (MultiplayerBuilder.ghostModel != null)
                {
                    UnityEngine.Object.Destroy(MultiplayerBuilder.ghostModel);
                }
                componentInParent3.SetIsInside(flag || flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);

                transform.localPosition = overridePosition;
                transform.localRotation = overrideRotation;

                outObject        = gameObject;
                outConstructable = componentInParent3;
            }
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }