Esempio n. 1
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                // Get objects
                GameObject model = this.GameObject.FindChild("Model");

                // Rotate model
                //model.transform.localEulerAngles = new Vector3(model.transform.localEulerAngles.x - 90f, model.transform.localEulerAngles.y, model.transform.localEulerAngles.z);

                // Move model
                //model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.032f, model.transform.localPosition.z);

                // Apply shaders and materials
                var     renderers    = this.GameObject.GetAllComponentsInChildren <Renderer>();
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture normal1      = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_normal");
                Texture spec1        = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_spec");
                Texture illum1       = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_illum");
                if (renderers.Length > 0)
                {
                    foreach (Renderer rend in renderers)
                    {
                        if (rend.materials.Length > 0)
                        {
                            foreach (Material tmpMat in rend.materials)
                            {
                                if (string.Compare(tmpMat.name, "precursor_lab_warper_liquid (Instance)", true, CultureInfo.InvariantCulture) != 0 && !tmpMat.name.StartsWith("precursor_lab_warper_tube_", true, CultureInfo.InvariantCulture))
                                {
                                    tmpMat.shader = marmosetUber;
                                    if (string.Compare(tmpMat.name, "precursor_lab_warper (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_SpecTex", spec1);
                                        tmpMat.SetTexture("_BumpMap", normal1);
                                        tmpMat.SetTexture("_Illum", illum1);
                                        tmpMat.SetFloat("_EmissionLM", 1f);

                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("_ZWRITE_ON");
                                    }
                                    else if (string.Compare(tmpMat.name, "precursor_lab_warper_box (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_SpecTex", spec1);
                                        tmpMat.SetTexture("_BumpMap", normal1);
                                        tmpMat.SetTexture("_Illum", illum1);
                                        tmpMat.SetFloat("_EmissionLM", 1f);

                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("_ZWRITE_ON");
                                    }
                                }
                            }
                        }
                    }
                }

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size   = new Vector3(0.0075f, 0.0075f, 0.038f);
                collider.center = new Vector3(collider.center.x, collider.center.y, collider.center.z + 0.019f);

                // Add sky applier
#if BELOWZERO
                BaseModuleLighting bml = this.GameObject.GetComponent <BaseModuleLighting>();
                if (bml == null)
                {
                    bml = this.GameObject.GetComponentInChildren <BaseModuleLighting>();
                }
                if (bml == null)
                {
                    bml = this.GameObject.AddComponent <BaseModuleLighting>();
                }
#endif
                SkyApplier applier = this.GameObject.AddComponent <SkyApplier>();
                applier.renderers    = renderers;
                applier.anchorSky    = Skies.Auto;
                applier.updaterIndex = 0;

                // Add contructable
                Constructable constructable = this.GameObject.AddComponent <Constructable>();
                constructable.allowedInBase           = true;
                constructable.allowedInSub            = true;
                constructable.allowedOnCeiling        = true;
                constructable.allowedOnWall           = true;
                constructable.allowedOnConstructables = true;
                constructable.allowedOutside          = false;
                constructable.allowedOnGround         = false;
#if BELOWZERO
                constructable.allowedUnderwater = true;
#endif
                constructable.controlModelState     = true;
                constructable.deconstructionAllowed = true;
                constructable.rotationEnabled       = true;
                constructable.model            = model;
                constructable.techType         = this.TechType;
                constructable.placeMinDistance = 0.6f;
                constructable.enabled          = true;

                // Add constructable bounds
                ConstructableBounds bounds = this.GameObject.AddComponent <ConstructableBounds>();
                //bounds.bounds.position = new Vector3(bounds.bounds.position.x, bounds.bounds.position.y + 0.032f, bounds.bounds.position.z);

                // Add warper specimen controller
                var warperSpecimenController = this.GameObject.AddComponent <WarperSpecimenController>();

                // Define unlock conditions
                if (ConfigSwitcher.AddItemsWhenDiscovered)
                {
                    SMLHelper.V2.Handlers.KnownTechHandler.SetAnalysisTechEntry(TechType.PrecursorWarper, new TechType[] { this.TechType });
                }

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Add new TechType to the buildables
                SMLHelper.V2.Handlers.CraftDataHandler.AddBuildable(this.TechType);
                SMLHelper.V2.Handlers.CraftDataHandler.AddToGroup(TechGroup.Miscellaneous, TechCategory.Misc, this.TechType);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, AssetsHelper.Assets.LoadAsset <Sprite>("warper_icon_1"));

                this.IsRegistered = true;
            }
        }
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                // Get model
                GameObject model = this.GameObject.FindChild("OutdoorLadderModel");

                // Scale model
                model.transform.localScale *= 100.0f;

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject, LargeWorldEntity.CellLevel.Far);

                // Add tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size   = new Vector3(0.3f, 2.7f, 0.07f);
                collider.center = new Vector3(collider.center.x, collider.center.y + 0.55f, collider.center.z - 0.24f);

                // Set proper shaders and materials
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture illum1       = AssetsHelper.Assets.LoadAsset <Texture>("base_ladder_01");
                Texture normal1      = AssetsHelper.Assets.LoadAsset <Texture>("base_ladder_01_normal");
                var     renderers    = this.GameObject.GetComponentsInChildren <Renderer>();
                if (renderers != null && renderers.Length > 0)
                {
                    foreach (Renderer rend in renderers)
                    {
                        foreach (Material tmpMat in rend.materials)
                        {
                            tmpMat.shader = marmosetUber;
                            if (tmpMat.name.StartsWith("base_ladder_01"))
                            {
                                tmpMat.SetTexture("_BumpMap", normal1);
#if SUBNAUTICA
                                tmpMat.SetTexture("_Illum", illum1);
                                tmpMat.SetFloat("_EmissionLM", 0.05f);
                                tmpMat.EnableKeyword("MARMO_EMISSION");
#endif
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                        }
                    }
                }

                // Add contructable
                Constructable constructable = this.GameObject.AddComponent <Constructable>();
                constructable.allowedInBase           = false;
                constructable.allowedInSub            = false;
                constructable.allowedOutside          = true;
                constructable.allowedOnCeiling        = true;
                constructable.allowedOnWall           = true;
                constructable.allowedOnGround         = true;
                constructable.allowedOnConstructables = true;
#if BELOWZERO
                constructable.allowedUnderwater = true;
#endif
                constructable.controlModelState     = true;
                constructable.deconstructionAllowed = true;
                constructable.rotationEnabled       = true;
                constructable.model            = model;
                constructable.techType         = this.TechType;
                constructable.surfaceType      = VFXSurfaceTypes.metal;
                constructable.placeMinDistance = 0.6f;
                constructable.placeMaxDistance = 10.0f;
                constructable.enabled          = true;

                // Add constructable bounds
                ConstructableBounds bounds = this.GameObject.AddComponent <ConstructableBounds>();

                // Add sky applier
#if BELOWZERO
                BaseModuleLighting bml = this.GameObject.GetComponent <BaseModuleLighting>();
                if (bml == null)
                {
                    bml = this.GameObject.GetComponentInChildren <BaseModuleLighting>();
                }
                if (bml == null)
                {
                    bml = this.GameObject.AddComponent <BaseModuleLighting>();
                }
#endif
                SkyApplier applier = this.GameObject.GetComponent <SkyApplier>();
                if (applier == null)
                {
                    applier = this.GameObject.GetComponentInChildren <SkyApplier>();
                }
                if (applier == null)
                {
                    applier = this.GameObject.AddComponent <SkyApplier>();
                }
                applier.renderers    = renderers;
                applier.anchorSky    = Skies.Auto;
                applier.updaterIndex = 0;
#if SUBNAUTICA
                applier.emissiveFromPower = true; // Emissive from power
#endif
                applier.enabled = true;

                // Add outdoor ladder controller
                OutdoorLadderController controller = this.GameObject.AddComponent <OutdoorLadderController>();

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Add new TechType to the buildables
                SMLHelper.V2.Handlers.CraftDataHandler.AddBuildable(this.TechType);
                SMLHelper.V2.Handlers.CraftDataHandler.AddToGroup(TechGroup.ExteriorModules, TechCategory.ExteriorModule, this.TechType);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, SpriteManager.Get(TechType.BaseLadder));

                this.IsRegistered = true;
            }
        }
