Exemple #1
0
            public static void Prefix(Comet __instance, Vector3 pos, int cell, int damage)
            {
                if (!Grid.IsValidCell(cell))
                {
                    return;
                }
                if (!MyGrid.IsScaffolding(cell))
                {
                    return;
                }

                GameObject gameObject = Grid.Objects[cell, (int)ObjectLayer.AttachableBuilding];

                if (gameObject != null)
                {
                    BuildingHP component = gameObject.GetComponent <BuildingHP>();
                    if (component != null)
                    {
                        float f = gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Bunker) ? ((float)damage * __instance.bunkerDamageMultiplier) : ((float)damage);
                        component.gameObject.Trigger((int)GameHashes.DoBuildingDamage, new BuildingHP.DamageSourceInfo
                        {
                            damage    = Mathf.RoundToInt(f),
                            source    = BUILDINGS.DAMAGESOURCES.COMET,
                            popString = UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
                        });
                    }
                }
            }
Exemple #2
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            GeneratedBuildings.RegisterSingleLogicInputPort(go);
            go.AddOrGet <LogicOperationalController>();
            go.AddOrGet <RotatableExhaust>();
            Vent vent = go.AddOrGet <Vent>();

            vent.conduitType      = ConduitType.Gas;
            vent.endpointType     = Endpoint.Sink;
            vent.overpressureMass = WallPumpsConfig.GetConfig().gasWallPressureVent.maxPressure;
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType        = ConduitType.Gas;
            conduitConsumer.ignoreMinMassCheck = true;
            Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

            storage.showInUI = true;
            go.AddOrGet <SimpleVent>();
            SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

            simCellOccupier.notifyOnMelt = true;
            go.AddOrGet <Insulator>();
            go.AddOrGet <TileTemperature>();
            BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

            buildingHP.destroyOnDamaged = true;
        }
Exemple #3
0
    // Build function for turret
    public override GameObject Build(Transform spawnPoint, Grid grid)
    {
        if (canBuild)
        {
            Vector3Int cellPosition     = grid.WorldToCell(spawnPoint.position);
            Vector3    turretSpawnPoint = new Vector3();
            turretSpawnPoint = grid.GetCellCenterLocal(cellPosition) + new Vector3(0f, 1f, 0f); // Add offset

            var turret = Instantiate(gameObject, turretSpawnPoint, Quaternion.identity);

            buildUIInfo = Instantiate(buildableUI, turretSpawnPoint - new Vector3(3.5f, 0.5f, 0f), Quaternion.Euler(Vector3.zero));
            buildUIInfo.GetComponentInChildren <BuildTimer>().SetBuildTime(this.buildTime);

            turret.GetComponent <TurretAI>().isbuilding  = true;
            turret.GetComponent <TurretAI>().buildUIInfo = this.buildUIInfo;

            CurrentHpDisplay = buildUIInfo.GetComponentInChildren <BuildingHP>();
            turret.GetComponent <TurretAI>().CurrentHpDisplay = this.CurrentHpDisplay;

            return(turret);
        }
        else
        {
            return(null);
        }
    }
Exemple #4
0
            /// <summary>
            /// Applied after DoDamage runs.
            /// </summary>
            internal static void Postfix(BuildingHP __instance, object data)
            {
                Wire wire;
                WireUtilityNetworkLink bridge;

                if (__instance != null && data is BuildingHP.DamageSourceInfo source &&
                    (source.source == STRINGS.BUILDINGS.DAMAGESOURCES.CIRCUIT_OVERLOADED ||
                     source.takeDamageEffect == SpawnFXHashes.BuildingSpark))
                {
                    var obj = __instance.gameObject;
#if DEBUG
                    PUtil.LogDebug("Wire overloaded: " + obj.name);
#endif
                    if ((wire = obj.GetComponentSafe <Wire>()) != null)
                    {
                        // Wire is overloading
                        AchievementStateComponent.OnOverload(wire.GetMaxWattageRating());
                    }
                    else if ((bridge = obj.GetComponentSafe <WireUtilityNetworkLink>()) != null)
                    {
                        // Wire bridge is overloading
                        AchievementStateComponent.OnOverload(bridge.GetMaxWattageRating());
                    }
                }
            }
