Пример #1
0
    public void RegisterEquipment(IEquipmentConfig config)
    {
        EquipmentDef equipmentDef      = config.CreateEquipmentDef();
        string       id                = equipmentDef.Id;
        string       name              = equipmentDef.Name;
        string       recipeDescription = equipmentDef.RecipeDescription;
        float        mass              = equipmentDef.Mass;
        bool         unitMass          = true;
        KAnimFile    anim              = equipmentDef.Anim;
        string       initialAnim       = "object";

        Grid.SceneLayer sceneLayer = Grid.SceneLayer.Ore;
        EntityTemplates.CollisionShape collisionShape = equipmentDef.CollisionShape;
        float      width         = equipmentDef.width;
        float      height        = equipmentDef.height;
        bool       isPickupable  = true;
        SimHashes  outputElement = equipmentDef.OutputElement;
        GameObject gameObject    = EntityTemplates.CreateLooseEntity(id, name, recipeDescription, mass, unitMass, anim, initialAnim, sceneLayer, collisionShape, width, height, isPickupable, 0, outputElement, null);
        Equippable equippable    = gameObject.AddComponent <Equippable>();

        equippable.def = equipmentDef;
        Debug.Assert((Object)equippable.def != (Object)null);
        equippable.slotID = equipmentDef.Slot;
        Debug.Assert(equippable.slot != null);
        config.DoPostConfigure(gameObject);
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
    }
Пример #2
0
    public static GameObject CreateAndRegisterSeedForPlant(GameObject plant, SeedProducer.ProductionType productionType, string id, string name, string desc, KAnimFile anim, string initialAnim = "object", int numberOfSeeds = 1, List <Tag> additionalTags = null, SingleEntityReceptacle.ReceptacleDirection planterDirection = SingleEntityReceptacle.ReceptacleDirection.Top, Tag replantGroundTag = default(Tag), int sortOrder = 0, string domesticatedDescription = "", CollisionShape collisionShape = CollisionShape.CIRCLE, float width = 0.25f, float height = 0.25f, Recipe.Ingredient[] recipe_ingredients = null, string recipe_description = "", bool ignoreDefaultSeedTag = false)
    {
        GameObject gameObject = CreateLooseEntity(id, name, desc, 1f, true, anim, initialAnim, Grid.SceneLayer.Front, collisionShape, width, height, true, SORTORDER.SEEDS + sortOrder, SimHashes.Creature, null);

        gameObject.AddOrGet <EntitySplitter>();
        CreateAndRegisterCompostableFromPrefab(gameObject);
        PlantableSeed plantableSeed = gameObject.AddOrGet <PlantableSeed>();

        plantableSeed.PlantID                 = new Tag(plant.name);
        plantableSeed.replantGroundTag        = replantGroundTag;
        plantableSeed.domesticatedDescription = domesticatedDescription;
        plantableSeed.direction               = planterDirection;
        KPrefabID component = gameObject.GetComponent <KPrefabID>();

        foreach (Tag additionalTag in additionalTags)
        {
            component.AddTag(additionalTag, false);
        }
        if (!ignoreDefaultSeedTag)
        {
            component.AddTag(GameTags.Seed, false);
        }
        component.AddTag(GameTags.PedestalDisplayable, false);
        KPrefabID component2 = gameObject.GetComponent <KPrefabID>();

        Assets.AddPrefab(component2);
        SeedProducer seedProducer = plant.AddOrGet <SeedProducer>();

        seedProducer.Configure(gameObject.name, productionType, numberOfSeeds);
        return(gameObject);
    }
Пример #3
0
    public static GameObject CreateAndRegisterCompostableFromPrefab(GameObject original)
    {
        if ((Object)original.GetComponent <Compostable>() != (Object)null)
        {
            return(null);
        }
        Compostable compostable = original.AddComponent <Compostable>();

        compostable.isMarkedForCompost = false;
        KPrefabID  component  = original.GetComponent <KPrefabID>();
        GameObject gameObject = Object.Instantiate(original);

        Object.DontDestroyOnLoad(gameObject);
        string tag_string = "Compost" + component.PrefabTag.Name;
        string text       = MISC.TAGS.COMPOST_FORMAT.Replace("{Item}", component.PrefabTag.ProperName());

        gameObject.GetComponent <KPrefabID>().PrefabTag = TagManager.Create(tag_string, text);
        gameObject.GetComponent <KPrefabID>().AddTag(GameTags.Compostable, false);
        gameObject.name = text;
        gameObject.GetComponent <Compostable>().isMarkedForCompost = true;
        gameObject.GetComponent <KSelectable>().SetName(text);
        gameObject.GetComponent <Compostable>().originalPrefab = original;
        gameObject.GetComponent <Compostable>().compostPrefab  = gameObject;
        original.GetComponent <Compostable>().originalPrefab   = original;
        original.GetComponent <Compostable>().compostPrefab    = gameObject;
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
        return(gameObject);
    }