Esempio n. 3
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                GameObject model = this.GameObject.FindChild("Model");

                // Translate model
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.015f, model.transform.localPosition.z);

                // Set tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add prefab identifier
                this.GameObject.AddComponent <PrefabIdentifier>().ClassId = this.ClassID;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size   = new Vector3(0.3f, 0.1f, 0.2f);
                collider.center = new Vector3(collider.center.x, collider.center.y + 0.05f, collider.center.z);

                // Set proper shaders (for crafting animation)
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture normal1      = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_normal");
                Texture spec1        = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_spec");
                Texture illum1       = AssetsHelper.Assets.LoadAsset <Texture>("precursor_lab_warper_illum");
                Texture normal2      = AssetsHelper.Assets.LoadAsset <Texture>("warper_normal");
                Texture spec2        = AssetsHelper.Assets.LoadAsset <Texture>("warper_spec");
                Texture illum2       = AssetsHelper.Assets.LoadAsset <Texture>("warper_illum");
                Texture normal3      = AssetsHelper.Assets.LoadAsset <Texture>("warper_entrails_normal");
                Texture spec3        = AssetsHelper.Assets.LoadAsset <Texture>("warper_entrails_spec");
                Texture illum3       = AssetsHelper.Assets.LoadAsset <Texture>("warper_entrails_illum");
                var     renderers    = this.GameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer rend in renderers)
                {
                    if (rend.materials.Length > 0)
                    {
                        foreach (Material tmpMat in rend.materials)
                        {
                            if (string.Compare(tmpMat.name, "precursor_lab_warper_tube_01 (Instance)", true, CultureInfo.InvariantCulture) != 0 &&
                                string.Compare(tmpMat.name, "precursor_lab_warper_tube_02 (Instance)", true, CultureInfo.InvariantCulture) != 0 &&
                                string.Compare(tmpMat.name, "precursor_lab_warper_liquid (Instance)", true, CultureInfo.InvariantCulture) != 0)
                            {
                                tmpMat.shader = marmosetUber;
                                if (string.Compare(tmpMat.name, "precursor_lab_warper (Instance)", true, CultureInfo.InvariantCulture) == 0 ||
                                    string.Compare(tmpMat.name, "precursor_lab_warper_box (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                {
                                    tmpMat.SetTexture("_SpecTex", spec1);
                                    tmpMat.SetTexture("_BumpMap", normal1);
                                    tmpMat.SetTexture("_Illum", illum1);
                                    tmpMat.SetFloat("_EmissionLM", 1f);

                                    tmpMat.EnableKeyword("MARMO_SPECMAP");
                                    tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                    tmpMat.EnableKeyword("MARMO_EMISSION");
                                    tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                }
                                else if (string.Compare(tmpMat.name, "Warper (Instance)", true, CultureInfo.InvariantCulture) == 0 ||
                                         string.Compare(tmpMat.name, "Warper_alpha (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                {
                                    tmpMat.SetTexture("_SpecTex", spec2);
                                    tmpMat.SetTexture("_BumpMap", normal2);
                                    tmpMat.SetTexture("_Illum", illum2);
                                    tmpMat.SetFloat("_EmissionLM", 1f);

                                    tmpMat.EnableKeyword("MARMO_SPECMAP");
                                    tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                    tmpMat.EnableKeyword("MARMO_EMISSION");
                                    tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                }
                                else if (string.Compare(tmpMat.name, "warper_entrails (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                {
                                    tmpMat.SetTexture("_SpecTex", spec3);
                                    tmpMat.SetTexture("_BumpMap", normal3);
                                    tmpMat.SetTexture("_Illum", illum3);
                                    tmpMat.SetFloat("_EmissionLM", 1f);

                                    tmpMat.EnableKeyword("MARMO_SPECMAP");
                                    tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                    tmpMat.EnableKeyword("MARMO_EMISSION");
                                    tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                }
                            }
                        }
                    }
                }

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add sky applier
                PrefabsHelper.SetDefaultSkyApplier(this.GameObject, renderers);

                // We can pick this item
                PrefabsHelper.SetDefaultPickupable(this.GameObject);

                // We can place this item
                this.GameObject.AddComponent <CustomPlaceToolController>();
                var placeTool = this.GameObject.AddComponent <GenericPlaceTool>();
                placeTool.allowedInBase          = true;
                placeTool.allowedOnConstructable = true;
                placeTool.allowedOnRigidBody     = true;
                placeTool.allowedOnBase          = true;
                placeTool.allowedOnGround        = true;
                placeTool.allowedOnCeiling       = false;
                placeTool.allowedOnWalls         = false;
                placeTool.allowedOutside         = ConfigSwitcher.AllowPlaceOutside;
                placeTool.rotationEnabled        = true;
                placeTool.enabled              = true;
                placeTool.hasAnimations        = false;
                placeTool.hasBashAnimation     = false;
                placeTool.hasFirstUseAnimation = false;
                placeTool.ghostModelPrefab     = this.GameObject;
                placeTool.mainCollider         = collider;
                placeTool.pickupable           = this.GameObject.GetComponent <Pickupable>();
                placeTool.drawTime             = 0.5f;
                placeTool.dropTime             = 1;
                placeTool.holsterTime          = 0.35f;

                // Define unlock conditions
                if (ConfigSwitcher.AddItemsWhenDiscovered)
                {
                    SMLHelper.V2.Handlers.KnownTechHandler.SetAnalysisTechEntry(TechType.PrecursorLostRiverWarperParts, new TechType[] { this.TechType });
                }

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Add the new TechType to Hand Equipment type.
                SMLHelper.V2.Handlers.CraftDataHandler.SetEquipmentType(this.TechType, EquipmentType.Hand);

                // Set quick slot type.
                SMLHelper.V2.Handlers.CraftDataHandler.SetQuickSlotType(this.TechType, QuickSlotType.Selectable);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, AssetsHelper.Assets.LoadAsset <Sprite>("warper_icon_5"));

                this.IsRegistered = true;
            }
        }
