コード例 #1
0
 private void DisableUpgradesMeshes(GameObject prefab)
 {
     for (int i = 0; i < 6; i++)
     {
         GameObjectHelpers.FindGameObject(prefab, $"module_{i+1}")?.SetActive(false);
     }
 }
コード例 #2
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(_prefab);
                prefab.name = this.PrefabFileName;

                var center = new Vector3(0f, 0.2518765f, 0f);
                var size   = new Vector3(0.5021304f, 0.5062426f, 0.5044461f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                //Add the FCSTechFabricatorTag component
                prefab.AddComponent <FCSTechFabricatorTag>();

                // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN
                var lwe = prefab.AddComponent <LargeWorldEntity>();
                lwe.cellLevel = LargeWorldEntity.CellLevel.Global;

                prefab.AddComponent <GaspodManager>();
                prefab.AddComponent <GaspodCollectorController>();

                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(null);
        }
コード例 #3
0
        private void btnCreateGame_Click(object sender, RoutedEventArgs e)
        {
            List <Airline> airlines = new List <Airline>();

            foreach (Airline airline in this.SelectedAirlines)
            {
                airlines.Add(airline);
            }

            this.StartData.Opponents = airlines;


            BackgroundWorker bgWorker = new BackgroundWorker();

            bgWorker.DoWork += (y, x) =>
            {
                GameObjectHelpers.CreateGame(this.StartData);
            };
            bgWorker.RunWorkerCompleted += (y, x) =>
            {
                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

                PageNavigator.ClearNavigator();
            };
            bgWorker.RunWorkerAsync();
        }
コード例 #4
0
        private void CreateDisplayedContainer(GameObject prefab)
        {
            GameObject container = prefab.FindChild("model")
                                   .FindChild("mesh_body")
                                   .FindChild("cargo_container")?.gameObject;

            if (container != null)
            {
                QuickLogger.Debug("Container Display Object Created", true);
                var cargoBox = Resources.Load <GameObject>("WorldEntities/Doodads/Debris/Wrecks/Decoration/Starship_cargo");

                if (cargoBox == null)
                {
                    QuickLogger.Debug("Cargo Box could not be found.");
                    return;
                }

                var cargoBoxModel = GameObject.Instantiate <GameObject>(cargoBox);

                GameObjectHelpers.DestroyComponent(cargoBoxModel);
                cargoBoxModel.transform.SetParent(container.transform, false);
                cargoBoxModel.transform.localPosition = new Vector3(0f, -0.3f, 0f);
                cargoBoxModel.transform.localScale    = new Vector3(0.5f, 0.5f, 0.5f);
                cargoBoxModel.transform.Rotate(new Vector3(0, 90, 0));
            }
            else
            {
                QuickLogger.Error("Cannot Find cargo_container in the prefab");
            }
        }
コード例 #5
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            while (!IsPaused && !this.Worker.CancellationPending)
            {
                this.IsFinish = false;

                Stopwatch sw = new Stopwatch();

                sw.Start();
                GameObjectHelpers.SimulateTurn();
                sw.Stop();

                long waittime = (int)Settings.GetInstance().GameSpeed - (sw.ElapsedMilliseconds);


                /*
                 * if ((this.Worker.CancellationPending == true))
                 * {
                 *  e.Cancel = true;
                 *
                 * }*/

                if (waittime > 0)
                {
                    Thread.Sleep((int)waittime);
                }
            }

            this.IsFinish = true;
        }