Пример #4
0
    public static void LoadGeneratedOre(List <Type> types)
    {
        Type typeFromHandle         = typeof(IOreConfig);
        HashSet <SimHashes> hashSet = new HashSet <SimHashes>();

        foreach (Type type in types)
        {
            if (typeFromHandle.IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface)
            {
                object     obj       = Activator.CreateInstance(type);
                IOreConfig oreConfig = obj as IOreConfig;
                SimHashes  elementID = oreConfig.ElementID;
                if (elementID != SimHashes.Void)
                {
                    hashSet.Add(elementID);
                }
                GameObject gameObject = oreConfig.CreatePrefab();
                KPrefabID  component  = gameObject.GetComponent <KPrefabID>();
                Assets.AddPrefab(component);
            }
        }
        List <Element> elements = ElementLoader.elements;

        foreach (Element item in elements)
        {
            if (item != null && !hashSet.Contains(item.id))
            {
                if (item.substance != null && (UnityEngine.Object)item.substance.anim != (UnityEngine.Object)null)
                {
                    GameObject gameObject2 = null;
                    if (item.IsSolid)
                    {
                        gameObject2 = EntityTemplates.CreateSolidOreEntity(item.id, null);
                    }
                    else if (item.IsLiquid)
                    {
                        gameObject2 = EntityTemplates.CreateLiquidOreEntity(item.id, null);
                    }
                    else if (item.IsGas)
                    {
                        gameObject2 = EntityTemplates.CreateGasOreEntity(item.id, null);
                    }
                    if ((UnityEngine.Object)gameObject2 != (UnityEngine.Object)null)
                    {
                        KPrefabID component2 = gameObject2.GetComponent <KPrefabID>();
                        Assets.AddPrefab(component2);
                    }
                }
                else
                {
                    Debug.LogError("Missing substance or anim for element [" + item.name + "]");
                }
            }
        }
    }
    public static GameObject CreateEgg(string id, string name, string desc, Tag creature_id, string anim, float mass, int egg_sort_order, float base_incubation_rate)
    {
        GameObject gameObject = EntityTemplates.CreateLooseEntity(id, name, desc, mass, true, Assets.GetAnim(anim), "idle", Grid.SceneLayer.Ore, EntityTemplates.CollisionShape.RECTANGLE, 0.8f, 0.8f, true, 0, SimHashes.Creature, null);

        gameObject.AddOrGet <KBoxCollider2D>().offset = new Vector2f(0f, 0.36f);
        Pickupable pickupable = gameObject.AddOrGet <Pickupable>();

        pickupable.sortOrder = SORTORDER.EGGS + egg_sort_order;
        gameObject.AddOrGet <Effects>();
        KPrefabID kPrefabID = gameObject.AddOrGet <KPrefabID>();

        kPrefabID.AddTag(GameTags.Egg, false);
        kPrefabID.AddTag(GameTags.IncubatableEgg, false);
        kPrefabID.AddTag(GameTags.PedestalDisplayable, false);
        IncubationMonitor.Def def = gameObject.AddOrGetDef <IncubationMonitor.Def>();
        def.spawnedCreature    = creature_id;
        def.baseIncubationRate = base_incubation_rate;
        OvercrowdingMonitor.Def def2 = gameObject.AddOrGetDef <OvercrowdingMonitor.Def>();
        def2.spaceRequiredPerCreature = 0;
        Object.Destroy(gameObject.GetComponent <EntitySplitter>());
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
        string arg = string.Format(STRINGS.BUILDINGS.PREFABS.EGGCRACKER.RESULT_DESCRIPTION, name);

        ComplexRecipe.RecipeElement[] array = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(id, 1f)
        };
        ComplexRecipe.RecipeElement[] array2 = new ComplexRecipe.RecipeElement[2]
        {
            new ComplexRecipe.RecipeElement("RawEgg", 0.5f * mass),
            new ComplexRecipe.RecipeElement("EggShell", 0.5f * mass)
        };
        string        obsolete_id   = ComplexRecipeManager.MakeObsoleteRecipeID(id, "RawEgg");
        string        text          = ComplexRecipeManager.MakeRecipeID(id, array, array2);
        ComplexRecipe complexRecipe = new ComplexRecipe(text, array, array2);

        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.EGGCRACKER.RECIPE_DESCRIPTION, name, arg);
        complexRecipe.fabricators = new List <Tag>
        {
            "EggCracker"
        };
        complexRecipe.time = 5f;
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, text);
        return(gameObject);
    }
