コード例 #1
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);
        }