public void InitObjects() { Debug.LogWarning("kOS: InitObjects: " + (shared == null)); shared = new SharedObjects(); CreateFactory(); shared.Vessel = vessel; shared.Processor = this; shared.UpdateHandler = new UpdateHandler(); shared.BindingMgr = new BindingManager(shared); shared.Interpreter = shared.Factory.CreateInterpreter(shared); shared.Screen = shared.Interpreter; shared.ScriptHandler = new Compilation.KS.KSScript(); shared.Logger = new KSPLogger(shared); shared.VolumeMgr = new VolumeManager(shared); shared.ProcessorMgr = new ProcessorManager(); shared.Cpu = new Execution.CPU(shared); // Make the window that is going to correspond to this kOS part: var gObj = new GameObject("kOSTermWindow", typeof(kOS.Screen.TermWindow)); DontDestroyOnLoad(gObj); shared.Window = (kOS.Screen.TermWindow)gObj.GetComponent(typeof(kOS.Screen.TermWindow)); shared.Window.AttachTo(shared); // initialize archive var archive = shared.Factory.CreateArchive(); shared.VolumeMgr.Add(archive); // initialize harddisk if (HardDisk == null && archive.CheckRange(vessel)) { HardDisk = new Harddisk(Mathf.Min(diskSpace, PROCESSOR_HARD_CAP)); var bootProgramFile = archive.GetByName(bootFile); if (bootProgramFile != null) { // Copy to HardDisk as "boot". var boot = new ProgramFile(bootProgramFile) { Filename = "boot" }; HardDisk.Add(boot); } } shared.VolumeMgr.Add(HardDisk); // process setting if (!Config.Instance.StartOnArchive) { shared.VolumeMgr.SwitchTo(HardDisk); } shared.Cpu.Boot(); }
public static Harddisk ToHardDisk(this ConfigNode configNode) { var capacity = 10000; if (configNode.HasValue("capacity")) capacity = int.Parse(configNode.GetValue("capacity")); var toReturn = new Harddisk(capacity); if (configNode.HasValue("volumeName")) toReturn.Name = configNode.GetValue("volumeName"); foreach (ConfigNode fileNode in configNode.GetNodes("file")) { toReturn.Add(fileNode.ToProgramFile()); } return toReturn; }
public void InitObjects() { SafeHouse.Logger.LogWarning("InitObjects: " + (shared == null)); shared = new SharedObjects(); CreateFactory(); shared.Vessel = vessel; shared.Processor = this; shared.KSPPart = part; shared.UpdateHandler = new UpdateHandler(); shared.BindingMgr = new BindingManager(shared); shared.Interpreter = shared.Factory.CreateInterpreter(shared); shared.Screen = shared.Interpreter; shared.ScriptHandler = new KSScript(); shared.Logger = new KSPLogger(shared); shared.VolumeMgr = shared.Factory.CreateVolumeManager(shared); shared.ProcessorMgr = new ProcessorManager(); shared.FunctionManager = new FunctionManager(shared); shared.TransferManager = new TransferManager(shared); shared.Cpu = new CPU(shared); shared.SoundMaker = Sound.SoundMaker.Instance; // Make the window that is going to correspond to this kOS part: var gObj = new GameObject("kOSTermWindow", typeof(Screen.TermWindow)); DontDestroyOnLoad(gObj); shared.Window = (Screen.TermWindow)gObj.GetComponent(typeof(Screen.TermWindow)); shared.Window.AttachTo(shared); // initialize archive var archive = shared.Factory.CreateArchive(); shared.VolumeMgr.Add(archive); // initialize harddisk if (HardDisk == null) { HardDisk = new Harddisk(Mathf.Min(diskSpace, PROCESSOR_HARD_CAP)); if (!String.IsNullOrEmpty(Tag)) { HardDisk.Name = Tag; } // populate it with the boot file, but only if using a new disk and in PRELAUNCH situation: if (vessel.situation == Vessel.Situations.PRELAUNCH && bootFile != "None" && !Config.Instance.StartOnArchive) { var bootProgramFile = archive.GetByName(bootFile); if (bootProgramFile != null) { // Copy to HardDisk as "boot". var boot = new ProgramFile(bootProgramFile) { Filename = bootFile }; HardDisk.Add(boot); } } } shared.VolumeMgr.Add(HardDisk); // process setting if (!Config.Instance.StartOnArchive) { shared.VolumeMgr.SwitchTo(HardDisk); } InitProcessorTracking(); }
public void InitObjects() { SafeHouse.Logger.LogWarning("InitObjects: " + (shared == null)); shared = new SharedObjects(); CreateFactory(); shared.Vessel = vessel; shared.Processor = this; shared.KSPPart = part; shared.UpdateHandler = new UpdateHandler(); shared.BindingMgr = new BindingManager(shared); shared.Interpreter = shared.Factory.CreateInterpreter(shared); shared.Screen = shared.Interpreter; shared.ScriptHandler = new KSScript(); shared.Logger = new KSPLogger(shared); shared.VolumeMgr = shared.Factory.CreateVolumeManager(shared); shared.ProcessorMgr = new ProcessorManager(); shared.FunctionManager = new FunctionManager(shared); shared.TransferManager = new TransferManager(shared); shared.Cpu = new CPU(shared); shared.SoundMaker = Sound.SoundMaker.Instance; // Make the window that is going to correspond to this kOS part: var gObj = new GameObject("kOSTermWindow", typeof(Screen.TermWindow)); DontDestroyOnLoad(gObj); shared.Window = (Screen.TermWindow)gObj.GetComponent(typeof(Screen.TermWindow)); shared.Window.AttachTo(shared); // initialize archive var archive = shared.Factory.CreateArchive(); shared.VolumeMgr.Add(archive); // initialize harddisk if (HardDisk == null) { HardDisk = new Harddisk(Mathf.Min(diskSpace, PROCESSOR_HARD_CAP)); // populate it with the boot file, but only if using a new disk and in PRELAUNCH situation: if (vessel.situation == Vessel.Situations.PRELAUNCH && bootFile != "None" && !Config.Instance.StartOnArchive) { var bootProgramFile = archive.GetByName(bootFile); if (bootProgramFile != null) { // Copy to HardDisk as "boot". var boot = new ProgramFile(bootProgramFile) { Filename = bootFile }; HardDisk.Add(boot); } } } shared.VolumeMgr.Add(HardDisk); // process setting if (!Config.Instance.StartOnArchive) { shared.VolumeMgr.SwitchTo(HardDisk); } InitProcessorTracking(); }