コード例 #6
0
        private void btnCreateGame_Click(object sender, RoutedEventArgs e)
        {
            this.StartData.Airline       = (Airline)cbAirline.SelectedItem;
            this.StartData.Airport       = (Airport)cbAirport.SelectedItem;
            this.StartData.CEO           = (string)txtCEO.Text;
            this.StartData.HomeCountry   = (Country)cbCountry.SelectedItem;
            this.StartData.TimeZone      = (GameTimeZone)cbTimeZone.SelectedItem;
            this.StartData.LocalCurrency = cbLocalCurrency.IsChecked.Value && this.StartData.HomeCountry.HasLocalCurrency;

            if (!this.StartData.RandomOpponents)
            {
                PageNavigator.NavigateTo(new PageSelectOpponents(this.StartData));
            }
            else
            {
                SplashControl scCreating = UIHelpers.FindChild <SplashControl>(this, "scCreating");

                scCreating.Visibility = System.Windows.Visibility.Visible;

                BackgroundWorker bgWorker = new BackgroundWorker();
                bgWorker.DoWork += (y, x) =>
                {
                    GameObjectHelpers.CreateGame(this.StartData);
                };
                bgWorker.RunWorkerCompleted += (y, x) =>
                {
                    scCreating.Visibility = System.Windows.Visibility.Collapsed;

                    PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

                    PageNavigator.ClearNavigator();
                };
                bgWorker.RunWorkerAsync();
            }
        }
コード例 #7
0
        private void OnGenerate()
        {
            if (PlatformLegsExtended)
            {
                return;
            }

            QuickLogger.Debug("OnGenerate", true);
            if (!_allPlateFormsFound)
            {
                var pillar = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg")?.AddComponent <Pillar>();
                pillar?.Instantiate(this);

                var pillar1 = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg_2")?.AddComponent <Pillar>();
                pillar1?.Instantiate(this);

                var pillar2 = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg_3")?.AddComponent <Pillar>();
                pillar2?.Instantiate(this);

                var pillar3 = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg_4")?.AddComponent <Pillar>();
                pillar3?.Instantiate(this);

                var pillar4 = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg_5")?.AddComponent <Pillar>();
                pillar4?.Instantiate(this);

                var pillar5 = GameObjectHelpers.FindGameObject(gameObject, "PlatfromLeg_6")?.AddComponent <Pillar>();
                pillar5?.Instantiate(this);

                var pillar6 = GameObjectHelpers.FindGameObject(gameObject, "DrillTunnelBase")?.AddComponent <Pillar>();
                pillar6?.Instantiate(this, true);
                _allPlateFormsFound = true;
            }
        }
コード例 #8
0
        private void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            _messageText = GameObjectHelpers.FindGameObject(gameObject, "Message")?.GetComponent <Text>();

            _cancelBTNObject = GameObjectHelpers.FindGameObject(gameObject, "CancelBTN");
            _cancelBTN       = _cancelBTNObject?.GetComponent <Button>();
            _cancelBTNText   = _cancelBTNObject?.GetComponentInChildren <Text>(true);
            _cancelBTN?.onClick.AddListener(() =>
            {
                OnCancelButtonClick?.Invoke(_messageId);
                HideMessageBox();
            });

            _confirmButtonObject = GameObjectHelpers.FindGameObject(gameObject, "ConfirmBTN");
            _confirmBTNText      = _confirmButtonObject?.GetComponentInChildren <Text>(true);
            _confirmBTN          = _confirmButtonObject?.GetComponent <Button>();
            _confirmBTN?.onClick.AddListener(() =>
            {
                OnConfirmButtonClick?.Invoke(_messageId);
                HideMessageBox();
            });

            _initialized = true;
        }
コード例 #9
0
        private void btnCreateGame_Click(object sender, RoutedEventArgs e)
        {
            List <Airline> airlines = new List <Airline>();

            foreach (Airline airline in this.SelectedAirlines)
            {
                airlines.Add(airline);
            }

            this.StartData.Opponents = airlines;

            StandardMasterPage smp = this.Content as StandardMasterPage;

            // SplashControl scCreating = UIHelpers.FindChild<SplashControl>(smp, "scCreating");

            //scCreating.Visibility = System.Windows.Visibility.Visible;

            BackgroundWorker bgWorker = new BackgroundWorker();

            bgWorker.DoWork += (y, x) =>
            {
                GameObjectHelpers.CreateGame(this.StartData);
            };
            bgWorker.RunWorkerCompleted += (y, x) =>
            {
                //  scCreating.Visibility = System.Windows.Visibility.Collapsed;

                PageNavigator.NavigateTo(new PageAirline(GameObject.GetInstance().HumanAirline));

                PageNavigator.ClearNavigator();
            };
            bgWorker.RunWorkerAsync();
        }
