Exemple #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);
        }
Exemple #2
0
 // Token: 0x06002B98 RID: 11160 RVA: 0x0001E955 File Offset: 0x0001CB55
 public static bool Begin(GameObject modulePrefab)
 {
     MultiplayerBuilder.Initialize();
     if (modulePrefab == null)
     {
         Debug.LogWarning("Builder : Begin() : Module prefab is null!");
         return(false);
     }
     if (modulePrefab != MultiplayerBuilder.prefab)
     {
         MultiplayerBuilder.End();
     }
     MultiplayerBuilder.prefab = modulePrefab;
     MultiplayerBuilder.Update();
     return(true);
 }
Exemple #3
0
 // Token: 0x06002B99 RID: 11161 RVA: 0x00103D44 File Offset: 0x00101F44
 public static void End()
 {
     MultiplayerBuilder.Initialize();
     MultiplayerBuilder.inputHandler.canHandleInput = false;
     if (MultiplayerBuilder.ghostModel != null)
     {
         ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();
         if (componentInParent != null)
         {
             UnityEngine.Object.Destroy(componentInParent.gameObject);
         }
         UnityEngine.Object.Destroy(MultiplayerBuilder.ghostModel);
     }
     MultiplayerBuilder.prefab           = null;
     MultiplayerBuilder.ghostModel       = null;
     MultiplayerBuilder.canPlace         = false;
     MultiplayerBuilder.placementTarget  = null;
     MultiplayerBuilder.additiveRotation = 0f;
 }
Exemple #4
0
        public static ConstructableBase TryPlaceBase(Optional <GameObject> opTargetBaseGameObject)
        {
            MultiplayerBuilder.Initialize();
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();
            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 (opTargetBaseGameObject.IsPresent())
            {
                GameObject targetBaseGameObject = opTargetBaseGameObject.Get();
                Base       targetBase           = targetBaseGameObject.GetComponent <Base>();

                if (targetBase != null)
                {
                    component.ReflectionSet("targetBase", targetBase);
                    componentInParent.transform.SetParent(targetBase.transform, true);
                }
                else
                {
                    Console.WriteLine("Could not find base component on the given game object");
                }
            }

            componentInParent.SetState(false, true);

            component.GhostBase.transform.position = overridePosition;

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

            return(componentInParent);
        }
        public static ConstructableBase TryPlaceBase(GameObject targetBaseGameObject)
        {
            MultiplayerBuilder.Initialize();
            global::Utils.PlayEnvSound(MultiplayerBuilder.placeSound, MultiplayerBuilder.ghostModel.transform.position, 10f);
            ConstructableBase componentInParent = MultiplayerBuilder.ghostModel.GetComponentInParent <ConstructableBase>();
            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 (targetBaseGameObject)
            {
                Base targetBase = targetBaseGameObject.GetComponent <Base>();

                if (targetBase != null)
                {
                    component.targetBase = targetBase;
                    componentInParent.transform.SetParent(targetBase.transform, true);
                }
                else
                {
                    Log.Error("Could not find base component on the given game object: " + targetBaseGameObject.name);
                }
            }

            componentInParent.SetState(false, true);

            component.GhostBase.transform.position = overridePosition;

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

            return(componentInParent);
        }
Exemple #6
0
        // Token: 0x06002B9A RID: 11162
        public static void Update()
        {
            MultiplayerBuilder.Initialize();
            MultiplayerBuilder.canPlace = false;
            if (MultiplayerBuilder.prefab == null)
            {
                return;
            }
            if (MultiplayerBuilder.CreateGhost())
            {
                Console.WriteLine("Ghost Created!");
            }
            MultiplayerBuilder.canPlace = MultiplayerBuilder.UpdateAllowed();
            Transform expr_58 = MultiplayerBuilder.ghostModel.transform;

            expr_58.position   = MultiplayerBuilder.placePosition + MultiplayerBuilder.placeRotation * MultiplayerBuilder.ghostModelPosition;
            expr_58.rotation   = MultiplayerBuilder.placeRotation * MultiplayerBuilder.ghostModelRotation;
            expr_58.localScale = MultiplayerBuilder.ghostModelScale;
            Color color = (!MultiplayerBuilder.canPlace) ? MultiplayerBuilder.placeColorDeny : MultiplayerBuilder.placeColorAllow;

            MaterialExtensions.SetColor(MultiplayerBuilder.renderers, ShaderPropertyID._Tint, color);
        }
        // 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);
        }