Пример #1
0
        public static GameObject TryPlaceFurniture(SubRoot currentSub)
        {
            MultiplayerBuilder.Initialize();
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);

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

            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 expr_138 = gameObject.transform;

            expr_138.position = MultiplayerBuilder.placePosition;
            expr_138.rotation = MultiplayerBuilder.placeRotation;
            Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();

            componentInParent3.SetState(false, true);
            global::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);

            if (currentSub != null && currentSub.isCyclops)
            {
                gameObject.transform.localPosition = overridePosition;
                gameObject.transform.localRotation = overrideQuaternion;
            }
            else
            {
                gameObject.transform.position = overridePosition;
                gameObject.transform.rotation = overrideQuaternion;
            }

            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;

            return(gameObject);
        }
Пример #2
0
        public static GameObject TryPlaceFurniture(SubRoot currentSub)
        {
#pragma warning disable CS0618
            //Disabling warning as we dont have the FModAsset to use instead.
            Utils.PlayEnvSound(PLACE_SOUND, ghostModel.transform.position);
#pragma warning restore CS0618

            GameObject gameObject = Object.Instantiate <GameObject>(prefab);
            bool       flag       = false;
            bool       flag2      = false;
            if (currentSub != null)
            {
                flag  = currentSub.isBase;
                flag2 = currentSub.isCyclops;
                gameObject.transform.parent = currentSub.GetModulesRoot();
            }
            else if (placementTarget != null && allowedOutside)
            {
                SubRoot componentInParent2 = placementTarget.GetComponentInParent <SubRoot>();
                if (componentInParent2 != null)
                {
                    gameObject.transform.parent = componentInParent2.GetModulesRoot();
                }
            }

            Transform expr138 = gameObject.transform;
            expr138.position = PlacePosition;
            expr138.rotation = PlaceRotation;
            Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
            componentInParent3.SetState(false);
            Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"));
            if (ghostModel != null)
            {
                Object.Destroy(ghostModel);
            }

            componentInParent3.SetIsInside(flag || flag2);
            SkyEnvironmentChanged.Send(gameObject, currentSub);

            if (currentSub != null && currentSub.isCyclops)
            {
                gameObject.transform.localPosition = OverridePosition;
                gameObject.transform.localRotation = OverrideQuaternion;
            }
            else
            {
                gameObject.transform.position = OverridePosition;
                gameObject.transform.rotation = OverrideQuaternion;
            }

            ghostModel       = null;
            prefab           = null;
            RotationMetadata = Optional.Empty;

            return(gameObject);
        }
Пример #3
0
        // Token: 0x06002B9D RID: 11165
        public static bool TryPlace()
        {
            MultiplayerBuilder.Initialize();
            if (MultiplayerBuilder.prefab == null || !MultiplayerBuilder.canPlace)
            {
                return(false);
            }
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();

            if (componentInParent != null)
            {
                BaseGhost component = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();
                component.GhostBase.transform.position = overridePosition;
                component.Place();

                componentInParent.transform.position = overridePosition;

                component.transform.position = overridePosition;
                component.transform.rotation = overrideQuaternion;
                if (component.TargetBase != null)
                {
                    componentInParent.transform.SetParent(component.TargetBase.transform, true);
                }
                componentInParent.SetState(false, true);

                component.GhostBase.transform.position = overridePosition;

                if (component.TargetBase != null)
                {
                    component.TargetBase.transform.position = overridePosition;
                }
            }
            else
            {
                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 expr_138 = gameObject.transform;
                expr_138.position = MultiplayerBuilder.placePosition;
                expr_138.rotation = MultiplayerBuilder.placeRotation;
                Constructable componentInParent3 = gameObject.GetComponentInParent <Constructable>();
                componentInParent3.SetState(false, true);
                global::Utils.SetLayerRecursively(gameObject, LayerMask.NameToLayer((!flag) ? "Interior" : "Default"), true, -1);
                componentInParent3.SetIsInside(flag | flag2);
                SkyEnvironmentChanged.Send(gameObject, currentSub);
                gameObject.transform.position = overridePosition;
                gameObject.transform.rotation = overrideQuaternion;
            }
            Console.WriteLine("mBuilder.ghostModel.transform.position: " + MultiplayerBuilder.ghostModel.transform.position);
            Console.WriteLine("mBuilder.placePosition: " + MultiplayerBuilder.placePosition);
            Console.WriteLine("m op: " + MultiplayerBuilder.overridePosition);
            Console.WriteLine("m oq: " + MultiplayerBuilder.overrideQuaternion);
            MultiplayerBuilder.ghostModel = null;
            MultiplayerBuilder.prefab     = null;
            MultiplayerBuilder.canPlace   = false;
            return(true);
        }
Пример #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);
        }