コード例 #10
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(_prefab);

                prefab.name = this.PrefabFileName;

                //var ping = prefab.EnsureComponent<PingInstance>();
                //ping.origin = prefab.transform;
                //ping.pingType = PingType.Signal;


                var center = new Vector3(0f, 1.433978f, 0f);
                var size   = new Vector3(2.274896f, 2.727271f, 2.069269f);
                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(null);
            }
        }
コード例 #11
0
        public override void Initialize()
        {
            if (DumpContainer == null)
            {
                DumpContainer = new DumpContainer();
                DumpContainer.Initialize(transform, "Item Display Receptical", AuxPatchers.NotAllowed(), AuxPatchers.CannotBeStored(), this, 1, 1);
            }

            var icon = GameObjectHelpers.FindGameObject(gameObject, "Icon");

            _icon   = icon?.AddComponent <uGUI_Icon>();
            _button = InterfaceHelpers.CreateButton(icon, "IconClick", InterfaceButtonMode.Background,
                                                    OnButtonClick, Color.white, Color.gray, 5.0f);


            _amount = GameObjectHelpers.FindGameObject(gameObject, "Text")?.GetComponent <Text>();

            var addBTN = GameObjectHelpers.FindGameObject(gameObject, "AddBTN");

            InterfaceHelpers.CreateButton(addBTN, "AddBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            var deleteBTN = GameObjectHelpers.FindGameObject(gameObject, "DeleteBTN");

            InterfaceHelpers.CreateButton(deleteBTN, "DeleteBTN", InterfaceButtonMode.Background,
                                          OnButtonClick, Color.gray, Color.white, 5.0f, AuxPatchers.ColorPage());

            AddToBaseManager();

            InvokeRepeating(nameof(UpdateScreen), 1f, 1f);

            IsInitialized = true;
        }
コード例 #12
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(_gameObjectKit);

                if (SetKitLabel(prefab))
                {
                    prefab.name = this.PrefabFileName;

                    PrefabIdentifier prefabID = prefab.EnsureComponent <PrefabIdentifier>();

                    prefabID.ClassId = this.ClassID;

                    var techTag = prefab.EnsureComponent <TechTag>();
                    techTag.type = TechType;

                    var center = new Vector3(0f, 0.2518765f, 0f);
                    var size   = new Vector3(0.5021304f, 0.5062426f, 0.5044461f);

                    GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                    //Add the FCSTechFabricatorTag component
                    prefab.AddComponent <FCSTechFabricatorTag>();

                    return(prefab);
                }
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(null);
        }
コード例 #13
0
        private void Register()
        {
            if (_prefab != null)
            {
                var meshRenderers = _prefab.GetComponentsInChildren <MeshRenderer>();

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = _prefab.GetComponentsInChildren <Renderer>(true);
                SkyApplier skyApplier = _prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = _prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall    = true;
                constructable.allowedOnGround  = false;
                constructable.allowedInSub     = true;
                constructable.allowedInBase    = true;
                constructable.allowedOnCeiling = false;
                constructable.allowedOutside   = false;
                constructable.model            = _prefab.FindChild("model");
                constructable.techType         = TechType;

                GameObjectHelpers.AddConstructableBounds(_prefab, new Vector3(0.4528692f, 0.6682342f, 0.03642998f),
                                                         new Vector3(0, -0.02660185f, 0.05301314f));
            }
        }
