Пример #1
0
 override public void Awake()
 {
     // Init UI
     lblStatus   = GameObjectFinder.FindByName(this.gameObject, "lblStatus").gameObject.GetComponent <Text>();
     lblBattery  = GameObjectFinder.FindByName(this.gameObject, "lblBattery").gameObject.GetComponent <Text>();
     lblEmission = GameObjectFinder.FindByName(this.gameObject, "lblEmission").gameObject.GetComponent <Text>();
     lblDepth    = GameObjectFinder.FindByName(this.gameObject, "lblDepth").gameObject.GetComponent <Text>();
     // Set Depth
     SetEmittedRate();
     lblDepth.text = $"{Mathf.RoundToInt(Mathf.Abs(this.gameObject.transform.position.y)).ToString()} m";
 }
Пример #2
0
        // Start is called before the first frame update
        public void Start()
        {
            IsEnabled = false;

            engine = GameObjectFinder.FindByName(this.gameObject, "Engine");

            anim = engine.GetComponent <Animation>();
            anim.AddClip(Utils.Helper.Bundle.LoadAsset <AnimationClip>("Drilling"), "Drilling");

            btnActivate = GameObjectFinder.FindByName(this.gameObject, "btnActivate").GetComponent <Button>();
            btnActivate.onClick.AddListener(() => StartNStop());

            StartNStop();
        }
Пример #3
0
        public override void Awake()
        {
            try
            {
                this.isBase  = true;
                modulesRoot  = this.transform;
                lightControl = GameObjectFinder.FindByName(this.gameObject, "LightingController").AddComponent <LightingController>();

                voiceNotificationManager         = GameObjectFinder.FindByName(this.gameObject, "VoiceSource").AddComponent <VoiceNotificationManager>();
                voiceNotificationManager.subRoot = this;
                //base.Awake();


                //Spawn a seamoth for reference.
                var seamothRef = CraftData.GetPrefabForTechType(TechType.Seamoth);
                //Get the seamoth's water clip proxy component. This is what displaces the water.
                var seamothProxy = seamothRef.GetComponentInChildren <WaterClipProxy>();
                //Find the parent of all the ship's clip proxys.
                Transform proxyParent = GameObjectFinder.FindByName(this.gameObject, "ProxyParent").transform;
                //Loop through them all
                foreach (Transform child in proxyParent)
                {
                    var waterClip = child.gameObject.AddComponent <WaterClipProxy>();
                    waterClip.shape = WaterClipProxy.Shape.Box;
                    //Apply the seamoth's clip material. No idea what shader it uses or what settings it actually has, so this is an easier option. Reuse the game's assets.
                    waterClip.clipMaterial = seamothProxy.clipMaterial;
                    //You need to do this. By default the layer is 0. This makes it displace everything in the default rendering layer. We only want to displace water.
                    waterClip.gameObject.layer = 28;// SeaMoth layer is 28
                }
                //Unload the prefab to save on resources.
                //Resources.UnloadAsset(seamothRef);
            }
            catch (Exception ex)
            {
                AD3D_HabitatSolution.BO.Utils.Helper.LogEvent($"ERROR : {ex.Message} [{ex.StackTrace}]", true);
            }
        }
Пример #4
0
        public override GameObject GetGameObject()
        {
            //Instantiates a copy of the prefab that is loaded from the AssetBundle loaded above.
            GameObject _prefab = GameObject.Instantiate(Utils.Helper.Bundle.LoadAsset <GameObject>("HabitatTest.prefab"));

            _prefab.name = Constant.HabitatTest_ClassID;
            //Need a tech tag for most prefabs
            var techTag = _prefab.AddComponent <TechTag>();

            techTag.type = TechType;

            _prefab.EnsureComponent <LargeWorldEntity>().cellLevel = LargeWorldEntity.CellLevel.Global;
            _prefab.EnsureComponent <PrefabIdentifier>().ClassId   = ClassID;

            //Collider for the turbine pole and builder tool
            //var collider = _prefab.AddComponent<BoxCollider>();
            //collider.center = new Vector3(-0.1f, 1.2f, 00f);
            //collider.size = new Vector3(3f, 2.35f, 2f);

            //Update all shaders
            ApplySubnauticaShaders(_prefab);

            // Add constructable - This prefab normally isn't constructed.
            ConstructableBase constructible = _prefab.AddComponent <ConstructableBase>();

            constructible.constructedAmount       = 1;
            constructible.allowedInBase           = false;
            constructible.allowedInSub            = false;
            constructible.allowedOutside          = true;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true;
            constructible.allowedOnWall           = false;
            constructible.allowedOnConstructables = false;
            constructible.techType             = this.TechType;
            constructible.rotationEnabled      = true;
            constructible.placeDefaultDistance = 6f;
            constructible.placeMinDistance     = 0.5f;
            constructible.placeMaxDistance     = 15f;
            constructible.surfaceType          = VFXSurfaceTypes.metal;
            constructible.model        = _prefab;//.transform.GetChild(0).gameObject;
            constructible.forceUpright = true;
            //_prefab.AddComponent<LayerSelector>();

            //_prefab.AddComponent<Rigidbody>();
            //var constructableBase = _prefab.AddComponent<ConstructableBase>();
            //var prefabIdentifier = _prefab.AddComponent<PrefabIdentifier>();


            PowerRelay baseRoom  = CraftData.GetPrefabForTechType(TechType.BaseRoom).GetComponent <PowerRelay>();
            var        baseGhost = GameObjectFinder.FindByName(_prefab, "Habitat_Proxy");
            var        baseG     = baseGhost.AddComponent <global::Base>();

            baseG = baseRoom.GetComponent <global::Base>();
            //baseG.isGhost = false;
            var baseGC = baseGhost.AddComponent <BaseAddCellGhost>();

            baseGC = baseRoom.GetComponent <BaseAddCellGhost>();
            //baseGC.cellType = Base.CellType.Moonpool;
            //baseGC.minHeightFromTerrain = 2;
            //baseGC.maxHeightFromTerrain = 10;
            //_prefab.AddComponent<BehaviourLOD>();
            //_prefab.AddComponent<PowerRelay>();
            //_prefab.AddComponent<LiveMixin>();
            //_prefab.AddComponent<Stabilizer>();
            //_prefab.AddComponent<DealDamageOnImpact>();
            //_prefab.AddComponent<SubWaterPlane>();
            //_prefab.AddComponent<CrushDamage>();

            return(_prefab);
        }