Esempio n. 4
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                // Get model
                GameObject model = this.GameObject.FindChild("docking_clerical_penholder");

                // Scale
                model.transform.localScale *= 4f;
                // Translate
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.001f, model.transform.localPosition.z);
                // Rotate
                //model.transform.localEulerAngles = new Vector3(model.transform.localEulerAngles.x, model.transform.localEulerAngles.y + -25.0f, model.transform.localEulerAngles.z);

                // Set tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add prefab identifier
                var pi = this.GameObject.AddComponent <PrefabIdentifier>();
                pi.ClassId = this.ClassID;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size          = new Vector3(0.1f, 0.1f, 0.1f);
                collider.contactOffset = 0.01f;
                //collider.center = new Vector3(collider.center.x - 0.15f, collider.center.y + 0.1f, collider.center.z);
                collider.enabled = true;

                // Set proper shaders (for crafting animation)
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture normal       = AssetsHelper.Assets.LoadAsset <Texture>("docking_clerical_01_normal");
                var     renderers    = this.GameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer rend in renderers)
                {
                    foreach (Material tmpMat in rend.materials)
                    {
                        tmpMat.shader = marmosetUber;
                        if (string.Compare(tmpMat.name, "docking_clerical_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                        {
                            tmpMat.SetTexture("_BumpMap", normal);
                            tmpMat.EnableKeyword("MARMO_NORMALMAP");
                            tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                        }
                    }
                }

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add rigid body
                PrefabsHelper.SetDefaultRigidBody(this.GameObject);
                Rigidbody rb = this.GameObject.GetComponent <Rigidbody>();
                rb.mass = 0.4f;

                // Add sky applier
                PrefabsHelper.SetDefaultSkyApplier(this.GameObject, renderers);

                // We can pick this item
                PrefabsHelper.SetDefaultPickupable(this.GameObject);

                // We can place this item
                PrefabsHelper.SetDefaultPlaceTool(this.GameObject, collider);

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Add the new TechType to Hand Equipment type.
                SMLHelper.V2.Handlers.CraftDataHandler.SetEquipmentType(this.TechType, EquipmentType.Hand);

                // Set quick slot type.
                SMLHelper.V2.Handlers.CraftDataHandler.SetQuickSlotType(this.TechType, QuickSlotType.Selectable);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, AssetsHelper.Assets.LoadAsset <Sprite>("penholdericon"));

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                this.IsRegistered = true;
            }
        }
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                GameObject model = this.GameObject.FindChild("Lost_river_sea_dragon_skeleton");

                // Scale model
                model.transform.localScale *= 2.0f;

                // Translate model
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.19f, model.transform.localPosition.z);

                // Rotate model
                model.transform.localEulerAngles = new Vector3(model.transform.localEulerAngles.x, model.transform.localEulerAngles.y + 90.0f, model.transform.localEulerAngles.z + 35.0f);

                // Set tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size = new Vector3(0.6f, 0.5f, 0.6f);

                // Set proper shaders (for crafting animation)
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture normal       = AssetsHelper.Assets.LoadAsset <Texture>("Lost_river_sea_dragon_skeleton_bones_normal");
                Texture normal2      = AssetsHelper.Assets.LoadAsset <Texture>("Lost_river_sea_dragon_skeleton_skull_normal");
                var     renderers    = this.GameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer rend in renderers)
                {
                    foreach (Material tmpMat in rend.materials)
                    {
                        tmpMat.shader = marmosetUber;
                        if (string.Compare(tmpMat.name, "Lost_river_sea_dragon_skeleton_bones (Instance)", true, CultureInfo.InvariantCulture) == 0)
                        {
                            tmpMat.SetTexture("_BumpMap", normal);
                            tmpMat.EnableKeyword("MARMO_NORMALMAP");
                            tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                        }
                        else if (string.Compare(tmpMat.name, "Lost_river_sea_dragon_skeleton_skull (Instance)", true, CultureInfo.InvariantCulture) == 0)
                        {
                            tmpMat.SetTexture("_BumpMap", normal2);
                            tmpMat.EnableKeyword("MARMO_NORMALMAP");
                            tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                        }
                    }
                }

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add rigid body
                PrefabsHelper.SetDefaultRigidBody(this.GameObject);

                // Add sky applier
                PrefabsHelper.SetDefaultSkyApplier(this.GameObject, renderers);

                // We can pick this item
                PrefabsHelper.SetDefaultPickupable(this.GameObject);

                // We can place this item
                PrefabsHelper.SetDefaultPlaceTool(this.GameObject, collider);

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Set item occupies 4 slots
                SMLHelper.V2.Handlers.CraftDataHandler.SetItemSize(this.TechType, new Vector2int(2, 2));

                // Add the new TechType to Hand Equipment type
                SMLHelper.V2.Handlers.CraftDataHandler.SetEquipmentType(this.TechType, EquipmentType.Hand);

                // Set quick slot type
                SMLHelper.V2.Handlers.CraftDataHandler.SetQuickSlotType(this.TechType, QuickSlotType.Selectable);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, AssetsHelper.Assets.LoadAsset <Sprite>("seadragonskeletonicon"));

                this.IsRegistered = true;
            }
        }
        public override GameObject GetGameObject()
        {
            GameObject prefab = GameObject.Instantiate(this.GameObject);

            prefab.name = this.ClassID;

            // Remove unwanted elements
            GameObject.DestroyImmediate(prefab.GetComponent <Rigidbody>());
            GameObject.DestroyImmediate(prefab.GetComponent <IncubatorEgg>());
            GameObject.DestroyImmediate(prefab.GetComponent <VFXController>());
            GameObject.DestroyImmediate(prefab.GetComponentInChildren <Animator>());
            GameObject.DestroyImmediate(prefab.GetComponentInChildren <IncubatorEggAnimation>());

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

            // Rotate model
            model.transform.localEulerAngles = new Vector3(model.transform.localEulerAngles.x, model.transform.localEulerAngles.y + 180f, model.transform.localEulerAngles.z);

            // Scale model
            model.transform.localScale *= 0.2f;

            // Scale colliders
            foreach (SphereCollider c in prefab.GetAllComponentsInChildren <SphereCollider>())
            {
                c.radius *= 0.15f;
            }

            // Update TechTag
            var techTag = prefab.GetComponent <TechTag>();

            if (techTag == null)
            {
                if ((techTag = prefab.GetComponentInChildren <TechTag>()) == null)
                {
                    techTag = prefab.AddComponent <TechTag>();
                }
            }
            techTag.type = this.TechType;

            // Update prefab ID
            var prefabId = prefab.GetComponent <PrefabIdentifier>();

            if (prefabId == null)
            {
                if ((prefabId = prefab.GetComponentInChildren <PrefabIdentifier>()) == null)
                {
                    prefabId = prefab.AddComponent <PrefabIdentifier>();
                }
            }
            prefabId.ClassId = this.ClassID;

            // Update sky applier
            PrefabsHelper.SetDefaultSkyApplier(prefab);

            // Set large world entity
            PrefabsHelper.SetDefaultLargeWorldEntity(prefab);

            // We can pick this item
            PrefabsHelper.SetDefaultPickupable(prefab);

            // We can place this item
            prefab.AddComponent <CustomPlaceToolController>();
            prefab.AddComponent <EggSeaEmperor_PT>();
            PrefabsHelper.SetDefaultPlaceTool(prefab);

            // Add fabricating animation
            var fabricating = prefab.AddComponent <VFXFabricating>();

            fabricating.localMinY   = -0.2f;
            fabricating.localMaxY   = 0.8f;
            fabricating.posOffset   = new Vector3(0f, 0.03f, 0.04f);
            fabricating.eulerOffset = new Vector3(0f, 0f, 0f);
            fabricating.scaleFactor = 1.15f;

            return(prefab);
        }
        public override GameObject GetGameObject()
        {
            GameObject prefab    = GameObject.Instantiate(this.GameObject);
            GameObject container = GameObject.Instantiate(this.CargoCrateContainer);
            GameObject model     = prefab.FindChild("submarine_locker_05");

            prefab.name = this.ClassID;

            // Update container renderers
            GameObject cargoCrateModel = container.FindChild("model");

            Renderer[] cargoCrateRenderers = cargoCrateModel.GetComponentsInChildren <Renderer>();
            container.transform.parent = prefab.transform;
            foreach (Renderer rend in cargoCrateRenderers)
            {
                rend.enabled = false;
            }
            container.transform.localPosition    = new Vector3(0.0f, 0.0f, 0.0f);
            container.transform.localScale       = new Vector3(0.001f, 0.001f, 0.001f);
            container.transform.localEulerAngles = new Vector3(0.0f, 0.0f, 0.0f);
            container.SetActive(true);

            // Update colliders
            GameObject  builderTrigger  = container.FindChild("Builder Trigger");
            GameObject  objectTrigger   = container.FindChild("Collider");
            BoxCollider builderCollider = builderTrigger.GetComponent <BoxCollider>();

            builderCollider.isTrigger = false;
            builderCollider.enabled   = false;
            BoxCollider objectCollider = objectTrigger.GetComponent <BoxCollider>();

            objectCollider.isTrigger = false;
            objectCollider.enabled   = false;

            // Delete constructable bounds
            ConstructableBounds cb = container.GetComponent <ConstructableBounds>();

            GameObject.DestroyImmediate(cb);

            // Update TechTag
            var techTag = prefab.AddComponent <TechTag>();

            techTag.type = this.TechType;

            // Update prefab ID
            var prefabId = prefab.GetComponent <PrefabIdentifier>();

            prefabId.ClassId = this.ClassID;

            // Remove rigid body
            Rigidbody rb = prefab.GetComponent <Rigidbody>();

            GameObject.DestroyImmediate(rb);

            // Add collider
            BoxCollider collider = model.AddComponent <BoxCollider>();

            collider.size   = new Vector3(0.4f, 2.0f, 0.5f);
            collider.center = new Vector3(0.0f, 1.0f, 0.0f);

            // Update large world entity
            PrefabsHelper.SetDefaultLargeWorldEntity(prefab);

            // Update sky applier
            PrefabsHelper.SetDefaultSkyApplier(prefab);

            // Set as constructible
            Constructable constructible = prefab.AddComponent <Constructable>();

            constructible.techType                = this.TechType;
            constructible.allowedOnWall           = false;
            constructible.allowedInBase           = true;
            constructible.allowedInSub            = true;
            constructible.allowedOutside          = ConfigSwitcher.AllowBuildOutside;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true;
            constructible.allowedOnConstructables = false;
            constructible.rotationEnabled         = true;
            constructible.deconstructionAllowed   = true;
            constructible.controlModelState       = true;
            constructible.model = model;

            // Add constructable bounds
            ConstructableBounds bounds = prefab.AddComponent <ConstructableBounds>();

            // Add model controler
            var decorativeLockerController = prefab.AddComponent <DecorativeLockerController>();

            return(prefab);
        }
