Esempio n. 1
0
        // Token: 0x06002BB7 RID: 11191 RVA: 0x00104FDC File Offset: 0x001031DC
        private static void CreatePowerPreview(TechType constructableTechType, GameObject ghostModel)
        {
            GameObject gameObject        = null;
            string     poweredPrefabName = CraftData.GetPoweredPrefabName(constructableTechType);

            if (poweredPrefabName != string.Empty)
            {
                gameObject = PrefabDatabase.GetPrefabForFilename(poweredPrefabName);
            }

            if (gameObject != null)
            {
                PowerRelay component = gameObject.GetComponent <PowerRelay>();
                if (component.powerFX != null && component.powerFX.attachPoint != null)
                {
                    PowerFX powerFX = ghostModel.AddComponent <PowerFX>();
                    powerFX.attachPoint = new GameObject
                    {
                        transform =
                        {
                            parent        = ghostModel.transform,
                            localPosition = component.powerFX.attachPoint.localPosition
                        }
                    }.transform;
                }

                PowerRelay powerRelay = ghostModel.AddComponent <PowerRelay>();
                powerRelay.maxOutboundDistance = component.maxOutboundDistance;
                powerRelay.dontConnectToRelays = component.dontConnectToRelays;
                if (component.internalPowerSource != null)
                {
                    powerRelay.internalPowerSource = ghostModel.AddComponent <PowerSource>();
                }
            }
        }
Esempio n. 2
0
        private static void CreatePowerPreview()
        {
            GameObject gameObject        = null;
            string     poweredPrefabName = CraftData.GetPoweredPrefabName(constructableTechType);

            if (poweredPrefabName != string.Empty)
            {
#pragma warning disable CS0618
                //Ignore warning to use an async method when we need sync.
                gameObject = PrefabDatabase.GetPrefabForFilename(poweredPrefabName);
#pragma warning restore CS0618
            }

            if (gameObject == null)
            {
                return;
            }

            PowerRelay component = gameObject.GetComponent <PowerRelay>();
            if (component.powerFX != null && component.powerFX.attachPoint != null)
            {
                PowerFX powerFX = ghostModel.AddComponent <PowerFX>();
                powerFX.attachPoint = new GameObject
                {
                    transform =
                    {
                        parent        = ghostModel.transform,
                        localPosition = component.powerFX.attachPoint.localPosition
                    }
                }.transform;
            }

            PowerRelay powerRelay = ghostModel.AddComponent <PowerRelay>();
            powerRelay.maxOutboundDistance = component.maxOutboundDistance;
            powerRelay.dontConnectToRelays = component.dontConnectToRelays;
            if (component.internalPowerSource != null)
            {
                powerRelay.internalPowerSource = ghostModel.AddComponent <PowerSource>();
            }
        }