public void Setup()
        {
            _defaultWorld                      = new DefaultWorld(EntityCount);
            _defaultEntitySet                  = _defaultWorld.GetEntities().With <DefaultComponent>().AsSet();
            _defaultRunner                     = new DefaultParallelRunner(Environment.ProcessorCount);
            _defaultSystem                     = new DefaultEcsSystem(_defaultWorld);
            _defaultMultiSystem                = new DefaultEcsSystem(_defaultWorld, _defaultRunner);
            _defaultEntityComponentSystem      = new DefaultEcsEntityComponentSystem(_defaultWorld);
            _defaultMultiEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld, _defaultRunner);
            _defaultComponentSystem            = new DefaultEcsComponentSystem(_defaultWorld);
            _defaultComponentMultiSystem       = new DefaultEcsComponentSystem(_defaultWorld, _defaultRunner);

            _entitasWorld       = new Context <EntitasEntity>(1, () => new EntitasEntity());
            _entitasSystem      = new EntitasSystem(_entitasWorld);
            _entitasMultiSystem = new EntitasSystem(_entitasWorld, Environment.ProcessorCount);

            for (int i = 0; i < EntityCount; ++i)
            {
                DefaultEntity defaultEntity = _defaultWorld.CreateEntity();
                defaultEntity.Set <DefaultComponent>();

                EntitasEntity entitasEntity = _entitasWorld.CreateEntity();
                entitasEntity.AddComponent(0, new EntitasComponent());
            }
        }
Пример #2
0
        public PlayerTriggers(ITagContainer diContainer)
        {
            world                    = diContainer.GetTag <DefaultEcs.World>();
            playerControls           = diContainer.GetTag <PlayerControls>();
            zzContainer              = diContainer.GetTag <IZanzarahContainer>();
            zzContainer.OnMouseDown += HandleMouseDown;

            var game = diContainer.GetTag <Game>();

            cameraLocation     = diContainer.GetTag <rendering.Camera>().Location;
            playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>());

            npcMarker = world.CreateEntity();
            npcMarker.Set(new Location());
            npcMarker.Set(new components.behaviour.Rotate(Vector3.UnitY, 90f));
            npcMarker.Set(ManagedResource <ClumpBuffers> .Create(
                              new resources.ClumpInfo(resources.ClumpType.Model, "marker.dff")));
            ModelLoader.LoadMaterialsFor(npcMarker,
                                         zzio.scn.FOModelRenderType.Solid,
                                         zzio.IColor.Green,
                                         new zzio.SurfaceProperties(1f, 1f, 1f));
            var materials = npcMarker.Get <List <materials.BaseModelInstancedMaterial> >();

            foreach (var material in materials)
            {
                material.Uniforms.Ref.vertexColorFactor = 1f;
            }
        }
