internal void WriteBufferToFile() { const string signature = "e2d (lvl2d)"; Color32 view_color = (Color32)view.backgroundColor; var header = new LvlHeader() { palette = (ushort)palette.Length, layers = (ushort)chunk.layers.Count, width = (ushort)(chunk.scaled_bounds.width), height = (ushort)(chunk.scaled_bounds.height), name = config.name, author = signature, camera = new LvlHeader.Camera() { x = saved_view.position.x, y = saved_view.position.y, z = saved_view.position.z, ortho_size = saved_view.orthographic_size, set_color = config.set_camera_color, r = view_color.r, g = view_color.g, b = view_color.b } }; Func <GameObject, int> find_prefab = (e) => FindPrefab(e, out _); Func <int, LvlLayer> find_layer = (l) => { return(new LvlLayer() { layer_id = l, z_depth = chunk.layers[l].z_depth }); }; Func <int, Vector2Int, GameObject> find_entity = (l, grid_pos) => { layer = l; return(Select(grid_pos)); }; using (var fs = File.Open(config.path, FileMode.Create)) { using (var bin = new BinaryWriter(fs)) { var lvl = new LvlWriter(bin); lvl.WriteAll(header, find_layer, find_entity, find_prefab); } } log = string.Format("Write: {0}", config.path); if (OnFileSaved != null) { OnFileSaved(this, config.path); } }
public AdminCore() { //TODO: check EnableRuntime before creating these objects to save memory Database = new SQLHandler(this); Server = new ServerManager(this); WebAdmin = new WebServer(this); Rcon = new RconClient(this); Players = new PlayerHandler(this); Announce = new AnnounceHandler(this); Game = new GameHandler(this); Commands = new CommandDispatcher(this); Mods = new LvlWriter(this); Plugins = new PluginManager(this); }