Exemple #5
0
    private void OnBuildingRepaired(object data)
    {
        BuildingHP buildingHP = (BuildingHP)data;
        float      damage     = 1f - (float)buildingHP.HitPoints / (float)buildingHP.MaxHitPoints;

        building.RunOnArea(delegate(int offset_cell)
        {
            WorldDamage.Instance.RestoreDamageToValue(offset_cell, damage);
        });
    }
Exemple #6
0
    public bool Connect()
    {
        BuildingHP component = GetComponent <BuildingHP>();

        if ((UnityEngine.Object)component == (UnityEngine.Object)null || component.HitPoints > 0)
        {
            disconnected = false;
            Game.Instance.logicCircuitSystem.ForceRebuildNetworks();
        }
        return(!disconnected);
    }
Exemple #7
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

            simCellOccupier.notifyOnMelt = true;
            go.AddOrGet <Insulator>();
            go.AddOrGet <TileTemperature>();
            BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

            buildingHP.destroyOnDamaged = true;
        }
Exemple #8
0
    public bool Connect()
    {
        BuildingHP component = GetComponent <BuildingHP>();

        if ((UnityEngine.Object)component == (UnityEngine.Object)null || component.HitPoints > 0)
        {
            disconnected = false;
            GetNetworkManager().ForceRebuildNetworks();
        }
        return(!disconnected);
    }
Exemple #9
0
    public override GameObject Build(Transform spawnPoint, Grid grid)
    {
        if (canBuild)
        {
            Vector3Int cellPosition   = grid.WorldToCell(spawnPoint.position);  // Converts World position to cell, and cell back to world
            Vector3    wallSpawnPoint = new Vector3();
            wallSpawnPoint = grid.GetCellCenterLocal(cellPosition);

            spawnAngle = spawnPoint.GetComponentInParent <RotateFromMouse>().transform.localEulerAngles.z; // Spawn angle's rotation

            float offset = (grid.cellSize.x / 2);                                                          // Since size of grid is 1, we want the wall to be 1/2 from the middle

            if ((spawnAngle <= 45f && spawnAngle >= 0f) || (spawnAngle <= 359.9f && spawnAngle >= 315.0f)) // Right
            {
                buildAngle      = 90;
                wallSpawnPoint -= new Vector3(offset, 0f, 0f);
            }
            else if (spawnAngle <= 135.0f && spawnAngle > 45.0f)    // Up
            {
                buildAngle      = 180;
                wallSpawnPoint -= new Vector3(0f, offset, 0f);
            }
            else if (spawnAngle >= 135.0f && spawnAngle < 225.0f)   // Left
            {
                buildAngle      = 270;
                wallSpawnPoint += new Vector3(offset, 0f, 0f);
            }
            else if (spawnAngle >= 225.0f && spawnAngle < 315.0f)   // Down
            {
                buildAngle      = 360;
                wallSpawnPoint += new Vector3(0f, offset, 0f);
            }

            var wall = Instantiate(gameObject, wallSpawnPoint, Quaternion.Euler(0, 0, buildAngle));     // Spawning wall

            // Setting up info for wall clone
            buildUIInfo = (GameObject)Instantiate(buildableUI, wallSpawnPoint - new Vector3(3.5f, 0.5f, 0f), Quaternion.Euler(Vector3.zero));
            buildUIInfo.GetComponentInChildren <BuildTimer>().SetBuildTime(this.buildTime);

            wall.GetComponent <Wall>().isbuilding  = true;
            wall.GetComponent <Wall>().buildUIInfo = this.buildUIInfo;

            CurrentHpDisplay = buildUIInfo.GetComponentInChildren <BuildingHP>();
            wall.GetComponent <Wall>().CurrentHpDisplay = this.CurrentHpDisplay;

            return(wall);
        }
        else
        {
            return(null);
        }
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

        simCellOccupier.doReplaceElement = true;
        go.AddOrGet <TileTemperature>();
        KAnimGridTileVisualizer kAnimGridTileVisualizer = go.AddOrGet <KAnimGridTileVisualizer>();

        kAnimGridTileVisualizer.blockTileConnectorID = BlockTileConnectorID;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        buildingHP.destroyOnDamaged = true;
    }
    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            PlayerMovement pm = col.GetComponent <PlayerMovement>();
            pm.HealthBar.value -= pm.ShootThreeDamage;
        }
        if (col.tag == "Building")
        {
            BuildingHP BHP = col.GetComponent <BuildingHP>();

            BHP.HP -= 20;
        }
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
        SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

        simCellOccupier.doReplaceElement = false;
        go.AddOrGet <TileTemperature>();
        KAnimGridTileVisualizer kAnimGridTileVisualizer = go.AddOrGet <KAnimGridTileVisualizer>();

        kAnimGridTileVisualizer.blockTileConnectorID = BlockTileConnectorID;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        buildingHP.destroyOnDamaged = true;
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
        SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

        simCellOccupier.movementSpeedMultiplier = DUPLICANTSTATS.MOVEMENT.BONUS_3;
        simCellOccupier.notifyOnMelt            = true;
        go.AddOrGet <TileTemperature>();
        KAnimGridTileVisualizer kAnimGridTileVisualizer = go.AddOrGet <KAnimGridTileVisualizer>();

        kAnimGridTileVisualizer.blockTileConnectorID = BlockTileConnectorID;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        buildingHP.destroyOnDamaged = true;
    }