Esempio n. 8
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                GameObject aquarium = Resources.Load <GameObject>("Submarine/Build/Aquarium");

                // Retrieve model node
                GameObject model = this.GameObject.FindChild("prawnsuit");

                // Move model
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y - 0.002f, model.transform.localPosition.z);

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add box collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                //collider.radius = 0.0375f;
                collider.size   = new Vector3(0.04f, 0.115f, 0.04f);
                collider.center = new Vector3(collider.center.x, collider.center.y + 0.0575f, collider.center.z);

                // Get glass material
                Material   glass      = null;
                Renderer[] aRenderers = aquarium.GetComponentsInChildren <Renderer>(true);
                foreach (Renderer aRenderer in aRenderers)
                {
                    foreach (Material aMaterial in aRenderer.materials)
                    {
                        if (aMaterial.name.StartsWith("Aquarium_glass", StringComparison.OrdinalIgnoreCase))
                        {
                            glass = aMaterial;
                            break;
                        }
                    }
                    if (glass != null)
                    {
                        break;
                    }
                }

                // Set proper shaders (for crafting animation)
                Shader  shader     = Shader.Find("MarmosetUBER");
                Texture normal     = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_normal");
                Texture spec       = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_spec");
                Texture colorMask  = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_colorMask");
                Texture illum      = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_illum");
                Texture normal2    = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_fp_normal");
                Texture illum2     = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_fp_illum");
                Texture normal3    = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_Arm_Propulsion_Cannon_normal");
                Texture colorMask3 = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_Arm_Propulsion_Cannon_colorMask");
                Texture illum3     = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_Arm_Propulsion_Cannon_illum");
                Texture normal4    = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_grappling_arm_normal");
                Texture colorMask4 = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_grappling_arm_colorMask");
                Texture illum4     = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_grappling_arm_illum");
                Texture normal5    = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_01_glass_normal");
                Texture normal6    = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_storage_01_normal");
                Texture colorMask6 = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_storage_01_colorMask");
                Texture illum6     = AssetsHelper.Assets.LoadAsset <Texture>("exosuit_storage_01_illum");
                Texture normal7    = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_torpedo_launcher_arm_normal");
                Texture colorMask7 = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_torpedo_launcher_arm_colorMask");
                Texture illum7     = AssetsHelper.Assets.LoadAsset <Texture>("Exosuit_torpedo_launcher_arm_illum");
                Texture normal8    = AssetsHelper.Assets.LoadAsset <Texture>("engine_power_cell_ion_normal");
                Texture spec8      = AssetsHelper.Assets.LoadAsset <Texture>("engine_power_cell_ion_spec");
                Texture illum8     = AssetsHelper.Assets.LoadAsset <Texture>("engine_power_cell_ion_illum");
                Texture normal9    = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_normal");
                Texture spec9      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_spec");
                Texture normal10   = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_upgrade_slots_01_normal");
                Texture spec10     = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_upgrade_slots_01_spec");
                Texture illum10    = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_upgrade_slots_01_illum");
                Texture normal11   = AssetsHelper.Assets.LoadAsset <Texture>("submarine_engine_power_cells_01_normal");
                Texture spec11     = AssetsHelper.Assets.LoadAsset <Texture>("submarine_engine_power_cells_01_spec");
                Texture illum11    = AssetsHelper.Assets.LoadAsset <Texture>("submarine_engine_power_cells_01_illum");

                Renderer[] renderers = this.GameObject.GetAllComponentsInChildren <Renderer>();
                foreach (Renderer renderer in renderers)
                {
                    if (renderer.name.StartsWith("Exosuit_cabin_01_glass", true, CultureInfo.InvariantCulture))
                    {
                        renderer.material = glass;
                    }
                    else if (renderer.materials != null)
                    {
                        foreach (Material tmpMat in renderer.materials)
                        {
                            // Associate MarmosetUBER shader
                            if (string.Compare(tmpMat.name, "exosuit_cabin_01_glass (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.EnableKeyword("MARMO_SIMPLE_GLASS");
                                tmpMat.EnableKeyword("WBOIT");
                            }
                            else if (string.Compare(tmpMat.name, "exosuit_01_glass (Instance)", true, CultureInfo.InvariantCulture) != 0)
                            {
                                tmpMat.shader = shader;
                            }

                            if (string.Compare(tmpMat.name, "exosuit_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal);
                                tmpMat.SetTexture("_ColorMask", colorMask);
                                tmpMat.SetTexture("_SpecTex", spec);
                                tmpMat.SetTexture("_Illum", illum);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable color mask
                                tmpMat.EnableKeyword("MARMO_VERTEX_COLOR");
                                // Enable specular
                                //tmpMat.EnableKeyword("MARMO_SPECULAR_ON");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_IBL");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_DIRECT");
                                tmpMat.EnableKeyword("MARMO_SPECMAP");
                                tmpMat.EnableKeyword("MARMO_MIP_GLOSS");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "exosuit_01_fp (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal2);
                                tmpMat.SetTexture("_Illum", illum2);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "Exosuit_Arm_Propulsion_Cannon (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal3);
                                tmpMat.SetTexture("_ColorMask", colorMask3);
                                tmpMat.SetTexture("_Illum", illum3);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable color mask
                                tmpMat.EnableKeyword("MARMO_VERTEX_COLOR");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "Exosuit_grappling_arm (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal4);
                                tmpMat.SetTexture("_ColorMask", colorMask4);
                                tmpMat.SetTexture("_Illum", illum4);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable color mask
                                tmpMat.EnableKeyword("MARMO_VERTEX_COLOR");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }

                            /*
                             * else if (tmpMat.name.CompareTo("exosuit_01_glass (Instance)") == 0)
                             * {
                             *  tmpMat.SetTexture("_BumpMap", normal5);
                             *
                             *  tmpMat.EnableKeyword("MARMO_SIMPLE_GLASS");
                             *  tmpMat.EnableKeyword("MARMO_NORMALMAP");
                             *  tmpMat.EnableKeyword("WBOIT");
                             *  tmpMat.EnableKeyword("_ZWRITE_ON");
                             * }
                             * else if (tmpMat.name.CompareTo("exosuit_cabin_01_glass (Instance)") == 0)
                             * {
                             *  tmpMat.EnableKeyword("MARMO_SIMPLE_GLASS");
                             *  tmpMat.EnableKeyword("WBOIT");
                             * }
                             */
                            else if (string.Compare(tmpMat.name, "exosuit_storage_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal6);
                                tmpMat.SetTexture("_ColorMask", colorMask6);
                                tmpMat.SetTexture("_Illum", illum6);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable color mask
                                tmpMat.EnableKeyword("MARMO_VERTEX_COLOR");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "Exosuit_torpedo_launcher_arm (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal7);
                                tmpMat.SetTexture("_ColorMask", colorMask7);
                                tmpMat.SetTexture("_Illum", illum7);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable color mask
                                tmpMat.EnableKeyword("MARMO_VERTEX_COLOR");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "power_cell_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal8);
                                tmpMat.SetTexture("_SpecTex", spec8);
                                tmpMat.SetTexture("_Illum", illum8);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable specular
                                tmpMat.EnableKeyword("MARMO_SPECULAR_IBL");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_DIRECT");
                                tmpMat.EnableKeyword("MARMO_SPECMAP");
                                tmpMat.EnableKeyword("MARMO_MIP_GLOSS");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "seamoth_torpedo_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal9);
                                tmpMat.SetTexture("_SpecTex", spec9);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable specular
                                tmpMat.EnableKeyword("MARMO_SPECULAR_IBL");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_DIRECT");
                                tmpMat.EnableKeyword("MARMO_SPECMAP");
                                tmpMat.EnableKeyword("MARMO_MIP_GLOSS");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "seamoth_upgrade_slots_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal10);
                                tmpMat.SetTexture("_SpecTex", spec10);
                                tmpMat.SetTexture("_Illum", illum10);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable specular
                                tmpMat.EnableKeyword("MARMO_SPECULAR_IBL");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_DIRECT");
                                tmpMat.EnableKeyword("MARMO_SPECMAP");
                                tmpMat.EnableKeyword("MARMO_MIP_GLOSS");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                            else if (string.Compare(tmpMat.name, "submarine_engine_power_cells_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                            {
                                tmpMat.SetTexture("_BumpMap", normal11);
                                tmpMat.SetTexture("_SpecTex", spec11);
                                tmpMat.SetTexture("_Illum", illum11);
                                tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                // Enable specular
                                tmpMat.EnableKeyword("MARMO_SPECULAR_IBL");
                                tmpMat.EnableKeyword("MARMO_SPECULAR_DIRECT");
                                tmpMat.EnableKeyword("MARMO_SPECMAP");
                                tmpMat.EnableKeyword("MARMO_MIP_GLOSS");
                                // Enable normal map
                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                // Enable emission map
                                tmpMat.EnableKeyword("MARMO_EMISSION");
                                // Enable Z write
                                tmpMat.EnableKeyword("_ZWRITE_ON");
                            }
                        }
                    }
                }

                // Add sky applier
                SkyApplier applier = this.GameObject.GetComponent <SkyApplier>();
                if (applier == null)
                {
                    applier = this.GameObject.AddComponent <SkyApplier>();
                }
                applier.renderers    = renderers;
                applier.anchorSky    = Skies.Auto;
                applier.updaterIndex = 0;
                SkyApplier[] appliers = this.GameObject.GetComponentsInChildren <SkyApplier>();
                if (appliers != null && appliers.Length > 0)
                {
                    foreach (SkyApplier ap in appliers)
                    {
                        ap.renderers    = renderers;
                        ap.anchorSky    = Skies.Auto;
                        ap.updaterIndex = 0;
                    }
                }

                // Add contructable
                var constructible = this.GameObject.AddComponent <Constructable>();
                constructible.allowedInBase           = true;
                constructible.allowedInSub            = true;
                constructible.allowedOutside          = true;
                constructible.allowedOnCeiling        = false;
                constructible.allowedOnGround         = true;
                constructible.allowedOnConstructables = true;
#if BELOWZERO
                constructible.allowedUnderwater = true;
#endif
                constructible.controlModelState     = true;
                constructible.deconstructionAllowed = true;
                constructible.rotationEnabled       = true;
                constructible.model    = model;
                constructible.techType = this.TechType;
                constructible.enabled  = true;

                // Add constructable bounds
                var bounds = this.GameObject.AddComponent <ConstructableBounds>();
                bounds.bounds.position = new Vector3(bounds.bounds.position.x, bounds.bounds.position.y + 0.002f, bounds.bounds.position.z);

                // Add model controler
                var exosuitDollControler = this.GameObject.AddComponent <ExosuitDollController>();

                #region Disable right arms (except hand arm)

                GameObject rightArm           = model.FindChild("ExosuitArmRight");
                GameObject rightArmRig        = rightArm.FindChild("exosuit_01_armRight 1").FindChild("ArmRig 1");
                GameObject rightTorpedoArm    = rightArmRig.FindChild("exosuit_arm_torpedoLauncher_geo 1");
                GameObject rightDrillArm      = rightArmRig.FindChild("exosuit_drill_geo 1");
                GameObject rightGrapplinArm   = rightArmRig.FindChild("exosuit_grapplingHook_geo 1");
                GameObject rightGrapplinHand  = rightArmRig.FindChild("exosuit_grapplingHook_hand_geo 1");
                GameObject rightHandArm       = rightArmRig.FindChild("exosuit_hand_geo 1");
                GameObject rightPropulsionArm = rightArmRig.FindChild("exosuit_propulsion_geo 1");

                // Disable right torpedo arm
                List <Renderer> rightTorpedoArmRenderers = new List <Renderer>();
                rightTorpedoArm.GetComponentsInChildren <Renderer>(rightTorpedoArmRenderers);
                if (!rightTorpedoArmRenderers.Contains(rightTorpedoArm.GetComponent <Renderer>()))
                {
                    rightTorpedoArmRenderers.Add(rightTorpedoArm.GetComponent <Renderer>());
                }
                foreach (Renderer rend in rightTorpedoArmRenderers)
                {
                    rend.enabled = false;
                }

                // Disable right drill arm
                rightDrillArm.GetComponent <Renderer>().enabled = false;

                // Disable right grapplin arm
                List <Renderer> rightGrapplinArmRenderers = new List <Renderer>();
                rightGrapplinHand.GetComponentsInChildren <Renderer>(rightGrapplinArmRenderers);
                if (!rightGrapplinArmRenderers.Contains(rightGrapplinHand.GetComponent <Renderer>()))
                {
                    rightGrapplinArmRenderers.Add(rightGrapplinHand.GetComponent <Renderer>());
                }
                foreach (Renderer rend in rightGrapplinArmRenderers)
                {
                    rend.enabled = false;
                }
                rightGrapplinArm.GetComponent <Renderer>().enabled = false;

                // Disable right propulsion arm
                rightPropulsionArm.GetComponent <Renderer>().enabled = false;

                #endregion

                #region Disable left arms (except hand arm)

                GameObject leftArm           = model.FindChild("ExosuitArmLeft");
                GameObject leftArmRig        = leftArm.FindChild("exosuit_01_armRight").FindChild("ArmRig");
                GameObject leftTorpedoArm    = leftArmRig.FindChild("exosuit_arm_torpedoLauncher_geo");
                GameObject leftDrillArm      = leftArmRig.FindChild("exosuit_drill_geo");
                GameObject leftGrapplinArm   = leftArmRig.FindChild("exosuit_grapplingHook_geo");
                GameObject leftGrapplinHand  = leftArmRig.FindChild("exosuit_grapplingHook_hand_geo");
                GameObject leftHandArm       = leftArmRig.FindChild("exosuit_hand_geo");
                GameObject leftPropulsionArm = leftArmRig.FindChild("exosuit_propulsion_geo");

                // Disable left torpedo arm
                List <Renderer> leftTorpedoArmRenderers = new List <Renderer>();
                leftTorpedoArm.GetComponentsInChildren <Renderer>(leftTorpedoArmRenderers);
                if (!leftTorpedoArmRenderers.Contains(leftTorpedoArm.GetComponent <Renderer>()))
                {
                    leftTorpedoArmRenderers.Add(leftTorpedoArm.GetComponent <Renderer>());
                }
                foreach (Renderer rend in leftTorpedoArmRenderers)
                {
                    rend.enabled = false;
                }

                // Disable left drill arm
                leftDrillArm.GetComponent <Renderer>().enabled = false;

                // Disable right grapplin arm
                List <Renderer> leftGrapplinArmRenderers = new List <Renderer>();
                leftGrapplinHand.GetComponentsInChildren <Renderer>(leftGrapplinArmRenderers);
                if (!leftGrapplinArmRenderers.Contains(leftGrapplinHand.GetComponent <Renderer>()))
                {
                    leftGrapplinArmRenderers.Add(leftGrapplinHand.GetComponent <Renderer>());
                }
                foreach (Renderer rend in leftGrapplinArmRenderers)
                {
                    rend.enabled = false;
                }
                leftGrapplinArm.GetComponent <Renderer>().enabled = false;

                // Disable right propulsion arm
                leftPropulsionArm.GetComponent <Renderer>().enabled = false;

                #endregion

                // Add new TechType to the buildables
                SMLHelper.V2.Handlers.CraftDataHandler.AddBuildable(this.TechType);
                SMLHelper.V2.Handlers.CraftDataHandler.AddToGroup(TechGroup.Miscellaneous, TechCategory.Misc, this.TechType);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, SpriteManager.Get(TechType.Exosuit));

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                this.IsRegistered = true;
            }
        }
        public override GameObject GetGameObject()
        {
            GameObject prefab = GameObject.Instantiate(this.GameObject);

            prefab.name = this.ClassID;

            // Scale
            foreach (Transform tr in prefab.transform)
            {
                tr.transform.localScale *= 0.4f;
            }

            // Update TechTag
            var techTag = prefab.GetComponent <TechTag>();

            if (techTag == null)
            {
                if ((techTag = prefab.GetComponentInChildren <TechTag>()) == null)
                {
                    techTag = prefab.AddComponent <TechTag>();
                }
            }
            techTag.type = this.TechType;

            // Update prefab ID
            var prefabId = prefab.GetComponent <PrefabIdentifier>();

            if (prefabId == null)
            {
                if ((prefabId = prefab.GetComponentInChildren <PrefabIdentifier>()) == null)
                {
                    prefabId = prefab.AddComponent <PrefabIdentifier>();
                }
            }
            prefabId.ClassId = this.ClassID;

            // Clean all the crap
            GameObject.DestroyImmediate(prefab.GetComponent <Rigidbody>());
            GameObject.DestroyImmediate(prefab.GetComponent <ConstructionObstacle>());
            GameObject.DestroyImmediate(prefab.GetComponent <LargeWorldEntity>());
            GameObject.DestroyImmediate(prefab.GetComponent <SkyApplier>());

            // Update sky applier
            PrefabsHelper.SetDefaultSkyApplier(prefab);

            // Set large world entity
            PrefabsHelper.SetDefaultLargeWorldEntity(prefab);

            // Ajust collider
            BoxCollider c = prefab.GetComponentInChildren <BoxCollider>();

            c.size = new Vector3(c.size.x * 0.5f, c.size.y, c.size.z * 0.5f);

            // Set as constructible
            Constructable constructible = prefab.AddComponent <Constructable>();

            constructible.techType                = this.TechType;
            constructible.allowedOnWall           = false;
            constructible.allowedInBase           = true;
            constructible.allowedInSub            = true;
            constructible.allowedOutside          = ConfigSwitcher.AllowBuildOutside;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true;
            constructible.allowedOnConstructables = true;
            constructible.rotationEnabled         = true;
            constructible.deconstructionAllowed   = true;
            constructible.controlModelState       = true;
            constructible.model = prefab.FindChild("precursor_deco_props_01");

            // Add constructable bounds
            prefab.AddComponent <ConstructableBounds>();

            return(prefab);
        }
Esempio n. 10
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = GameObject.Instantiate(this.GameObject);

            prefab.name = this.ClassID;

            // Remove unwanted elements
            GameObject.DestroyImmediate(prefab.GetComponent <Rigidbody>());
            GameObject.DestroyImmediate(prefab.GetComponent <ImmuneToPropulsioncannon>());

            // Rotate model
            GameObject model = prefab.FindChild("Creatures_eggs_17");

            model.transform.localEulerAngles = new Vector3(model.transform.localEulerAngles.x - 90f, model.transform.localEulerAngles.y, model.transform.localEulerAngles.z);
            // Scale model
            model.transform.localScale *= 0.8f;

            // Scale collider
            CapsuleCollider c = prefab.GetComponentInChildren <CapsuleCollider>();

            c.radius *= 0.5f;
            c.height *= 0.5f;

            // Update TechTag
            var techTag = prefab.GetComponent <TechTag>();

            if (techTag == null)
            {
                if ((techTag = prefab.GetComponentInChildren <TechTag>()) == null)
                {
                    techTag = prefab.AddComponent <TechTag>();
                }
            }
            techTag.type = this.TechType;

            // Update prefab ID
            var prefabId = prefab.GetComponent <PrefabIdentifier>();

            if (prefabId == null)
            {
                if ((prefabId = prefab.GetComponentInChildren <PrefabIdentifier>()) == null)
                {
                    prefabId = prefab.AddComponent <PrefabIdentifier>();
                }
            }
            prefabId.ClassId = this.ClassID;

            // Update sky applier
            PrefabsHelper.SetDefaultSkyApplier(prefab);

            // Set large world entity
            PrefabsHelper.SetDefaultLargeWorldEntity(prefab);

            // We can pick this item
            PrefabsHelper.SetDefaultPickupable(prefab);

            // We can place this item
            //prefab.AddComponent<EggSeaDragon_PT>();
            PrefabsHelper.SetDefaultPlaceTool(prefab);

            // Add fabricating animation
            var fabricating = prefab.AddComponent <VFXFabricating>();

            fabricating.localMinY   = -0.2f;
            fabricating.localMaxY   = 0.8f;
            fabricating.posOffset   = new Vector3(0f, 0.03f, -0.15f);
            fabricating.eulerOffset = new Vector3(0f, 0f, 0f);
            fabricating.scaleFactor = 0.35f;

            return(prefab);
        }
Esempio n. 11
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                GameObject aquarium = Resources.Load <GameObject>("Submarine/Build/Aquarium");

                // Move model
                GameObject model = this.GameObject.FindChild("Model");
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.032f, model.transform.localPosition.z);

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size   = new Vector3(0.07f, 0.054f, 0.07f);
                collider.center = new Vector3(collider.center.x, collider.center.y + 0.027f, collider.center.z);

                // Get glass material
                Material   glass      = null;
                Renderer[] aRenderers = aquarium.GetComponentsInChildren <Renderer>(true);
                foreach (Renderer aRenderer in aRenderers)
                {
                    foreach (Material aMaterial in aRenderer.materials)
                    {
                        if (aMaterial.name.StartsWith("Aquarium_glass", StringComparison.OrdinalIgnoreCase))
                        {
                            glass = aMaterial;
                            break;
                        }
                    }
                    if (glass != null)
                    {
                        break;
                    }
                }

                // Set proper shaders (for crafting animation)
                Shader  marmosetUber = Shader.Find("MarmosetUBER");
                Texture normal1      = AssetsHelper.Assets.LoadAsset <Texture>("power_cell_01_normal");
                Texture spec1        = AssetsHelper.Assets.LoadAsset <Texture>("power_cell_01_spec");
                Texture illum1       = AssetsHelper.Assets.LoadAsset <Texture>("power_cell_01_illum");
                Texture normal2      = AssetsHelper.Assets.LoadAsset <Texture>("Submersible_SeaMoth_normal");
                Texture spec2        = AssetsHelper.Assets.LoadAsset <Texture>("Submersible_SeaMoth_spec");
                Texture illum2       = AssetsHelper.Assets.LoadAsset <Texture>("Submersible_SeaMoth_illum");
                Texture normal3      = AssetsHelper.Assets.LoadAsset <Texture>("Submersible_SeaMoth_indoor_normal");
                Texture illum3       = AssetsHelper.Assets.LoadAsset <Texture>("Submersible_SeaMoth_indoor_illum");
                Texture normal4      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_storage_01_normal");
                Texture normal5      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_storage_02_normal");
                Texture illum5       = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_storage_02_illum");
                Texture normal6      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_power_cell_slot_01_normal");
                Texture spec6        = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_power_cell_slot_01_spec");
                Texture normal7      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_normal");
                Texture spec7        = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_spec");
                Texture normal8      = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_hatch_01_normal");
                Texture spec8        = AssetsHelper.Assets.LoadAsset <Texture>("seamoth_torpedo_01_hatch_01_spec");

                var renderers = this.GameObject.GetAllComponentsInChildren <Renderer>();
                if (renderers.Length > 0)
                {
                    foreach (Renderer rend in renderers)
                    {
                        if (rend.name.StartsWith("Submersible_SeaMoth_glass_geo", true, CultureInfo.InvariantCulture))
                        {
                            rend.material = glass;
                        }
                        else if (rend.materials.Length > 0)
                        {
                            foreach (Material tmpMat in rend.materials)
                            {
                                if (string.Compare(tmpMat.name, "Submersible_SeaMoth_Glass_interior (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                {
                                    tmpMat.EnableKeyword("MARMO_SIMPLE_GLASS");
                                    tmpMat.EnableKeyword("WBOIT");
                                }
                                else if (string.Compare(tmpMat.name, "Submersible_SeaMoth_Glass (Instance)", true, CultureInfo.InvariantCulture) != 0)
                                {
                                    tmpMat.shader = marmosetUber;
                                    if (string.Compare(tmpMat.name, "power_cell_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal1);
                                        tmpMat.SetTexture("_SpecTex", spec1);
                                        tmpMat.SetTexture("_Illum", illum1);
                                        tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "Submersible_SeaMoth (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal2);
                                        tmpMat.SetTexture("_SpecTex", spec2);
                                        tmpMat.SetTexture("_Illum", illum2);
                                        tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "Submersible_SeaMoth_indoor (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal3);
                                        tmpMat.SetTexture("_Illum", illum3);
                                        tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "seamoth_storage_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal4);

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "seamoth_storage_02 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal5);
                                        tmpMat.SetTexture("_Illum", illum5);
                                        tmpMat.SetFloat("_EmissionLM", 0.75f); // Set always visible

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_EMISSION");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "seamoth_power_cell_slot_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal6);
                                        tmpMat.SetTexture("_SpecTex", spec6);

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "seamoth_torpedo_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal7);
                                        tmpMat.SetTexture("_SpecTex", spec7);

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                    else if (string.Compare(tmpMat.name, "seamoth_torpedo_01_hatch_01 (Instance)", true, CultureInfo.InvariantCulture) == 0)
                                    {
                                        tmpMat.SetTexture("_BumpMap", normal8);
                                        tmpMat.SetTexture("_SpecTex", spec8);

                                        tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                        tmpMat.EnableKeyword("MARMO_SPECMAP");
                                        tmpMat.EnableKeyword("_ZWRITE_ON"); // Enable Z write
                                    }
                                }
                            }
                        }
                    }
                }

                // Add contructable
                Constructable constructable = this.GameObject.AddComponent <Constructable>();
                constructable.allowedInBase           = true;
                constructable.allowedInSub            = true;
                constructable.allowedOutside          = true;
                constructable.allowedOnCeiling        = false;
                constructable.allowedOnGround         = true;
                constructable.allowedOnConstructables = true;
#if BELOWZERO
                constructable.allowedUnderwater = true;
#endif
                constructable.controlModelState     = true;
                constructable.deconstructionAllowed = true;
                constructable.rotationEnabled       = true;
                constructable.model    = model;
                constructable.techType = this.TechType;
                constructable.enabled  = true;

                // Add constructable bounds
                ConstructableBounds bounds = this.GameObject.AddComponent <ConstructableBounds>();
                bounds.bounds.position = new Vector3(bounds.bounds.position.x, bounds.bounds.position.y + 0.032f, bounds.bounds.position.z);

                // Add sky applier
                SkyApplier applier = this.GameObject.GetComponent <SkyApplier>();
                if (applier == null)
                {
                    applier = this.GameObject.AddComponent <SkyApplier>();
                }
                applier.renderers    = renderers;
                applier.anchorSky    = Skies.Auto;
                applier.updaterIndex = 0;
                SkyApplier[] appliers = this.GameObject.GetComponentsInChildren <SkyApplier>();
                if (appliers != null && appliers.Length > 0)
                {
                    foreach (SkyApplier ap in appliers)
                    {
                        ap.renderers    = renderers;
                        ap.anchorSky    = Skies.Auto;
                        ap.updaterIndex = 0;
                    }
                }

                // Add lights/model controler
                SeamothDollController controller = this.GameObject.AddComponent <SeamothDollController>();

                // Add new TechType to the buildables
                SMLHelper.V2.Handlers.CraftDataHandler.AddBuildable(this.TechType);
                SMLHelper.V2.Handlers.CraftDataHandler.AddToGroup(TechGroup.Miscellaneous, TechCategory.Misc, this.TechType);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, SpriteManager.Get(TechType.Seamoth));

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                this.IsRegistered = true;
            }
        }
