コード例 #1
0
        public override GameObject GetGameObject()
        {
            SubRoot cyclops = Player.main.currentSub;

            if (cyclops != null)
            {
                BioAuxCyclopsManager mgr = MCUServices.Find.AuxCyclopsManager <BioAuxCyclopsManager>(cyclops);

                if (mgr.TrackedBuildablesCount >= BioAuxCyclopsManager.MaxBioReactors)
                {
                    ErrorMessage.AddMessage(OverLimitString());
                    return(null);
                }
            }

            if (_prefab == null)
            {
                QuickLogger.Error("_prefab is null", true);
            }


            var prefab = GameObject.Instantiate(_prefab);

            if (prefab == null)
            {
                QuickLogger.Error("Prefab is null", true);
            }

            GameObject model = prefab.FindChild("model");

            // Update sky applier
            SkyApplier skyApplier = prefab.AddComponent <SkyApplier>();

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

            //Add the constructible component to the prefab
            Constructable constructible = prefab.AddComponent <Constructable>();

            constructible.allowedInBase           = false;
            constructible.allowedInSub            = true; // Only allowed in Cyclops
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true; // Only on ground
            constructible.allowedOnWall           = false;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = true;
            constructible.techType = this.TechType;
            constructible.model    = model;

            prefab.AddComponent <PrefabIdentifier>().ClassId = this.ClassID;

            CyBioReactorMono bioReactorComponent = prefab.AddComponent <CyBioReactorMono>(); // The component that makes the magic happen

            return(prefab);
        }
コード例 #2
0
        internal static void Postfix(uGUI_InventoryTab __instance)
        {
            if (__instance == null || !CyBioReactorMono.PdaIsOpen)
            {
                return;
            }

            ItemsContainer   containerObj = __instance.storage.container;
            CyBioReactorMono reactor      = CyBioReactorMono.OpenInPda;

            reactor.ConnectToContainer(__instance.storage.items);
        }
コード例 #3
0
        internal static void Postfix(uGUI_InventoryTab __instance)
        {
            // This event happens whenever the player opens their PDA.
            // We will make a series of checks to see if what they have opened is the Cyclops Bioreactor item container.

            if (__instance == null || !CyBioReactorMono.PdaIsOpen)
            {
                return;
            }

            ItemsContainer   containerObj = __instance.storage.container;
            CyBioReactorMono reactor      = CyBioReactorMono.OpenInPda;

            reactor.ConnectToInventory(__instance.storage.items);
        }
コード例 #4
0
        internal CyBioReactorAnimationHandler(CyBioReactorMono mono)
        {
            _mono     = mono;
            _animator = mono.transform.GetComponent <Animator>();

            if (_animator == null)
            {
                MCUServices.Logger.Error("Animator component not found on the GameObject.");
            }

            if (_animator != null && _animator.enabled == false)
            {
                MCUServices.Logger.Debug("Animator was disabled and now has been enabled");
                _animator.enabled = true;
            }
        }
コード例 #5
0
        public override GameObject GetGameObject()
        {
            // Instantiate Fabricator object
            var prefab = GameObject.Instantiate(CraftData.GetPrefabForTechType(TechType.SpecimenAnalyzer));

            GameObject.DestroyImmediate(prefab.GetComponentInChildren <SpecimenAnalyzerBase>()); // Don't need this
            GameObject.DestroyImmediate(prefab.GetComponent <SpecimenAnalyzer>());               // Don't need this
            GameObject model = prefab.FindChild("model");

            const float modelScaling = 0.18f;

            model.transform.localScale -= new Vector3(modelScaling, modelScaling, modelScaling);

            // Update sky applier
            SkyApplier skyApplier = prefab.GetComponent <SkyApplier>();

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

            // Modify existing constructable - This is just a modified SpecimenAnalyzer which already had a Constructible component.
            Constructable constructible = prefab.GetComponent <Constructable>();

            constructible.allowedInBase           = false;
            constructible.allowedInSub            = true; // Only allowed in Cyclops
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true; // Only on ground
            constructible.allowedOnWall           = false;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = true;
            constructible.techType = this.TechType;
            constructible.model    = model;

            // Set the custom texture
            Texture2D           customTexture       = ImageUtils.LoadTextureFromFile(@"./QMods/MoreCyclopsUpgrades/Assets/CyBioReactorT.png");
            SkinnedMeshRenderer skinnedMeshRenderer = prefab.GetComponentInChildren <SkinnedMeshRenderer>();

            skinnedMeshRenderer.material.mainTexture = customTexture;

            CyBioReactorMono bioReactorComponent = prefab.AddComponent <CyBioReactorMono>(); // The component that makes the magic happen

            bioReactorComponent.Battery = prefab.AddComponent <Battery>();

            return(prefab);
        }