コード例 #14
0
        private void FindLaserPoints()
        {
            if (_mono?.gameObject == null)
            {
                return;
            }

            _lasersStarters = GameObjectHelpers.FindGameObject(_mono.gameObject, "Lasers_Main");
            _xBubblesGroup  = GameObjectHelpers.FindGameObject(_mono.gameObject, "xBubbles_Group");
            var lasersEnds = GameObjectHelpers.FindGameObject(_mono.gameObject, "Laser_Ends");

            if (!_lasersStarters || !_xBubblesGroup || !lasersEnds)
            {
                return;
            }

            for (var i = 0; i < _lasersStarters.transform.childCount; i++)
            {
                var laser     = _lasersStarters.transform.GetChild(i);
                var laserComp = laser.GetChild(0).gameObject.AddComponent <LaserScript>();
                var end       = lasersEnds.transform.GetChild(i);
                laserComp.StartPoint = laser.transform;
                laserComp.EndPoint   = end;
            }

            if (!_mono.IsUnderWater())
            {
                ChangeBubblesState(false);
            }
            _initialized = true;
        }
コード例 #15
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(_prefab);

                GameObjectHelpers.AddConstructableBounds(prefab, _bSize, _bCenter);

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

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;
                //========== Allows the building animation and material colors ==========//

                // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN
                var lwe = prefab.AddComponent <LargeWorldEntity>();
                lwe.cellLevel = LargeWorldEntity.CellLevel.Far;

                // Add constructible
                var constructable = prefab.AddComponent <Constructable>();

                constructable.allowedOutside          = true;
                constructable.allowedInBase           = true;
                constructable.allowedOnGround         = true;
                constructable.allowedOnWall           = false;
                constructable.rotationEnabled         = true;
                constructable.allowedOnCeiling        = false;
                constructable.allowedInSub            = true;
                constructable.allowedOnConstructables = false;
                constructable.model    = model;
                constructable.techType = TechType;

                var light = prefab.GetComponentInChildren <Light>();

                var lightR = prefab.AddComponent <RegistredLightSource>();
                lightR.hostLight = light;

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

                AddBubbles(prefab);
                AddVaporBlast(prefab);

                prefab.AddComponent <TechTag>().type = TechType;
                prefab.AddComponent <HydroHarvController>();
                //Apply the glass shader here because of autosort lockers for some reason doesnt like it.
                MaterialHelpers.ApplyGlassShaderTemplate(prefab, "_glass", Mod.ModName);
                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(null);
            }
        }
コード例 #16
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = null;

            try
            {
                prefab = GameObject.Instantiate(_prefab);

                var container2 = GameObject.Instantiate(CreateStorage());
                container2.name             = "StorageContainerUnit";
                container2.transform.parent = prefab.transform;

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall           = false;
                constructable.allowedOnGround         = true;
                constructable.allowedInSub            = false;
                constructable.allowedInBase           = false;
                constructable.allowedOnCeiling        = false;
                constructable.allowedOutside          = true;
                constructable.model                   = prefab.FindChild("model");
                constructable.techType                = TechType;
                constructable.rotationEnabled         = true;
                constructable.allowedOnConstructables = Player.main.GetDepth() > 1;

                // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN
                var lwe = prefab.AddComponent <LargeWorldEntity>();
                lwe.cellLevel = LargeWorldEntity.CellLevel.Global;

                //var beacon = prefab.AddComponent<Beacon>();

                //beacon.label = "DeepDriller";

                var center = new Vector3(0f, 1.579518f, 0f);
                var size   = new Vector3(2.669801f, 2.776958f, 2.464836f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                //prefab.AddComponent<MonoClassTest>();
                prefab.AddComponent <PrefabIdentifier>().ClassId = this.ClassID;
                prefab.AddComponent <FMOD_CustomLoopingEmitter>();
                prefab.AddComponent <ExStorageDepotController>();
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(prefab);
        }
コード例 #17
0
        private void OnLoadProgrammingGrid(DisplayData data)
        {
            try
            {
                if (_isBeingDestroyed)
                {
                    return;
                }

                QuickLogger.Debug($"OnLoadProgrammingGrid : {data.ItemsGrid}", true);

                _programmingGrid.ClearPage();


                var grouped = _mono.UpgradeManager.Upgrades;


                if (data.EndPosition > grouped.Count)
                {
                    data.EndPosition = grouped.Count;
                }

                for (int i = data.StartPosition; i < data.EndPosition; i++)
                {
                    GameObject buttonPrefab = Instantiate(data.ItemsPrefab);

                    if (buttonPrefab == null || data.ItemsGrid == null)
                    {
                        if (buttonPrefab != null)
                        {
                            Destroy(buttonPrefab);
                        }
                        return;
                    }

                    buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false);
                    var upgradeText = buttonPrefab.GetComponentInChildren <Text>();
                    upgradeText.text = grouped.ElementAt(i).Format();

                    var deleteButton = GameObjectHelpers.FindGameObject(buttonPrefab, "DeleteBTN")?.GetComponent <Button>();
                    deleteButton?.onClick.AddListener(Test);
                    var function = grouped.ElementAt(i);
                    deleteButton?.onClick.AddListener(() => { _mono.UpgradeManager.DeleteFunction(function); });

                    var activateButton = GameObjectHelpers.FindGameObject(buttonPrefab, "ActivationBTN")?.GetComponent <Button>();
                    activateButton?.onClick.AddListener(Test);
                    activateButton?.onClick.AddListener(() => { function.ToggleUpdate(); });
                }

                _programmingGrid.UpdaterPaginator(grouped.Count);
            }
            catch (Exception e)
            {
                QuickLogger.Error("Error Caught");
                QuickLogger.Error($"Error Message: {e.Message}");
                QuickLogger.Error($"Error StackTrace: {e.StackTrace}");
            }
        }