Пример #6
0
    public GameObject CreateBuildingPreview(BuildingDef def)
    {
        GameObject gameObject = CreateBuilding(def, previewTemplate, null);

        Object.DontDestroyOnLoad(gameObject);
        int num = LayerMask.NameToLayer("Place");

        gameObject.transform.SetPosition(new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer)));
        Add2DComponents(def, gameObject, "place", true, num);
        KAnimControllerBase component = gameObject.GetComponent <KAnimControllerBase>();

        if ((Object)component != (Object)null)
        {
            component.fgLayer = Grid.SceneLayer.NoLayer;
        }
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(gameObject, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        KPrefabID kPrefabID = AddID(gameObject, def.PrefabID + "Preview");

        kPrefabID.defaultLayer = num;
        KSelectable component2 = gameObject.GetComponent <KSelectable>();

        component2.SetName(def.Name);
        UpdateComponentRequirement <BuildingCellVisualizer>(gameObject, def.CheckRequiresBuildingCellVisualizer());
        KAnimGraphTileVisualizer component3 = gameObject.GetComponent <KAnimGraphTileVisualizer>();

        if ((Object)component3 != (Object)null)
        {
            Object.DestroyImmediate(component3);
        }
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(gameObject, LogicOperationalController.INPUT_PORTS_0_0);
        }
        gameObject.PreInit();
        Assets.AddPrefab(gameObject.GetComponent <KPrefabID>());
        return(gameObject);
    }
Пример #7
0
    public static GameObject CreateAndRegisterPreview(string id, KAnimFile anim, string initial_anim, ObjectLayer object_layer, int width, int height)
    {
        GameObject gameObject = CreatePlacedEntity(id, id, id, 1f, anim, initial_anim, Grid.SceneLayer.Front, width, height, TUNING.BUILDINGS.DECOR.NONE, default(EffectorValues), SimHashes.Creature, null, 293f);

        gameObject.UpdateComponentRequirement <KSelectable>(false);
        gameObject.UpdateComponentRequirement <SaveLoadRoot>(false);
        EntityPreview entityPreview = gameObject.AddOrGet <EntityPreview>();

        entityPreview.objectLayer = object_layer;
        OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>();

        occupyArea.objectLayers = new ObjectLayer[1]
        {
            object_layer
        };
        occupyArea.ApplyToCells = false;
        gameObject.AddOrGet <Storage>();
        KPrefabID component = gameObject.GetComponent <KPrefabID>();

        Assets.AddPrefab(component);
        return(gameObject);
    }