Exemple #14
0
    protected override void OnSpawn()
    {
        inputOne = new LogicEventHandler(base.InputCellOne, UpdateState, null, LogicPortSpriteType.Input);
        if (base.RequiresTwoInputs)
        {
            inputTwo = new LogicEventHandler(base.InputCellTwo, UpdateState, null, LogicPortSpriteType.Input);
        }
        Subscribe(774203113, OnBuildingBrokenDelegate);
        Subscribe(-1735440190, OnBuildingFullyRepairedDelegate);
        BuildingHP component = GetComponent <BuildingHP>();

        if ((Object)component == (Object)null || !component.IsBroken)
        {
            Connect();
        }
    }
Exemple #15
0
        protected override void OnSpawn()
        {
            inputOne = CreateLogicEventHandler(InputCellOne, new Action <int>(UpdateState), null, LogicPortSpriteType.RibbonInput);
            if (RequiresTwoInputs)
            {
                inputTwo = CreateLogicEventHandler(InputCellTwo, new Action <int>(UpdateState), null, LogicPortSpriteType.RibbonInput);
            }
            Subscribe(774203113, OnBuildingBrokenDelegate);
            Subscribe(-1735440190, OnBuildingFullyRepairedDelegate);
            BuildingHP component = GetComponent <BuildingHP>();

            if (component != null && component.IsBroken)
            {
                return;
            }
            Connect();
        }
Exemple #16
0
    private void DamageThings(Vector3 pos, int cell, int damage)
    {
        if (Grid.IsValidCell(cell))
        {
            GameObject gameObject = Grid.Objects[cell, 1];
            if ((Object)gameObject != (Object)null)
            {
                BuildingHP component  = gameObject.GetComponent <BuildingHP>();
                Building   component2 = gameObject.GetComponent <Building>();
                if ((Object)component != (Object)null && !damagedEntities.Contains(gameObject))
                {
                    KPrefabID component3 = gameObject.GetComponent <KPrefabID>();
                    float     f          = (!component3.HasTag(GameTags.Bunker)) ? ((float)damage) : ((float)damage * bunkerDamageMultiplier);
                    if ((Object)component2 != (Object)null && (Object)component2.Def != (Object)null)
                    {
                        PlayBuildingDamageSound(component2.Def, Grid.CellToPos(cell));
                    }
                    component.gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
                    {
                        damage    = Mathf.RoundToInt(f),
                        source    = (string)BUILDINGS.DAMAGESOURCES.COMET,
                        popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
                    });
                    damagedEntities.Add(gameObject);
                }
            }
            ListPool <ScenePartitionerEntry, Comet> .PooledList pooledList = ListPool <ScenePartitionerEntry, Comet> .Allocate();

            GameScenePartitioner.Instance.GatherEntries((int)pos.x, (int)pos.y, 1, 1, GameScenePartitioner.Instance.pickupablesLayer, pooledList);
            foreach (ScenePartitionerEntry item in pooledList)
            {
                Pickupable pickupable = item.obj as Pickupable;
                Health     component4 = pickupable.GetComponent <Health>();
                if ((Object)component4 != (Object)null && !damagedEntities.Contains(pickupable.gameObject))
                {
                    KPrefabID component5 = pickupable.GetComponent <KPrefabID>();
                    float     amount     = (!component5.HasTag(GameTags.Bunker)) ? ((float)damage) : ((float)damage * bunkerDamageMultiplier);
                    component4.Damage(amount);
                    damagedEntities.Add(pickupable.gameObject);
                }
            }
            pooledList.Recycle();
        }
    }