コード例 #18
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = null;

            try
            {
                prefab = GameObject.Instantiate(_prefab);

                var meshRenderers = prefab.GetComponentsInChildren <MeshRenderer>();

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall    = false;
                constructable.allowedOnGround  = true;
                constructable.allowedInSub     = false;
                constructable.allowedInBase    = false;
                constructable.allowedOnCeiling = false;
                constructable.allowedOutside   = true;
                constructable.model            = prefab.FindChild("model");
                constructable.techType         = TechType;
                constructable.rotationEnabled  = true;

                // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN
                var lwe = prefab.AddComponent <LargeWorldEntity>();
                lwe.cellLevel = LargeWorldEntity.CellLevel.Global;

                //var beacon = prefab.AddComponent<Beacon>();


                var center = new Vector3(0, 3.048428f, 0);
                var size   = new Vector3(4.821606f, 3.35228f, 4.941598f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                //beacon.label = "DeepDriller";
                //prefab.AddComponent<LiveMixin>();
                prefab.AddComponent <PrefabIdentifier>().ClassId = this.ClassID;
                prefab.AddComponent <FMOD_CustomLoopingEmitter>();
                prefab.AddComponent <FCSDeepDrillerController>();
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(prefab);
        }
コード例 #19
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = null;

            try
            {
                prefab = GameObject.Instantiate <GameObject>(_prefab);

                //========== Allows the building animation and material colors ==========//
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = prefab.GetComponentsInChildren <Renderer>();
                skyApplier.anchorSky = Skies.Auto;

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall        = false;
                constructable.allowedOnGround      = true;
                constructable.allowedInSub         = false;
                constructable.allowedInBase        = false;
                constructable.allowedOnCeiling     = false;
                constructable.allowedOutside       = true;
                constructable.model                = prefab.FindChild("model");
                constructable.techType             = TechType;
                constructable.rotationEnabled      = true;
                constructable.forceUpright         = true;
                constructable.placeDefaultDistance = 10f;

                // Add large world entity ALLOWS YOU TO SAVE ON TERRAIN
                var lwe = prefab.AddComponent <LargeWorldEntity>();
                lwe.cellLevel = LargeWorldEntity.CellLevel.Global;

                //var beacon = prefab.AddComponent<Beacon>();


                var center = new Vector3(0, 3.106274f, 0);
                var size   = new Vector3(6.85554f, 6.670462f, 7.002856f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                //beacon.label = "DeepDriller";
                //prefab.AddComponent<LiveMixin>();
                prefab.AddComponent <PrefabIdentifier>().ClassId = this.ClassID;
                prefab.AddComponent <TechTag>().type             = TechTypeID;
                prefab.AddComponent <FMOD_CustomLoopingEmitter>();
                prefab.AddComponent <FCSDeepDrillerController>();
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(prefab);
        }
コード例 #20
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(_Prefab);

                //========== Allows the building animation and material colors ==========//

                Shader     shader  = Shader.Find("MarmosetUBER");
                Renderer[] renders = prefab.GetComponentsInChildren <Renderer>();
                foreach (Renderer renderer in renders)
                {
                    renderer.material.shader = shader;
                }

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

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall    = false;
                constructable.allowedOnGround  = true;
                constructable.allowedInSub     = true;
                constructable.allowedInBase    = true;
                constructable.allowedOnCeiling = false;
                constructable.allowedOutside   = false;
                constructable.rotationEnabled  = true;
                constructable.model            = prefab.FindChild("model");
                constructable.techType         = TechType;

                //Get the Size and Center of a box ow collision around the mesh that will be used as bounds
                var center = new Vector3(0.05496028f, 1.019654f, 0.05290359f);
                var size   = new Vector3(0.9710827f, 1.908406f, 0.4202727f);

                //Create or get the constructable bounds
                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                var techTag = prefab.EnsureComponent <TechTag>();
                techTag.type = TechType;

                prefab.EnsureComponent <PrefabIdentifier>().ClassId = this.ClassID;
                prefab.EnsureComponent <AnimationManager>();
                prefab.EnsureComponent <ARSolutionsSeaBreezeController>();

                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(null);
            }
        }
