Example #1
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);
    }