/// <summary> /// Initializes a new instance of the <see cref="Game" /> class. /// </summary> /// <param name="title"> (Optional) title. </param> /// <param name="gcLatencyMode"> (Optional) GCLatencyMode. </param> protected Game(string title = "Exomia.Framework", GCLatencyMode gcLatencyMode = GCLatencyMode.SustainedLowLatency) { GCSettings.LatencyMode = gcLatencyMode; _gameComponents = new Dictionary <string, IComponent>(INITIAL_QUEUE_SIZE); _pendingInitializables = new List <IInitializable>(INITIAL_QUEUE_SIZE); _updateableComponent = new List <IUpdateable>(INITIAL_QUEUE_SIZE); _drawableComponent = new List <IDrawable>(INITIAL_QUEUE_SIZE); _contentableComponent = new List <IContentable>(INITIAL_QUEUE_SIZE); _currentlyUpdateableComponent = new List <IUpdateable>(INITIAL_QUEUE_SIZE); _currentlyDrawableComponent = new List <IDrawable>(INITIAL_QUEUE_SIZE); _currentlyContentableComponent = new List <IContentable>(INITIAL_QUEUE_SIZE); _collector = new DisposeCollector(); _serviceRegistry = new ServiceRegistry(); _serviceRegistry.AddService <IGraphicsDevice>(_graphicsDevice = new GraphicsDevice()); _serviceRegistry.AddService(_contentManager = new ContentManager(_serviceRegistry)); _platform = GamePlatform.Create(this, title); _serviceRegistry.AddService(_platform.MainWindow); // NOTE: The input device should be registered during the platform creation! _inputDevice = _serviceRegistry.GetService <IInputDevice>(); }
public Scene(IServiceRegistry services) { Contract.Requires <ArgumentNullException>(services != null, "services"); messenger = new Messenger(); entityMap = new EntityMap(this); systemMap = new SystemMap(this); updateableSystems = new List <IUpdateableSystem>(); renderableSystems = new List <IRenderableSystem>(); currentlyUpdatingSystems = new List <IUpdateableSystem>(); currentlyRenderingSystems = new List <IRenderableSystem>(); Services = services; Services.AddService(typeof(IEntityProvider), this); Services.AddService(typeof(IResourceProvider), this); var content = Services.GetService <IAssetProvider>(); content.AddMapping("Scene", typeof(Scene)); entityMap.EntityAdded += systemMap.OnEntityAdded; entityMap.EntityRemoved += systemMap.OnEntityRemoved; entityMap.EntityComponentAdded += systemMap.OnEntityComponentAdded; entityMap.EntityComponentRemoved += systemMap.OnEntityComponentRemoved; systemMap.SystemAdded += SystemMapOnSystemAdded; systemMap.SystemRemoved += SystemMapOnSystemRemoved; tagManager = new TagManager(); }
/// <summary> /// Create an new instance of AudioSystem /// </summary> /// <param name="registry">The service registry in which to register the <see cref="AudioSystem"/> services</param> public AudioSystem(IServiceRegistry registry) : base(registry) { Enabled = true; registry.AddService(typeof(AudioSystem), this); registry.AddService(typeof(IAudioEngineProvider), this); }
public AssetManager(IServiceRegistry services) { Serializer = new AssetSerializer(); if (services != null) { services.AddService(typeof(IAssetManager), this); services.AddService(typeof(AssetManager), this); Serializer.SerializerContextTags.Set(ServiceRegistry.ServiceRegistryKey, services); } }
internal Application() { var platformTypeAttribute = ReflectionHelper.GetAttribute <PlatformTypeAttribute>(GetType()); if (!ReflectionHelper.IsTypeDerived(platformTypeAttribute.PlatformType, typeof(ApplicationPlatform))) { throw new InvalidOperationException("PlatformType must be derived from ApplicationPlatform."); } services = new ServiceRegistry(); appTime = new ApplicationTime(); totalTime = new TimeSpan(); timer = new TimerTick(); IsFixedTimeStep = false; maximumElapsedTime = TimeSpan.FromMilliseconds(500.0); TargetElapsedTime = TimeSpan.FromTicks(10000000 / 120); // target elapsed time is by default 60Hz lastUpdateCount = new int[4]; nextLastUpdateCountIndex = 0; // Calculate the updateCountAverageSlowLimit (assuming moving average is >=3 ) // Example for a moving average of 4: // updateCountAverageSlowLimit = (2 * 2 + (4 - 2)) / 4 = 1.5f const int BadUpdateCountTime = 2; // number of bad frame (a bad frame is a frame that has at least 2 updates) var maxLastCount = 2 * Math.Min(BadUpdateCountTime, lastUpdateCount.Length); updateCountAverageSlowLimit = (float)(maxLastCount + (lastUpdateCount.Length - maxLastCount)) / lastUpdateCount.Length; services.AddService(typeof(IWindowService), this); services.AddService(typeof(ITimeService), appTime); // Setup Content Manager contentManager = new ContentManager(services); contentManager.AddMapping(AssetType.EngineReferences, typeof(EngineReferenceCollection)); contentManager.AddMapping(AssetType.Model, typeof(Model)); contentManager.AddMapping(AssetType.Effect, typeof(ShaderCollection)); contentManager.AddMapping(AssetType.Texture2D, typeof(Texture2D)); contentManager.AddMapping(AssetType.TextureCube, typeof(TextureCube)); contentManager.AddMapping(AssetType.Cutscene, typeof(Cutscene)); var additionalServices = ReflectionHelper.GetAttributes <RequiredServiceAttribute>(GetType()); foreach (var requiredService in additionalServices) { var service = Activator.CreateInstance(requiredService.ClassType, services); services.AddService(requiredService.ServiceType, service); } // Setup Platform applicationPlatform = (ApplicationPlatform)Activator.CreateInstance(platformTypeAttribute.PlatformType, this); applicationPlatform.Activated += ApplicationPlatformActivated; applicationPlatform.Deactivated += ApplicationPlatformDeactivated; applicationPlatform.Exiting += ApplicationPlatform_Exiting; applicationPlatform.WindowCreated += ApplicationPlatformWindowCreated; }
/// <summary> /// Initializes a new instance of the <see cref="StreamingManager"/> class. /// </summary> /// <param name="services">The servicies registry.</param> /// <remarks> /// The GameSystem expects the following services to be registered: <see cref="T:Stride.Games.IGame" /> and <see cref="T:Stride.Core.Serialization.Contents.IContentManager" />. /// </remarks> public StreamingManager([NotNull] IServiceRegistry services) : base(services) { services.AddService(this); services.AddService <IStreamingManager>(this); services.AddService <ITexturesStreamingProvider>(this); ContentStreaming = new ContentStreamingService(); Enabled = true; EnabledChanged += OnEnabledChanged; }
/// <summary> /// Creates a new instance of <see cref="SpriteAnimationSystem"/> and register it in the services. /// </summary> /// <param name="registry"></param> public SpriteAnimationSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(SpriteAnimationSystem), this); DefaultFramesPerSecond = 30; }
/// <summary> /// Initializes a new instance of the <see cref="GameSystemBase" /> class. /// </summary> /// <param name="registry">The registry.</param> /// <remarks>The GameSystem is expecting the following services to be registered: <see cref="IGame" /> and <see cref="IAssetManager" />.</remarks> public SceneSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(SceneSystem), this); Enabled = true; Visible = true; }
/// <summary> /// Initializes a new instance of the <see cref="GameSystemBase" /> class. /// </summary> /// <param name="registry">The registry.</param> /// <remarks>The GameSystem is expecting the following services to be registered: <see cref="IGame" /> and <see cref="IContentManager" />.</remarks> public SceneSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(SceneSystem), this); Enabled = true; Visible = true; }
public DebugConsoleSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(DebugConsoleSystem), this); Visible = true; DrawOrder = 0xffffff; }
public Bullet2PhysicsSystem(IServiceRegistry registry) : base(registry) { UpdateOrder = -1000; //make sure physics runs before everything registry.AddService(typeof(IPhysicsSystem), this); Enabled = true; //enabled by default }
/// <summary> /// Create an new instance of AudioSystem /// </summary> /// <param name="registry">The service registry in which to register the <see cref="AudioSystem"/> services</param> public AudioSystem(IServiceRegistry registry) : base(registry) { Enabled = true; AudioEngine = new AudioEngine(); registry.AddService(typeof(AudioSystem), this); }
/// <summary> /// Initializes a new instance of the <see cref="GraphicsDeviceServiceLocal"/> class. /// </summary> /// <param name="registry">The registry.</param> /// <param name="graphicsDevice">The graphics device.</param> public GraphicsDeviceServiceLocal(IServiceRegistry registry, GraphicsDevice graphicsDevice) { if (registry != null) { registry.AddService(typeof(IGraphicsDeviceService), this); } GraphicsDevice = graphicsDevice; }
/// <summary> /// Create an new instance of AudioSystem /// </summary> /// <param name="registry">The service registry in which to register the <see cref="AudioSystem"/> services</param> public AudioSystem(IServiceRegistry registry) : base(registry) { Enabled = true; AudioEngine = AudioEngineFactory.NewAudioEngine(); registry.AddService(typeof(AudioSystem), this); }
public DebugConsoleSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(DebugConsoleSystem), this); Visible = true; DrawOrder = 0xffffff; UpdateOrder = -100100; //before script }
public GamePlatformDesktop(IServiceRegistry services) : base(services) { // By default, the mouse is hidden isMouseVisible = false; Cursor.Hide(); IsBlockingRun = true; gameWindowDesktop = new GameWindowDesktop(); services.AddService(typeof(IGraphicsDeviceFactory), this); }
public GameProfilingSystem(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(GameProfilingSystem), this); DrawOrder = 0xffffff; gcProfiler = new GcProfiling(); gcMemoryStringBase = "Memory> Total: {0} Peak: {1} Last allocations: {2}"; gcCollectionsStringBase = "Collections> Gen 0: {0} Gen 1: {1} Gen 3: {2}"; }
private static void registerDefaultServices(IServiceRegistry s) { s.SetServiceIfNone<ILogger, ExceptionLogger>(); s.SetServiceIfNone<Parser, OptimizedParser>(); s.SetServiceIfNone<IStylizer, PlainStylizer>(); s.SetServiceIfNone<IImporter, DefaultImporter>(); s.SetServiceIfNone<IFileReader, FileReader>(); s.SetServiceIfNone<ILessEngine, DefaultEngine>(); s.SetServiceIfNone<IPathResolver, AssetPathResolver>(); s.SetServiceIfNone<ILessCompiler, LessCompiler>(); s.AddService<ITransformerPolicy, LessTransformerPolicy>(); }
/// <summary> /// Get <see cref="GameEventSystem"/> from the service registry or adds one if it doesn't exist. /// </summary> public static GameEventSystem GetFromServices(IServiceRegistry services) { var ges = services.GetService <GameEventSystem>(); if (ges == null) { ges = new GameEventSystem(services); services.AddService <GameEventSystem>(ges); services.GetService <IGame>().GameSystems.Add(ges); } return(ges); }
private static void registerDefaultServices(IServiceRegistry s) { s.SetServiceIfNone <ILogger, ExceptionLogger>(); s.SetServiceIfNone <Parser, OptimizedParser>(); s.SetServiceIfNone <IStylizer, PlainStylizer>(); s.SetServiceIfNone <IImporter, DefaultImporter>(); s.SetServiceIfNone <IFileReader, FileReader>(); s.SetServiceIfNone <ILessEngine, DefaultEngine>(); s.SetServiceIfNone <IPathResolver, AssetPathResolver>(); s.SetServiceIfNone <ILessCompiler, LessCompiler>(); s.AddService <ITransformerPolicy, LessTransformerPolicy>(); }
/// <summary> /// Create an instance of an UI element renderer. /// </summary> /// <param name="services">The list of registered services</param> public ElementRenderer(IServiceRegistry services) { Content = services.GetSafeServiceAs <IContentManager>(); GraphicsDeviceService = services.GetSafeServiceAs <IGraphicsDeviceService>(); UI = services.GetService <UISystem>(); if (UI == null) { UI = new UISystem(services); services.AddService(UI); var gameSystems = services.GetService <IGameSystemCollection>(); gameSystems?.Add(UI); } }
public GameSystemCollection(IServiceRegistry registry) { drawableGameSystems = new List <KeyValuePair <IDrawable, ProfilingKey> >(); currentlyContentGameSystems = new List <IContentable>(); currentlyDrawingGameSystems = new List <KeyValuePair <IDrawable, ProfilingKey> >(); pendingGameSystems = new List <IGameSystemBase>(); updateableGameSystems = new List <KeyValuePair <IUpdateable, ProfilingKey> >(); currentlyUpdatingGameSystems = new List <KeyValuePair <IUpdateable, ProfilingKey> >(); contentableGameSystems = new List <IContentable>(); registry.AddService(typeof(IGameSystemCollection), this); // Register events on GameSystems. CollectionChanged += GameSystems_CollectionChanged; }
protected virtual void Initialize() { const string filePath = Global.DataPath + "System.yaml"; const string references = "EngineReferences"; if (!NativeFile.Exists(filePath)) { throw new InvalidOperationException(string.Format("Odyssey System Data not found: check if {0} exists", filePath)); } contentManager.LoadAssetList(filePath); var refData = contentManager.Load <EngineReferenceCollection>(references); services.AddService(typeof(IReferenceService), refData); SetupDeviceEvents(); }
private void configureServices(IServiceRegistry services) { services.SetServiceIfNone<ITemplateRegistry>(_templateRegistry); services.SetServiceIfNone<ISparkViewEngine>(new SparkViewEngine()); services.AddService<IActivator, SparkActivator>(); services.AddService<IRenderStrategy, NestedRenderStrategy>(); services.AddService<IRenderStrategy, AjaxRenderStrategy>(); services.AddService<IRenderStrategy, DefaultRenderStrategy>(); services.AddService<IViewModifier, PageActivation>(); services.AddService<IViewModifier, SiteResourceAttacher>(); services.AddService<IViewModifier, ContentActivation>(); services.AddService<IViewModifier, OnceTableActivation>(); services.AddService<IViewModifier, OuterViewOutputActivator>(); services.AddService<IViewModifier, NestedViewOutputActivator>(); services.AddService<IViewModifier, ViewContentDisposer>(); services.AddService<IViewModifier, NestedOutputActivation>(); }
public ContentManager(IServiceRegistry services) { this.services = services; services.AddService(typeof(IAssetProvider), this); // Content resolvers Resolvers = new ObservableCollection <IResourceResolver>(); Resolvers.ItemAdded += ContentResolvers_ItemAdded; Resolvers.ItemRemoved += ContentResolvers_ItemRemoved; registeredContentResolvers = new List <IResourceResolver>(); // Content readers. Readers = new ObservableDictionary <Type, IContentReader>(); Readers.ItemAdded += ContentReaders_ItemAdded; Readers.ItemRemoved += ContentReaders_ItemRemoved; registeredContentReaders = new Dictionary <Type, IContentReader>(); loadedAssets = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); assetLockers = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); // Init ContentManager Resolvers.Add(new FileSystemResourceResolver(Global.Assets)); }
public CameraProvider(IServiceRegistry registry) : base(registry) { registry.AddService(typeof(ICameraService), this); }
public void RegisterServices(IServiceRegistry services) { services.AddService <IContentFolderService>(_contentFolderService); services.AddService <IMimeTypeProvider>(_mimeTypeProvider); }
public static void AddService <TService>(this IServiceRegistry serviceRegistry, Func <IServiceProvider, TService> factory) where TService : class { serviceRegistry.AddService(typeof(TService), factory); }
public static void AddService <TService, TServiceImpl>(this IServiceRegistry serviceRegistry) where TService : class where TServiceImpl : class, TService { serviceRegistry.AddService(typeof(TService), typeof(TServiceImpl)); }
private static void registerDefaultServices(IServiceRegistry s) { s.SetServiceIfNone<ILessEngine>(new LessEngine()); s.SetServiceIfNone<ILessCompiler, LessCompiler>(); s.AddService<ITransformerPolicy, LessTransformerPolicy>(); }
private static void registerDefaultServices(IServiceRegistry registry) { registerCompiler(registry); registry.AddService <ITransformerPolicy, CoffeeTransformerPolicy>(); }
protected GamePlatform(GameBase game) { this.game = game; Services = game.Services; Services.AddService(typeof(IGraphicsDeviceFactory), this); }
public ThumbnailGenerator(EffectCompilerBase effectCompiler) { // create base services Services = new ServiceRegistry(); Services.AddService(MicrothreadLocalDatabases.ProviderService); ContentManager = new ContentManager(Services); Services.AddService <IContentManager>(ContentManager); Services.AddService(ContentManager); GraphicsDevice = GraphicsDevice.New(); GraphicsContext = new GraphicsContext(GraphicsDevice); GraphicsCommandList = GraphicsContext.CommandList; Services.AddService(GraphicsContext); sceneSystem = new SceneSystem(Services); Services.AddService(sceneSystem); fontSystem = new GameFontSystem(Services); Services.AddService(fontSystem.FontSystem); Services.AddService <IFontFactory>(fontSystem.FontSystem); GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice); Services.AddService(GraphicsDeviceService); var uiSystem = new UISystem(Services); Services.AddService(uiSystem); var physicsSystem = new Bullet2PhysicsSystem(Services); Services.AddService <IPhysicsSystem>(physicsSystem); gameSystems = new GameSystemCollection(Services) { fontSystem, uiSystem, physicsSystem }; Services.AddService <IGameSystemCollection>(gameSystems); Simulation.DisableSimulation = true; //make sure we do not simulate physics within the editor // initialize base services gameSystems.Initialize(); // create remaining services EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); gameSystems.Add(EffectSystem); gameSystems.Add(sceneSystem); EffectSystem.Initialize(); // Mount the same database for the cache EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(effectCompiler.FileProvider, EffectSystem); // Deactivate the asynchronous effect compilation ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false; // load game system content gameSystems.LoadContent(); // create the default fonts var fontItem = OfflineRasterizedSpriteFontFactory.Create(); fontItem.FontType.Size = 22; DefaultFont = OfflineRasterizedFontCompiler.Compile(fontSystem.FontSystem, fontItem, true); // create utility members nullGameTime = new GameTime(); SpriteBatch = new SpriteBatch(GraphicsDevice); UIBatch = new UIBatch(GraphicsDevice); // create the pipeline SetUpPipeline(); }
private void configureServices(IServiceRegistry services) { services.SetServiceIfNone <ITemplateRegistry>(_templateRegistry); services.SetServiceIfNone <ISparkViewEngine>(new SparkViewEngine()); services.AddService <IActivator, SparkActivator>(); services.AddService <IRenderStrategy, NestedRenderStrategy>(); services.AddService <IRenderStrategy, AjaxRenderStrategy>(); services.AddService <IRenderStrategy, DefaultRenderStrategy>(); services.AddService <IViewModifier, PageActivation>(); services.AddService <IViewModifier, SiteResourceAttacher>(); services.AddService <IViewModifier, ContentActivation>(); services.AddService <IViewModifier, OnceTableActivation>(); services.AddService <IViewModifier, OuterViewOutputActivator>(); services.AddService <IViewModifier, NestedViewOutputActivator>(); services.AddService <IViewModifier, ViewContentDisposer>(); services.AddService <IViewModifier, NestedOutputActivation>(); }
public SimpleDeviceManager(IServiceRegistry services) { services.AddService(typeof(IDirectXDeviceService), this); services.AddService(typeof(IDirectXDeviceSettings), this); services.AddService(typeof(ISwapChainPresenterService), this); }
private static void registerDefaultServices(IServiceRegistry registry) { registerCompiler(registry); registry.AddService<ITransformerPolicy, CoffeeTransformerPolicy>(); }
public void RegisterServices(IServiceRegistry services) { services.AddService<IImageUrlResolver>(_imageUrlResolver); }
private static void services(IServiceRegistry s) { s.SetServiceIfNone<ISassCompiler, DefaultSassCompiler>(); s.SetServiceIfNone<SassAndCoffee.Ruby.Sass.ISassCompiler, SassAndCoffee.Ruby.Sass.SassCompiler>(); s.AddService<ITransformerPolicy, SassTransformerPolicy>(); }
public void RegisterServices(IServiceRegistry services) { services.AddService<IContentFolderService>(_contentFolderService); }
protected GamePlatform(Game game) { this.game = game; Services = game.Services; Services.AddService(typeof(IGraphicsDeviceFactory), this); }
public void RegisterServices(IServiceRegistry services) { services.AddService<IContentFolderService>(_contentFolderService); services.AddService<IMimeTypeProvider>(_mimeTypeProvider); }
private static void registerDefaultServices(IServiceRegistry s) { s.SetServiceIfNone <ILessEngine>(new LessEngine()); s.SetServiceIfNone <ILessCompiler, LessCompiler>(); s.AddService <ITransformerPolicy, LessTransformerPolicy>(); }
private static void services(IServiceRegistry s) { s.SetServiceIfNone <ISassCompiler, DefaultSassCompiler>(); s.SetServiceIfNone <SassAndCoffee.Ruby.Sass.ISassCompiler, SassAndCoffee.Ruby.Sass.SassCompiler>(); s.AddService <ITransformerPolicy, SassTransformerPolicy>(); }
public GamePlatformWP8(IServiceRegistry services) : base(services) { gameWindowWP8 = new GameWindowWP8(); services.AddService(typeof(IGraphicsDeviceFactory), this); }
public GamePlatformDesktop(IServiceRegistry services) : base(services) { IsBlockingRun = true; gameWindowDesktop = new GameWindowDesktop(); services.AddService(typeof(IGraphicsDeviceFactory), this); }