コード例 #21
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = GameObject.Instantiate(_prefab);

            //========== Allows the building animation and material colors ==========//

            Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
            SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();

            skyApplier.renderers = renderers;
            skyApplier.anchorSky = Skies.Auto;

            //========== Allows the building animation and material colors ==========//


            QuickLogger.Debug("Adding Constructible");

            // Add constructible
            var constructable = prefab.EnsureComponent <Constructable>();

            constructable.allowedOnWall    = true;
            constructable.allowedOnGround  = false;
            constructable.allowedInSub     = true;
            constructable.allowedInBase    = true;
            constructable.allowedOnCeiling = false;
            constructable.allowedOutside   = false;
            constructable.model            = prefab.FindChild("model");
            constructable.techType         = TechType;

            // Add constructible bounds

            var center = new Vector3(0.2078698f, -0.04198265f, 0.2626062f);
            var size   = new Vector3(1.412603f, 1.45706f, 0.4747875f);

            GameObjectHelpers.AddConstructableBounds(prefab, size, center);

            QuickLogger.Debug("GetOrAdd TechTag");
            // Allows the object to be saved into the game
            //by setting the TechTag and the PrefabIdentifier
            prefab.EnsureComponent <TechTag>().type = this.TechType;

            QuickLogger.Debug("GetOrAdd PrefabIdentifier");

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

            QuickLogger.Debug("Add GameObject CustomBatteryController");

            prefab.EnsureComponent <FCSPowerStorageDisplay>();

            prefab.EnsureComponent <FCSPowerStorageController>();

            QuickLogger.Debug("Made GameObject");

            return(prefab);
        }
コード例 #22
0
        public override void Initialize()
        {
            if (NameController == null)
            {
                NameController = new ExStorageDepotNameManager();
                NameController.Initialize(this);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <ExStorageDepotAnimationManager>();
            }

            if (Storage == null)
            {
                Storage = gameObject.AddComponent <ExStorageDepotStorageManager>();
                Storage.Initialize(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage);
                DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed;
            }

            if (Display == null)
            {
                Display = gameObject.AddComponent <ExStorageDepotDisplayManager>();
                Display.Initialize(this);
            }

            var locker = GameObjectHelpers.FindGameObject(gameObject, "Locker", SearchOption.StartsWith);
            var sRoot  = GameObjectHelpers.FindGameObject(gameObject, "StorageRoot");

            if (locker != null)
            {
                Destroy(locker);
            }

            if (sRoot != null)
            {
                Destroy(sRoot);
            }

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, Storage, new ExStoragePowerManager(), true);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(FCSConnectableDevice, GetPrefabID(), Mod.ExStorageTabID);
            }

            _initialized = true;
        }