Пример #8
0
    public GameObject CreateBuildingUnderConstruction(BuildingDef def)
    {
        GameObject gameObject = CreateBuilding(def, constructionTemplate, null);

        Object.DontDestroyOnLoad(gameObject);
        KSelectable component = gameObject.GetComponent <KSelectable>();

        component.SetName(def.Name);
        for (int i = 0; i < def.Mass.Length; i++)
        {
            gameObject.GetComponent <PrimaryElement>().MassPerUnit += def.Mass[i];
        }
        KPrefabID kPrefabID = AddID(gameObject, def.PrefabID + "UnderConstruction");

        UpdateComponentRequirement <BuildingCellVisualizer>(gameObject, def.CheckRequiresBuildingCellVisualizer());
        Constructable component2 = gameObject.GetComponent <Constructable>();

        component2.SetWorkTime(def.ConstructionTime);
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(gameObject, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        Add2DComponents(def, gameObject, "place", false, kPrefabID.defaultLayer = LayerMask.NameToLayer("Construction"));
        UpdateComponentRequirement <Vent>(gameObject, false);
        bool required = (Object)def.BuildingComplete.GetComponent <AnimTileable>() != (Object)null;

        UpdateComponentRequirement <AnimTileable>(gameObject, required);
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(gameObject, LogicOperationalController.INPUT_PORTS_0_0);
        }
        Assets.AddPrefab(kPrefabID);
        gameObject.PreInit();
        return(gameObject);
    }
    public void test()
    {
        // configurations
        string         id                   = "HatchHard";
        string         name                 = "Stone Hatch";
        string         desc                 = "Stone Hatches excrete solid Coal as waste and enjoy burrowing into the ground.";
        string         anim_file            = "hatch_kanim";
        bool           is_baby              = false;
        string         traitId              = "HatchHardBaseTrait";
        string         override_prefix      = "hvy_";
        int            space_requirement    = HatchTuning.PEN_SIZE_PER_CREATURE;
        float          lifespan             = 100f;
        float          mass                 = 100f;
        int            width                = 1;
        int            height               = 1;
        EffectorValues decor                = TUNING.DECOR.BONUS.TIER0;
        string         navGridName          = !is_baby ? "WalkerNavGrid1x1" : "WalkerBabyNavGrid";
        NavType        navi                 = NavType.Floor;
        float          moveSpeed            = 2f;
        string         dropOnDeath          = "Meat";
        int            dropCount            = 2;
        bool           canDrown             = true;
        bool           canCrushed           = false;
        float          tempLowDeath         = 243.15f;
        float          tempLowWarning       = 283.15f;
        float          tempBorn             = 293f;
        float          tempHighWarning      = 293.15f;
        float          tempHighDeath        = 343.15f;
        bool           pickup_only_from_top = true;
        bool           pickup_allow_mark    = true;
        bool           pickup_use_gun       = false;
        Tag            tag                  = GameTags.Creatures.Walker;
        Tag            species              = GameTags.Creatures.Species.HatchSpecies;
        float          attackValue          = 1f;

        ChoreTable.Builder chore_table = new ChoreTable.Builder().Add(new DeathStates.Def(), true).Add(new AnimInterruptStates.Def(), true).Add(new ExitBurrowStates.Def(), !is_baby).Add(new PlayAnimsStates.Def(GameTags.Creatures.Burrowed, true, "idle_mound", STRINGS.CREATURES.STATUSITEMS.BURROWED.NAME, STRINGS.CREATURES.STATUSITEMS.BURROWED.TOOLTIP), !is_baby).Add(new GrowUpStates.Def(), true).Add(new TrappedStates.Def(), true).Add(new IncubatingStates.Def(), true).Add(new BaggedStates.Def(), true).Add(new FallStates.Def(), true).Add(new StunnedStates.Def(), true).Add(new DrowningStates.Def(), true).Add(new DebugGoToStates.Def(), true).Add(new FleeStates.Def(), true).Add(new AttackStates.Def(), !is_baby).PushInterruptGroup().Add(new CreatureSleepStates.Def(), true).Add(new FixedCaptureStates.Def(), true).Add(new RanchedStates.Def(), true).Add(new PlayAnimsStates.Def(GameTags.Creatures.WantsToEnterBurrow, false, "hide", STRINGS.CREATURES.STATUSITEMS.BURROWING.NAME, STRINGS.CREATURES.STATUSITEMS.BURROWING.TOOLTIP), !is_baby).Add(new LayEggStates.Def(), true).Add(new EatStates.Def(), true).Add(new PlayAnimsStates.Def(GameTags.Creatures.Poop, false, "poop", STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.NAME, STRINGS.CREATURES.STATUSITEMS.EXPELLING_SOLID.TOOLTIP), true).Add(new CallAdultStates.Def(), true).PopInterruptGroup().Add(new IdleStates.Def(), true);

        string adultId           = "HatchHard";
        string eggId             = "HatchHardBaby";
        string eggName           = "Stone Hatchling Egg";
        string anim_egg          = "egg_hatch_kanim";
        float  egg_mass          = 2f;
        string dropOnMature      = null;
        float  fertility_cycles  = 60f;
        float  incubation_cycles = 20f;
        int    egg_sortorder     = 2;
        List <FertilityMonitor.BreedingChance> egg_chances = new List <FertilityMonitor.BreedingChance>();

        egg_chances.Add(BreedingChance("HatchHardEgg", 1f));
        bool  is_ranchable = true;
        bool  is_fish      = false;
        float egg_scale    = 1f;

        float            calories_per_KG = 700000f / 140f;
        float            min_poop_KG     = 25;
        List <Diet.Info> diet_list       = BaseHatchConfig.HardRockDiet(SimHashes.Carbon.CreateTag(), calories_per_KG, TUNING.CREATURES.CONVERSION_EFFICIENCY.NORMAL, null, 0f);
        // end of configurations

        // basic generation
        object    obj           = Activator.CreateInstance(typeof(HatchHardConfig));
        KPrefabID obj_kPrefabID = (obj as HatchHardConfig).CreatePrefab().GetComponent <KPrefabID>();

        obj_kPrefabID.prefabInitFn  += (obj as HatchHardConfig).OnPrefabInit;
        obj_kPrefabID.prefabSpawnFn += (obj as HatchHardConfig).OnSpawn;
        Assets.AddPrefab(obj_kPrefabID);

        // advanced generation
        // critter = BaseHatchConfig.BaseHatch(id, name, desc, anim_file, traitId, is_baby, override_prefix);
        GameObject critter;

        critter = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, Assets.GetAnim(anim_file), "idle_loop", Grid.SceneLayer.Creatures, width, height, decor, default(EffectorValues), SimHashes.Creature, null, tempBorn);
        EntityTemplates.ExtendEntityToBasicCreature(critter, FactionManager.FactionID.Pest, traitId, navGridName, navi, 32, moveSpeed, dropOnDeath, dropCount, canDrown, canCrushed, tempLowWarning, tempHighWarning, tempLowDeath, tempHighDeath);
        if (override_prefix != null)
        {
            critter.AddOrGet <SymbolOverrideController>().ApplySymbolOverridesByAffix(Assets.GetAnim(anim_file), override_prefix, null, 0);
        }
        critter.AddOrGet <Trappable>();
        critter.AddOrGetDef <CreatureFallMonitor.Def>();
        critter.AddOrGetDef <BurrowMonitor.Def>();
        critter.AddOrGetDef <WorldSpawnableMonitor.Def>().adjustSpawnLocationCb = (int cell) => { return(cell); };//new Func<int, int>(BaseHatchConfig.AdjustSpawnLocationCB);
        critter.AddOrGetDef <ThreatMonitor.Def>().fleethresholdState            = Health.HealthState.Dead;
        critter.AddWeapon(attackValue, attackValue, AttackProperties.DamageType.Standard, AttackProperties.TargetType.Single, 1, 0f);
        EntityTemplates.CreateAndRegisterBaggedCreature(critter, pickup_only_from_top, pickup_allow_mark, pickup_use_gun);
        KPrefabID prefabID = critter.GetComponent <KPrefabID>();

        prefabID.AddTag(tag, false);
        prefabID.prefabInitFn += delegate(GameObject inst) { inst.GetAttributes().Add(Db.Get().Attributes.MaxUnderwaterTravelCost); };
        EntityTemplates.AddCreatureBrain(critter, chore_table, species, override_prefix);

        EntityTemplates.ExtendEntityToWildCreature(critter, space_requirement, lifespan);

        Diet diet = new Diet(diet_list.ToArray());

        CreatureCalorieMonitor.Def calorieMonitor = critter.AddOrGetDef <CreatureCalorieMonitor.Def>();
        calorieMonitor.diet = diet;
        calorieMonitor.minPoopSizeInCalories = calories_per_KG * min_poop_KG;
        critter.AddOrGetDef <SolidConsumerMonitor.Def>().diet = diet;

        if (is_baby)
        {
            EntityTemplates.ExtendEntityToBeingABaby(critter, adultId, dropOnMature);
        }
        else
        {
            EntityTemplates.ExtendEntityToFertileCreature(critter, eggId, eggName, desc, anim_egg,
                                                          egg_mass, eggId, fertility_cycles,
                                                          incubation_cycles, egg_chances,
                                                          egg_sortorder, is_ranchable, is_fish, true, egg_scale);
        }
    }
