public static FileSystemNode ToFilesystemNode(this FileInfo file, string mime = "") => FileSystemNode.CreateFile( file.Name, file.Directory.FullName, file.CreationTime, file.LastWriteTime, file.Length, Path.DirectorySeparatorChar.ToString(), mime);
static void ConvertModel(string[] args) { Root r = new Root(args, true); FileSystemNode models = r.FileSystem.Get("models"); FileSystemNode model = (FileSystemNode)models[args[0]]; Hashtable ht = new Hashtable(); //collect submeshes to convert foreach (DictionaryEntry de in model) { string name = (string)de.Key; if (name.EndsWith(".submesh") && !model.ContainsKey(name + ".bin")) { ht.Add(de.Key, de.Value); } } //convert all files in ht foreach (DictionaryEntry de in ht) { string name = (string)de.Key; FileSystemNode submeshnode = (FileSystemNode)de.Value; SubMesh sm = (SubMesh)r.ResourceManager.Load(submeshnode, typeof(SubMesh)); FileSystemNode newnode = model.CreateFile(name + ".bin"); SubMeshSaver sms = new SubMeshSaver(); sms.Save(sm, newnode.getStream()); } }
private void ServerStart_Click(object sender, EventArgs e) { if (HostSinglePlayer.Checked) { SingleStart(); return; } if (GameRunning) { Root.Instance.Quit = true; return; } //start non-dedicated or dedicated server GameRunning = true; ServerStart.Text = "Stop"; Helper h = null; if (HostDedicated.Checked) { //SimpleUserInterface sui = new SimpleUserInterface(); Cheetah.Root.Instance.LocalObjects.Add(h = new Helper()); } Root r = Root.Instance; if (HostNonDedicated.Checked) { //bring up the userinterface //ViewerForm vf = new ViewerForm(); //vf.Show(); //r.ClientClient(new string[] { }, vf.glControl1); r.ClientClient(new string[] {}); } r.ServerServer(new string[] { }); r.Authoritive = true; r.Scene = new Scene(); if (HostRecordDemo.Checked) { string name = string.Format("{2}{3,02}{4,2}{5,2}{6,2}-{0}-{1}.demo", ((Type)HostRule.SelectedItem).Name, ((Type)HostMap.SelectedItem).Name, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute); name = name.Replace(' ', '0'); FileSystemNode demo = Root.Instance.FileSystem.Get("demos"); demo = demo.CreateFile(name); Root.Instance.Recorder = new DemoRecorder(demo.getStream(), true, 20); } Flow f; if (CurrentGameSettings is IRuleCreator) { if (HostDedicated.Checked) { f = new SpaceWar2006.Flows.GameServer( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value ); } else { f = new SpaceWar2006.Flows.Game( ((IRuleCreator)CurrentGameSettings).CreateRule(), CreateMap(), (int)HostBots.Value, false ); } } else { if (HostNonDedicated.Checked) { throw new Exception(); } f = new SpaceWar2006.Flows.GameServer(); } Root.Instance.ResourceManager.LoadConfig("config/global.config").Set("server.password", this.HostPassword.Text); r.CurrentFlow = f; f.Start(); r.ServerRun(HostDedicated.Checked); f.Stop(); r.ServerStop(); r.ResourceManager.UnloadAll(); if (r.UserInterface != null) { r.Dispose(); r.UserInterface = null; } if (h != null) { Cheetah.Root.Instance.LocalObjects.Remove(h); } Root.Instance.Recorder = null; GameRunning = false; if (HostRecordDemo.Checked) { LoadDemos(); } ServerStart.Text = "Start"; //StatusBar.Text = "Dedicated Server stopped. Ready."; }