コード例 #23
0
        internal void Register()
        {
            HydroponicHarvestersModelPrefab.GetPrefabs();

            _prefab = HydroponicHarvestersModelPrefab.BottlePrefab;

            if (_prefab == null)
            {
                QuickLogger.Error("FloraKleen prefab is null");
                return;
            }

            GameObjectHelpers.AddConstructableBounds(_prefab, new Vector3(0.1969692f, 0.25098f, 0.1916926f), new Vector3(0, -0.01675579f, 0));

            QuickLogger.Debug("Added Constructable Bounds");

            //Make the rigid body isKinematic so it doesnt shake the cyclops
            var rb = _prefab.AddComponent <Rigidbody>();

            rb.isKinematic = true;
            QuickLogger.Debug("Added Rigid Body");



            // Make the object drop slowly in water
            var wf = _prefab.EnsureComponent <WorldForces>();

            wf.underwaterGravity = 0;
            wf.underwaterDrag    = 10f;
            wf.enabled           = true;
            QuickLogger.Debug("Ensuring World Forces");

            // Add fabricating animation
            var fabricatingA = _prefab.EnsureComponent <VFXFabricating>();

            fabricatingA.localMinY   = -0.1f;
            fabricatingA.localMaxY   = 0.6f;
            fabricatingA.posOffset   = new Vector3(0f, 0f, 0f);
            fabricatingA.eulerOffset = new Vector3(0f, 0f, 0f);
            fabricatingA.scaleFactor = 1.0f;
            QuickLogger.Debug("Ensuring VFXFabricating");

            //// Set proper shaders (for crafting animation)
            var renderer = _prefab.GetComponentInChildren <Renderer>();

            QuickLogger.Debug("Getting Renderer");

            // Update sky applier
            var applier = _prefab.EnsureComponent <SkyApplier>();

            applier.renderers = new Renderer[] { renderer };
            applier.anchorSky = Skies.Auto;
            QuickLogger.Debug("Ensuring SkyApplier");
        }
コード例 #24
0
        private void FindSlots()
        {
            for (int i = 0; i < 6; i++)
            {
                _slots[i] = GameObjectHelpers.FindGameObject(gameObject, $"module_{i + 1}");
            }

            if (_slots.Count(x => x != null) == 6)
            {
                _slotsFound = true;
            }
        }
コード例 #25
0
        private void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            _checkMark = GameObjectHelpers.FindGameObject(gameObject, "CheckMark");
            if (_checkMark == null)
            {
                QuickLogger.Debug("Cannot find the CheckMark");
            }

            _initialized = true;
        }
コード例 #26
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(DSSModelPrefab.FloorMountRackPrefab);

                var size   = new Vector3(0.5399321f, 0.9509504f, 0.5594633f);
                var center = new Vector3(0f, 0.5926822f, 0f);
                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

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

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;
                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.AddComponent <Constructable>();

                constructable.allowedOutside          = false;
                constructable.allowedInBase           = true;
                constructable.allowedOnGround         = true;
                constructable.allowedOnWall           = false;
                constructable.rotationEnabled         = true;
                constructable.allowedOnCeiling        = false;
                constructable.allowedInSub            = true;
                constructable.allowedOnConstructables = false;
                constructable.model    = model;
                constructable.techType = TechType;

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

                prefab.AddComponent <TechTag>().type = TechType;
                prefab.AddComponent <DSSRackController>();

                //Apply the glass shader here because of autosort lockers for some reason doesnt like it.
                MaterialHelpers.ApplyGlassShaderTemplate(prefab, "_glass", Mod.ModName);
                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(null);
            }
        }
