Esempio n. 1
0
        // Token: 0x06002B9B RID: 11163 RVA: 0x00103EBC File Offset: 0x001020BC
        private static bool CreateGhost()
        {
            if (MultiplayerBuilder.ghostModel != null)
            {
                return(false);
            }

            Constructable component = MultiplayerBuilder.prefab.GetComponent <Constructable>();

            MultiplayerBuilder.constructableTechType   = component.techType;
            MultiplayerBuilder.placeMinDistance        = component.placeMinDistance;
            MultiplayerBuilder.placeMaxDistance        = component.placeMaxDistance;
            MultiplayerBuilder.placeDefaultDistance    = component.placeDefaultDistance;
            MultiplayerBuilder.allowedSurfaceTypes     = component.allowedSurfaceTypes;
            MultiplayerBuilder.forceUpright            = component.forceUpright;
            MultiplayerBuilder.allowedInSub            = component.allowedInSub;
            MultiplayerBuilder.allowedInBase           = component.allowedInBase;
            MultiplayerBuilder.allowedOutside          = component.allowedOutside;
            MultiplayerBuilder.allowedOnConstructables = component.allowedOnConstructables;
            MultiplayerBuilder.rotationEnabled         = component.rotationEnabled;
            ConstructableBase component2 = MultiplayerBuilder.prefab.GetComponent <ConstructableBase>();

            if (component2 != null)
            {
                GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(MultiplayerBuilder.prefab);
                component2 = gameObject.GetComponent <ConstructableBase>();
                MultiplayerBuilder.ghostModel = component2.model;
                BaseGhost component3 = MultiplayerBuilder.ghostModel.GetComponent <BaseGhost>();
                component3.SetupGhost();
                MultiplayerBuilder.ghostModelPosition = Vector3.zero;
                MultiplayerBuilder.ghostModelRotation = Quaternion.identity;
                MultiplayerBuilder.ghostModelScale    = Vector3.one;
                MultiplayerBuilder.renderers          = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial);
                MultiplayerBuilder.InitBounds(MultiplayerBuilder.ghostModel);
            }
            else
            {
                MultiplayerBuilder.ghostModel = UnityEngine.Object.Instantiate <GameObject>(component.model);
                MultiplayerBuilder.ghostModel.SetActive(true);
                Transform  component4 = component.GetComponent <Transform>();
                Transform  component5 = component.model.GetComponent <Transform>();
                Quaternion quaternion = Quaternion.Inverse(component4.rotation);
                MultiplayerBuilder.ghostModelPosition = quaternion * (component5.position - component4.position);
                MultiplayerBuilder.ghostModelRotation = quaternion * component5.rotation;
                MultiplayerBuilder.ghostModelScale    = component5.lossyScale;
                Collider[] componentsInChildren = MultiplayerBuilder.ghostModel.GetComponentsInChildren <Collider>();
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    UnityEngine.Object.Destroy(componentsInChildren[i]);
                }

                MultiplayerBuilder.renderers = MaterialExtensions.AssignMaterial(MultiplayerBuilder.ghostModel, MultiplayerBuilder.ghostStructureMaterial);
                MultiplayerBuilder.SetupRenderers(MultiplayerBuilder.ghostModel, Player.main.IsInSub());
                MultiplayerBuilder.CreatePowerPreview(MultiplayerBuilder.constructableTechType, MultiplayerBuilder.ghostModel);
                MultiplayerBuilder.InitBounds(MultiplayerBuilder.prefab);
            }

            return(true);
        }
Esempio n. 2
0
        private static void CreateGhost()
        {
            Constructable component = prefab.GetComponent <Constructable>();

            constructableTechType = component.techType;
            allowedOutside        = component.allowedOutside;
            ConstructableBase component2 = prefab.GetComponent <ConstructableBase>();

            if (component2 != null)
            {
                GameObject gameObject = Object.Instantiate <GameObject>(prefab);
                component2 = gameObject.GetComponent <ConstructableBase>();
                ghostModel = component2.model;
                BaseGhost component3 = ghostModel.GetComponent <BaseGhost>();
                component3.SetupGhost();
                ghostModelPosition = Vector3.zero;
                ghostModelRotation = Quaternion.identity;
                ghostModelScale    = Vector3.one;
                renderers          = MaterialExtensions.AssignMaterial(ghostModel, ghostStructureMaterial);
                InitBounds(ghostModel);
            }
            else
            {
                ghostModel = Object.Instantiate <GameObject>(component.model);
                ghostModel.SetActive(true);
                Transform  component4 = component.GetComponent <Transform>();
                Transform  component5 = component.model.GetComponent <Transform>();
                Quaternion quaternion = Quaternion.Inverse(component4.rotation);
                ghostModelPosition = quaternion * (component5.position - component4.position);
                ghostModelRotation = quaternion * component5.rotation;
                ghostModelScale    = component5.lossyScale;
                Collider[] componentsInChildren = ghostModel.GetComponentsInChildren <Collider>();
                foreach (Collider collider in componentsInChildren)
                {
                    Object.Destroy(collider);
                }

                renderers = MaterialExtensions.AssignMaterial(ghostModel, ghostStructureMaterial);
                SetupRenderers(ghostModel, Player.main.IsInSub());
                CreatePowerPreview();
                InitBounds(prefab);
            }
        }