Пример #3
0
        private ManagedResource <resources.UITileSheetInfo, TileSheet> Preload(
            out TileSheet tileSheet,
            string name,
            bool isFont,
            float lineHeight  = float.NaN,
            float charSpacing = float.NaN,
            float lineOffset  = float.NaN)
        {
            var resource = ManagedResource <TileSheet> .Create(new resources.UITileSheetInfo(name, isFont));

            var entity = world.CreateEntity();

            entity.Set(resource);
            entity.Disable();
            tileSheet = entity.Get <TileSheet>();
            if (float.IsFinite(lineHeight))
            {
                tileSheet.LineHeight = lineHeight;
            }
            if (float.IsFinite(charSpacing))
            {
                tileSheet.CharSpacing = charSpacing;
            }
            if (float.IsFinite(lineOffset))
            {
                tileSheet.LineOffset = lineOffset;
            }
            return(resource);
        }
        public void Setup()
        {
            _defaultWorld                      = new DefaultWorld(EntityCount);
            _defaultEntitySet                  = _defaultWorld.GetEntities().With <DefaultComponent>().AsSet();
            _defaultRunner                     = new DefaultParallelRunner(Environment.ProcessorCount);
            _defaultSystem                     = new DefaultEcsSystem(_defaultWorld);
            _defaultMultiSystem                = new DefaultEcsSystem(_defaultWorld, _defaultRunner);
            _defaultEntityComponentSystem      = new DefaultEcsEntityComponentSystem(_defaultWorld);
            _defaultMultiEntityComponentSystem = new DefaultEcsEntityComponentSystem(_defaultWorld, _defaultRunner);
            _defaultComponentSystem            = new DefaultEcsComponentSystem(_defaultWorld);
            _defaultComponentMultiSystem       = new DefaultEcsComponentSystem(_defaultWorld, _defaultRunner);
            _defaultGeneratorSystem            = new DefaultEcsGeneratorSystem(_defaultWorld);
            _defaultGeneratorMultiSystem       = new DefaultEcsGeneratorSystem(_defaultWorld, _defaultRunner);

            _entitasWorld       = new Context <EntitasEntity>(1, () => new EntitasEntity());
            _entitasSystem      = new EntitasSystem(_entitasWorld);
            _entitasMultiSystem = new EntitasSystem(_entitasWorld, Environment.ProcessorCount);

            _monoWorld = new WorldBuilder().AddSystem(new MonoSystem()).Build();
            _time      = new GameTime();

            _leoWorld   = new LeoWorld();
            _leoSystem  = new LeoSystem();
            _leoSystems = new LeoSystems(_leoWorld).Add(_leoSystem);
            _leoSystems.ProcessInjects().Init();

            SimpleEntitiesSubmissionScheduler sveltoScheduler = new SimpleEntitiesSubmissionScheduler();

            _sveltoWorld  = new EnginesRoot(sveltoScheduler);
            _sveltoSystem = new SveltoSystem();
            _sveltoWorld.AddEngine(_sveltoSystem);
            IEntityFactory sveltoFactory = _sveltoWorld.GenerateEntityFactory();

            for (int i = 0; i < EntityCount; ++i)
            {
                DefaultEntity defaultEntity = _defaultWorld.CreateEntity();
                defaultEntity.Set <DefaultComponent>();

                EntitasEntity entitasEntity = _entitasWorld.CreateEntity();
                entitasEntity.AddComponent(0, new EntitasComponent());

                MonoEntity monoEntity = _monoWorld.CreateEntity();
                monoEntity.Attach(new MonoComponent());

                LeoEntity leoEntity = _leoWorld.NewEntity();
                leoEntity.Get <LeoComponent>();

                sveltoFactory.BuildEntity <SveltoEntity>((uint)i, _sveltoGroup);
            }

            sveltoScheduler.SubmitEntities();
        }
Пример #5
0
        public UI(ITagContainer diContainer)
        {
            tagContainer          = new TagContainer().FallbackTo(diContainer);
            zzContainer           = GetTag <IZanzarahContainer>();
            zzContainer.OnResize += HandleResize;
            time = GetTag <GameTime>();

            var resourceFactory = GetTag <ResourceFactory>();

            graphicsDevice   = GetTag <GraphicsDevice>();
            projectionBuffer = resourceFactory.CreateBuffer(
                // Buffer has to be multiple of 16 bytes big even though we only need 8
                new BufferDescription(sizeof(float) * 4, BufferUsage.UniformBuffer));
            HandleResize();

            AddTag(this);
            AddTag(ecsWorld = new DefaultEcs.World());
            AddTag(new resources.UIBitmap(this));
            AddTag(new resources.UITileSheet(this));
            AddTag(Preload = new systems.ui.UIPreloader(this));

            CursorEntity = ecsWorld.CreateEntity();
            CursorEntity.Set <Rect>();
            CursorEntity.Set <components.Visibility>();

            updateSystems = new systems.RecordingSequentialSystem <float>(this);
            updateSystems.Add(
                new systems.ui.Cursor(this),
                new systems.ui.ScrDeck(this),
                new systems.ui.ScrGotCard(this),
                new systems.ui.ButtonTiles(this),
                new systems.ui.Slider(this),
                new systems.ui.AnimatedLabel(this),
                new systems.ui.Label(this),
                new systems.ui.Tooltip(this),
                new systems.ui.CorrectRenderOrder(this),
                new systems.ui.Fade(this),
                new systems.Reaper(this),
                new systems.ParentReaper(this));

            renderSystems = new SequentialSystem <CommandList>(
                new systems.ui.Batcher(this));
        }