public GameObjectFactory(IMessageBus bus,IObjectCreator creator) { _creator = creator; GameObjects = new ConcurrentDictionary<Guid, IGameObject>(); Bus = bus; Bus.OfType<GameObjectRequest>().Subscribe(CreateGameObject); // Bus.OfType<DestroyGameObject>().Subscribe(DestroyGameObject); }
public Game(ITimer timer, IGraphics graphics, IMessageBus bus, IGameObjectFactory factory) { Timer = timer; Timer.SubSample(5).Subscribe(t => Bus.SendAll()); Graphics = graphics; Bus = bus; Factory = factory; Timer.Subscribe(Update); Bus.OfType<RequestCloseMessage>().Subscribe(m => Stop()); }
public GameEngine(IObservableTimer timer, IMessageBus bus, IGameObjectFactory factory, IGraphicsEngine graphics, IAudioEngine audio, IPhysicsEngine physics) { Timer = timer; Bus = bus; Graphics = graphics; Audio = audio; Physics = physics; Factory = factory; Bus.Add(new DebugMessage(Timer.LastTickTime, "Initialising Engines")); Bus.OfType<ExitGameRequest>().Subscribe(m => Stop()); Timer.Subscribe(Update); Timer.SubSample(5).Subscribe(t => bus.SendAll()); Running = false; }
public GraphicsWindow(IMessageBus bus, IObservableTimer timer) : base(1280, 720, new GraphicsMode(32, 0, 0, 4), "Sharp Engine") { Views = new ConcurrentDictionary<int, IGameObjectView>(); _assets = new AssetManager { Shaders = new ShaderProvider(), VBO = new VBOProvider(), Textures = new TextureProvider() }; _timer = timer; Bus = bus; _gui = new GUIManager(_assets); Mouse.ButtonDown += MouseButtonDown; Bus.OfType<GameObjectCreated>().Subscribe(OnGameObjectCreated); }
public GraphicsWindow(IMessageBus bus, IObservableTimer timer, IGUI gui, IAssets assets, IProfiler profiler, ICamera camera) : base(1280, 720, new GraphicsMode(32, 0, 0, 4), "Sharp Engine") { _profiler = profiler; _camera = camera; _profile = _profiler.Profile("Graphics"); _timer = timer; _gui = gui; Bus = bus; Views = new ConcurrentDictionary<Guid, IGameObjectView>(); SetupGUI(); _assets = assets; foreach (var viewtype in AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(IGameObjectView).IsAssignableFrom(p) && p.IsClass && p.IsDefined(typeof(BindViewAttribute), false)).ToList()) { var bindViewAttribute = viewtype.GetCustomAttributes(typeof(BindViewAttribute), true).Cast<BindViewAttribute>().FirstOrDefault(); if (bindViewAttribute != null) _availableViews.Add(bindViewAttribute.GameObjectType, viewtype); } Bus.OfType<GameObjectCreated>().Subscribe(OnGameObjectCreated); }