コード例 #6
0
        internal static void Postfix(uGUI_InventoryTab __instance)
        {
            // This event happens whenever the player opens their PDA.
            // We will make a series of checks to see if what they have opened is the Cyclops Bioreactor item container.

            if (__instance is null)
            {
                return; // Safety check
            }
            if (!Player.main.IsInSub() || !Player.main.currentSub.isCyclops)
            {
                return; // If not in Cyclops then all is irrelevant
            }
            if (__instance.storage is null)
            {
                return; // Safety check
            }
            ItemsContainer containerObj = __instance.storage.container;

            if (containerObj is null)
            {
                return; // If this isn't a non-null ItemsContainer, then it's not what we want.
            }
            string label = containerObj._label;

            if (label != CyBioReactor.StorageLabel)
            {
                return; // Not a Cyclops Bioreactor storage
            }
            List <CyBioReactorMono> reactors = CyclopsManager.GetBioReactors(Player.main.currentSub);

            if (reactors is null || reactors.Count == 0)
            {
                return; // Cyclops has no bioreactors
            }
            // Look for the reactor that matches the container we just opened.
            CyBioReactorMono reactor = reactors.Find(r => r.Container == containerObj);

            if (reactor is null)
            {
                return; // Didn't find the reactor we were looking for. Could it be on another cyclops?
            }
            Dictionary <InventoryItem, uGUI_ItemIcon> lookup = __instance.storage.items;

            reactor.ConnectToInventory(lookup); // Found!
        }
コード例 #7
0
 internal CyBioReactorDisplayHandler(CyBioReactorMono mono)
 {
     _mono       = mono;
     _gameobject = mono.gameObject;
     FindAllComponents();
 }
コード例 #8
0
        public static IEnumerator AddToReactor(SubRoot subRoot, TechType fishType, Vector2int sizePerFish, CyBioReactorMono reactor)
        {
            var task = CraftData.GetPrefabForTechTypeAsync(fishType, false);

            yield return(task);

            var prefab = task.GetResult();

            prefab.SetActive(false);

            if (!reactor.container.HasRoomFor(sizePerFish.x, sizePerFish.y))
            {
                var breedCount = 1;

                if (QModServices.Main.ModPresent("FCSEnergySolutions"))
                {
                    AGCompat.TryOverflowIntoAlterraGens(subRoot, fishType, ref breedCount);
                }

                if (breedCount > 0)
                {
                    Main.TryOverflowIntoBioreactors(subRoot, fishType, ref breedCount);
                }

                yield break;
            }

            var gameObject = Object.Instantiate(prefab);

            var pickupable = gameObject.EnsureComponent <Pickupable>();

#if SUBNAUTICA_EXP
            TaskResult <Pickupable> taskResult = new TaskResult <Pickupable>();
            yield return(pickupable.PickupAsync(taskResult, false));

            pickupable = taskResult.Get();
#else
            pickupable.Pickup(false);
#endif
            reactor.container.AddItem(pickupable);
        }