Exemple #1
0
        private IEnumerator UpdatePowerRelay()
        {
            QuickLogger.Debug("In UpdatePowerRelay found at last!");

            var i = 1;

            while (_connectedRelay == null)
            {
                QuickLogger.Debug($"Checking For Relay... Attempt {i}");

                PowerRelay relay = PowerSource.FindRelay(this.transform);
                if (relay != null && relay != _connectedRelay)
                {
                    _connectedRelay = relay;
                    QuickLogger.Debug("PowerRelay found at last!");
                }
                else
                {
                    _connectedRelay = null;
                }

                i++;
                yield return(new WaitForSeconds(0.5f));
            }
        }
        private void UpdatePowerRelay()
        {
            try
            {
                var relay = PowerSource.FindRelay(transform);

                if (relay != null && relay != _powerRelay)
                {
                    if (_powerRelay != null)
                    {
                        _powerRelay.RemoveInboundPower(this);
                    }
                    _powerRelay = relay;
                    _powerRelay.AddInboundPower(this);
                    CancelInvoke("UpdatePowerRelay");
                }
                else
                {
                    _powerRelay = null;
                }

                if (_powerRelay != null)
                {
                    _powerRelay.RemoveInboundPower(this);
                    _powerRelay.AddInboundPower(this);
                    CancelInvoke("UpdatePowerRelay");
                }
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
            }
        }
Exemple #3
0
        private void UpdatePowerRelay()
        {
            PowerRelay relay = PowerSource.FindRelay(_mono.transform);

            if (relay != null && relay != _connectedRelay)
            {
                _connectedRelay = relay;
                QuickLogger.Debug("PowerRelay found at last!");
            }
            else
            {
                _connectedRelay = null;
            }
        }
Exemple #4
0
        private GameObject PreProcessPrefab(GameObject prefab)
        {
            Constructable constructible = null;
            GhostCrafter  crafter;

            switch (this.Model)
            {
            case Models.Fabricator:
            default:
                crafter = prefab.GetComponent <Fabricator>();
                break;

            case Models.Workbench:
                crafter = prefab.GetComponent <Workbench>();
                break;

#if SUBNAUTICA
            case Models.MoonPool:
                crafter = prefab.GetComponent <Fabricator>();

                // Add prefab ID because CyclopsFabricator normaly doesn't have one
                PrefabIdentifier prefabId = prefab.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;
                prefabId.name    = this.FriendlyName;

                // Add tech tag because CyclopsFabricator normaly doesn't have one
                TechTag techTag = prefab.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Retrieve sub game objects
                GameObject cyclopsFabLight = prefab.FindChild("fabricatorLight");
                GameObject cyclopsFabModel = prefab.FindChild("submarine_fabricator_03");
                // Translate CyclopsFabricator model and light
                prefab.transform.localPosition = new Vector3(cyclopsFabModel.transform.localPosition.x,        // Same X position
                                                             cyclopsFabModel.transform.localPosition.y - 0.8f, // Push towards the wall slightly
                                                             cyclopsFabModel.transform.localPosition.z);       // Same Z position
                prefab.transform.localPosition = new Vector3(cyclopsFabLight.transform.localPosition.x,        // Same X position
                                                             cyclopsFabLight.transform.localPosition.y - 0.8f, // Push towards the wall slightly
                                                             cyclopsFabLight.transform.localPosition.z);       // Same Z position
                // Add constructable - This prefab normally isn't constructed.
                constructible       = prefab.AddComponent <Constructable>();
                constructible.model = cyclopsFabModel;
                break;
#endif
            case Models.Custom:
                crafter = prefab.EnsureComponent <Fabricator>();
                break;
            }

            crafter.craftTree    = this.TreeTypeID;
            crafter.handOverText = $"Use {this.FriendlyName}";

            if (constructible is null)
            {
                constructible = prefab.GetComponent <Constructable>();
            }

            constructible.allowedInBase           = this.AllowedInBase;
            constructible.allowedInSub            = this.AllowedInCyclops;
            constructible.allowedOutside          = this.AllowedOutside;
            constructible.allowedOnCeiling        = this.AllowedOnCeiling;
            constructible.allowedOnGround         = this.AllowedOnGround;
            constructible.allowedOnWall           = this.AllowedOnWall;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = this.RotationEnabled;
            constructible.techType = this.TechType; // This was necessary to correctly associate the recipe at building time

            SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
            skyApplier.renderers = prefab.GetComponentsInChildren <Renderer>();
            skyApplier.anchorSky = Skies.Auto;

            if (this.UseCustomTint)
            {
                SkinnedMeshRenderer skinnedMeshRenderer = prefab.GetComponentInChildren <SkinnedMeshRenderer>();
                skinnedMeshRenderer.material.color = this.ColorTint; // Tint option available
            }

            crafter.powerRelay = PowerSource.FindRelay(prefab.transform);

            return(prefab);
        }