Esempio n. 1
0
        public void Placer(string prefab_id, Element element)
        {
            BuildingDef buildingDef  = Assets.GetBuildingDef(prefab_id);
            int         buildingCell = buildingDef.GetBuildingCell(Grid.OffsetCell(Instance.RootCell, Left, Bot));
            Vector3     pos          = Grid.CellToPosCBC(buildingCell, Grid.SceneLayer.Building);

            UpdateMinMax(Left, Bot);
            UpdateMinMax(Left + buildingDef.WidthInCells - 1, Bot + buildingDef.HeightInCells - 1);
            Left += buildingDef.WidthInCells;
            Scenario.RunAfterNextUpdate(delegate
            {
                Assets.GetBuildingDef(prefab_id).TryPlace(null, pos, Orientation.Neutral, new Tag[2]
                {
                    element.tag,
                    ElementLoader.FindElementByHash(SimHashes.SedimentaryRock).tag
                }, 0);
            });
        }
Esempio n. 2
0
    public static GameObject PlaceBuilding(int root_cell, int x, int y, string prefab_id, SimHashes element = SimHashes.Cuprite)
    {
        int         cell        = Grid.OffsetCell(root_cell, x, y);
        BuildingDef buildingDef = Assets.GetBuildingDef(prefab_id);

        if ((UnityEngine.Object)buildingDef == (UnityEngine.Object)null || buildingDef.PlacementOffsets == null)
        {
            DebugUtil.LogErrorArgs("Missing def for", prefab_id);
        }
        Element element2 = ElementLoader.FindElementByHash(element);

        Debug.Assert(element2 != null, "Missing primary element.");
        GameObject gameObject = buildingDef.Build(buildingDef.GetBuildingCell(cell), Orientation.Neutral, null, new Tag[2]
        {
            element2.tag,
            ElementLoader.FindElementByHash(SimHashes.SedimentaryRock).tag
        }, 293.15f, false, -1f);
        PrimaryElement component = gameObject.GetComponent <PrimaryElement>();

        component.InternalTemperature = 300f;
        component.Temperature         = 300f;
        return(gameObject);
    }