Ejemplo n.º 1
0
    void LoadFurnitureLua(string filePath)
    {
        string myLuaCode = System.IO.File.ReadAllText(filePath);

        // Instantiate the singleton

        FurnitureActions.addScript(myLuaCode);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Loads all TileType definitions in Data\ and Data\Mods
    /// </summary>
    public static void LoadTileTypes()
    {
        // Load lua code
        string luaPath     = System.IO.Path.Combine(Application.streamingAssetsPath, "LUA");
        string luaFilePath = System.IO.Path.Combine(luaPath, "Tile.lua");
        string luaCode     = System.IO.File.ReadAllText(luaFilePath);

        FurnitureActions.addScript(luaCode);

        // Load all mod defined lua code
        foreach (DirectoryInfo mod in WorldController.Instance.modsManager.GetMods())
        {
            foreach (FileInfo file in mod.GetFiles("Tiles.lua"))
            {
                Debug.ULogChannel("TileType", "Loading mod " + mod.Name + " TileType definitions!");

                luaCode = System.IO.File.ReadAllText(file.FullName);

                FurnitureActions.addScript(luaCode);
            }
        }

        // Load TileType xml definitions
        string dataPath = System.IO.Path.Combine(Application.streamingAssetsPath, "Data");
        string xmlPath  = System.IO.Path.Combine(dataPath, "Tiles.xml");
        string xmlText  = System.IO.File.ReadAllText(xmlPath);

        readTileTypesFromXml(xmlText);

        // Load all mod defined TileType definitions
        foreach (DirectoryInfo mod in WorldController.Instance.modsManager.GetMods())
        {
            foreach (FileInfo file in mod.GetFiles("Tiles.xml"))
            {
                Debug.ULogChannel("TileType", "Loading mod " + mod.Name + " TileType definitions!");

                xmlText = System.IO.File.ReadAllText(file.FullName);

                readTileTypesFromXml(xmlText);
            }
        }
    }