示例#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);
        }
示例#2
0
            /// <summary>
            /// Applied after OnSpawn runs.
            /// </summary>
            internal static void Postfix(Constructable __instance,
                                         ref bool ___waitForFetchesBeforeDigging)
            {
                var building = __instance.GetComponent <Building>();

                // Does it have an airlock door?
                if (building != null && building.Def.BuildingComplete.GetComponent <
                        AirlockDoor>() != null)
                {
                    ___waitForFetchesBeforeDigging = true;
                }
            }
示例#3
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);
            }
        }
示例#4
0
        private static void AlertedNewBuilderBuild(BuilderTool arg1, Constructable arg2)
        {
            if (arg2 != null)
            {
                Log.Info($"Name: {arg2.gameObject.name}");

                var powerFX = arg2.GetComponent(typeof(PowerFX));

                if (powerFX != null)
                {
                    var fx = powerFX as PowerFX;
                    Log.Info($"PowerFX: {fx.vfxPrefab.name}");
                }

                //var list = arg2.GetComponentsInChildren(typeof(Component));
                //for (int i = 0; i < list.Length; i++)
                //{
                //    Log.Info($"Component Name: {list[i].name}");
                //}
            }
        }
示例#5
0
            public static void Postfix(ref Constructable __instance, ref Building ___building)
            {
                // Check if the building is not a background object
                if (___building.Def.ObjectLayer != ObjectLayer.Building)
                {
                    return;
                }
                PrioritySetting masterPriority = __instance.GetComponent <Prioritizable> ().GetMasterPriority();

                ___building.RunOnArea(delegate(int offset_cell) {
                    GameObject gameObject = Grid.Objects [offset_cell, (int)ObjectLayer.Plants];
                    if (gameObject != null)
                    {
                        // This component should always exist but lets check it just in case
                        if (gameObject.GetComponent <Uprootable> () != null)
                        {
                            gameObject.GetComponent <Uprootable> ().MarkForUproot(true);
                            gameObject.GetComponent <Prioritizable> ().SetMasterPriority(masterPriority);
                        }
                    }
                });
            }