Ejemplo n.º 1
0
 public void Setup()
 {
     fallback = new TagContainer();
     fallback.AddTag <Tag1>(new SubTag1Of1());
     fallback.AddTag(new Tag2());
     main = new TagContainer();
     main.AddTag(new Tag3());
     main.AddTag(new SubTag2Of1() as Tag1);
     container = main.FallbackTo(fallback);
 }
Ejemplo n.º 2
0
        public SceneEditor(ITagContainer diContainer)
        {
            this.diContainer = diContainer;
            resourcePool     = diContainer.GetTag <IResourcePool>();
            Window           = diContainer.GetTag <WindowContainer>().NewWindow("Scene Editor");
            Window.AddTag(this);
            Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f);
            editor = new TwoColumnEditorTag(Window, diContainer);
            var onceAction = new OnceAction();

            Window.AddTag(onceAction);
            Window.OnContent += onceAction.Invoke;
            locationBuffer    = new LocationBuffer(diContainer.GetTag <GraphicsDevice>());
            AddDisposable(locationBuffer);
            var menuBar = new MenuBarWindowTag(Window);

            menuBar.AddButton("Open", HandleMenuOpen);
            openFileModal                    = new OpenFileModal(diContainer);
            openFileModal.Filter             = "*.scn";
            openFileModal.IsFilterChangeable = false;
            openFileModal.OnOpenedResource  += Load;

            camera = new Camera(diContainer.ExtendedWith(locationBuffer));
            AddDisposable(camera);
            controls     = new FlyControlsTag(Window, camera.Location, diContainer);
            gridRenderer = new DebugGridRenderer(diContainer);
            gridRenderer.Material.LinkTransformsTo(camera);
            gridRenderer.Material.World.Ref = Matrix4x4.Identity;
            AddDisposable(gridRenderer);
            fbArea           = Window.GetTag <FramebufferArea>();
            fbArea.OnResize += HandleResize;
            fbArea.OnRender += camera.Update;
            fbArea.OnRender += locationBuffer.Update;
            fbArea.OnRender += gridRenderer.Render;

            localDiContainer = diContainer
                               .FallbackTo(Window)
                               .ExtendedWith(this, Window, gridRenderer, locationBuffer)
                               .AddTag <IAssetLoader <Texture> >(new CachedAssetLoader <Texture>(diContainer.GetTag <IAssetLoader <Texture> >()))
                               .AddTag <IAssetLoader <ClumpBuffers> >(new CachedClumpAssetLoader(diContainer))
                               .AddTag(camera);
            new DatasetComponent(localDiContainer);
            new WorldComponent(localDiContainer);
            new ModelComponent(localDiContainer);
            new FOModelComponent(localDiContainer);
            new TriggerComponent(localDiContainer);
            new SelectionComponent(localDiContainer);
        }