Exemple #17
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
        SimCellOccupier simCellOccupier = go.AddOrGet <SimCellOccupier>();

        simCellOccupier.setTransparent = true;
        simCellOccupier.notifyOnMelt   = true;
        go.AddOrGet <TileTemperature>();
        KAnimGridTileVisualizer kAnimGridTileVisualizer = go.AddOrGet <KAnimGridTileVisualizer>();

        kAnimGridTileVisualizer.blockTileConnectorID = BlockTileConnectorID;
        BuildingHP buildingHP = go.AddOrGet <BuildingHP>();

        buildingHP.destroyOnDamaged = true;
        KPrefabID component = go.GetComponent <KPrefabID>();

        component.AddTag(GameTags.Window, false);
    }
Exemple #18
0
        private static void DoWorldDamage(GameObject part, Vector3 apparentPosition)
        {
            OccupyArea component = part.GetComponent <OccupyArea>();

            component.UpdateOccupiedArea();
            CellOffset[] occupiedCellsOffsets = component.OccupiedCellsOffsets;
            foreach (CellOffset offset in occupiedCellsOffsets)
            {
                int num = Grid.OffsetCell(Grid.PosToCell(apparentPosition), offset);
                if (Grid.IsValidCell(num))
                {
                    if (Grid.Solid[num])
                    {
                        WorldDamage instance    = WorldDamage.Instance;
                        int         cell        = num;
                        float       amount      = 10000f;
                        int         src_cell    = num;
                        string      source_name = BUILDINGS.DAMAGESOURCES.ROCKET;
                        instance.ApplyDamage(cell, amount, src_cell, -1, source_name, UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.ROCKET);
                    }
                    else if (Grid.FakeFloor[num])
                    {
                        GameObject gameObject = Grid.Objects[num, 38];
                        if ((Object)gameObject != (Object)null)
                        {
                            BuildingHP component2 = gameObject.GetComponent <BuildingHP>();
                            if ((Object)component2 != (Object)null)
                            {
                                gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
                                {
                                    damage    = component2.MaxHitPoints,
                                    source    = (string)BUILDINGS.DAMAGESOURCES.ROCKET,
                                    popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.ROCKET
                                });
                            }
                        }
                    }
                }
            }
        }
Exemple #19
0
    private void SetupBuildingTest(RowLayout row_layout, bool is_powered, bool break_building)
    {
        Builder builder = null;
        int     num     = 0;

        foreach (BuildingDef buildingDef in Assets.BuildingDefs)
        {
            if (builder == null)
            {
                builder = row_layout.NextRow();
                num     = Left;
                if (is_powered)
                {
                    builder.Minion(null);
                    builder.Minion(null);
                }
            }
            if (buildingDef.Name != "Excavator")
            {
                GameObject gameObject = builder.Building(buildingDef.PrefabID);
                if (break_building)
                {
                    BuildingHP component = gameObject.GetComponent <BuildingHP>();
                    if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                    {
                        component.DoDamage(2147483647);
                    }
                }
            }
            if (builder.Left > num + 100)
            {
                builder.FinalizeRoom(SimHashes.Oxygen, SimHashes.Steel);
                builder = null;
            }
        }
        builder.FinalizeRoom(SimHashes.Oxygen, SimHashes.Steel);
    }