Пример #10
0
    public GameObject CreateBuildingComplete(GameObject go, BuildingDef def)
    {
        go.name = def.PrefabID + "Complete";
        go.transform.SetPosition(new Vector3(0f, 0f, Grid.GetLayerZ(def.SceneLayer)));
        KSelectable component = go.GetComponent <KSelectable>();

        component.SetName(def.Name);
        PrimaryElement component2 = go.GetComponent <PrimaryElement>();

        component2.MassPerUnit = 0f;
        for (int i = 0; i < def.Mass.Length; i++)
        {
            component2.MassPerUnit += def.Mass[i];
        }
        component2.Temperature = 273.15f;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        if (def.Invincible)
        {
            buildingHP.invincible = true;
        }
        buildingHP.SetHitPoints(def.HitPoints);
        if (def.Repairable)
        {
            UpdateComponentRequirement <Repairable>(go, true);
        }
        int      defaultLayer = go.layer = LayerMask.NameToLayer("Default");
        Building component3   = go.GetComponent <BuildingComplete>();

        component3.Def = def;
        if (def.InputConduitType != 0 || def.OutputConduitType != 0)
        {
            go.AddComponent <BuildingConduitEndpoints>();
        }
        if (!Add2DComponents(def, go, null, false, -1))
        {
            Debug.Log(def.Name + " is not yet a 2d building!");
        }
        UpdateComponentRequirement <EnergyConsumer>(go, def.RequiresPowerInput);
        Rotatable rotatable = UpdateComponentRequirement <Rotatable>(go, def.PermittedRotations != PermittedRotations.Unrotatable);

        if ((bool)rotatable)
        {
            rotatable.permittedRotations = def.PermittedRotations;
        }
        if (def.Breakable)
        {
            go.AddComponent <Breakable>();
        }
        ConduitConsumer conduitConsumer = UpdateComponentRequirement <ConduitConsumer>(go, def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid);

        if ((Object)conduitConsumer != (Object)null)
        {
            conduitConsumer.SetConduitData(def.InputConduitType);
        }
        bool          required      = def.RequiresPowerInput || def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid;
        RequireInputs requireInputs = UpdateComponentRequirement <RequireInputs>(go, required);

        if ((Object)requireInputs != (Object)null)
        {
            requireInputs.SetRequirements(def.RequiresPowerInput, def.InputConduitType == ConduitType.Gas || def.InputConduitType == ConduitType.Liquid);
        }
        UpdateComponentRequirement <RequireOutputs>(go, def.OutputConduitType != ConduitType.None);
        UpdateComponentRequirement <Operational>(go, !def.isUtility);
        if (def.Floodable)
        {
            go.AddComponent <Floodable>();
        }
        if (def.Disinfectable)
        {
            go.AddOrGet <AutoDisinfectable>();
            go.AddOrGet <Disinfectable>();
        }
        if (def.Overheatable)
        {
            Overheatable overheatable = go.AddComponent <Overheatable>();
            overheatable.baseOverheatTemp = def.OverheatTemperature;
            overheatable.baseFatalTemp    = def.FatalHot;
        }
        if (def.Entombable)
        {
            go.AddComponent <Structure>();
        }
        if (def.RequiresPowerInput)
        {
            GeneratedBuildings.RegisterLogicPorts(go, LogicOperationalController.INPUT_PORTS_0_0);
            go.AddOrGet <LogicOperationalController>();
        }
        UpdateComponentRequirement <BuildingCellVisualizer>(go, def.CheckRequiresBuildingCellVisualizer());
        if (def.BaseDecor != 0f)
        {
            DecorProvider decorProvider = UpdateComponentRequirement <DecorProvider>(go, true);
            decorProvider.baseDecor  = def.BaseDecor;
            decorProvider.baseRadius = def.BaseDecorRadius;
        }
        if (def.AttachmentSlotTag != Tag.Invalid)
        {
            AttachableBuilding attachableBuilding = UpdateComponentRequirement <AttachableBuilding>(go, true);
            attachableBuilding.attachableToTag = def.AttachmentSlotTag;
        }
        KPrefabID kPrefabID = AddID(go, def.PrefabID);

        kPrefabID.defaultLayer = defaultLayer;
        Assets.AddPrefab(kPrefabID);
        go.PreInit();
        return(go);
    }