コード例 #27
0
        public override GameObject GetGameObject()
        {
            try
            {
                var prefab = GameObject.Instantiate(DSSModelPrefab.ItemDisplayPrefab);

                var size   = new Vector3(0.6082662f, 0.8234746f, 0.2771493f);
                var center = new Vector3(0f, -0.003837466f, 0.1747157f);
                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

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

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;
                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.AddComponent <Constructable>();

                constructable.allowedOutside          = false;
                constructable.allowedInBase           = true;
                constructable.allowedOnGround         = false;
                constructable.allowedOnWall           = true;
                constructable.rotationEnabled         = false;
                constructable.allowedOnCeiling        = false;
                constructable.allowedInSub            = true;
                constructable.allowedOnConstructables = false;
                constructable.model    = model;
                constructable.techType = TechType;

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

                prefab.AddComponent <TechTag>().type = TechType;
                prefab.AddComponent <DSSItemDisplayController>();

                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(null);
            }
        }
コード例 #28
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = null;

            try
            {
                prefab = GameObject.Instantiate(_Prefab);

                var meshRenderers = prefab.GetComponentsInChildren <MeshRenderer>();

                //========== Allows the building animation and material colors ==========//
                Shader     shader     = Shader.Find("MarmosetUBER");
                Renderer[] renderers  = prefab.GetComponentsInChildren <Renderer>();
                SkyApplier skyApplier = prefab.EnsureComponent <SkyApplier>();
                skyApplier.renderers = renderers;
                skyApplier.anchorSky = Skies.Auto;

                //========== Allows the building animation and material colors ==========//

                // Add constructible
                var constructable = prefab.EnsureComponent <Constructable>();
                constructable.allowedOnWall    = false;
                constructable.allowedOnGround  = true;
                constructable.allowedInSub     = true;
                constructable.allowedInBase    = true;
                constructable.allowedOnCeiling = false;
                constructable.allowedOutside   = false;
                constructable.model            = prefab.FindChild("model");
                constructable.techType         = TechType;
                constructable.rotationEnabled  = true;

                var center = new Vector3(0.04392624f, 1.421124f, 0f);
                var size   = new Vector3(2.401972f, 2.700523f, 2.280661f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                prefab.EnsureComponent <PrefabIdentifier>().ClassId = this.ClassID;
                prefab.AddComponent <FMOD_CustomLoopingEmitter>();
                prefab.EnsureComponent <AMMiniMedBayController>();
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
            }

            return(prefab);
        }
コード例 #29
0
        public override GameObject GetGameObject()
        {
            try
            {
                var        prefab       = GameObject.Instantiate(_Prefab);
                GameObject consoleModel = prefab.FindChild("model");

                // Update sky applier
                SkyApplier skyApplier = prefab.AddComponent <SkyApplier>();
                skyApplier.renderers = consoleModel.GetComponentsInChildren <MeshRenderer>();
                skyApplier.anchorSky = Skies.Auto;

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

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

                var center = new Vector3(-0.006649137f, 0f, 0.1839597f);
                var size   = new Vector3(2.706617f, 1.698831f, 0.3483825f);

                GameObjectHelpers.AddConstructableBounds(prefab, size, center);

                //Add the prefabIdentifier
                PrefabIdentifier prefabID = prefab.AddComponent <PrefabIdentifier>();
                prefabID.ClassId = this.ClassID;
                prefab.EnsureComponent <AIPowerCellSocketAnimator>();
                prefab.EnsureComponent <AIPowerCellSocketPowerManager>();
                prefab.EnsureComponent <AIPowerCellSocketController>();

                return(prefab);
            }
            catch (Exception e)
            {
                QuickLogger.Error <AIPowerCellSocketBuildable>(e.Message);
                return(null);
            }
        }
コード例 #30
0
        public override void Initialize()
        {
            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <AlterraGenPowerManager>();
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, AlterraGenBuildable.BodyMaterial);
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, "AlterraGen Receptacle", AlterraGenBuildable.NotAllowedItem(), AlterraGenBuildable.StorageFullMessage(), PowerManager, 3, 3);
            }

            if (_fcsConnectableDevice == null)
            {
                _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(_fcsConnectableDevice, GetPrefabID(), Mod.ModTabID);
            }


            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <AlterraGenDisplayManager>();
                DisplayManager.Setup(this);
            }

            _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles");

            IsInitialized = true;
        }