Esempio n. 12
0
        public override void RegisterItem()
        {
            if (this.IsRegistered == false)
            {
                GameObject model = this.GameObject.FindChild("CyclopsDoll");

                // Scale model
                model.transform.localScale *= 0.12f;

                // Move model
                model.transform.localPosition = new Vector3(model.transform.localPosition.x, model.transform.localPosition.y + 0.135f, model.transform.localPosition.z);

                // Add prefab identifier
                var prefabId = this.GameObject.AddComponent <PrefabIdentifier>();
                prefabId.ClassId = this.ClassID;

                // Add large world entity
                PrefabsHelper.SetDefaultLargeWorldEntity(this.GameObject);

                // Add tech tag
                var techTag = this.GameObject.AddComponent <TechTag>();
                techTag.type = this.TechType;

                // Add collider
                var collider = this.GameObject.AddComponent <BoxCollider>();
                collider.size   = new Vector3(0.06f, 0.148f, 0.42f);
                collider.center = new Vector3(collider.center.x - 0.02f, collider.center.y + 0.135f, collider.center.z - 0.105f);

                // Get shaders/textures
                Shader marmosetUber = Shader.Find("MarmosetUBER");
                if (normals == null)
                {
                    normals = new Dictionary <string, Texture>();
                    foreach (KeyValuePair <string, string> elem in normalnames)
                    {
                        normals.Add(elem.Key, AssetsHelper.Assets.LoadAsset <Texture>(elem.Value));
                    }
                }

                // Get glass material
                GameObject aquarium   = Resources.Load <GameObject>("Submarine/Build/Aquarium");
                Material   glass      = null;
                Renderer[] aRenderers = aquarium.GetComponentsInChildren <Renderer>(true);
                foreach (Renderer aRenderer in aRenderers)
                {
                    foreach (Material aMaterial in aRenderer.materials)
                    {
                        if (aMaterial.name.StartsWith("Aquarium_glass", StringComparison.OrdinalIgnoreCase))
                        {
                            glass = aMaterial;
                            break;
                        }
                    }
                    if (glass != null)
                    {
                        break;
                    }
                }

                // Set proper shaders/textures
                var renderers = this.GameObject.GetAllComponentsInChildren <Renderer>();
                if (renderers.Length > 0)
                {
#if DEBUG_CYCLOPS_DOLL
                    Logger.Log("DEBUG: Printing renderers:");
#endif
                    foreach (Renderer rend in renderers)
                    {
                        if (rend.name.StartsWith("Cyclops_submarine_exterior_glass", true, CultureInfo.InvariantCulture) ||
                            rend.name.StartsWith("glass", true, CultureInfo.InvariantCulture))
                        {
                            rend.material = glass;
                        }
                        else if (rend.materials.Length > 0)
                        {
#if DEBUG_CYCLOPS_DOLL
                            Logger.Log("DEBUG: Found renderer name=[" + rend.name + "] type=[" + rend.GetType().ToString() + "]");
#endif
                            foreach (Material tmpMat in rend.materials)
                            {
#if DEBUG_CYCLOPS_DOLL
                                Logger.Log("DEBUG: \t=> material name=[" + tmpMat.name + "]");
#endif
                                tmpMat.shader = marmosetUber;
                                if (tmpMat.name.StartsWith("cyclops_submarine_exterior_decals_01_24", false, CultureInfo.InvariantCulture))
                                {
                                    tmpMat.SetFloat("_EnableCutOff", 1.0f);
                                    tmpMat.SetFloat("_Cutoff", 0.1f);
                                    tmpMat.EnableKeyword("MARMO_ALPHA_CLIP");
                                }
                                else if (normals != null)
                                {
                                    foreach (KeyValuePair <string, string> elem in normalnames)
                                    {
                                        if (tmpMat.name.StartsWith(elem.Key, false, CultureInfo.InvariantCulture))
                                        {
                                            if (elem.Value != null && normals.ContainsKey(elem.Value) && normals[elem.Value] != null)
                                            {
                                                tmpMat.SetTexture("_BumpMap", normals[elem.Value]);
                                                tmpMat.EnableKeyword("MARMO_NORMALMAP");
                                                tmpMat.EnableKeyword("_ZWRITE_ON");
                                            }
#if DEBUG_CYCLOPS_DOLL
                                            else
                                            {
                                                Logger.Log("DEBUG: Warning missing cyclops texture.");
                                            }
#endif
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Add contructable
                Constructable constructable = this.GameObject.AddComponent <Constructable>();
                constructable.allowedInBase           = true;
                constructable.allowedInSub            = true;
                constructable.allowedOutside          = true;
                constructable.allowedOnCeiling        = false;
                constructable.allowedOnGround         = true;
                constructable.allowedOnConstructables = true;
#if BELOWZERO
                constructable.allowedUnderwater = true;
#endif
                constructable.controlModelState     = true;
                constructable.deconstructionAllowed = true;
                constructable.rotationEnabled       = true;
                constructable.model            = model;
                constructable.techType         = this.TechType;
                constructable.surfaceType      = VFXSurfaceTypes.metal;
                constructable.placeMinDistance = 0.6f;
                constructable.enabled          = true;

                // Add constructable bounds
                ConstructableBounds bounds = this.GameObject.AddComponent <ConstructableBounds>();
                bounds.bounds.size *= 0.9f;
                Vector3 pos = bounds.bounds.position;
                bounds.bounds.position = new Vector3(pos.x - 0.02f, pos.y + 0.135f, pos.z - 0.105f);

                // Add sky applier
#if BELOWZERO
                BaseModuleLighting bml = this.GameObject.GetComponent <BaseModuleLighting>();
                if (bml == null)
                {
                    bml = this.GameObject.GetComponentInChildren <BaseModuleLighting>();
                }
                if (bml == null)
                {
                    bml = this.GameObject.AddComponent <BaseModuleLighting>();
                }
#endif
                SkyApplier applier = this.GameObject.AddComponent <SkyApplier>();
                if (applier != null)
                {
                    applier.renderers    = renderers;
                    applier.anchorSky    = Skies.Auto;
                    applier.updaterIndex = 0;
                }

                // Add size controler
                CyclopsDollController controller = this.GameObject.AddComponent <CyclopsDollController>();

                // Associate recipe to the new TechType
                SMLHelper.V2.Handlers.CraftDataHandler.SetTechData(this.TechType, this.Recipe);

                // Add new TechType to the buildables
                SMLHelper.V2.Handlers.CraftDataHandler.AddBuildable(this.TechType);
                SMLHelper.V2.Handlers.CraftDataHandler.AddToGroup(TechGroup.Miscellaneous, TechCategory.Misc, this.TechType);

                // Set the buildable prefab
                SMLHelper.V2.Handlers.PrefabHandler.RegisterPrefab(this);

                // Set the custom sprite
                SMLHelper.V2.Handlers.SpriteHandler.RegisterSprite(this.TechType, SpriteManager.Get(TechType.Cyclops));

                this.IsRegistered = true;
            }
        }