private static string GetPath(IBaseDirectory baseDirectory) { var path = Path.Combine(baseDirectory.FullPath, "Content", TargetPlatformUtility.GetExecutingPlatform().ToString()); Directory.CreateDirectory(path); return(path); }
private static string GetPath(IBaseDirectory baseDirectory) { var path = Path.Combine(baseDirectory.FullPath, "Content"); Directory.CreateDirectory(path); return(path); }
public SourceDirLocalFilesystemAssetFsLayer(IBaseDirectory baseDirectory) { _localLayer = null; var sourcePath = Path.Combine(baseDirectory.FullPath, "Content", ".source"); if (!File.Exists(sourcePath)) { return; } using (var reader = new StreamReader(sourcePath)) { sourcePath = reader.ReadLine(); if (string.Equals(sourcePath, Path.Combine(baseDirectory.FullPath, "Content"), StringComparison.OrdinalIgnoreCase)) { return; } } Directory.CreateDirectory(sourcePath); _localLayer = new LocalFilesystemAssetFsLayer(sourcePath); }
public CurrentDirPlatformLocalFilesystemAssetFsLayer(IBaseDirectory baseDirectory) : base(GetPath(baseDirectory)) { }
public void LoadFromPath( IConsoleHandle consoleHandle, IBaseDirectory baseDirectory, IBackBufferDimensions backBufferDimensions, string gameAssembly) { // Wrap the backbuffer dimensions service in a proxy, since GraphicsDevice can not // cross the AppDomain boundary. backBufferDimensions = new BackBufferDimensionsProxy(backBufferDimensions); // Load the target assembly. consoleHandle.LogDebug("Loading game assembly from " + gameAssembly + "..."); var assembly = Assembly.LoadFrom(gameAssembly); consoleHandle.LogDebug("Constructing standard kernel..."); var kernel = new StandardKernel(); kernel.Bind <IRawLaunchArguments>() .ToMethod(x => new DefaultRawLaunchArguments(new string[0])) .InSingletonScope(); // Bind our extension hook first so that it runs before everything else. kernel.Bind <IEngineHook>().To <ExtensionEngineHook>().InSingletonScope(); Func <System.Reflection.Assembly, Type[]> TryGetTypes = a => { try { return(a.GetTypes()); } catch { return(new Type[0]); } }; consoleHandle.LogDebug("Finding configuration classes in " + gameAssembly + "..."); var typeSource = new List <Type>(); foreach (var attribute in assembly.GetCustomAttributes(false)) { if (attribute.GetType().FullName == "Protogame.ConfigurationAttribute") { typeSource.Add(((ConfigurationAttribute)attribute).GameConfigurationOrServerClass); } } if (typeSource.Count == 0) { // Scan all types to find implementors of IGameConfiguration typeSource.AddRange(from type in TryGetTypes(assembly) select type); } consoleHandle.LogDebug("Found {0} configuration classes in " + gameAssembly, typeSource.Count); consoleHandle.LogDebug("Constructing game configurations..."); var gameConfigurations = new List <IGameConfiguration>(); foreach (var type in typeSource) { if (typeof(IGameConfiguration).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { gameConfigurations.Add(Activator.CreateInstance(type) as IGameConfiguration); } } ICoreGame game = null; var hasBoundNewEventEngine = false; consoleHandle.LogDebug("Configuring kernel and constructing game instance ({0} configurations)...", gameConfigurations.Count); foreach (var configuration in gameConfigurations) { consoleHandle.LogDebug("Configuring with {0}...", configuration.GetType().FullName); configuration.ConfigureKernel(kernel); // Rebind services so the game renders correctly inside the editor. kernel.Rebind <IBaseDirectory>().ToMethod(x => baseDirectory).InSingletonScope(); kernel.Rebind <IBackBufferDimensions>().ToMethod(x => backBufferDimensions).InSingletonScope(); kernel.Rebind <IDebugRenderer>().To <DefaultDebugRenderer>().InSingletonScope(); var bindings = kernel.GetCopyOfBindings(); var mustBindNewEventEngine = false; if (bindings.ContainsKey(typeof(IEngineHook))) { if (bindings[typeof(IEngineHook)].Any(x => x.Target == typeof(EventEngineHook))) { mustBindNewEventEngine = !hasBoundNewEventEngine; kernel.UnbindSpecific <IEngineHook>(x => x.Target == typeof(EventEngineHook)); } if (mustBindNewEventEngine) { kernel.Bind <IEngineHook>().ToMethod(ctx => { _editorEventEngineHook = ctx.Kernel.Get <EditorEventEngineHook>(ctx.Parent); return(_editorEventEngineHook); }).InSingletonScope(); } } if (game == null) { game = configuration.ConstructGame(kernel); } } if (game != null) { consoleHandle.LogDebug("Game instance is {0}", game.GetType().FullName); } _game = game; _logShipping = kernel.Get <ILogShipping>(); _consoleHandle = consoleHandle; consoleHandle.LogDebug("LoadFromPath complete"); }