Exemple #20
0
    private float DamageTiles(int cell, int prev_cell, float input_damage)
    {
        GameObject gameObject = Grid.Objects[cell, 9];
        float      num        = 1f;
        bool       flag       = false;

        if ((Object)gameObject != (Object)null)
        {
            if (gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Window))
            {
                num = windowDamageMultiplier;
            }
            else if (gameObject.GetComponent <KPrefabID>().HasTag(GameTags.Bunker))
            {
                num = bunkerDamageMultiplier;
                if ((Object)gameObject.GetComponent <Door>() != (Object)null)
                {
                    Game.Instance.savedInfo.blockedCometWithBunkerDoor = true;
                }
            }
            SimCellOccupier component = gameObject.GetComponent <SimCellOccupier>();
            if ((Object)component != (Object)null && !component.doReplaceElement)
            {
                flag = true;
            }
        }
        Element element = (!flag) ? Grid.Element[cell] : gameObject.GetComponent <PrimaryElement>().Element;

        if (element.strength == 0f)
        {
            return(0f);
        }
        float num2 = input_damage * num / element.strength;

        PlayTileDamageSound(element, Grid.CellToPos(cell));
        if (num2 == 0f)
        {
            return(0f);
        }
        float num3;

        if (flag)
        {
            BuildingHP component2 = gameObject.GetComponent <BuildingHP>();
            float      a          = (float)component2.HitPoints / (float)component2.MaxHitPoints;
            float      f          = num2 * (float)component2.MaxHitPoints;
            component2.gameObject.Trigger(-794517298, new BuildingHP.DamageSourceInfo
            {
                damage    = Mathf.RoundToInt(f),
                source    = (string)BUILDINGS.DAMAGESOURCES.COMET,
                popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET
            });
            num3 = Mathf.Min(a, num2);
        }
        else
        {
            WorldDamage instance    = WorldDamage.Instance;
            float       amount      = num2;
            string      source_name = BUILDINGS.DAMAGESOURCES.COMET;
            num3 = instance.ApplyDamage(cell, amount, prev_cell, -1, source_name, UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.COMET);
        }
        destroyedCells.Add(cell);
        float num4 = num3 / num2;

        return(input_damage * (1f - num4));
    }
Exemple #21
0
//---------------------------------------------------------------------MONO METHODS:

    void OnTriggerEnter(Collider col)
    {
        if (col.tag == "Player")
        {
            PlayerMovement pm = col.GetComponent <PlayerMovement>();
            Debug.Log(col.tag + " - " + gameObject.name);
            if (gameObject.tag == "Bullet")
            {
                if (FlakHitSound != null)
                {
                    Source.clip = FlakHitSound;
                    Source.Play();
                }
                pm.HealthBar.value -= pm.ShootOneDamage;
            }
            else if (gameObject.tag == "Cannon")
            {
                if (CannonHitSound != null)
                {
                    Source.clip = CannonHitSound;
                    Source.Play();
                }
                pm.HealthBar.value -= pm.ShootTwoDamage;
            }
        }
        else if (col.tag == "Left Gun")
        {
            PlayerMovement pm = col.transform.parent.GetComponent <PlayerMovement>();
            if (gameObject.tag == "Bullet")
            {
                pm.LeftGunHP -= pm.ShootOneDamage;
            }
            else if (gameObject.tag == "Cannon")
            {
                pm.LeftGunHP -= pm.ShootTwoDamage;
            }
        }
        else if (col.tag == "Right Gun")
        {
            PlayerMovement pm = col.transform.parent.GetComponent <PlayerMovement>();
            if (gameObject.tag == "Bullet")
            {
                pm.RightGunHP -= pm.ShootOneDamage;
            }
            else if (gameObject.tag == "Cannon")
            {
                pm.RightGunHP -= pm.ShootTwoDamage;
            }
        }

        if (col.tag == "Building")
        {
            BuildingHP BHP = col.GetComponent <BuildingHP>();

            if (gameObject.tag == "Bullet")
            {
                BHP.HP -= 1;
            }
            else if (gameObject.tag == "Cannon")
            {
                BHP.HP -= 8;
            }
        }
        //Spawn dust animation
        //Move back to queue
        Destroy(gameObject);
    }
Exemple #22
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);
    }