public override void LoadContent() { Instance = this; int depth = 0; World.CreateComponentPool<BulletComponent>(); World.SystemManager.SetSystem(new GridRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new BackgroundRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); //World.SystemManager.SetSystem(new ShipRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new SceneGraphRendererSystem<StandardShipModelRenderer>(new StandardShipModelRenderer()), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new BeamRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new BulletRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new ParticleSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new BoundingBoxRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new GenericDrawableRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); World.SystemManager.SetSystem(new PhysicsDebugDrawSystem(), Artemis.Manager.GameLoopType.Draw, depth++); _hardpointSystem = World.SystemManager.SetSystem(new HardpointRendererSystem(), Artemis.Manager.GameLoopType.Draw, depth++); //World.SystemManager.SetSystem(new GuiSystem(), Artemis.Manager.GameLoopType.Draw, depth++); int priority = 1; World.SystemManager.SetSystem(new EventSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new CameraControlSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new RigidBodySystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new MouseControlledTransformSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new BoundingBoxSelectionSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new MouseHoverSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new CoroutineSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new PlayerShipControlSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new BeamSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new BulletSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new ShipUpdateSystem(), Artemis.Manager.GameLoopType.Update, priority++); //World.SystemManager.SetSystem(new StorySystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new PhysicsSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new TurretRotationSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new WeaponSystem(), Artemis.Manager.GameLoopType.Update, priority++); World.SystemManager.SetSystem(new FrameAnimationSystem(), Artemis.Manager.GameLoopType.Update, priority++); Graphics = ServiceLocator.Instance.GetService<GraphicsDevice>(); World.InitializeAll(); CameraEntity = World.CreateCamera(Constants.ActiveCameraTag, Graphics); GridEntity = World.CreateGrid(new Vector2(100), new Microsoft.Xna.Framework.Color(5, 5, 10)); if (Document == null) { Document = GuiService.Context.LoadDocument(RefitScreenGuiDocument); Core.ScriptEvent += (o,e) => Instance?.HandleScriptEvent(o, e); } CurrentShip = World.CreateShip(Fleet[0].Variant, Vector2.Zero, 0); //CurrentShip = World.CreateShip("Jaeger", Vector2.Zero, 0f, physics:true); //debug AddHardpointMarkersToShip(CurrentShip); SetMode(EditorMode.Weapons); _mouse.ButtonDown += HandleMouseButtonDown; _mouse.ButtonUp += HandleMouseButtonUp; Document.GetElementById("availablePartsList").SetProperty("display", "none"); base.LoadContent(); }
internal void Initialize(D3D11Host host) { if (IsInitialized) return; IsInitialized = true; Services = new GameServiceContainer(); ServiceLocator.Initialize(Services); _host = host; Artemis.System.EntitySystem.BlackBoard.SetEntry("GraphicsDevice", _host.GraphicsDevice); Artemis.System.EntitySystem.BlackBoard.SetEntry("ServiceProvider", Services); Services.AddService<IGraphicsDeviceService>(host); Services.AddService(host.GraphicsDevice); _mouse = new MouseService(host); Services.AddService<IMouseService>(_mouse); _mouse.ButtonDown += OnMouseButtonDown; _keyboard = new KeyboardService(host); Services.AddService<IKeyboardService>(_keyboard); _timer = new TimerService(); Services.AddService<ITimerService>(_timer); Services.AddService(new FastSpriteBatch(host.GraphicsDevice)); _timer.LastFrameUpdateTime = _gameTime; _timer.LastFrameRenderTime = _gameTime; SpriteBatch = new SpriteBatch(host.GraphicsDevice); Services.AddService(SpriteBatch); Content = new ContentManager(Services); Content.RootDirectory = Environment.CurrentDirectory; SpriteManager = new SpriteManagerService(Content); Services.AddService<ISpriteManagerService>(SpriteManager); //LoadHullSprites("textures/hulls.json"); Artemis.System.EntitySystem.BlackBoard.SetEntry("ContentManager", Content); World = new EntityWorld(false, false, false); World.CreateComponentPool<Transform>(200, 200); _gridSystem = new GridRendererSystem(); _gridSystem.IsEnabled = false; World.SystemManager.SetSystem(_gridSystem, Artemis.Manager.GameLoopType.Draw, 1); //World.SystemManager.SetSystem(new ShipRendererSystem(), Artemis.Manager.GameLoopType.Draw, 2); World.SystemManager.SetSystem(new SceneGraphRendererSystem<StandardShipModelRenderer>(new StandardShipModelRenderer()), Artemis.Manager.GameLoopType.Draw, 3); World.SystemManager.SetSystem(new BoundingBoxRendererSystem(), Artemis.Manager.GameLoopType.Draw, 4); World.SystemManager.SetSystem(new GenericDrawableRendererSystem(), Artemis.Manager.GameLoopType.Draw, 5); _hardpointRendererSystem = new HardpointRendererSystem(); _hardpointRendererSystem.IsEnabled = false; World.SystemManager.SetSystem(_hardpointRendererSystem, Artemis.Manager.GameLoopType.Draw, 6); World.SystemManager.SetSystem(new CameraControlSystem(), Artemis.Manager.GameLoopType.Update, 1); _transformSystem = new MouseControlledTransformSystem(); World.SystemManager.SetSystem(_transformSystem, Artemis.Manager.GameLoopType.Update, 2); World.SystemManager.SetSystem(new ShipUpdateSystem(), Artemis.Manager.GameLoopType.Update, 3); World.SystemManager.SetSystem(new BoundingBoxSelectionSystem(), Artemis.Manager.GameLoopType.Update, 4); World.SystemManager.SetSystem(new ShowThrusterTrailsOverrideSystem(), Artemis.Manager.GameLoopType.Update, 5); World.InitializeAll(); CameraEntity = World.CreateCamera(Constants.ActiveCameraTag, _host.GraphicsDevice); CameraEntity.Tag = Constants.ActiveCameraTag; Camera = CameraEntity.GetComponent<Camera>(); GridEntity = World.CreateGrid(new Vector2(50, 50), GridColor); World.CreateCircle(Vector2.Zero, 10, 8, XnaColor.Red * 0.4f); host.PreviewKeyDown += HandleKeyboardInput; EditorService = new ShipEditorService(_mouse, World); CreateNewShipModelCommand.Execute(null); EditorService.SelectedPartEntities.CollectionChanged += (o, e) => { if (e.NewItems != null && e.NewItems.Count > 0) { var color = e.NewItems.Cast<Entity>().First().GetComponent<IShipPartComponent>().Part.Color; _selectedColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedColor))); } }; _mouse.WheelChanged += OnWheelChanged; IsHardpointsVisible = false; LoadHullSprites("textures/hulls.json"); IsGridVisible = true; }